[xboxclips] Fix extraction

This commit is contained in:
Sergey M․ 2014-12-31 23:59:16 +06:00
parent f86d543ebb
commit 7b24bbdf49

View File

@ -1,46 +1,42 @@
# encoding: utf-8 # encoding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
parse_iso8601,
float_or_none,
int_or_none, int_or_none,
parse_filesize,
unified_strdate,
) )
class XboxClipsIE(InfoExtractor): class XboxClipsIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?xboxclips\.com/video\.php\?.*vid=(?P<id>[\w-]{36})' _VALID_URL = r'https?://(?:www\.)?xboxclips\.com/(?:video\.php\?.*vid=|[^/]+/)(?P<id>[\w-]{36})'
_TEST = { _TEST = {
'url': 'https://xboxclips.com/video.php?uid=2533274823424419&gamertag=Iabdulelah&vid=074a69a9-5faf-46aa-b93b-9909c1720325', 'url': 'https://xboxclips.com/video.php?uid=2533274823424419&gamertag=Iabdulelah&vid=074a69a9-5faf-46aa-b93b-9909c1720325',
'md5': 'fbe1ec805e920aeb8eced3c3e657df5d', 'md5': 'fbe1ec805e920aeb8eced3c3e657df5d',
'info_dict': { 'info_dict': {
'id': '074a69a9-5faf-46aa-b93b-9909c1720325', 'id': '074a69a9-5faf-46aa-b93b-9909c1720325',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Iabdulelah playing Upload Studio', 'title': 'Iabdulelah playing Titanfall',
'filesize_approx': 28101836.8, 'filesize_approx': 26800000,
'timestamp': 1407388500,
'upload_date': '20140807', 'upload_date': '20140807',
'duration': 56, 'duration': 56,
} }
} }
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) video_id = self._match_id(url)
video_id = mobj.group('id')
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
video_url = self._html_search_regex( video_url = self._html_search_regex(
r'>Link: <a href="([^"]+)">', webpage, 'video URL') r'>(?:Link|Download): <a href="([^"]+)">', webpage, 'video URL')
title = self._html_search_regex( title = self._html_search_regex(
r'<title>XboxClips \| ([^<]+)</title>', webpage, 'title') r'<title>XboxClips \| ([^<]+)</title>', webpage, 'title')
timestamp = parse_iso8601(self._html_search_regex( upload_date = unified_strdate(self._html_search_regex(
r'>Recorded: ([^<]+)<', webpage, 'upload date', fatal=False)) r'>Recorded: ([^<]+)<', webpage, 'upload date', fatal=False))
filesize = float_or_none(self._html_search_regex( filesize = parse_filesize(self._html_search_regex(
r'>Size: ([\d\.]+)MB<', webpage, 'file size', fatal=False), invscale=1024 * 1024) r'>Size: ([^<]+)<', webpage, 'file size', fatal=False))
duration = int_or_none(self._html_search_regex( duration = int_or_none(self._html_search_regex(
r'>Duration: (\d+) Seconds<', webpage, 'duration', fatal=False)) r'>Duration: (\d+) Seconds<', webpage, 'duration', fatal=False))
view_count = int_or_none(self._html_search_regex( view_count = int_or_none(self._html_search_regex(
@ -50,7 +46,7 @@ class XboxClipsIE(InfoExtractor):
'id': video_id, 'id': video_id,
'url': video_url, 'url': video_url,
'title': title, 'title': title,
'timestamp': timestamp, 'upload_date': upload_date,
'filesize_approx': filesize, 'filesize_approx': filesize,
'duration': duration, 'duration': duration,
'view_count': view_count, 'view_count': view_count,