2 from __future__ import unicode_literals
4 from .theplatform import ThePlatformIE
13 class AMCNetworksIE(ThePlatformIE):
14 _VALID_URL = r'https?://(?:www\.)?(?:amc|bbcamerica|ifc|(?:we|sundance)tv)\.com/(?:movies|shows(?:/[^/]+)+)/(?P<id>[^/?#]+)'
16 'url': 'http://www.ifc.com/shows/maron/season-04/episode-01/step-1',
21 'title': 'Maron - Season 4 - Step 1',
22 'description': 'In denial about his current situation, Marc is reluctantly convinced by his friends to enter rehab. Starring Marc Maron and Constance Zimmer.',
24 'upload_date': '20160505',
25 'timestamp': 1462468831,
30 'skip_download': True,
32 'skip': 'Requires TV provider accounts',
34 'url': 'http://www.bbcamerica.com/shows/the-hunt/full-episodes/season-1/episode-01-the-hardest-challenge',
35 'only_matching': True,
37 'url': 'http://www.amc.com/shows/preacher/full-episodes/season-01/episode-00/pilot',
38 'only_matching': True,
40 'url': 'http://www.wetv.com/shows/million-dollar-matchmaker/season-01/episode-06-the-dumped-dj-and-shallow-hal',
41 'only_matching': True,
43 'url': 'http://www.ifc.com/movies/chaos',
44 'only_matching': True,
46 'url': 'http://www.bbcamerica.com/shows/doctor-who/full-episodes/the-power-of-the-daleks/episode-01-episode-1-color-version',
47 'only_matching': True,
49 'url': 'http://www.wetv.com/shows/mama-june-from-not-to-hot/full-episode/season-01/thin-tervention',
50 'only_matching': True,
52 'url': 'http://www.wetv.com/shows/la-hair/videos/season-05/episode-09-episode-9-2/episode-9-sneak-peek-3',
53 'only_matching': True,
55 'url': 'https://www.sundancetv.com/shows/riviera/full-episodes/season-1/episode-01-episode-1',
56 'only_matching': True,
59 def _real_extract(self, url):
60 display_id = self._match_id(url)
61 webpage = self._download_webpage(url, display_id)
66 media_url = self._search_regex(
67 r'window\.platformLinkURL\s*=\s*[\'"]([^\'"]+)',
69 theplatform_metadata = self._download_theplatform_metadata(self._search_regex(
70 r'link\.theplatform\.com/s/([^?]+)',
71 media_url, 'theplatform_path'), display_id)
72 info = self._parse_theplatform_metadata(theplatform_metadata)
73 video_id = theplatform_metadata['pid']
74 title = theplatform_metadata['title']
76 theplatform_metadata, lambda x: x['ratings'][0]['rating'])
77 auth_required = self._search_regex(
78 r'window\.authRequired\s*=\s*(true|false);',
79 webpage, 'auth required')
80 if auth_required == 'true':
81 requestor_id = self._search_regex(
82 r'window\.requestor_id\s*=\s*[\'"]([^\'"]+)',
83 webpage, 'requestor id')
84 resource = self._get_mvpd_resource(
85 requestor_id, title, video_id, rating)
86 query['auth'] = self._extract_mvpd_auth(
87 url, video_id, requestor_id, resource)
88 media_url = update_url_query(media_url, query)
89 formats, subtitles = self._extract_theplatform_smil(
91 self._sort_formats(formats)
94 'subtitles': subtitles,
96 'age_limit': parse_age_limit(parse_age_limit(rating)),
98 ns_keys = theplatform_metadata.get('$xmlns', {}).keys()
100 ns = list(ns_keys)[0]
101 series = theplatform_metadata.get(ns + '$show')
102 season_number = int_or_none(
103 theplatform_metadata.get(ns + '$season'))
104 episode = theplatform_metadata.get(ns + '$episodeTitle')
105 episode_number = int_or_none(
106 theplatform_metadata.get(ns + '$episode'))
108 title = 'Season %d - %s' % (season_number, title)
110 title = '%s - %s' % (series, title)
114 'season_number': season_number,
116 'episode_number': episode_number,