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.

56 lines
2.1 KiB

  1. from __future__ import unicode_literals
  2. from .theplatform import ThePlatformIE
  3. from ..utils import (
  4. update_url_query,
  5. smuggle_url,
  6. )
  7. class SyfyIE(ThePlatformIE):
  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. }]
  26. def _real_extract(self, url):
  27. display_id = self._match_id(url)
  28. webpage = self._download_webpage(url, display_id)
  29. syfy_mpx = list(self._parse_json(self._search_regex(
  30. r'jQuery\.extend\([^,]+,\s*({.+})\);', webpage, 'drupal settings'),
  31. display_id)['syfy']['syfy_mpx'].values())[0]
  32. video_id = syfy_mpx['mpxGUID']
  33. title = syfy_mpx['episodeTitle']
  34. query = {
  35. 'mbr': 'true',
  36. 'manifest': 'm3u',
  37. }
  38. if syfy_mpx.get('entitlement') == 'auth':
  39. resource = '<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>syfy</title><item><title><![CDATA[%s]]></title><guid>%s</guid><media:rating scheme="urn:v-chip">%s</media:rating></item></channel></rss>' % (title, video_id, syfy_mpx.get('mpxRating', 'TV-14'))
  40. query['auth'] = self._extract_mvpd_auth(
  41. url, video_id, 'syfy', resource)
  42. return {
  43. '_type': 'url_transparent',
  44. 'ie_key': 'ThePlatform',
  45. 'url': smuggle_url(update_url_query(
  46. self._proto_relative_url(syfy_mpx['releaseURL']), query),
  47. {'force_smil_url': True}),
  48. 'title': title,
  49. 'id': video_id,
  50. 'display_id': display_id,
  51. }