]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/xboxclips.py
Merge pull request #8061 from dstftw/introduce-chapter-and-series-fields
[yt-dlp.git] / youtube_dl / extractor / xboxclips.py
CommitLineData
64d02399 1# encoding: utf-8
31bf2130
S
2from __future__ import unicode_literals
3
64d02399 4from .common import InfoExtractor
31bf2130 5from ..utils import (
31bf2130 6 int_or_none,
7b24bbdf
S
7 parse_filesize,
8 unified_strdate,
31bf2130
S
9)
10
64d02399 11
12class XboxClipsIE(InfoExtractor):
7b24bbdf 13 _VALID_URL = r'https?://(?:www\.)?xboxclips\.com/(?:video\.php\?.*vid=|[^/]+/)(?P<id>[\w-]{36})'
64d02399 14 _TEST = {
31bf2130
S
15 'url': 'https://xboxclips.com/video.php?uid=2533274823424419&gamertag=Iabdulelah&vid=074a69a9-5faf-46aa-b93b-9909c1720325',
16 'md5': 'fbe1ec805e920aeb8eced3c3e657df5d',
17 'info_dict': {
18 'id': '074a69a9-5faf-46aa-b93b-9909c1720325',
19 'ext': 'mp4',
7b24bbdf
S
20 'title': 'Iabdulelah playing Titanfall',
21 'filesize_approx': 26800000,
31bf2130
S
22 'upload_date': '20140807',
23 'duration': 56,
24 }
25 }
64d02399 26
27 def _real_extract(self, url):
7b24bbdf 28 video_id = self._match_id(url)
64d02399 29
30 webpage = self._download_webpage(url, video_id)
64d02399 31
31bf2130 32 video_url = self._html_search_regex(
d156a1d9 33 r'>(?:Link|Download): <a[^>]+href="([^"]+)"', webpage, 'video URL')
31bf2130
S
34 title = self._html_search_regex(
35 r'<title>XboxClips \| ([^<]+)</title>', webpage, 'title')
7b24bbdf 36 upload_date = unified_strdate(self._html_search_regex(
31bf2130 37 r'>Recorded: ([^<]+)<', webpage, 'upload date', fatal=False))
7b24bbdf
S
38 filesize = parse_filesize(self._html_search_regex(
39 r'>Size: ([^<]+)<', webpage, 'file size', fatal=False))
31bf2130
S
40 duration = int_or_none(self._html_search_regex(
41 r'>Duration: (\d+) Seconds<', webpage, 'duration', fatal=False))
42 view_count = int_or_none(self._html_search_regex(
43 r'>Views: (\d+)<', webpage, 'view count', fatal=False))
64d02399 44
45 return {
31bf2130
S
46 'id': video_id,
47 'url': video_url,
48 'title': title,
7b24bbdf 49 'upload_date': upload_date,
31bf2130
S
50 'filesize_approx': filesize,
51 'duration': duration,
52 'view_count': view_count,
53 }