viewster.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. _TEST = {
  7. 'url': 'http://www.viewster.com/movie/1293-19341-000/hout-wood/',
  8. 'md5': '8f9d94b282d80c42b378dffdbb11caf3',
  9. 'info_dict': {
  10. 'id': '1293-19341-000',
  11. 'ext': 'flv',
  12. 'title': "'Hout' (Wood)",
  13. 'description': 'md5:925733185a9242ef96f436937683f33b',
  14. },
  15. }
  16. _ACCEPT_HEADER = 'application/json, text/javascript, */*; q=0.01'
  17. def _real_extract(self, url):
  18. video_id = self._match_id(url)
  19. request = compat_urllib_request.Request(
  20. 'http://api.live.viewster.com/api/v1/movielink?movieid=%s&action=movierent&paymethod=fre&price=0&currency=&language=en&subtitlelanguage=x&ischromecast=false' % video_id)
  21. request.add_header('Accept', self._ACCEPT_HEADER)
  22. movie_link = self._download_json(
  23. request, video_id, 'Downloading movie link JSON')
  24. formats = self._extract_f4m_formats(
  25. movie_link['url'] + '&hdcore=3.2.0&plugin=flowplayer-3.2.0.1', video_id)
  26. self._sort_formats(formats)
  27. request = compat_urllib_request.Request(
  28. 'http://api.live.viewster.com/api/v1/movie/%s' % video_id)
  29. request.add_header('Accept', self._ACCEPT_HEADER)
  30. movie = self._download_json(
  31. request, video_id, 'Downloading movie metadata JSON')
  32. title = movie.get('title') or movie['original_title']
  33. description = movie.get('synopsis')
  34. thumbnail = movie.get('large_artwork') or movie.get('artwork')
  35. return {
  36. 'id': video_id,
  37. 'title': title,
  38. 'description': description,
  39. 'thumbnail': thumbnail,
  40. 'formats': formats,
  41. }