File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 6
6
#
7
7
from minet .youtube import YouTubeScraper
8
8
from minet .youtube .types import YouTubeCaptionTrack , YouTubeCaptionLine
9
+ from minet .youtube .exceptions import YouTubeInvalidVideoTargetError
9
10
10
11
from minet .cli .utils import with_enricher_and_loading_bar
11
12
from minet .cli .loading_bar import LoadingBar
21
22
def action (cli_args , enricher , loading_bar : LoadingBar ):
22
23
scraper = YouTubeScraper ()
23
24
24
- with loading_bar .step ():
25
- for row , video in enricher .cells (cli_args .column , with_rows = True ):
26
- result = scraper .get_video_captions (video , langs = cli_args .lang )
25
+ lang_warning_printed = False
26
+
27
+ for row , video in enricher .cells (cli_args .column , with_rows = True ):
28
+ with loading_bar .step ():
29
+ try :
30
+ result = scraper .get_video_captions (video , langs = cli_args .lang )
31
+ except YouTubeInvalidVideoTargetError :
32
+ loading_bar .inc_stat ("not-a-video" , style = "error" )
33
+ continue
27
34
28
35
if result is None :
36
+ if not lang_warning_printed :
37
+ lang_warning_printed = True
38
+ loading_bar .warning (
39
+ "Did you forget to pass the correct value to [dim]--lang[/dim]?"
40
+ )
41
+
29
42
loading_bar .inc_stat ("not-found" , style = "error" )
30
43
continue
31
44
You can’t perform that action at this time.
0 commit comments