X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fyourupload.py;h=9fa77283899ceb005b6fed8f4ebcb626d38241ce;hb=HEAD;hp=40fc4165f402722eca38cbfbc7c06cf2e4409a64;hpb=f0b8e3607db6bc2e7cdfcf3175e85d9bccb22229;p=youtube-dl diff --git a/youtube_dl/extractor/yourupload.py b/youtube_dl/extractor/yourupload.py index 40fc4165f..9fa772838 100644 --- a/youtube_dl/extractor/yourupload.py +++ b/youtube_dl/extractor/yourupload.py @@ -1,58 +1,46 @@ # coding: utf-8 from __future__ import unicode_literals -import re - from .common import InfoExtractor +from ..utils import urljoin class YourUploadIE(InfoExtractor): - _VALID_URL = r'''(?x)https?://(?:www\.)? - (?:yourupload\.com/watch| - embed\.yourupload\.com| - embed\.yucache\.net - )/(?P[A-Za-z0-9]+) - ''' - _TESTS = [ - { - 'url': 'http://yourupload.com/watch/14i14h', - 'md5': 'bf5c2f95c4c917536e80936af7bc51e1', - 'info_dict': { - 'id': '14i14h', - 'ext': 'mp4', - 'title': 'BigBuckBunny_320x180.mp4', - 'thumbnail': 're:^https?://.*\.jpe?g', - } - }, - { - 'url': 'http://embed.yourupload.com/14i14h', - 'only_matching': True, - }, - { - 'url': 'http://embed.yucache.net/14i14h?client_file_id=803349', - 'only_matching': True, - }, - ] + _VALID_URL = r'https?://(?:www\.)?(?:yourupload\.com/(?:watch|embed)|embed\.yourupload\.com)/(?P[A-Za-z0-9]+)' + _TESTS = [{ + 'url': 'http://yourupload.com/watch/14i14h', + 'md5': '5e2c63385454c557f97c4c4131a393cd', + 'info_dict': { + 'id': '14i14h', + 'ext': 'mp4', + 'title': 'BigBuckBunny_320x180.mp4', + 'thumbnail': r're:^https?://.*\.jpe?g', + } + }, { + 'url': 'http://www.yourupload.com/embed/14i14h', + 'only_matching': True, + }, { + 'url': 'http://embed.yourupload.com/14i14h', + 'only_matching': True, + }] def _real_extract(self, url): - mobj = re.match(self._VALID_URL, url) - video_id = mobj.group('id') + video_id = self._match_id(url) - url = 'http://embed.yucache.net/{0:}'.format(video_id) - webpage = self._download_webpage(url, video_id) + embed_url = 'http://www.yourupload.com/embed/%s' % video_id - title = self._og_search_title(webpage) - thumbnail = self._og_search_thumbnail(webpage) - url = self._og_search_video_url(webpage) + webpage = self._download_webpage(embed_url, video_id) - formats = [{ - 'format_id': 'sd', - 'url': url, - }] + title = self._og_search_title(webpage) + video_url = urljoin(embed_url, self._og_search_video_url(webpage)) + thumbnail = self._og_search_thumbnail(webpage, default=None) return { 'id': video_id, 'title': title, - 'formats': formats, + 'url': video_url, 'thumbnail': thumbnail, + 'http_headers': { + 'Referer': embed_url, + }, }