fox.py 2.1 KB

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