Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Support catchall for sub language without country #2167
Comments
|
Untested prototype algorithm follows: diff --git a/youtube-dl b/youtube-dl
index e3eb877..1e06aaa 100755
Binary files a/youtube-dl and b/youtube-dl differ
diff --git a/youtube_dl/extractor/subtitles.py b/youtube_dl/extractor/subtitles.py
index 4b4c523..7ab94e6 100644
--- a/youtube_dl/extractor/subtitles.py
+++ b/youtube_dl/extractor/subtitles.py
@@ -51,8 +51,13 @@ class SubtitlesInfoExtractor(InfoExtractor):
sub_lang_list = {}
for sub_lang in requested_langs:
if not sub_lang in available_subs_list:
- self._downloader.report_warning(u'no closed captions found in the specified language "%s"' % sub_lang)
- continue
+ partial_dict = dict([(x[:len(sub_lang)], x) for x in reversed(available_subs_list)])
+ if sub_lang in partial_dict:
+ self._downloader.report_warning(u'no closed captions found in the specified language "%s", found partial match for "%s"' % (sub_lang, sub_lang))
+ sub_lang = partial_dict[sub_lang]
+ else:
+ self._downloader.report_warning(u'no closed captions found in the specified language "%s"' % sub_lang)
+ continue
sub_lang_list[sub_lang] = available_subs_list[sub_lang]
subtitles = {} |
When the
--sub-langswitch is specified with a value ofenit doesn't download subs labelled with a country code likeen-US. See this session log:It would be great if failing a perfect match the program downloaded whatever first entry matched partially the user specified value, changing the warning to:
Or maybe add the partial match behaviour as an additional switch if it breaks behaviour people depend on (aka: specifying a value and failing even if partial matches are found).