2021-02-19 20:44:36 +00:00
|
|
|
import re
|
|
|
|
|
2014-08-08 06:48:02 +00:00
|
|
|
from .common import InfoExtractor
|
2014-08-08 12:21:24 +00:00
|
|
|
from ..utils import (
|
|
|
|
int_or_none,
|
2021-02-19 20:44:36 +00:00
|
|
|
month_by_abbreviation,
|
2014-12-31 17:59:16 +00:00
|
|
|
parse_filesize,
|
2021-08-22 19:02:00 +00:00
|
|
|
parse_qs,
|
2014-08-08 12:21:24 +00:00
|
|
|
)
|
|
|
|
|
2014-08-08 06:48:02 +00:00
|
|
|
|
|
|
|
class XboxClipsIE(InfoExtractor):
|
2021-02-19 20:44:36 +00:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?(?:xboxclips\.com|gameclips\.io)/(?:video\.php\?.*vid=|[^/]+/)(?P<id>[\da-f]{8}-(?:[\da-f]{4}-){3}[\da-f]{12})'
|
|
|
|
_TESTS = [{
|
2016-04-14 19:30:38 +00:00
|
|
|
'url': 'http://xboxclips.com/video.php?uid=2533274823424419&gamertag=Iabdulelah&vid=074a69a9-5faf-46aa-b93b-9909c1720325',
|
2014-08-08 12:21:24 +00:00
|
|
|
'md5': 'fbe1ec805e920aeb8eced3c3e657df5d',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '074a69a9-5faf-46aa-b93b-9909c1720325',
|
|
|
|
'ext': 'mp4',
|
2021-02-19 20:44:36 +00:00
|
|
|
'title': 'iAbdulElah playing Titanfall',
|
2014-12-31 17:59:16 +00:00
|
|
|
'filesize_approx': 26800000,
|
2014-08-08 12:21:24 +00:00
|
|
|
'upload_date': '20140807',
|
|
|
|
'duration': 56,
|
|
|
|
}
|
2021-02-19 20:44:36 +00:00
|
|
|
}, {
|
|
|
|
'url': 'https://gameclips.io/iAbdulElah/074a69a9-5faf-46aa-b93b-9909c1720325',
|
|
|
|
'only_matching': True,
|
|
|
|
}]
|
2014-08-08 06:48:02 +00:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2014-12-31 17:59:16 +00:00
|
|
|
video_id = self._match_id(url)
|
2014-08-08 06:48:02 +00:00
|
|
|
|
2021-02-19 20:44:36 +00:00
|
|
|
if '/video.php' in url:
|
2021-08-22 19:02:00 +00:00
|
|
|
qs = parse_qs(url)
|
2021-02-19 20:44:36 +00:00
|
|
|
url = 'https://gameclips.io/%s/%s' % (qs['gamertag'][0], qs['vid'][0])
|
|
|
|
|
2014-08-08 06:48:02 +00:00
|
|
|
webpage = self._download_webpage(url, video_id)
|
2021-02-19 20:44:36 +00:00
|
|
|
info = self._parse_html5_media_entries(url, webpage, video_id)[0]
|
2014-08-08 06:48:02 +00:00
|
|
|
|
2021-02-19 20:44:36 +00:00
|
|
|
title = self._html_search_meta(['og:title', 'twitter:title'], webpage)
|
|
|
|
upload_date = None
|
|
|
|
mobj = re.search(
|
|
|
|
r'>Recorded: (\d{2})-(Jan|Feb|Mar|Apr|May|Ju[nl]|Aug|Sep|Oct|Nov|Dec)-(\d{4})',
|
|
|
|
webpage)
|
|
|
|
if mobj:
|
|
|
|
upload_date = '%s%.2d%s' % (mobj.group(3), month_by_abbreviation(mobj.group(2)), mobj.group(1))
|
2014-12-31 17:59:16 +00:00
|
|
|
filesize = parse_filesize(self._html_search_regex(
|
|
|
|
r'>Size: ([^<]+)<', webpage, 'file size', fatal=False))
|
2014-08-08 12:21:24 +00:00
|
|
|
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 06:48:02 +00:00
|
|
|
|
2021-02-19 20:44:36 +00:00
|
|
|
info.update({
|
2014-08-08 12:21:24 +00:00
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
2014-12-31 17:59:16 +00:00
|
|
|
'upload_date': upload_date,
|
2014-08-08 12:21:24 +00:00
|
|
|
'filesize_approx': filesize,
|
|
|
|
'duration': duration,
|
|
|
|
'view_count': view_count,
|
2021-02-19 20:44:36 +00:00
|
|
|
})
|
|
|
|
return info
|