youthsee 0.0.7__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,144 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # pipenv
88
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
90
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
91
+ # install all needed dependencies.
92
+ #Pipfile.lock
93
+
94
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95
+ __pypackages__/
96
+
97
+ # Celery stuff
98
+ celerybeat-schedule
99
+ celerybeat.pid
100
+
101
+ # SageMath parsed files
102
+ *.sage.py
103
+
104
+ # Environments
105
+ .env
106
+ .venv
107
+ env/
108
+ venv/
109
+ ENV/
110
+ env.bak/
111
+ venv.bak/
112
+ tmp/
113
+
114
+ # Spyder project settings
115
+ .spyderproject
116
+ .spyproject
117
+
118
+ # Rope project settings
119
+ .ropeproject
120
+
121
+ # mkdocs documentation
122
+ /site
123
+
124
+ # mypy
125
+ .mypy_cache/
126
+ .dmypy.json
127
+ dmypy.json
128
+
129
+ # Pyre type checker
130
+ .pyre/
131
+
132
+ # IDEs and editors
133
+ .idea/*
134
+ .project
135
+ .classpath
136
+ .c9/
137
+ *.launch
138
+ .settings/
139
+ *.sublime-workspace
140
+
141
+ # IDE - VSCode
142
+ .vscode/*
143
+ .DS_Store
144
+ scalene-*
youthsee-0.0.7/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 youthsee contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: youthsee
3
+ Version: 0.0.7
4
+ Summary: A local-first Python toolkit for collecting, transcribing, and organizing YouTube knowledge.
5
+ License-File: LICENSE
6
+ Requires-Dist: browser-cookie3>=0.20.1
7
+ Requires-Dist: typer>=0.21.1
8
+ Requires-Dist: yt-dlp>=2026.1.31
9
+ Dynamic: license-file
@@ -0,0 +1,49 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "setuptools_scm[toml]>=8"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "youthsee"
7
+ dynamic = ["version"]
8
+ description = "A local-first Python toolkit for collecting, transcribing, and organizing YouTube knowledge."
9
+ dependencies = [
10
+ "browser-cookie3>=0.20.1",
11
+ "typer>=0.21.1",
12
+ "yt-dlp>=2026.1.31",
13
+ ]
14
+
15
+ [project.scripts]
16
+ youthsee = "youthsee.cli:app"
17
+
18
+ [dependency-groups]
19
+ test = [
20
+ "pytest<8.0.0,>=7.4.3",
21
+ "pytest-asyncio>=0.23.8",
22
+ "pytest-cov<4.0.0,>=3.0.0",
23
+ "pytest-mock>=3.15.1",
24
+ "python-dotenv>=1.2.1",
25
+ ]
26
+ lint = [
27
+ "ruff<1.0.0,>=0.2.2",
28
+ "mypy<2.0.0,>=1.8.0",
29
+ "pre-commit<4.0.0,>=3.6.2",
30
+ "scalene>=2.1.3",
31
+ ]
32
+
33
+ [tool.setuptools]
34
+ package-dir = { "" = "src" }
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = ["src"]
38
+ namespaces = true
39
+
40
+ [tool.setuptools_scm]
41
+ version_scheme = "release-branch-semver"
42
+ local_scheme = "node-and-date"
43
+ tag_regex = "^v(?P<version>\\d+\\.\\d+\\.\\d+(?:a\\d+|b\\d+|rc\\d+)?)$"
44
+
45
+ [tool.pytest.ini_options]
46
+ pythonpath = ["src"]
47
+ testpaths = ["tests"]
48
+ python_files = "test_*.py"
49
+ log_cli = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,8 @@
1
+ from ..youthsee.services.cookies_extractor import CookiesExtractor
2
+ from ..youthsee.services.video_downloader import VideoDownloader
3
+
4
+ DOWNLOAD_STORE = "~/Downloads/_YouthSee"
5
+
6
+ if __name__ == "__main__":
7
+ CookiesExtractor().export_cookies_txt("cookies.txt", domain="youtube.com")
8
+ VideoDownloader(DOWNLOAD_STORE).download("https://www.youtube.com/watch?v=TQjLFNpu4r8")
@@ -0,0 +1,4 @@
1
+ from ..youthsee.services.cookies_extractor import CookiesExtractor
2
+
3
+ if __name__ == "__main__":
4
+ print(CookiesExtractor().export_cookies_str(domain="youtube.com"))
@@ -0,0 +1,7 @@
1
+ from ..youthsee.services.channel_manager import ChannelManager
2
+
3
+ if __name__ == "__main__":
4
+ cm = ChannelManager(channel_url="https://www.youtube.com/@IBM/videos")
5
+ videos = cm.get_video_infos()
6
+ print(f"Total videos: {len(videos)}")
7
+ print(videos)
@@ -0,0 +1,76 @@
1
+ import typer
2
+ from pathlib import Path
3
+ from typing import Optional
4
+
5
+ from .services.channel_manager import ChannelManager
6
+ from .services.cookies_extractor import CookiesExtractor
7
+ from .services.video_downloader import VideoDownloader
8
+
9
+
10
+ app = typer.Typer(help="Youthsee – YouTube knowledge pipeline")
11
+
12
+
13
+ # ─────────────────────────
14
+ # 🍪 Cookies
15
+ # ─────────────────────────
16
+
17
+ @app.command("show-cookies")
18
+ def show_cookies():
19
+ """
20
+ Show extracted YouTube cookies from browser (debug purpose).
21
+ """
22
+ print(CookiesExtractor().export_cookies_str(domain="youtube.com"))
23
+
24
+
25
+ @app.command("save-cookies")
26
+ def save_cookies(
27
+ output: Path = typer.Option("cookies.txt", help="Output cookies.txt"),
28
+ ):
29
+ """
30
+ Export YouTube cookies to cookies.txt (Netscape format).
31
+ """
32
+ CookiesExtractor().export_cookies_txt(output_file=output, domain="youtube.com")
33
+ typer.echo(f"✅ Cookies saved to {output}")
34
+
35
+
36
+ # ─────────────────────────
37
+ # 🎬 Download
38
+ # ─────────────────────────
39
+
40
+ @app.command("download-video")
41
+ def download_video(
42
+ url: str = typer.Argument(..., help="YouTube video URL"),
43
+ cookies: Path = typer.Option("cookies.txt", help="cookies.txt"),
44
+ outdir: Path = typer.Option("~/Downloads/_YouthSee", help="Output directory"),
45
+ ):
46
+ """
47
+ Download YouTube video.
48
+ """
49
+ CookiesExtractor().export_cookies_txt(cookies, domain="youtube.com")
50
+ VideoDownloader(outdir).download(url)
51
+ typer.echo(f"⬇️ Video has downloaded to: {outdir}")
52
+
53
+
54
+ # ─────────────────────────
55
+ # 📋 List videos
56
+ # ─────────────────────────
57
+
58
+ @app.command("list-videos")
59
+ def list_videos(
60
+ channel_url: str = typer.Argument(..., help="Channel URL"),
61
+ only: Optional[str] = typer.Option(
62
+ None, help="Filter: video | short | live"
63
+ ),
64
+ ):
65
+ """
66
+ List videos in a channel (optionally filter shorts/live).
67
+ """
68
+ cm = ChannelManager(channel_url=channel_url)
69
+ videos = cm.get_video_infos()
70
+
71
+ for v in videos:
72
+ typer.echo(
73
+ f"{v['title']:<90} ({v['duration']}s)"
74
+ )
75
+
76
+ typer.echo(f"\nTotal: {len(videos)}")
@@ -0,0 +1,29 @@
1
+ from yt_dlp import YoutubeDL
2
+
3
+
4
+ class ChannelManager:
5
+
6
+ def __init__(self, channel_url):
7
+ self._channel_url = channel_url
8
+ self._ydl_opts = {
9
+ "extract_flat": True, # --flat-playlist
10
+ "skip_download": True,
11
+ "quiet": True,
12
+ }
13
+
14
+ def get_video_infos(self):
15
+ return list(self._video_iter())
16
+
17
+ def _video_iter(self):
18
+ with YoutubeDL(self._ydl_opts) as ydl:
19
+ info = ydl.extract_info(self._channel_url, download=False)
20
+
21
+ for e in info["entries"]:
22
+ yield {
23
+ "id": e.get("id"),
24
+ "title": e.get("title"),
25
+ "url": e.get("url"),
26
+ "duration": e.get("duration"),
27
+ "upload_date": e.get("upload_date"),
28
+ "channel": e.get("channel"),
29
+ }
@@ -0,0 +1,63 @@
1
+ import browser_cookie3
2
+ import http.cookiejar as cookiejar
3
+
4
+ class CookiesExtractor:
5
+
6
+ def export_cookies_jar(self, domain: str | None = None):
7
+ """
8
+ Export cookies từ Google Chrome ra MozillaCookieJar object (Netscape format)
9
+
10
+ :param domain: ví dụ "youtube.com" để lọc cookie
11
+ """
12
+ cj = cookiejar.MozillaCookieJar()
13
+
14
+ # 🔒 Chỉ đọc cookies từ Chrome
15
+ cookies = browser_cookie3.chrome(domain_name=domain)
16
+
17
+ for c in cookies:
18
+ ck = cookiejar.Cookie(
19
+ version=0,
20
+ name=c.name,
21
+ value=c.value,
22
+ port=None,
23
+ port_specified=False,
24
+ domain=c.domain,
25
+ domain_specified=True,
26
+ domain_initial_dot=c.domain.startswith("."),
27
+ path=c.path,
28
+ path_specified=True,
29
+ secure=c.secure,
30
+ expires=c.expires,
31
+ discard=False,
32
+ comment=None,
33
+ comment_url=None,
34
+ rest={"HttpOnly": c.has_nonstandard_attr("HttpOnly")},
35
+ rfc2109=True,
36
+ )
37
+ cj.set_cookie(ck)
38
+
39
+ return cj
40
+
41
+ def export_cookies_txt(self,
42
+ output_file: str = "cookies.txt",
43
+ domain: str | None = None,
44
+ ):
45
+ """
46
+ Export cookies từ Google Chrome ra file cookies.txt (Netscape format)
47
+
48
+ :param output_file: đường dẫn file output
49
+ :param domain: ví dụ "youtube.com" để lọc cookie
50
+ """
51
+ cj = self.export_cookies_jar(domain=domain)
52
+ cj.save(output_file, ignore_discard=True, ignore_expires=True)
53
+ print(f"✅ Chrome cookies saved to {output_file}")
54
+
55
+ def export_cookies_str(self, domain: str | None = None) -> str:
56
+ return self._cookiejar_to_string(self.export_cookies_jar(domain=domain))
57
+
58
+ def _cookiejar_to_string(self, cj: cookiejar.MozillaCookieJar) -> str:
59
+ import tempfile
60
+ with tempfile.NamedTemporaryFile(mode="w+", delete=True) as f:
61
+ cj.save(f.name, ignore_discard=True, ignore_expires=True)
62
+ f.seek(0)
63
+ return f.read()
@@ -0,0 +1,45 @@
1
+ from yt_dlp import YoutubeDL
2
+
3
+ from ..utils._path_util import resolve_path
4
+
5
+ class VideoDownloader:
6
+ def __init__(self, download_store, cookies_txt_path: str | None = None):
7
+ self._download_store = resolve_path(download_store)
8
+ self._download_store.mkdir(parents=True, exist_ok=True)
9
+
10
+ self._ydl_opts = {
11
+ # Auth
12
+ "cookiefile": cookies_txt_path or "cookies.txt",
13
+
14
+ # JS challenge (YouTube 2025)
15
+ "js_runtimes": {
16
+ "node": {}
17
+ },
18
+ "extractor_args": {
19
+ "youtube": {
20
+ "player_skip": [],
21
+ }
22
+ },
23
+ "remote_components": ["ejs:github"],
24
+
25
+ # Format: MP4 <= 360p
26
+ "format": "best[ext=mp4][height<=360]",
27
+
28
+ # Output
29
+ "outtmpl": f"{self._download_store}/%(channel)s/%(channel)s | %(title)s | [%(id)s].%(ext)s",
30
+
31
+ "windowsfilenames": True,
32
+ "restrictfilenames": False,
33
+
34
+ # Network stability
35
+ "force_ipv4": True,
36
+ "noplaylist": True,
37
+
38
+ # Logging
39
+ "quiet": False,
40
+ "no_warnings": False,
41
+ }
42
+
43
+ def download(self, yt_url):
44
+ with YoutubeDL(self._ydl_opts) as ydl:
45
+ ydl.download([yt_url])
@@ -0,0 +1,9 @@
1
+ from pathlib import Path
2
+
3
+ def resolve_path(path: str | Path) -> Path:
4
+ """
5
+ Resolve path:
6
+ - expand ~
7
+ - convert to absolute path
8
+ """
9
+ return Path(path).expanduser().resolve()
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: youthsee
3
+ Version: 0.0.7
4
+ Summary: A local-first Python toolkit for collecting, transcribing, and organizing YouTube knowledge.
5
+ License-File: LICENSE
6
+ Requires-Dist: browser-cookie3>=0.20.1
7
+ Requires-Dist: typer>=0.21.1
8
+ Requires-Dist: yt-dlp>=2026.1.31
9
+ Dynamic: license-file
@@ -0,0 +1,17 @@
1
+ .gitignore
2
+ LICENSE
3
+ pyproject.toml
4
+ src/examples/download.py
5
+ src/examples/show_cookies.py
6
+ src/examples/show_videos.py
7
+ src/youthsee/cli.py
8
+ src/youthsee.egg-info/PKG-INFO
9
+ src/youthsee.egg-info/SOURCES.txt
10
+ src/youthsee.egg-info/dependency_links.txt
11
+ src/youthsee.egg-info/entry_points.txt
12
+ src/youthsee.egg-info/requires.txt
13
+ src/youthsee.egg-info/top_level.txt
14
+ src/youthsee/services/channel_manager.py
15
+ src/youthsee/services/cookies_extractor.py
16
+ src/youthsee/services/video_downloader.py
17
+ src/youthsee/utils/_path_util.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ youthsee = youthsee.cli:app
@@ -0,0 +1,3 @@
1
+ browser-cookie3>=0.20.1
2
+ typer>=0.21.1
3
+ yt-dlp>=2026.1.31
@@ -0,0 +1,2 @@
1
+ examples
2
+ youthsee