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.

70 lines
2.2 KiB

  1. from __future__ import unicode_literals
  2. import json
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. parse_iso8601,
  6. compat_urllib_parse,
  7. parse_age_limit,
  8. int_or_none,
  9. )
  10. class OpenFilmIE(InfoExtractor):
  11. _VALID_URL = r'http://(?:www\.)openfilm\.com/videos/(?P<id>.+)'
  12. _TEST = {
  13. 'url': 'http://www.openfilm.com/videos/human-resources-remastered',
  14. 'md5': '42bcd88c2f3ec13b65edf0f8ad1cac37',
  15. 'info_dict': {
  16. 'id': '32736',
  17. 'display_id': 'human-resources-remastered',
  18. 'ext': 'mp4',
  19. 'title': 'Human Resources (Remastered)',
  20. 'description': 'Social Engineering in the 20th Century.',
  21. 'thumbnail': 're:^https?://.*\.jpg$',
  22. 'duration': 7164,
  23. 'timestamp': 1334756988,
  24. 'upload_date': '20120418',
  25. 'uploader_id': '41117',
  26. 'view_count': int,
  27. 'age_limit': 0,
  28. },
  29. }
  30. def _real_extract(self, url):
  31. display_id = self._match_id(url)
  32. webpage = self._download_webpage(url, display_id)
  33. player = compat_urllib_parse.unquote_plus(
  34. self._og_search_video_url(webpage))
  35. video = json.loads(self._search_regex(
  36. r'\bp=({.+?})(?:&|$)', player, 'video JSON'))
  37. video_url = '%s1.mp4' % video['location']
  38. video_id = video.get('video_id')
  39. display_id = video.get('alias') or display_id
  40. title = video.get('title')
  41. description = video.get('description')
  42. thumbnail = video.get('main_thumb')
  43. duration = int_or_none(video.get('duration'))
  44. timestamp = parse_iso8601(video.get('dt_published'), ' ')
  45. uploader_id = video.get('user_id')
  46. view_count = int_or_none(video.get('views_count'))
  47. age_limit = parse_age_limit(video.get('age_limit'))
  48. return {
  49. 'id': video_id,
  50. 'display_id': display_id,
  51. 'url': video_url,
  52. 'title': title,
  53. 'description': description,
  54. 'thumbnail': thumbnail,
  55. 'duration': duration,
  56. 'timestamp': timestamp,
  57. 'uploader_id': uploader_id,
  58. 'view_count': view_count,
  59. 'age_limit': age_limit,
  60. }