lanbogao commited on
Commit
b4671e5
1 Parent(s): f51ada2

Mark subtitleslangs (requested_subtitles) for try speed up.

Browse files
Files changed (1) hide show
  1. fetchYoutubeSubtitle.py +11 -10
fetchYoutubeSubtitle.py CHANGED
@@ -40,15 +40,16 @@ def getUrlFromSubtitleItem(item, lang="en", subType="vtt"):
40
 
41
  def getRequestedSubtitlesUrl(info_dict, lang, subType):
42
  item = info_dict.get("requested_subtitles")
43
- langs = item.keys()
44
- for l in langs:
45
- if l.startswith(lang):
46
- item = {l: [item[l]]} if type(item[l]) == dict else item
47
- url = getUrlFromSubtitleItem(item, l, subType)
48
- if url:
49
- if debug:
50
- print("getRequestedSubtitlesUrl lang:{} url:{}".format(l, url))
51
- return url
 
52
  return None
53
 
54
 
@@ -128,7 +129,7 @@ async def fetchSubtitlebyType(
128
  "writeautomaticsub": True,
129
  # "listsubtitles": True,
130
  # "subtitlesformat": subType, # mark due to default youtube no srt and xml format
131
- "subtitleslangs": [reqLang],
132
  "skip_download": True,
133
  "socket_timeout": 10,
134
  "extractor_retries": 0,
 
40
 
41
  def getRequestedSubtitlesUrl(info_dict, lang, subType):
42
  item = info_dict.get("requested_subtitles")
43
+ if item:
44
+ langs = item.keys()
45
+ for l in langs:
46
+ if l.startswith(lang):
47
+ item = {l: [item[l]]} if type(item[l]) == dict else item
48
+ url = getUrlFromSubtitleItem(item, l, subType)
49
+ if url:
50
+ if debug:
51
+ print("getRequestedSubtitlesUrl lang:{} url:{}".format(l, url))
52
+ return url
53
  return None
54
 
55
 
 
129
  "writeautomaticsub": True,
130
  # "listsubtitles": True,
131
  # "subtitlesformat": subType, # mark due to default youtube no srt and xml format
132
+ # "subtitleslangs": [reqLang],
133
  "skip_download": True,
134
  "socket_timeout": 10,
135
  "extractor_retries": 0,