mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-12-23 12:40:11 +09:00
Commit suggested changes.
- Verify description through md5 - Implement robust detection of description - Remove format attribute to allow auto detection - Allow conditioning of URLs
This commit is contained in:
parent
041abb92b3
commit
73771cd768
@ -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 @@ class MegaCartoonsIE(InfoExtractor):
|
||||
# Video data is stored in a json -> extract it from the raw html
|
||||
url_json = json.loads(self._html_search_regex(r'<div.*data-item=["/\'](?P<videourls>{.*})["/\'].*>', 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>(?P<videodescription>.*)</p>', webpage, 'videodescription', fatal=False) or self._og_search_description(webpage)
|
||||
# Find the <article> class in the html
|
||||
article = self._search_regex(
|
||||
r'(?s)<article\b[^>]*?\bclass\s*=\s*[^>]*?\bpost\b[^>]*>(.+?)</article\b', webpage, 'post', default='')
|
||||
|
||||
# Extract the actual description from it
|
||||
video_description = (self._html_search_regex(r'(?s)<p>\s*([^<]+)\s*</p>', 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,
|
||||
|
Loading…
Reference in New Issue
Block a user