@jakende/media-info-cli 0.1.0

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.
package/media_tui.py ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env python3
2
+ from __future__ import annotations
3
+
4
+ from media_information_download.tui import main
5
+
6
+
7
+ if __name__ == "__main__":
8
+ raise SystemExit(main())
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@jakende/media-info-cli",
3
+ "version": "0.1.0",
4
+ "description": "Terminal app for downloading media from YouTube or RSS feeds, converting to MP3, and generating Whisper transcripts.",
5
+ "license": "UNLICENSED",
6
+ "bin": {
7
+ "media-information-download": "bin/media-information-download.js",
8
+ "media-info-download": "bin/media-information-download.js"
9
+ },
10
+ "files": [
11
+ "bin/",
12
+ "media_information_download/**/*.py",
13
+ "media_tui.py",
14
+ "youtube_download.py",
15
+ "youtube_download_transcribe.py",
16
+ "requirements.txt",
17
+ "requirements-transcribe.txt",
18
+ "pyproject.toml",
19
+ "README.md"
20
+ ],
21
+ "scripts": {
22
+ "test": "python3 -m unittest discover -s tests",
23
+ "pack:check": "npm pack --dry-run"
24
+ },
25
+ "engines": {
26
+ "node": ">=18"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/Jakende/media-information-download.git"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/Jakende/media-information-download/issues"
34
+ },
35
+ "homepage": "https://github.com/Jakende/media-information-download#readme"
36
+ }
package/pyproject.toml ADDED
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "media-information-download"
7
+ version = "0.1.0"
8
+ description = "Terminal app for downloading media from YouTube or RSS feeds, converting to MP3, and generating Whisper transcripts."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "yt-dlp>=2024.1.1",
13
+ ]
14
+
15
+ [project.optional-dependencies]
16
+ transcribe = [
17
+ "openai-whisper>=20231117",
18
+ "torch>=2.2.0",
19
+ ]
20
+
21
+ [project.scripts]
22
+ media-information-download = "media_information_download.tui:main"
23
+ media-info-download = "media_information_download.tui:main"
24
+
25
+ [tool.setuptools.packages.find]
26
+ include = ["media_information_download*"]
@@ -0,0 +1,3 @@
1
+ yt-dlp>=2024.1.1
2
+ openai-whisper>=20231117
3
+ torch>=2.2.0
@@ -0,0 +1 @@
1
+ yt-dlp>=2024.1.1
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env python3
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ import sys
6
+
7
+ from media_information_download.config import get_output_dir
8
+ from media_information_download.pipeline import MediaPipeline, ProcessOptions
9
+ from media_information_download.sources.youtube import parse_urls, validate_url
10
+
11
+
12
+ def print_error(message: str) -> None:
13
+ print(f"[ERROR] {message}", file=sys.stderr)
14
+
15
+
16
+ def parse_args() -> argparse.Namespace:
17
+ parser = argparse.ArgumentParser(description="Download YouTube video and extract MP3.")
18
+ parser.add_argument(
19
+ "--url",
20
+ help="One or more YouTube URLs, comma-separated. If omitted, prompts interactively.",
21
+ default="",
22
+ )
23
+ parser.add_argument(
24
+ "--delay",
25
+ type=float,
26
+ default=2.0,
27
+ help="Delay in seconds between batch entries. Default: 2.0",
28
+ )
29
+ return parser.parse_args()
30
+
31
+
32
+ def main() -> int:
33
+ args = parse_args()
34
+ raw_urls = args.url.strip()
35
+ if not raw_urls:
36
+ if sys.stdin.isatty():
37
+ raw_urls = input("YouTube URL(s), comma-separated: ").strip()
38
+ else:
39
+ print_error("No URL provided. Use: python3 youtube_download.py --url <URL1,URL2,...>")
40
+ return 1
41
+
42
+ urls = parse_urls(raw_urls)
43
+ invalid_urls = [url for url in urls if not validate_url(url)]
44
+ if not urls or invalid_urls:
45
+ for invalid_url in invalid_urls:
46
+ print_error(f"Invalid YouTube URL: {invalid_url}")
47
+ return 1
48
+
49
+ pipeline = MediaPipeline(progress=lambda message: print(message, flush=True))
50
+ results = pipeline.process(
51
+ ProcessOptions(
52
+ source_type="youtube",
53
+ raw_input=raw_urls,
54
+ output_dir=get_output_dir(),
55
+ transcribe=False,
56
+ delay_seconds=args.delay,
57
+ )
58
+ )
59
+ return 1 if any(result.error for result in results) else 0
60
+
61
+
62
+ if __name__ == "__main__":
63
+ raise SystemExit(main())
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env python3
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ import sys
6
+
7
+ from media_information_download.config import get_model_name, get_output_dir, get_whisper_language
8
+ from media_information_download.pipeline import MediaPipeline, ProcessOptions
9
+ from media_information_download.sources.youtube import parse_urls, validate_url
10
+
11
+
12
+ def print_error(message: str) -> None:
13
+ print(f"[ERROR] {message}", file=sys.stderr)
14
+
15
+
16
+ def parse_args() -> argparse.Namespace:
17
+ parser = argparse.ArgumentParser(description="Download YouTube video, extract MP3, transcribe to Markdown.")
18
+ parser.add_argument(
19
+ "--url",
20
+ default="",
21
+ help="One or more YouTube URLs, comma-separated.",
22
+ )
23
+ parser.add_argument(
24
+ "--delay",
25
+ type=float,
26
+ default=2.0,
27
+ help="Delay in seconds between batch entries. Default: 2.0",
28
+ )
29
+ parser.add_argument("--model", default="", help="Whisper model name. Defaults to WHISPER_MODEL or large.")
30
+ parser.add_argument("--language", default=None, help="Optional Whisper language code. Defaults to auto.")
31
+ return parser.parse_args()
32
+
33
+
34
+ def main() -> int:
35
+ args = parse_args()
36
+ raw_urls = args.url.strip()
37
+ if not raw_urls:
38
+ if sys.stdin.isatty():
39
+ raw_urls = input("YouTube URL(s), comma-separated: ").strip()
40
+ else:
41
+ print_error("No URL provided. Use: python3 youtube_download_transcribe.py --url <URL1,URL2,...>")
42
+ return 1
43
+
44
+ urls = parse_urls(raw_urls)
45
+ invalid_urls = [url for url in urls if not validate_url(url)]
46
+ if not urls or invalid_urls:
47
+ for invalid_url in invalid_urls:
48
+ print_error(f"Invalid YouTube URL: {invalid_url}")
49
+ return 1
50
+
51
+ pipeline = MediaPipeline(progress=lambda message: print(message, flush=True))
52
+ results = pipeline.process(
53
+ ProcessOptions(
54
+ source_type="youtube",
55
+ raw_input=raw_urls,
56
+ output_dir=get_output_dir(),
57
+ transcribe=True,
58
+ model_name=args.model or get_model_name(),
59
+ language=args.language if args.language is not None else get_whisper_language(),
60
+ delay_seconds=args.delay,
61
+ )
62
+ )
63
+ return 1 if any(result.error for result in results) else 0
64
+
65
+
66
+ if __name__ == "__main__":
67
+ raise SystemExit(main())