Spaces:
Sleeping
Sleeping
Mark subtitleslangs (requested_subtitles) for try speed up.
Browse files- 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 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
if
|
50 |
-
|
51 |
-
|
|
|
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,
|