mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-01-09 11:08:49 +00: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
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
from ..utils import url_or_none
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
|
||||||
@ -16,12 +17,7 @@ class MegaCartoonsIE(InfoExtractor):
|
|||||||
'title': 'Help Wanted',
|
'title': 'Help Wanted',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'thumbnail': r're:^https?://.*\.jpg$',
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||||||
'description': 'Help Wanted: Encouraged by his best friend, Patrick Starfish, '
|
'description': 'md5:2c909daa6c6cb16b2d4d791dd1a31632'
|
||||||
'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.'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,17 +32,20 @@ class MegaCartoonsIE(InfoExtractor):
|
|||||||
# Video data is stored in a json -> extract it from the raw html
|
# 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'))
|
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_url = url_or_none(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_or_none(url_json.get('splash') or self._og_search_thumbnail(webpage)) # Get the thumbnail
|
||||||
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
|
# Find the <article> class in the html
|
||||||
video_description = self._html_search_regex(r'<p>(?P<videodescription>.*)</p>', webpage, 'videodescription', fatal=False) or self._og_search_description(webpage)
|
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 {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'format': video_type,
|
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
'thumbnail': video_thumbnail,
|
'thumbnail': video_thumbnail,
|
||||||
'description': video_description,
|
'description': video_description,
|
||||||
|
Loading…
Reference in New Issue
Block a user