]> jfr.im git - yt-dlp.git/blame - youtube_dlc/extractor/fxnetworks.py
Merge branch 'master' of https://github.com/ssaqua/youtube-dl into ssaqua-master
[yt-dlp.git] / youtube_dlc / extractor / fxnetworks.py
CommitLineData
bf90c467
RA
1# coding: utf-8
2from __future__ import unicode_literals
3
818ac213 4from .adobepass import AdobePassIE
bf90c467 5from ..utils import (
bf90c467 6 extract_attributes,
c3206d02 7 int_or_none,
bf90c467
RA
8 parse_age_limit,
9 smuggle_url,
c3206d02 10 update_url_query,
bf90c467
RA
11)
12
13
818ac213 14class FXNetworksIE(AdobePassIE):
53fef319
RA
15 _VALID_URL = r'https?://(?:www\.)?(?:fxnetworks|simpsonsworld)\.com/video/(?P<id>\d+)'
16 _TESTS = [{
c3206d02 17 'url': 'http://www.fxnetworks.com/video/1032565827847',
18 'md5': '8d99b97b4aa7a202f55b6ed47ea7e703',
cbef4d5c 19 'info_dict': {
c3206d02 20 'id': 'dRzwHC_MMqIv',
cbef4d5c 21 'ext': 'mp4',
c3206d02 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.',
cbef4d5c
RA
24 'age_limit': 14,
25 'uploader': 'NEWA-FNG-FX',
c3206d02 26 'upload_date': '20170825',
27 'timestamp': 1503686274,
28 'episode_number': 0,
29 'season_number': 2,
30 'series': 'Better Things',
cbef4d5c
RA
31 },
32 'add_ie': ['ThePlatform'],
53fef319
RA
33 }, {
34 'url': 'http://www.simpsonsworld.com/video/716094019682',
35 'only_matching': True,
36 }]
bf90c467
RA
37
38 def _real_extract(self, url):
39 video_id = self._match_id(url)
40 webpage = self._download_webpage(url, video_id)
cbef4d5c
RA
41 if 'The content you are trying to access is not available in your region.' in webpage:
42 self.raise_geo_restricted()
bf90c467 43 video_data = extract_attributes(self._search_regex(
d783aee5 44 r'(<a.+?rel="https?://link\.theplatform\.com/s/.+?</a>)', webpage, 'video data'))
53fef319 45 player_type = self._search_regex(r'playerType\s*=\s*[\'"]([^\'"]+)', webpage, 'player type', default=None)
bf90c467
RA
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,
cbef4d5c 69 'title': title,
bf90c467 70 'url': smuggle_url(update_url_query(release_url, query), {'force_smil_url': True}),
c3206d02 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')),
bf90c467
RA
74 'thumbnail': video_data.get('data-large-thumb'),
75 'age_limit': parse_age_limit(rating),
76 'ie_key': 'ThePlatform',
77 }