From e0dcf1db42e36113e638db7fbf669a2827b41acf Mon Sep 17 00:00:00 2001 From: Ehtisham Sabir Date: Thu, 31 Mar 2022 15:21:38 +0500 Subject: [PATCH] adding https://commons.wikimedia.org to youtube-dl --- youtube_dl/extractor/wikimedia.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/wikimedia.py b/youtube_dl/extractor/wikimedia.py index 290db6baf..0cf538464 100644 --- a/youtube_dl/extractor/wikimedia.py +++ b/youtube_dl/extractor/wikimedia.py @@ -32,12 +32,14 @@ class WikimediaIE(InfoExtractor): subtitle_url = f'https://commons.wikimedia.org/w/api.php?' \ f'action=timedtext&lang=nl&title=File%3A{urllib.parse.quote(video_id)}&trackformat=srt' - with open(video_id + '.srt', 'w+', encoding='utf') as f: - subtitles = requests.post(subtitle_url).text - if 'timedtext-notfound' not in subtitles: + + subtitles = requests.post(subtitle_url).text + if 'timedtext-notfound' not in subtitles: + with open(video_id + '.srt', 'w+', encoding='utf') as f: f.write(subtitles) - else: - print("subtitles not found") + else: + print("subtitles not found") + resp['url'] = video_url resp['ext'] = 'webm' resp['id'] = video_id