From 041abb92b3ca37ce477e4d4b4f4e6d33e6263338 Mon Sep 17 00:00:00 2001 From: Daenges Date: Mon, 16 May 2022 22:32:47 +0200 Subject: [PATCH] Apply coding conventions --- youtube_dl/extractor/megacartoons.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/youtube_dl/extractor/megacartoons.py b/youtube_dl/extractor/megacartoons.py index c2789f4e9..5218c034e 100644 --- a/youtube_dl/extractor/megacartoons.py +++ b/youtube_dl/extractor/megacartoons.py @@ -13,10 +13,15 @@ class MegaCartoonsIE(InfoExtractor): 'md5': '4ba9be574f9a17abe0c074e2f955fded', 'info_dict': { 'id': 'help-wanted', - 'title': 'help-wanted', + 'title': 'Help Wanted', 'ext': 'mp4', 'thumbnail': r're:^https?://.*\.jpg$', - 'description': 'Help Wanted: Encouraged by his best friend, Patrick Starfish, SpongeBob overcomes his fears and finally applies for that dream job as a fry cook at the Krusty Krab. Challenged by the owner, Mr. Krabs, and his assistant Squidward, to prove himself worthy of the job, SpongeBob rises to the occasion, with the help of one very special spatula, by feeding a sea of ravenous anchovies.' + 'description': 'Help Wanted: Encouraged by his best friend, Patrick Starfish, ' + 'SpongeBob overcomes his fears and finally applies for that ' + 'dream job as a fry cook at the Krusty Krab. Challenged by the ' + 'owner, Mr. Krabs, and his assistant Squidward, to prove himself ' + 'worthy of the job, SpongeBob rises to the occasion, with the help ' + 'of one very special spatula, by feeding a sea of ravenous anchovies.' } } @@ -25,18 +30,18 @@ class MegaCartoonsIE(InfoExtractor): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) - # The id is equal to the title - title = video_id + # Try to find a good title or fallback to the ID + title = self._og_search_title(webpage) or video_id # Video data is stored in a json -> extract it from the raw html - url_json = json.loads(self._html_search_regex(r'{.*})".*>', webpage, 'videourls')) + url_json = json.loads(self._html_search_regex(r'{.*})["/\'].*>', webpage, 'videourls')) - video_url = url_json['sources'][0]['src'] # Get the video url - video_type = url_json['sources'][0]['type'] # Get the video type -> 'video/mp4' - video_thumbnail = url_json['splash'] # Get the thumbnail + video_url = url_json.get('sources')[0].get('src') or self._og_search_video_url(webpage) # Get the video url + video_type = url_json.get('sources')[0].get('type') # Get the video type -> 'video/mp4' + video_thumbnail = url_json.get('splash') or self._og_search_thumbnail(webpage) # Get the thumbnail # Every video has a short summary -> save it as description - video_description = self._html_search_regex(r'

(?P.*)

', webpage, 'videodescription') + video_description = self._html_search_regex(r'

(?P.*)

', webpage, 'videodescription', fatal=False) or self._og_search_description(webpage) return { 'id': video_id,