@@ -148,24 +148,31 @@ def download_vtts(number_of_jobs, video_ids, language, tmp_dir): # download, up
148148
149149def 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
155157def 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
171178def 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
278287def 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
0 commit comments