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.

70 lines
2.5 KiB

  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|simpsonsworld)\.com/video/(?P<id>\d+)'
  12. _TESTS = [{
  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. 'url': 'http://www.simpsonsworld.com/video/716094019682',
  28. 'only_matching': True,
  29. }]
  30. def _real_extract(self, url):
  31. video_id = self._match_id(url)
  32. webpage = self._download_webpage(url, video_id)
  33. if 'The content you are trying to access is not available in your region.' in webpage:
  34. self.raise_geo_restricted()
  35. video_data = extract_attributes(self._search_regex(
  36. r'(<a.+?rel="http://link\.theplatform\.com/s/.+?</a>)', webpage, 'video data'))
  37. player_type = self._search_regex(r'playerType\s*=\s*[\'"]([^\'"]+)', webpage, 'player type', default=None)
  38. release_url = video_data['rel']
  39. title = video_data['data-title']
  40. rating = video_data.get('data-rating')
  41. query = {
  42. 'mbr': 'true',
  43. }
  44. if player_type == 'movies':
  45. query.update({
  46. 'manifest': 'm3u',
  47. })
  48. else:
  49. query.update({
  50. 'switch': 'http',
  51. })
  52. if video_data.get('data-req-auth') == '1':
  53. resource = self._get_mvpd_resource(
  54. video_data['data-channel'], title,
  55. video_data.get('data-guid'), rating)
  56. query['auth'] = self._extract_mvpd_auth(url, video_id, 'fx', resource)
  57. return {
  58. '_type': 'url_transparent',
  59. 'id': video_id,
  60. 'title': title,
  61. 'url': smuggle_url(update_url_query(release_url, query), {'force_smil_url': True}),
  62. 'thumbnail': video_data.get('data-large-thumb'),
  63. 'age_limit': parse_age_limit(rating),
  64. 'ie_key': 'ThePlatform',
  65. }