From bac2ed765faebc6ca1c63c18e603900648a27509 Mon Sep 17 00:00:00 2001 From: Paul LaMendola Date: Sat, 2 Jul 2016 13:09:03 -0400 Subject: [PATCH] [XTube] Fix extraction. --- youtube_dl/extractor/xtube.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/youtube_dl/extractor/xtube.py b/youtube_dl/extractor/xtube.py index 4075b8a4f..7a4e4e014 100644 --- a/youtube_dl/extractor/xtube.py +++ b/youtube_dl/extractor/xtube.py @@ -26,7 +26,6 @@ class XTubeIE(InfoExtractor): 'title': 'strange erotica', 'description': 'contains:an ET kind of thing', 'uploader': 'greenshowers', - 'duration': 450, 'age_limit': 18, } }, { @@ -51,38 +50,39 @@ class XTubeIE(InfoExtractor): req.add_header('Cookie', 'age_verified=1; cookiesAccepted=1') webpage = self._download_webpage(req, display_id) - flashvars = self._parse_json( - self._search_regex( - r'xt\.playerOps\s*=\s*({.+?});', webpage, 'player ops'), - video_id)['flashvars'] + sources = self._search_regex(r'sources:\s*({.+?}),', webpage, 'sources') - title = flashvars.get('title') or self._search_regex( - r'

([^<]+)

', webpage, 'title') - video_url = compat_urllib_parse_unquote(flashvars['video_url']) - duration = int_or_none(flashvars.get('video_duration')) + sourcesdict = self._parse_json(sources, video_id) + + formats = [] + for formatkey in sourcesdict.keys(): + curformat = {} + curformat['height'] = int(formatkey) + curformat['url'] = sourcesdict[formatkey] + formats.append(curformat) + + formats = self._sort_formats(formats) + + title = self._search_regex( + r'videoTitle:\s*\'(.+?)\',', webpage, 'title') uploader = self._search_regex( - r']+name="contentOwnerId"[^>]+value="([^"]+)"', + r'([^<]+)', webpage, 'uploader', fatal=False) description = self._search_regex( r'\s*

([^<]+)', webpage, 'description', fatal=False) view_count = str_to_int(self._search_regex( r'

Views:
\s*
([\d,\.]+)
', webpage, 'view count', fatal=False)) - comment_count = str_to_int(self._html_search_regex( - r'>Comments? \(([\d,\.]+)\)<', - webpage, 'comment count', fatal=False)) return { 'id': video_id, 'display_id': display_id, - 'url': video_url, + 'formats': formats, 'title': title, 'description': description, 'uploader': uploader, - 'duration': duration, 'view_count': view_count, - 'comment_count': comment_count, 'age_limit': 18, }