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.

79 lines
2.7 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. js_to_json,
  7. smuggle_url,
  8. )
  9. class HGTVIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?hgtv\.ca/[^/]+/video/(?P<id>[^/]+)/video.html'
  11. _TEST = {
  12. 'url': 'http://www.hgtv.ca/homefree/video/overnight-success/video.html?v=738081859718&p=1&s=da#video',
  13. 'md5': '',
  14. 'info_dict': {
  15. 'id': 'aFH__I_5FBOX',
  16. 'ext': 'mp4',
  17. 'title': 'Overnight Success',
  18. 'description': 'After weeks of hard work, high stakes, breakdowns and pep talks, the final 2 contestants compete to win the ultimate dream.',
  19. 'uploader': 'SHWM-NEW',
  20. 'timestamp': 1470320034,
  21. 'upload_date': '20160804',
  22. },
  23. 'params': {
  24. # m3u8 download
  25. 'skip_download': True,
  26. },
  27. }
  28. def _real_extract(self, url):
  29. display_id = self._match_id(url)
  30. webpage = self._download_webpage(url, display_id)
  31. embed_vars = self._parse_json(self._search_regex(
  32. r'(?s)embed_vars\s*=\s*({.*?});',
  33. webpage, 'embed vars'), display_id, js_to_json)
  34. return {
  35. '_type': 'url_transparent',
  36. 'url': smuggle_url(
  37. 'http://link.theplatform.com/s/dtjsEC/%s?mbr=true&manifest=m3u' % embed_vars['pid'], {
  38. 'force_smil_url': True
  39. }),
  40. 'series': embed_vars.get('show'),
  41. 'season_number': int_or_none(embed_vars.get('season')),
  42. 'episode_number': int_or_none(embed_vars.get('episode')),
  43. 'ie_key': 'ThePlatform',
  44. }
  45. class HGTVComShowIE(InfoExtractor):
  46. IE_NAME = 'hgtv.com:show'
  47. _VALID_URL = r'https?://(?:www\.)?hgtv\.com/shows/[^/]+/(?P<id>[^/?#&]+)'
  48. _TEST = {
  49. 'url': 'http://www.hgtv.com/shows/flip-or-flop/flip-or-flop-full-episodes-videos',
  50. 'info_dict': {
  51. 'id': 'flip-or-flop-full-episodes-videos',
  52. 'title': 'Flip or Flop Full Episodes',
  53. },
  54. 'playlist_mincount': 15,
  55. }
  56. def _real_extract(self, url):
  57. display_id = self._match_id(url)
  58. webpage = self._download_webpage(url, display_id)
  59. config = self._parse_json(
  60. self._search_regex(
  61. r'(?s)data-module=["\']video["\'][^>]*>.*?<script[^>]+type=["\']text/x-config["\'][^>]*>(.+?)</script',
  62. webpage, 'video config'),
  63. display_id)['channels'][0]
  64. entries = [
  65. self.url_result(video['releaseUrl'])
  66. for video in config['videos'] if video.get('releaseUrl')]
  67. return self.playlist_result(
  68. entries, display_id, config.get('title'), config.get('description'))