]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/xboxclips.py
a9aa72e73cc67fc380a38a56c62b967e7db01e08
[youtubedl] / youtube_dl / extractor / xboxclips.py
1 # encoding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import (
8 parse_iso8601,
9 float_or_none,
10 int_or_none,
11 )
12
13
14 class XboxClipsIE(InfoExtractor):
15 _VALID_URL = r'https?://(?:www\.)?xboxclips\.com/video\.php\?.*vid=(?P<id>[\w-]{36})'
16 _TEST = {
17 'url': 'https://xboxclips.com/video.php?uid=2533274823424419&gamertag=Iabdulelah&vid=074a69a9-5faf-46aa-b93b-9909c1720325',
18 'md5': 'fbe1ec805e920aeb8eced3c3e657df5d',
19 'info_dict': {
20 'id': '074a69a9-5faf-46aa-b93b-9909c1720325',
21 'ext': 'mp4',
22 'title': 'Iabdulelah playing Upload Studio',
23 'filesize_approx': 28101836.8,
24 'timestamp': 1407388500,
25 'upload_date': '20140807',
26 'duration': 56,
27 }
28 }
29
30 def _real_extract(self, url):
31 mobj = re.match(self._VALID_URL, url)
32 video_id = mobj.group('id')
33
34 webpage = self._download_webpage(url, video_id)
35
36 video_url = self._html_search_regex(
37 r'>Link: <a href="([^"]+)">', webpage, 'video URL')
38 title = self._html_search_regex(
39 r'<title>XboxClips \| ([^<]+)</title>', webpage, 'title')
40 timestamp = parse_iso8601(self._html_search_regex(
41 r'>Recorded: ([^<]+)<', webpage, 'upload date', fatal=False))
42 filesize = float_or_none(self._html_search_regex(
43 r'>Size: ([\d\.]+)MB<', webpage, 'file size', fatal=False), invscale=1024 * 1024)
44 duration = int_or_none(self._html_search_regex(
45 r'>Duration: (\d+) Seconds<', webpage, 'duration', fatal=False))
46 view_count = int_or_none(self._html_search_regex(
47 r'>Views: (\d+)<', webpage, 'view count', fatal=False))
48
49 return {
50 'id': video_id,
51 'url': video_url,
52 'title': title,
53 'timestamp': timestamp,
54 'filesize_approx': filesize,
55 'duration': duration,
56 'view_count': view_count,
57 }