fxnetworks.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .adobepass import AdobePassIE
  4. from ..utils import (
  5. update_url_query,
  6. extract_attributes,
  7. parse_age_limit,
  8. smuggle_url,
  9. )
  10. class FXNetworksIE(AdobePassIE):
  11. _VALID_URL = r'https?://(?:www\.)?fxnetworks\.com/video/(?P<id>\d+)'
  12. _TEST = {
  13. 'url': 'http://www.fxnetworks.com/video/719841347694',
  14. 'md5': '1447d4722e42ebca19e5232ab93abb22',
  15. 'info_dict': {
  16. 'id': '719841347694',
  17. 'ext': 'mp4',
  18. 'title': 'Vanpage',
  19. 'description': 'F*ck settling down. You\'re the Worst returns for an all new season August 31st on FXX.',
  20. 'age_limit': 14,
  21. 'uploader': 'NEWA-FNG-FX',
  22. 'upload_date': '20160706',
  23. 'timestamp': 1467844741,
  24. },
  25. 'add_ie': ['ThePlatform'],
  26. }
  27. def _real_extract(self, url):
  28. video_id = self._match_id(url)
  29. webpage = self._download_webpage(url, video_id)
  30. if 'The content you are trying to access is not available in your region.' in webpage:
  31. self.raise_geo_restricted()
  32. video_data = extract_attributes(self._search_regex(
  33. r'(<a.+?rel="http://link\.theplatform\.com/s/.+?</a>)', webpage, 'video data'))
  34. player_type = self._search_regex(r'playerType\s*=\s*[\'"]([^\'"]+)', webpage, 'player type', fatal=False)
  35. release_url = video_data['rel']
  36. title = video_data['data-title']
  37. rating = video_data.get('data-rating')
  38. query = {
  39. 'mbr': 'true',
  40. }
  41. if player_type == 'movies':
  42. query.update({
  43. 'manifest': 'm3u',
  44. })
  45. else:
  46. query.update({
  47. 'switch': 'http',
  48. })
  49. if video_data.get('data-req-auth') == '1':
  50. resource = self._get_mvpd_resource(
  51. video_data['data-channel'], title,
  52. video_data.get('data-guid'), rating)
  53. query['auth'] = self._extract_mvpd_auth(url, video_id, 'fx', resource)
  54. return {
  55. '_type': 'url_transparent',
  56. 'id': video_id,
  57. 'title': title,
  58. 'url': smuggle_url(update_url_query(release_url, query), {'force_smil_url': True}),
  59. 'thumbnail': video_data.get('data-large-thumb'),
  60. 'age_limit': parse_age_limit(rating),
  61. 'ie_key': 'ThePlatform',
  62. }