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.

129 lines
4.6 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..compat import compat_urllib_request
  4. class ViewsterIE(InfoExtractor):
  5. _VALID_URL = r'http://(?:www\.)?viewster\.com/movie/(?P<id>\d+-\d+-\d+)'
  6. _TESTS = [{
  7. # movielink, paymethod=fre
  8. 'url': 'http://www.viewster.com/movie/1293-19341-000/hout-wood/',
  9. 'playlist': [{
  10. 'md5': '8f9d94b282d80c42b378dffdbb11caf3',
  11. 'info_dict': {
  12. 'id': '1293-19341-000-movie',
  13. 'ext': 'flv',
  14. 'title': "'Hout' (Wood) - Movie",
  15. },
  16. }],
  17. 'info_dict': {
  18. 'id': '1293-19341-000',
  19. 'title': "'Hout' (Wood)",
  20. 'description': 'md5:925733185a9242ef96f436937683f33b',
  21. }
  22. }, {
  23. # movielink, paymethod=adv
  24. 'url': 'http://www.viewster.com/movie/1140-11855-000/the-listening-project/',
  25. 'playlist': [{
  26. 'md5': '77a005453ca7396cbe3d35c9bea30aef',
  27. 'info_dict': {
  28. 'id': '1140-11855-000-movie',
  29. 'ext': 'flv',
  30. 'title': "THE LISTENING PROJECT - Movie",
  31. },
  32. }],
  33. 'info_dict': {
  34. 'id': '1140-11855-000',
  35. 'title': "THE LISTENING PROJECT",
  36. 'description': 'md5:714421ae9957e112e672551094bf3b08',
  37. }
  38. }, {
  39. # direct links, no movielink
  40. 'url': 'http://www.viewster.com/movie/1198-56411-000/sinister/',
  41. 'playlist': [{
  42. 'md5': '0307b7eac6bfb21ab0577a71f6eebd8f',
  43. 'info_dict': {
  44. 'id': '1198-56411-000-trailer',
  45. 'ext': 'mp4',
  46. 'title': "Sinister - Trailer",
  47. },
  48. }, {
  49. 'md5': '80b9ee3ad69fb368f104cb5d9732ae95',
  50. 'info_dict': {
  51. 'id': '1198-56411-000-behind-scenes',
  52. 'ext': 'mp4',
  53. 'title': "Sinister - Behind Scenes",
  54. },
  55. }, {
  56. 'md5': '3b3ea897ecaa91fca57a8a94ac1b15c5',
  57. 'info_dict': {
  58. 'id': '1198-56411-000-scene-from-movie',
  59. 'ext': 'mp4',
  60. 'title': "Sinister - Scene from movie",
  61. },
  62. }],
  63. 'info_dict': {
  64. 'id': '1198-56411-000',
  65. 'title': "Sinister",
  66. 'description': 'md5:014c40b0488848de9683566a42e33372',
  67. }
  68. }]
  69. _ACCEPT_HEADER = 'application/json, text/javascript, */*; q=0.01'
  70. def _real_extract(self, url):
  71. video_id = self._match_id(url)
  72. request = compat_urllib_request.Request(
  73. 'http://api.live.viewster.com/api/v1/movie/%s' % video_id)
  74. request.add_header('Accept', self._ACCEPT_HEADER)
  75. movie = self._download_json(
  76. request, video_id, 'Downloading movie metadata JSON')
  77. title = movie.get('title') or movie['original_title']
  78. description = movie.get('synopsis')
  79. thumbnail = movie.get('large_artwork') or movie.get('artwork')
  80. entries = []
  81. for clip in movie['play_list']:
  82. entry = None
  83. # movielink api
  84. link_request = clip.get('link_request')
  85. if link_request:
  86. request = compat_urllib_request.Request(
  87. 'http://api.live.viewster.com/api/v1/movielink?movieid=%(movieid)s&action=%(action)s&paymethod=%(paymethod)s&price=%(price)s&currency=%(currency)s&language=%(language)s&subtitlelanguage=%(subtitlelanguage)s&ischromecast=%(ischromecast)s'
  88. % link_request)
  89. request.add_header('Accept', self._ACCEPT_HEADER)
  90. movie_link = self._download_json(
  91. request, video_id, 'Downloading movie link JSON', fatal=False)
  92. if movie_link:
  93. formats = self._extract_f4m_formats(
  94. movie_link['url'] + '&hdcore=3.2.0&plugin=flowplayer-3.2.0.1', video_id)
  95. self._sort_formats(formats)
  96. entry = {
  97. 'formats': formats,
  98. }
  99. # direct link
  100. clip_url = clip.get('clip_data', {}).get('url')
  101. if clip_url:
  102. entry = {
  103. 'url': clip_url,
  104. 'ext': 'mp4',
  105. }
  106. if entry:
  107. entry.update({
  108. 'id': '%s-%s' % (video_id, clip['canonical_title']),
  109. 'title': '%s - %s' % (title, clip['title']),
  110. })
  111. entries.append(entry)
  112. playlist = self.playlist_result(entries, video_id, title, description)
  113. playlist['thumbnail'] = thumbnail
  114. return playlist