1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-12-28 06:32:52 +08:00
youtube-dl/youtube_dl/extractor/xboxclips.py

54 lines
1.9 KiB
Python
Raw Normal View History

2016-10-02 19:39:18 +08:00
# coding: utf-8
from __future__ import unicode_literals
2014-08-08 14:48:02 +08:00
from .common import InfoExtractor
from ..utils import (
int_or_none,
2015-01-01 01:59:16 +08:00
parse_filesize,
unified_strdate,
)
2014-08-08 14:48:02 +08:00
class XboxClipsIE(InfoExtractor):
2015-01-01 01:59:16 +08:00
_VALID_URL = r'https?://(?:www\.)?xboxclips\.com/(?:video\.php\?.*vid=|[^/]+/)(?P<id>[\w-]{36})'
2014-08-08 14:48:02 +08:00
_TEST = {
'url': 'http://xboxclips.com/video.php?uid=2533274823424419&gamertag=Iabdulelah&vid=074a69a9-5faf-46aa-b93b-9909c1720325',
'md5': 'fbe1ec805e920aeb8eced3c3e657df5d',
'info_dict': {
'id': '074a69a9-5faf-46aa-b93b-9909c1720325',
'ext': 'mp4',
2015-01-01 01:59:16 +08:00
'title': 'Iabdulelah playing Titanfall',
'filesize_approx': 26800000,
'upload_date': '20140807',
'duration': 56,
}
}
2014-08-08 14:48:02 +08:00
def _real_extract(self, url):
2015-01-01 01:59:16 +08:00
video_id = self._match_id(url)
2014-08-08 14:48:02 +08:00
webpage = self._download_webpage(url, video_id)
video_url = self._html_search_regex(
2015-01-11 17:25:29 +08:00
r'>(?:Link|Download): <a[^>]+href="([^"]+)"', webpage, 'video URL')
title = self._html_search_regex(
r'<title>XboxClips \| ([^<]+)</title>', webpage, 'title')
2015-01-01 01:59:16 +08:00
upload_date = unified_strdate(self._html_search_regex(
r'>Recorded: ([^<]+)<', webpage, 'upload date', fatal=False))
2015-01-01 01:59:16 +08:00
filesize = parse_filesize(self._html_search_regex(
r'>Size: ([^<]+)<', webpage, 'file size', fatal=False))
duration = int_or_none(self._html_search_regex(
r'>Duration: (\d+) Seconds<', webpage, 'duration', fatal=False))
view_count = int_or_none(self._html_search_regex(
r'>Views: (\d+)<', webpage, 'view count', fatal=False))
2014-08-08 14:48:02 +08:00
return {
'id': video_id,
'url': video_url,
'title': title,
2015-01-01 01:59:16 +08:00
'upload_date': upload_date,
'filesize_approx': filesize,
'duration': duration,
'view_count': view_count,
}