]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/fxnetworks.py
Update changelog
[youtubedl] / youtube_dl / extractor / fxnetworks.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .adobepass import AdobePassIE
5 from ..utils import (
6 update_url_query,
7 extract_attributes,
8 parse_age_limit,
9 smuggle_url,
10 )
11
12
13 class FXNetworksIE(AdobePassIE):
14 _VALID_URL = r'https?://(?:www\.)?(?:fxnetworks|simpsonsworld)\.com/video/(?P<id>\d+)'
15 _TESTS = [{
16 'url': 'http://www.fxnetworks.com/video/719841347694',
17 'md5': '1447d4722e42ebca19e5232ab93abb22',
18 'info_dict': {
19 'id': '719841347694',
20 'ext': 'mp4',
21 'title': 'Vanpage',
22 'description': 'F*ck settling down. You\'re the Worst returns for an all new season August 31st on FXX.',
23 'age_limit': 14,
24 'uploader': 'NEWA-FNG-FX',
25 'upload_date': '20160706',
26 'timestamp': 1467844741,
27 },
28 'add_ie': ['ThePlatform'],
29 }, {
30 'url': 'http://www.simpsonsworld.com/video/716094019682',
31 'only_matching': True,
32 }]
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="http://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
62 return {
63 '_type': 'url_transparent',
64 'id': video_id,
65 'title': title,
66 'url': smuggle_url(update_url_query(release_url, query), {'force_smil_url': True}),
67 'thumbnail': video_data.get('data-large-thumb'),
68 'age_limit': parse_age_limit(rating),
69 'ie_key': 'ThePlatform',
70 }