logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

xboxclips.py (2481B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..compat import (
  6. compat_parse_qs,
  7. compat_urllib_parse_urlparse,
  8. )
  9. from ..utils import (
  10. int_or_none,
  11. month_by_abbreviation,
  12. parse_filesize,
  13. )
  14. class XboxClipsIE(InfoExtractor):
  15. _VALID_URL = r'https?://(?:www\.)?(?:xboxclips\.com|gameclips\.io)/(?:video\.php\?.*vid=|[^/]+/)(?P<id>[\da-f]{8}-(?:[\da-f]{4}-){3}[\da-f]{12})'
  16. _TESTS = [{
  17. 'url': 'http://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 Titanfall',
  23. 'filesize_approx': 26800000,
  24. 'upload_date': '20140807',
  25. 'duration': 56,
  26. }
  27. }, {
  28. 'url': 'https://gameclips.io/iAbdulElah/074a69a9-5faf-46aa-b93b-9909c1720325',
  29. 'only_matching': True,
  30. }]
  31. def _real_extract(self, url):
  32. video_id = self._match_id(url)
  33. if '/video.php' in url:
  34. qs = compat_parse_qs(compat_urllib_parse_urlparse(url).query)
  35. url = 'https://gameclips.io/%s/%s' % (qs['gamertag'][0], qs['vid'][0])
  36. webpage = self._download_webpage(url, video_id)
  37. info = self._parse_html5_media_entries(url, webpage, video_id)[0]
  38. title = self._html_search_meta(['og:title', 'twitter:title'], webpage)
  39. upload_date = None
  40. mobj = re.search(
  41. r'>Recorded: (\d{2})-(Jan|Feb|Mar|Apr|May|Ju[nl]|Aug|Sep|Oct|Nov|Dec)-(\d{4})',
  42. webpage)
  43. if mobj:
  44. upload_date = '%s%.2d%s' % (mobj.group(3), month_by_abbreviation(mobj.group(2)), mobj.group(1))
  45. filesize = parse_filesize(self._html_search_regex(
  46. r'>Size: ([^<]+)<', webpage, 'file size', fatal=False))
  47. duration = int_or_none(self._html_search_regex(
  48. r'>Duration: (\d+) Seconds<', webpage, 'duration', fatal=False))
  49. view_count = int_or_none(self._html_search_regex(
  50. r'>Views: (\d+)<', webpage, 'view count', fatal=False))
  51. info.update({
  52. 'id': video_id,
  53. 'title': title,
  54. 'upload_date': upload_date,
  55. 'filesize_approx': filesize,
  56. 'duration': duration,
  57. 'view_count': view_count,
  58. })
  59. return info