From 76f2b63a26a5dd416b2760d9b3e23155f7f27f92 Mon Sep 17 00:00:00 2001 From: kikuyan Date: Mon, 25 Oct 2021 10:38:32 +0900 Subject: [PATCH 1/5] [extractor/mtv] fix mgid extraction Fixes: #29814, #30139 --- youtube_dl/extractor/mtv.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/mtv.py b/youtube_dl/extractor/mtv.py index 5a5205c0e..142945b09 100644 --- a/youtube_dl/extractor/mtv.py +++ b/youtube_dl/extractor/mtv.py @@ -290,7 +290,17 @@ class MTVServicesInfoExtractor(InfoExtractor): main_container = self._extract_child_with_type(data, 'MainContainer') ab_testing = self._extract_child_with_type(main_container, 'ABTesting') video_player = self._extract_child_with_type(ab_testing or main_container, 'VideoPlayer') - mgid = video_player['props']['media']['video']['config']['uri'] + if video_player: + mgid = video_player['props']['media']['video']['config']['uri'] + else: + flex_wrapper = self._extract_child_with_type(ab_testing or main_container, 'FlexWrapper') + auth_suite_wrapper = self._extract_child_with_type(flex_wrapper, 'AuthSuiteWrapper') + player = self._extract_child_with_type(auth_suite_wrapper or flex_wrapper, 'Player') + if player: + mgid = player['props']['videoDetail']['mgid'] + + if not mgid: + raise ExtractorError('Could not extract mgid') return mgid From 2fe0d70b6e3d301cdd2c48e8293325cae5345301 Mon Sep 17 00:00:00 2001 From: Sipherdrakon <64430430+Sipherdrakon@users.noreply.github.com> Date: Wed, 24 Nov 2021 03:01:49 -0500 Subject: [PATCH 2/5] Update test for SouthPark Original PR: https://github.com/yt-dlp/yt-dlp/pull/1713 Authored by: Sipherdrakon --- youtube_dl/extractor/southpark.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/youtube_dl/extractor/southpark.py b/youtube_dl/extractor/southpark.py index 0774da06e..eb784291f 100644 --- a/youtube_dl/extractor/southpark.py +++ b/youtube_dl/extractor/southpark.py @@ -6,19 +6,18 @@ from .mtv import MTVServicesInfoExtractor class SouthParkIE(MTVServicesInfoExtractor): IE_NAME = 'southpark.cc.com' - _VALID_URL = r'https?://(?:www\.)?(?Psouthpark(?:\.cc|studios)\.com/(?:clips|(?:full-)?episodes|collections)/(?P.+?)(\?|#|$))' + _VALID_URL = r'https?://(?:www\.)?(?Psouthpark(?:\.cc|studios)\.com/((?:video-)?clips|(?:full-)?episodes|collections)/(?P.+?)(\?|#|$))' _FEED_URL = 'http://feeds.mtvnservices.com/od/feed/intl-mrss-player-feed' _TESTS = [{ - 'url': 'http://southpark.cc.com/clips/104437/bat-daded#tab=featured', + 'url': 'https://southpark.cc.com/video-clips/d7wr06/south-park-you-all-agreed-to-counseling', 'info_dict': { - 'id': 'a7bff6c2-ed00-11e0-aca6-0026b9414f30', 'ext': 'mp4', - 'title': 'South Park|Bat Daded', - 'description': 'Randy disqualifies South Park by getting into a fight with Bat Dad.', - 'timestamp': 1112760000, - 'upload_date': '20050406', + 'title': 'You All Agreed to Counseling', + 'description': 'Kenny, Cartman, Stan, and Kyle visit Mr. Mackey and ask for his help getting Mrs. Nelson to come back. Mr. Mackey reveals the only way to get things back to normal is to get the teachers vaccinated.', + 'timestamp': 1615352400, + 'upload_date': '20210310', }, }, { 'url': 'http://southpark.cc.com/collections/7758/fan-favorites/1', @@ -40,11 +39,11 @@ class SouthParkIE(MTVServicesInfoExtractor): class SouthParkEsIE(SouthParkIE): IE_NAME = 'southpark.cc.com:español' - _VALID_URL = r'https?://(?:www\.)?(?Psouthpark\.cc\.com/episodios-en-espanol/(?P.+?)(\?|#|$))' + _VALID_URL = r'https?://(?:www\.)?(?Psouthpark\.cc\.com/es/episodios/(?P.+?)(\?|#|$))' _LANG = 'es' _TESTS = [{ - 'url': 'http://southpark.cc.com/episodios-en-espanol/s01e01-cartman-consigue-una-sonda-anal#source=351c1323-0b96-402d-a8b9-40d01b2e9bde&position=1&sort=!airdate', + 'url': 'http://southpark.cc.com/es/episodios/s01e01-cartman-consigue-una-sonda-anal#source=351c1323-0b96-402d-a8b9-40d01b2e9bde&position=1&sort=!airdate', 'info_dict': { 'title': 'Cartman Consigue Una Sonda Anal', 'description': 'Cartman Consigue Una Sonda Anal', From 1cd4bb0d829db8e7c36090aee564d34fe420135c Mon Sep 17 00:00:00 2001 From: dirkf Date: Sun, 27 Feb 2022 04:52:38 +0000 Subject: [PATCH 3/5] [mtv] Get timestamp from if not found in of feed XML --- youtube_dl/extractor/mtv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/mtv.py b/youtube_dl/extractor/mtv.py index 142945b09..36caf9f1b 100644 --- a/youtube_dl/extractor/mtv.py +++ b/youtube_dl/extractor/mtv.py @@ -157,7 +157,7 @@ class MTVServicesInfoExtractor(InfoExtractor): description = strip_or_none(xpath_text(itemdoc, 'description')) - timestamp = timeconvert(xpath_text(itemdoc, 'pubDate')) + timestamp = timeconvert(xpath_text(itemdoc, 'pubDate') or xpath_text(itemdoc, 'airDate')) title_el = None if title_el is None: From 81d6b10f48d255b762d0e7a08612d0d510ea0234 Mon Sep 17 00:00:00 2001 From: dirkf Date: Sun, 27 Feb 2022 04:54:24 +0000 Subject: [PATCH 4/5] [utils] timeconvert() should return int --- youtube_dl/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index e722eed58..363aaaf1c 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -2074,7 +2074,7 @@ def timeconvert(timestr): timetuple = email.utils.parsedate_tz(timestr) if timetuple is not None: timestamp = email.utils.mktime_tz(timetuple) - return timestamp + return int(timestamp) if timestamp is not None else timestamp def sanitize_filename(s, restricted=False, is_id=False): From 44f73880fed2cd1f4095fb1af7641bf82563ab4a Mon Sep 17 00:00:00 2001 From: dirkf Date: Sun, 27 Feb 2022 04:55:00 +0000 Subject: [PATCH 5/5] [SouthPark] Fix tests again --- youtube_dl/extractor/southpark.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/southpark.py b/youtube_dl/extractor/southpark.py index eb784291f..3277b49f1 100644 --- a/youtube_dl/extractor/southpark.py +++ b/youtube_dl/extractor/southpark.py @@ -13,10 +13,11 @@ class SouthParkIE(MTVServicesInfoExtractor): _TESTS = [{ 'url': 'https://southpark.cc.com/video-clips/d7wr06/south-park-you-all-agreed-to-counseling', 'info_dict': { + 'id': '31929ad5-8269-11eb-8774-70df2f866ace', 'ext': 'mp4', 'title': 'You All Agreed to Counseling', 'description': 'Kenny, Cartman, Stan, and Kyle visit Mr. Mackey and ask for his help getting Mrs. Nelson to come back. Mr. Mackey reveals the only way to get things back to normal is to get the teachers vaccinated.', - 'timestamp': 1615352400, + 'timestamp': 1615377600, 'upload_date': '20210310', }, }, { @@ -68,6 +69,7 @@ class SouthParkDeIE(SouthParkIE): 'timestamp': 1380160800, 'upload_date': '20130926', }, + 'skip': 'Geo-restricted', }, { # non-ASCII characters in initial URL 'url': 'http://www.southpark.de/alle-episoden/s18e09-hashtag-aufwärmen', @@ -76,6 +78,7 @@ class SouthParkDeIE(SouthParkIE): 'description': 'Kyle will mit seinem kleinen Bruder Ike Videospiele spielen. Als der nicht mehr mit ihm spielen will, hat Kyle Angst, dass er die Kids von heute nicht mehr versteht.', }, 'playlist_count': 3, + 'skip': 'Geo-restricted', }, { # non-ASCII characters in redirect URL 'url': 'http://www.southpark.de/alle-episoden/s18e09', @@ -84,6 +87,7 @@ class SouthParkDeIE(SouthParkIE): 'description': 'Kyle will mit seinem kleinen Bruder Ike Videospiele spielen. Als der nicht mehr mit ihm spielen will, hat Kyle Angst, dass er die Kids von heute nicht mehr versteht.', }, 'playlist_count': 3, + 'skip': 'Geo-restricted', }, { 'url': 'http://www.southpark.de/collections/2476/superhero-showdown/1', 'only_matching': True, @@ -102,6 +106,7 @@ class SouthParkNlIE(SouthParkIE): 'description': 'Stan is addicted to the new Terrance and Phillip mobile game.', }, 'playlist_mincount': 3, + 'skip': 'Geo-restricted', }] @@ -117,6 +122,7 @@ class SouthParkDkIE(SouthParkIE): 'description': 'Butters is convinced he\'s living in a virtual reality.', }, 'playlist_mincount': 3, + 'skip': 'Geo-restricted', }, { 'url': 'http://www.southparkstudios.dk/collections/2476/superhero-showdown/1', 'only_matching': True,