Skip to content

Commit 6b2cebe

Browse files
Merge pull request #162 from NotJoeMartinez/failed_db_add_large_channel
Failed db add large channel
2 parents 85aa66e + 3c8eb4e commit 6b2cebe

File tree

4 files changed

+27
-129
lines changed

4 files changed

+27
-129
lines changed

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "yt-fts"
7-
version = "0.1.54"
7+
version = "0.1.55"
88
description = "Search all of a YouTube channel from the command line"
99
readme = "README.md"
1010
requires-python = ">=3.8"
@@ -23,11 +23,11 @@ dependencies = [
2323
"click==8.1.7",
2424
"openai==1.35.3",
2525
"chromadb==0.5.2",
26-
"requests==2.31.0",
26+
"requests>=2.32.2,<3",
2727
"rich==13.7.1",
2828
"sqlite-utils==3.36",
2929
"beautifulsoup4==4.12.3",
30-
"yt-dlp==2024.5.27",
30+
"yt-dlp==2024.7.16",
3131
"webvtt-py==0.5.1"
3232
]
3333

requirements.txt

Lines changed: 0 additions & 111 deletions
This file was deleted.

yt_fts/download.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,24 +148,31 @@ def download_vtts(number_of_jobs, video_ids, language, tmp_dir): # download, up
148148

149149
def quiet_progress_hook(d): # download
150150
if d['status'] == 'finished':
151-
filename = Path(d['filename']).name
152-
print(f" -> {filename}")
151+
# TODO: Add verbose flag to show full path
152+
print(f" -> {d['filename']}")
153+
# filename = Path(d['filename']).name
154+
# print(f" -> {filename}")
153155

154156

155157
def get_vtt(tmp_dir, video_url, language): # download
156-
ydl_opts = {
157-
'outtmpl': f'{tmp_dir}/%(id)s',
158-
'writeinfojson': True,
159-
'writeautomaticsub': True,
160-
'subtitlesformat': 'vtt',
161-
'skip_download': True,
162-
'subtitleslangs': [language, '-live_chat'],
163-
'quiet': True,
164-
'progress_hooks': [quiet_progress_hook]
165-
}
166158

167-
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
168-
ydl.download([video_url])
159+
try:
160+
ydl_opts = {
161+
'outtmpl': f'{tmp_dir}/%(id)s',
162+
'writeinfojson': True,
163+
'writeautomaticsub': True,
164+
'subtitlesformat': 'vtt',
165+
'skip_download': True,
166+
'subtitleslangs': [language, '-live_chat'],
167+
'quiet': True,
168+
'progress_hooks': [quiet_progress_hook]
169+
}
170+
171+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
172+
ydl.download([video_url])
173+
174+
except Exception as e:
175+
console.print(f"Failed to get: {video_url}\n{e}")
169176

170177

171178
def vtt_to_db(dir_path): # download, update
@@ -264,6 +271,7 @@ def download_channel(channel_id, channel_name, language, number_of_jobs, s): #
264271
import tempfile
265272
from yt_fts.db_utils import add_channel_info
266273

274+
# TODO: Allow for partial downloads
267275
with tempfile.TemporaryDirectory() as tmp_dir:
268276
channel_url = f"https://www.youtube.com/channel/{channel_id}/videos"
269277
list_of_videos_urls = get_videos_list(channel_url)
@@ -275,6 +283,7 @@ def download_channel(channel_id, channel_name, language, number_of_jobs, s): #
275283
return True
276284

277285

286+
# TODO: Allow for partial downloads
278287
def download_playlist(playlist_url, s, language=None, number_of_jobs=None): # yt-fts
279288
"""
280289
Downloads all subtitles from playlist, making new channels where needed

yt_fts/yt_fts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
show_message
2727
)
2828

29-
YT_FTS_VERSION = "0.1.54"
29+
YT_FTS_VERSION = "0.1.55"
3030
console = Console()
3131

3232

0 commit comments

Comments
 (0)