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.

60 lines
2.5 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .adobepass import AdobePassIE
  4. from ..utils import (
  5. int_or_none,
  6. smuggle_url,
  7. update_url_query,
  8. )
  9. class ScrippsNetworksWatchIE(AdobePassIE):
  10. IE_NAME = 'scrippsnetworks:watch'
  11. _VALID_URL = r'https?://watch\.(?:hgtv|foodnetwork|travelchannel|diynetwork|cookingchanneltv)\.com/player\.[A-Z0-9]+\.html#(?P<id>\d+)'
  12. _TEST = {
  13. 'url': 'http://watch.hgtv.com/player.HNT.html#0256538',
  14. 'md5': '26545fd676d939954c6808274bdb905a',
  15. 'info_dict': {
  16. 'id': '0256538',
  17. 'ext': 'mp4',
  18. 'title': 'Seeking a Wow House',
  19. 'description': 'Buyers retiring in Palm Springs, California, want a modern house with major wow factor. They\'re also looking for a pool and a large, open floorplan with tall windows looking out at the views.',
  20. 'uploader': 'SCNI',
  21. 'upload_date': '20170207',
  22. 'timestamp': 1486450493,
  23. },
  24. 'skip': 'requires TV provider authentication',
  25. }
  26. def _real_extract(self, url):
  27. video_id = self._match_id(url)
  28. webpage = self._download_webpage(url, video_id)
  29. channel = self._parse_json(self._search_regex(
  30. r'"channels"\s*:\s*(\[.+\])',
  31. webpage, 'channels'), video_id)[0]
  32. video_data = next(v for v in channel['videos'] if v.get('nlvid') == video_id)
  33. title = video_data['title']
  34. release_url = video_data['releaseUrl']
  35. if video_data.get('restricted'):
  36. requestor_id = self._search_regex(
  37. r'requestorId\s*=\s*"([^"]+)";', webpage, 'requestor id')
  38. resource = self._get_mvpd_resource(
  39. requestor_id, title, video_id,
  40. video_data.get('ratings', [{}])[0].get('rating'))
  41. auth = self._extract_mvpd_auth(
  42. url, video_id, requestor_id, resource)
  43. release_url = update_url_query(release_url, {'auth': auth})
  44. return {
  45. '_type': 'url_transparent',
  46. 'id': video_id,
  47. 'title': title,
  48. 'url': smuggle_url(release_url, {'force_smil_url': True}),
  49. 'description': video_data.get('description'),
  50. 'thumbnail': video_data.get('thumbnailUrl'),
  51. 'series': video_data.get('showTitle'),
  52. 'season_number': int_or_none(video_data.get('season')),
  53. 'episode_number': int_or_none(video_data.get('episodeNumber')),
  54. 'ie_key': 'ThePlatform',
  55. }