cchar = '?'
json_url = url + cchar + 'skin=json&version=2&no_wrap=1'
request = compat_urllib_request.Request(json_url)
+ request.add_header('User-Agent', 'iTunes/10.6.1')
self.report_extraction(mobj.group(1))
info = None
try:
'urlhandle': urlh
}
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
- self._downloader.trouble(u'ERROR: unable to download video info webpage: %s' % compat_str(err))
- return
+ raise ExtractorError(u'ERROR: unable to download video info webpage: %s' % compat_str(err))
if info is None: # Regular URL
try:
json_code_bytes = urlh.read()
'format': data['media']['mimeType'],
'thumbnail': data['thumbnailUrl'],
'description': data['description'],
- 'player_url': data['embedUrl']
+ 'player_url': data['embedUrl'],
+ 'user_agent': 'iTunes/10.6.1',
}
except (ValueError,KeyError) as err:
self._downloader.trouble(u'ERROR: unable to parse video information: %s' % repr(err))
return
- std_headers['User-Agent'] = 'iTunes/10.6.1'
return [info]
"""Information extractor for youjizz.com."""
_VALID_URL = r'^(?:https?://)?(?:\w+\.)?youjizz\.com/videos/(?P<videoid>[^.]+).html$'
- def __init__(self, downloader=None):
- InfoExtractor.__init__(self, downloader)
-
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
if mobj is None:
webpage = self._download_webpage(url, video_id)
# Get the video title
- VIDEO_TITLE_RE = r'<title>(?P<title>.*)</title>'
- result = re.search(VIDEO_TITLE_RE, webpage)
+ result = re.search(r'<title>(?P<title>.*)</title>', webpage)
if result is None:
- self._downloader.trouble(u'ERROR: unable to extract video title')
- return
+ raise ExtractorError(u'ERROR: unable to extract video title')
video_title = result.group('title').strip()
# Get the embed page
- EMBED_PAGE_RE = r'http://www.youjizz.com/videos/embed/(?P<videoid>[0-9]+)'
- result = re.search(EMBED_PAGE_RE, webpage)
+ result = re.search(r'https?://www.youjizz.com/videos/embed/(?P<videoid>[0-9]+)', webpage)
if result is None:
- self._downloader.trouble(u'ERROR: unable to extract embed page')
- return
+ raise ExtractorError(u'ERROR: unable to extract embed page')
embed_page_url = result.group(0).strip()
video_id = result.group('videoid')
webpage = self._download_webpage(embed_page_url, video_id)
# Get the video URL
- SOURCE_RE = r'so.addVariable\("file",encodeURIComponent\("(?P<source>[^"]+)"\)\);'
- result = re.search(SOURCE_RE, webpage)
+ result = re.search(r'so.addVariable\("file",encodeURIComponent\("(?P<source>[^"]+)"\)\);', webpage)
if result is None:
- self._downloader.trouble(u'ERROR: unable to extract video url')
- return
+ raise ExtractorError(u'ERROR: unable to extract video url')
video_url = result.group('source')
info = {'id': video_id,
'url': video_url,
- 'uploader': None,
- 'upload_date': None,
'title': video_title,
'ext': 'flv',
'format': 'flv',
- 'thumbnail': None,
- 'description': None,
'player_url': embed_page_url}
return [info]