You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.0 KiB

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