From 73771cd768bdff96745f4d80536c0f4e61a7f5e7 Mon Sep 17 00:00:00 2001 From: Daenges Date: Sat, 21 May 2022 16:19:18 +0200 Subject: [PATCH] Commit suggested changes. - Verify description through md5 - Implement robust detection of description - Remove format attribute to allow auto detection - Allow conditioning of URLs --- youtube_dl/extractor/megacartoons.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/youtube_dl/extractor/megacartoons.py b/youtube_dl/extractor/megacartoons.py index 5218c034efb..80c17c100c5 100644 --- a/youtube_dl/extractor/megacartoons.py +++ b/youtube_dl/extractor/megacartoons.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals import json +from ..utils import url_or_none from .common import InfoExtractor @@ -16,12 +17,7 @@ class MegaCartoonsIE(InfoExtractor): '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': 'md5:2c909daa6c6cb16b2d4d791dd1a31632' } } @@ -36,17 +32,20 @@ def _real_extract(self, url): # Video data is stored in a json -> extract it from the raw html url_json = json.loads(self._html_search_regex(r'{.*})["/\'].*>', webpage, 'videourls')) - 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 + video_url = url_or_none(url_json.get('sources')[0].get('src') or self._og_search_video_url(webpage)) # Get the video url + video_thumbnail = url_or_none(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', fatal=False) or self._og_search_description(webpage) + # Find the
class in the html + article = self._search_regex( + r'(?s)]*?\bclass\s*=\s*[^>]*?\bpost\b[^>]*>(.+?)\s*([^<]+)\s*

', article, 'videodescription', fatal=False) + or self._og_search_description(webpage)) return { 'id': video_id, 'title': title, - 'format': video_type, 'url': video_url, 'thumbnail': video_thumbnail, 'description': video_description,