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.

53 lines
1.9 KiB

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