syfy.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. from .adobepass import AdobePassIE
  2. from ..utils import (
  3. smuggle_url,
  4. update_url_query,
  5. )
  6. class SyfyIE(AdobePassIE):
  7. _WORKING = False
  8. _VALID_URL = r'https?://(?:www\.)?syfy\.com/(?:[^/]+/)?videos/(?P<id>[^/?#]+)'
  9. _TESTS = [{
  10. 'url': 'http://www.syfy.com/theinternetruinedmylife/videos/the-internet-ruined-my-life-season-1-trailer',
  11. 'info_dict': {
  12. 'id': '2968097',
  13. 'ext': 'mp4',
  14. 'title': 'The Internet Ruined My Life: Season 1 Trailer',
  15. 'description': 'One tweet, one post, one click, can destroy everything.',
  16. 'uploader': 'NBCU-MPAT',
  17. 'upload_date': '20170113',
  18. 'timestamp': 1484345640,
  19. },
  20. 'params': {
  21. # m3u8 download
  22. 'skip_download': True,
  23. },
  24. 'add_ie': ['ThePlatform'],
  25. 'skip': 'Redirects to main page',
  26. }]
  27. def _real_extract(self, url):
  28. display_id = self._match_id(url)
  29. webpage = self._download_webpage(url, display_id)
  30. syfy_mpx = next(iter(self._parse_json(self._search_regex(
  31. r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);', webpage, 'drupal settings'),
  32. display_id)['syfy']['syfy_mpx'].values()))
  33. video_id = syfy_mpx['mpxGUID']
  34. title = syfy_mpx['episodeTitle']
  35. query = {
  36. 'mbr': 'true',
  37. 'manifest': 'm3u',
  38. }
  39. if syfy_mpx.get('entitlement') == 'auth':
  40. resource = self._get_mvpd_resource(
  41. 'syfy', title, video_id,
  42. syfy_mpx.get('mpxRating', 'TV-14'))
  43. query['auth'] = self._extract_mvpd_auth(
  44. url, video_id, 'syfy', resource)
  45. return {
  46. '_type': 'url_transparent',
  47. 'ie_key': 'ThePlatform',
  48. 'url': smuggle_url(update_url_query(
  49. self._proto_relative_url(syfy_mpx['releaseURL']), query),
  50. {'force_smil_url': True}),
  51. 'title': title,
  52. 'id': video_id,
  53. 'display_id': display_id,
  54. }