mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-11-18 03:20:09 +09:00
[xboxclips] fix extraction(closes #27151)
This commit is contained in:
parent
f94d764993
commit
6d32c6c6d3
@ -1,40 +1,55 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..compat import (
|
||||||
|
compat_parse_qs,
|
||||||
|
compat_urllib_parse_urlparse,
|
||||||
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
month_by_abbreviation,
|
||||||
parse_filesize,
|
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|gameclips\.io)/(?:video\.php\?.*vid=|[^/]+/)(?P<id>[\da-f]{8}-(?:[\da-f]{4}-){3}[\da-f]{12})'
|
||||||
_TEST = {
|
_TESTS = [{
|
||||||
'url': 'http://xboxclips.com/video.php?uid=2533274823424419&gamertag=Iabdulelah&vid=074a69a9-5faf-46aa-b93b-9909c1720325',
|
'url': 'http://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 Titanfall',
|
'title': 'iAbdulElah playing Titanfall',
|
||||||
'filesize_approx': 26800000,
|
'filesize_approx': 26800000,
|
||||||
'upload_date': '20140807',
|
'upload_date': '20140807',
|
||||||
'duration': 56,
|
'duration': 56,
|
||||||
}
|
}
|
||||||
}
|
}, {
|
||||||
|
'url': 'https://gameclips.io/iAbdulElah/074a69a9-5faf-46aa-b93b-9909c1720325',
|
||||||
|
'only_matching': True,
|
||||||
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
webpage = self._download_webpage(url, video_id)
|
if '/video.php' in url:
|
||||||
|
qs = compat_parse_qs(compat_urllib_parse_urlparse(url).query)
|
||||||
|
url = 'https://gameclips.io/%s/%s' % (qs['gamertag'][0], qs['vid'][0])
|
||||||
|
|
||||||
video_url = self._html_search_regex(
|
webpage = self._download_webpage(url, video_id)
|
||||||
r'>(?:Link|Download): <a[^>]+href="([^"]+)"', webpage, 'video URL')
|
info = self._parse_html5_media_entries(url, webpage, video_id)[0]
|
||||||
title = self._html_search_regex(
|
|
||||||
r'<title>XboxClips \| ([^<]+)</title>', webpage, 'title')
|
title = self._html_search_meta(['og:title', 'twitter:title'], webpage)
|
||||||
upload_date = unified_strdate(self._html_search_regex(
|
upload_date = None
|
||||||
r'>Recorded: ([^<]+)<', webpage, 'upload date', fatal=False))
|
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))
|
||||||
filesize = parse_filesize(self._html_search_regex(
|
filesize = parse_filesize(self._html_search_regex(
|
||||||
r'>Size: ([^<]+)<', webpage, 'file size', fatal=False))
|
r'>Size: ([^<]+)<', webpage, 'file size', fatal=False))
|
||||||
duration = int_or_none(self._html_search_regex(
|
duration = int_or_none(self._html_search_regex(
|
||||||
@ -42,12 +57,12 @@ class XboxClipsIE(InfoExtractor):
|
|||||||
view_count = int_or_none(self._html_search_regex(
|
view_count = int_or_none(self._html_search_regex(
|
||||||
r'>Views: (\d+)<', webpage, 'view count', fatal=False))
|
r'>Views: (\d+)<', webpage, 'view count', fatal=False))
|
||||||
|
|
||||||
return {
|
info.update({
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'url': video_url,
|
|
||||||
'title': title,
|
'title': title,
|
||||||
'upload_date': upload_date,
|
'upload_date': upload_date,
|
||||||
'filesize_approx': filesize,
|
'filesize_approx': filesize,
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
'view_count': view_count,
|
'view_count': view_count,
|
||||||
}
|
})
|
||||||
|
return info
|
||||||
|
Loading…
Reference in New Issue
Block a user