logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

syfy.py (2046B)


  1. from __future__ import unicode_literals
  2. from .adobepass import AdobePassIE
  3. from ..utils import (
  4. update_url_query,
  5. smuggle_url,
  6. )
  7. class SyfyIE(AdobePassIE):
  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\(Drupal\.settings\s*,\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 = self._get_mvpd_resource(
  40. 'syfy', title, video_id,
  41. syfy_mpx.get('mpxRating', 'TV-14'))
  42. query['auth'] = self._extract_mvpd_auth(
  43. url, video_id, 'syfy', resource)
  44. return {
  45. '_type': 'url_transparent',
  46. 'ie_key': 'ThePlatform',
  47. 'url': smuggle_url(update_url_query(
  48. self._proto_relative_url(syfy_mpx['releaseURL']), query),
  49. {'force_smil_url': True}),
  50. 'title': title,
  51. 'id': video_id,
  52. 'display_id': display_id,
  53. }