web-dl-cli 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.5
2
+ Name: web-dl-cli
3
+ Version: 0.1.0
4
+ Summary: web-dl: download anything from a URL, using yt-dlp for media sites and curl for files
5
+ Project-URL: Homepage, https://web-dl.net
6
+ Author-email: web-dl <hello@web-dl.net>
7
+ License-Expression: MIT
8
+ Classifier: Development Status :: 2 - Pre-Alpha
9
+ Classifier: Environment :: Console
10
+ Classifier: Topic :: Internet :: WWW/HTTP
11
+ Requires-Python: >=3.9
12
+ Requires-Dist: yt-dlp
13
+ Description-Content-Type: text/markdown
14
+
15
+ # web-dl CLI
16
+
17
+ Early versions of the `web-dl` command, published to hold the name on each registry. Today it is a thin wrapper:
18
+ `web-dl <url>` downloads with yt-dlp when the site is one yt-dlp supports, and falls back to curl for plain files.
19
+ Magnet links, infohashes, .torrent and .nzb files are pointed to https://web-dl.net until the real client ships.
20
+
21
+ | Registry | Package | Install |
22
+ |---|---|---|
23
+ | PyPI | `web-dl-cli` (`web-dl` is blocked as too similar to `webdl`) | `pipx install web-dl-cli` |
24
+ | npm | see `node/package.json` | `npm i -g <package>` |
25
+ | crates.io | `web-dl` | `cargo install web-dl` |
26
+
27
+ The Python package depends on yt-dlp, so it works without anything else installed. The npm and Rust versions call
28
+ `yt-dlp` and `curl` from PATH.
29
+
30
+ Usage: `web-dl [-o DIR] [-x] URL...` where `-x` extracts audio only (yt-dlp).
@@ -0,0 +1,16 @@
1
+ # web-dl CLI
2
+
3
+ Early versions of the `web-dl` command, published to hold the name on each registry. Today it is a thin wrapper:
4
+ `web-dl <url>` downloads with yt-dlp when the site is one yt-dlp supports, and falls back to curl for plain files.
5
+ Magnet links, infohashes, .torrent and .nzb files are pointed to https://web-dl.net until the real client ships.
6
+
7
+ | Registry | Package | Install |
8
+ |---|---|---|
9
+ | PyPI | `web-dl-cli` (`web-dl` is blocked as too similar to `webdl`) | `pipx install web-dl-cli` |
10
+ | npm | see `node/package.json` | `npm i -g <package>` |
11
+ | crates.io | `web-dl` | `cargo install web-dl` |
12
+
13
+ The Python package depends on yt-dlp, so it works without anything else installed. The npm and Rust versions call
14
+ `yt-dlp` and `curl` from PATH.
15
+
16
+ Usage: `web-dl [-o DIR] [-x] URL...` where `-x` extracts audio only (yt-dlp).
@@ -0,0 +1,23 @@
1
+ [project]
2
+ name = "web-dl-cli"
3
+ version = "0.1.0"
4
+ description = "web-dl: download anything from a URL, using yt-dlp for media sites and curl for files"
5
+ readme = "README.md"
6
+ requires-python = ">=3.9"
7
+ license = "MIT"
8
+ authors = [{ name = "web-dl", email = "hello@web-dl.net" }]
9
+ dependencies = ["yt-dlp"]
10
+ classifiers = ["Development Status :: 2 - Pre-Alpha", "Environment :: Console", "Topic :: Internet :: WWW/HTTP"]
11
+
12
+ [project.urls]
13
+ Homepage = "https://web-dl.net"
14
+
15
+ [project.scripts]
16
+ web-dl = "web_dl:main"
17
+
18
+ [build-system]
19
+ requires = ["hatchling"]
20
+ build-backend = "hatchling.build"
21
+
22
+ [tool.hatch.build.targets.wheel]
23
+ packages = ["src/web_dl"]
@@ -0,0 +1,79 @@
1
+ """web-dl: download a URL with yt-dlp when a site is supported, otherwise with curl."""
2
+
3
+ import argparse
4
+ import os
5
+ import re
6
+ import shutil
7
+ import subprocess
8
+ import sys
9
+ import urllib.parse
10
+
11
+ __version__ = "0.1.0"
12
+ SITE = "https://web-dl.net"
13
+
14
+
15
+ def is_p2p(url):
16
+ u = url.lower().split("?")[0]
17
+ return (u.startswith("magnet:") or u.endswith((".torrent", ".nzb"))
18
+ or re.fullmatch(r"[0-9a-f]{40}|[a-z2-7]{32}", u) is not None)
19
+
20
+
21
+ def content_type(url):
22
+ """The final Content-Type after redirects, from a HEAD request; '' if unknown."""
23
+ try:
24
+ out = subprocess.run(["curl", "-sIL", "--max-time", "15", "-o", os.devnull, "-w", "%{content_type}", url],
25
+ capture_output=True, text=True).stdout
26
+ except OSError:
27
+ return ""
28
+ return out.split(";")[0].strip().lower()
29
+
30
+
31
+ def ytdlp(url, outdir, audio):
32
+ cmd = [sys.executable, "-m", "yt_dlp", "-P", outdir]
33
+ if audio:
34
+ cmd.append("-x")
35
+ proc = subprocess.Popen(cmd + [url], stderr=subprocess.PIPE, text=True, errors="replace")
36
+ unsupported = False
37
+ for line in proc.stderr:
38
+ sys.stderr.write(line)
39
+ unsupported |= "Unsupported URL" in line
40
+ return proc.wait(), unsupported
41
+
42
+
43
+ def curl(url, outdir):
44
+ if not shutil.which("curl"):
45
+ print("web-dl: curl not found", file=sys.stderr)
46
+ return 127
47
+ parts = urllib.parse.urlsplit(url)
48
+ if os.path.basename(parts.path):
49
+ name = ["-O", "-J"] # name from the URL, or from Content-Disposition when the server sends one
50
+ else:
51
+ name = ["-o", (parts.hostname or "index") + ".html"]
52
+ return subprocess.call(["curl", "-fL", "--retry", "3", *name, url], cwd=outdir)
53
+
54
+
55
+ def main():
56
+ ap = argparse.ArgumentParser(prog="web-dl", description="Download a URL: yt-dlp for media sites, curl for files.")
57
+ ap.add_argument("urls", nargs="+", metavar="URL")
58
+ ap.add_argument("-o", "--output", default=".", help="directory to save into (default: current)")
59
+ ap.add_argument("-x", "--audio", action="store_true", help="audio only (yt-dlp)")
60
+ ap.add_argument("-V", "--version", action="version", version=f"web-dl {__version__}")
61
+ args = ap.parse_args()
62
+ os.makedirs(args.output, exist_ok=True)
63
+ status = 0
64
+ for url in args.urls:
65
+ if is_p2p(url):
66
+ print(f"web-dl: torrents and Usenet are not in the CLI yet, open {SITE} to stream or download them",
67
+ file=sys.stderr)
68
+ status = 2
69
+ continue
70
+ ctype = content_type(url)
71
+ if ctype and ctype != "text/html" and not args.audio:
72
+ status = status or curl(url, args.output) # a file, not a page: plain download keeps its name
73
+ continue
74
+ code, unsupported = ytdlp(url, args.output, args.audio)
75
+ if code != 0 and unsupported:
76
+ print("web-dl: not a media page, downloading with curl", file=sys.stderr)
77
+ code = curl(url, args.output)
78
+ status = status or code
79
+ sys.exit(status)
@@ -0,0 +1,57 @@
1
+ version = 1
2
+ revision = 5
3
+ requires-python = ">=3.9"
4
+ resolution-markers = [
5
+ "python_full_version >= '3.11'",
6
+ "python_full_version == '3.10.*'",
7
+ "python_full_version < '3.10'",
8
+ ]
9
+
10
+ [[package]]
11
+ name = "web-dl-cli"
12
+ version = "0.1.0"
13
+ source = { editable = "." }
14
+ dependencies = [
15
+ { name = "yt-dlp", version = "2025.10.14", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" },
16
+ { name = "yt-dlp", version = "2026.10.21", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.10.*'" },
17
+ { name = "yt-dlp", version = "2026.12.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" },
18
+ ]
19
+
20
+ [package.metadata]
21
+ requires-dist = [{ name = "yt-dlp" }]
22
+
23
+ [[package]]
24
+ name = "yt-dlp"
25
+ version = "2025.10.14"
26
+ source = { registry = "https://pypi.org/simple" }
27
+ resolution-markers = [
28
+ "python_full_version < '3.10'",
29
+ ]
30
+ sdist = { url = "https://files.pythonhosted.org/packages/03/b7/dab729345e22891e79294273bc59c5213a1ec87331f49cb82ccea2b1bc9f/yt_dlp-2025.10.14.tar.gz", hash = "sha256:b18436aa9bb6f04354fd78d31ad9eeaae8c81b6a859f07072b25c18cd6c25844", size = 3045272, upload-time = "2025-10-14T23:39:52.688Z" }
31
+ wheels = [
32
+ { url = "https://files.pythonhosted.org/packages/b0/19/399c85d29bd7b366b31ede82698f7963374e5a3842ae9de0cde6514506b0/yt_dlp-2025.10.14-py3-none-any.whl", hash = "sha256:0b9da17eda1bbf48e2315130043d7993fd4ca1c5a35571f8231da1a910c9c115", size = 3248664, upload-time = "2025-10-14T23:39:49.95Z" },
33
+ ]
34
+
35
+ [[package]]
36
+ name = "yt-dlp"
37
+ version = "2026.10.21"
38
+ source = { registry = "https://pypi.org/simple" }
39
+ resolution-markers = [
40
+ "python_full_version == '3.10.*'",
41
+ ]
42
+ sdist = { url = "https://files.pythonhosted.org/packages/06/13/d2ea252871826205dc4965cb70e6037ab93697fcabf4feda49fe981f6da0/yt_dlp-2026.10.21.tar.gz", hash = "sha256:cbf748d7d17cd37647c4b9f07b6c25f24384bfd4361407ee5ec519e753d22539", size = 3057326, upload-time = "2026-10-21T21:54:53.563Z" }
43
+ wheels = [
44
+ { url = "https://files.pythonhosted.org/packages/b7/75/ae700ddc7e0b1095fd06cf7e251627dcf4cafcaff460cce92cdc08023b13/yt_dlp-2026.10.21-py3-none-any.whl", hash = "sha256:94a3a3e2c423129d0bbd2f1be000c4171fa1226c29e251c84aff868f2851c247", size = 3188012, upload-time = "2026-10-21T21:54:50.808Z" },
45
+ ]
46
+
47
+ [[package]]
48
+ name = "yt-dlp"
49
+ version = "2026.12.6"
50
+ source = { registry = "https://pypi.org/simple" }
51
+ resolution-markers = [
52
+ "python_full_version >= '3.11'",
53
+ ]
54
+ sdist = { url = "https://files.pythonhosted.org/packages/14/5d/f6f733e90d147668e330c5570315b1bea85182ee8dd879aa6e93588459d5/yt_dlp-2026.12.6.tar.gz", hash = "sha256:3001cfa50c0f272c708a4c4b309fbfd0548334ae85b09d5488e338d878c62a75", size = 3061476, upload-time = "2026-12-06T01:09:19.517Z" }
55
+ wheels = [
56
+ { url = "https://files.pythonhosted.org/packages/0c/76/fe095c284a3f5e2e58d13e3df86a9b0469685e1807472d23a3e8891b7ded/yt_dlp-2026.12.6-py3-none-any.whl", hash = "sha256:68889fa4cd4a5fc89487cd0c53bb7e33ec1ec8213df249604a6a6bb7adde1992", size = 3194206, upload-time = "2026-12-06T01:09:17.258Z" },
57
+ ]