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.

77 lines
2.9 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .adobepass import AdobePassIE
  4. from ..utils import (
  5. extract_attributes,
  6. int_or_none,
  7. parse_age_limit,
  8. smuggle_url,
  9. update_url_query,
  10. )
  11. class FXNetworksIE(AdobePassIE):
  12. _VALID_URL = r'https?://(?:www\.)?(?:fxnetworks|simpsonsworld)\.com/video/(?P<id>\d+)'
  13. _TESTS = [{
  14. 'url': 'http://www.fxnetworks.com/video/1032565827847',
  15. 'md5': '8d99b97b4aa7a202f55b6ed47ea7e703',
  16. 'info_dict': {
  17. 'id': 'dRzwHC_MMqIv',
  18. 'ext': 'mp4',
  19. 'title': 'First Look: Better Things - Season 2',
  20. 'description': 'Because real life is like a fart. Watch this FIRST LOOK to see what inspired the new season of Better Things.',
  21. 'age_limit': 14,
  22. 'uploader': 'NEWA-FNG-FX',
  23. 'upload_date': '20170825',
  24. 'timestamp': 1503686274,
  25. 'episode_number': 0,
  26. 'season_number': 2,
  27. 'series': 'Better Things',
  28. },
  29. 'add_ie': ['ThePlatform'],
  30. }, {
  31. 'url': 'http://www.simpsonsworld.com/video/716094019682',
  32. 'only_matching': True,
  33. }]
  34. def _real_extract(self, url):
  35. video_id = self._match_id(url)
  36. webpage = self._download_webpage(url, video_id)
  37. if 'The content you are trying to access is not available in your region.' in webpage:
  38. self.raise_geo_restricted()
  39. video_data = extract_attributes(self._search_regex(
  40. r'(<a.+?rel="https?://link\.theplatform\.com/s/.+?</a>)', webpage, 'video data'))
  41. player_type = self._search_regex(r'playerType\s*=\s*[\'"]([^\'"]+)', webpage, 'player type', default=None)
  42. release_url = video_data['rel']
  43. title = video_data['data-title']
  44. rating = video_data.get('data-rating')
  45. query = {
  46. 'mbr': 'true',
  47. }
  48. if player_type == 'movies':
  49. query.update({
  50. 'manifest': 'm3u',
  51. })
  52. else:
  53. query.update({
  54. 'switch': 'http',
  55. })
  56. if video_data.get('data-req-auth') == '1':
  57. resource = self._get_mvpd_resource(
  58. video_data['data-channel'], title,
  59. video_data.get('data-guid'), rating)
  60. query['auth'] = self._extract_mvpd_auth(url, video_id, 'fx', resource)
  61. return {
  62. '_type': 'url_transparent',
  63. 'id': video_id,
  64. 'title': title,
  65. 'url': smuggle_url(update_url_query(release_url, query), {'force_smil_url': True}),
  66. 'series': video_data.get('data-show-title'),
  67. 'episode_number': int_or_none(video_data.get('data-episode')),
  68. 'season_number': int_or_none(video_data.get('data-season')),
  69. 'thumbnail': video_data.get('data-large-thumb'),
  70. 'age_limit': parse_age_limit(rating),
  71. 'ie_key': 'ThePlatform',
  72. }