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