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.

58 lines
2.0 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .adobepass import AdobePassIE
  4. from ..utils import (
  5. smuggle_url,
  6. update_url_query,
  7. )
  8. class FOXIE(AdobePassIE):
  9. _VALID_URL = r'https?://(?:www\.)?fox\.com/watch/(?P<id>[0-9]+)'
  10. _TEST = {
  11. 'url': 'http://www.fox.com/watch/255180355939/7684182528',
  12. 'md5': 'ebd296fcc41dd4b19f8115d8461a3165',
  13. 'info_dict': {
  14. 'id': '255180355939',
  15. 'ext': 'mp4',
  16. 'title': 'Official Trailer: Gotham',
  17. 'description': 'Tracing the rise of the great DC Comics Super-Villains and vigilantes, Gotham reveals an entirely new chapter that has never been told.',
  18. 'duration': 129,
  19. 'timestamp': 1400020798,
  20. 'upload_date': '20140513',
  21. 'uploader': 'NEWA-FNG-FOXCOM',
  22. },
  23. 'add_ie': ['ThePlatform'],
  24. }
  25. def _real_extract(self, url):
  26. video_id = self._match_id(url)
  27. webpage = self._download_webpage(url, video_id)
  28. settings = self._parse_json(self._search_regex(
  29. r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);',
  30. webpage, 'drupal settings'), video_id)
  31. fox_pdk_player = settings['fox_pdk_player']
  32. release_url = fox_pdk_player['release_url']
  33. query = {
  34. 'mbr': 'true',
  35. 'switch': 'http'
  36. }
  37. if fox_pdk_player.get('access') == 'locked':
  38. ap_p = settings['foxAdobePassProvider']
  39. rating = ap_p.get('videoRating')
  40. if rating == 'n/a':
  41. rating = None
  42. resource = self._get_mvpd_resource('fbc-fox', None, ap_p['videoGUID'], rating)
  43. query['auth'] = self._extract_mvpd_auth(url, video_id, 'fbc-fox', resource)
  44. info = self._search_json_ld(webpage, video_id, fatal=False)
  45. info.update({
  46. '_type': 'url_transparent',
  47. 'ie_key': 'ThePlatform',
  48. 'url': smuggle_url(update_url_query(release_url, query), {'force_smil_url': True}),
  49. 'id': video_id,
  50. })
  51. return info