From 922680a9dc586389ddbc9491c531199c41a5c758 Mon Sep 17 00:00:00 2001 From: Aniruddh Joshi Date: Thu, 14 Oct 2021 12:20:35 +0530 Subject: [PATCH 1/5] Add subtitles download for SonyLIV --- youtube_dl/extractor/sonyliv.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/youtube_dl/extractor/sonyliv.py b/youtube_dl/extractor/sonyliv.py index fedfceb62..dfe99c9af 100644 --- a/youtube_dl/extractor/sonyliv.py +++ b/youtube_dl/extractor/sonyliv.py @@ -96,6 +96,19 @@ class SonyLIVIE(InfoExtractor): episode = metadata.get('episodeTitle') if episode and title != episode: title += ' - ' + episode + + subtitles = {} + for subtitle in (content.get('subtitle') or []): + base_url = subtitle.get('subtitleUrl') + if not base_url: + continue + lang_code = subtitle.get('subtitleLanguageName') + if not lang_code: + continue + subtitles[lang_code] = [{ + 'ext': 'vtt', + 'url': base_url, + }] return { 'id': video_id, @@ -109,4 +122,5 @@ class SonyLIVIE(InfoExtractor): 'episode': episode, 'episode_number': int_or_none(metadata.get('episodeNumber')), 'release_year': int_or_none(metadata.get('year')), + 'subtitles': subtitles } From 30d8bbf6facbb9897c306c3a7d29993fc95db1bf Mon Sep 17 00:00:00 2001 From: Aniruddh Joshi Date: Thu, 14 Oct 2021 12:32:59 +0530 Subject: [PATCH 2/5] Fix whitespace --- youtube_dl/extractor/sonyliv.py | 1 - 1 file changed, 1 deletion(-) diff --git a/youtube_dl/extractor/sonyliv.py b/youtube_dl/extractor/sonyliv.py index dfe99c9af..155074dbc 100644 --- a/youtube_dl/extractor/sonyliv.py +++ b/youtube_dl/extractor/sonyliv.py @@ -96,7 +96,6 @@ class SonyLIVIE(InfoExtractor): episode = metadata.get('episodeTitle') if episode and title != episode: title += ' - ' + episode - subtitles = {} for subtitle in (content.get('subtitle') or []): base_url = subtitle.get('subtitleUrl') From 174b7954858fcad19eb647507a79699d2f69da5e Mon Sep 17 00:00:00 2001 From: Aniruddh Joshi Date: Fri, 15 Oct 2021 10:02:17 +0530 Subject: [PATCH 3/5] Proposed changes --- youtube_dl/extractor/sonyliv.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/sonyliv.py b/youtube_dl/extractor/sonyliv.py index 155074dbc..972cedb05 100644 --- a/youtube_dl/extractor/sonyliv.py +++ b/youtube_dl/extractor/sonyliv.py @@ -9,6 +9,7 @@ from ..compat import compat_HTTPError from ..utils import ( ExtractorError, int_or_none, + try_get ) @@ -98,7 +99,7 @@ class SonyLIVIE(InfoExtractor): title += ' - ' + episode subtitles = {} for subtitle in (content.get('subtitle') or []): - base_url = subtitle.get('subtitleUrl') + base_url = try_get(subtitle, lambda x: x['subtitleUrl'], compat_str) if not base_url: continue lang_code = subtitle.get('subtitleLanguageName') From bef35dfd9bcf9ce6ba5bb9dbfc886960a44d47e3 Mon Sep 17 00:00:00 2001 From: Aniruddh Joshi Date: Fri, 15 Oct 2021 10:05:10 +0530 Subject: [PATCH 4/5] compat_str req --- youtube_dl/extractor/sonyliv.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/sonyliv.py b/youtube_dl/extractor/sonyliv.py index 972cedb05..0e890f909 100644 --- a/youtube_dl/extractor/sonyliv.py +++ b/youtube_dl/extractor/sonyliv.py @@ -9,7 +9,8 @@ from ..compat import compat_HTTPError from ..utils import ( ExtractorError, int_or_none, - try_get + try_get, + compat_str ) From 3287b4a114ec2e2c460d22846828dad955459a9a Mon Sep 17 00:00:00 2001 From: Aniruddh Joshi Date: Fri, 15 Oct 2021 23:37:22 +0530 Subject: [PATCH 5/5] Fixed compat_str import --- youtube_dl/extractor/sonyliv.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/sonyliv.py b/youtube_dl/extractor/sonyliv.py index 0e890f909..8307c5f20 100644 --- a/youtube_dl/extractor/sonyliv.py +++ b/youtube_dl/extractor/sonyliv.py @@ -5,12 +5,14 @@ import time import uuid from .common import InfoExtractor -from ..compat import compat_HTTPError +from ..compat import ( + compat_HTTPError, + compat_str +) from ..utils import ( ExtractorError, int_or_none, - try_get, - compat_str + try_get )