]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/playplustv.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_HTTPError
16 class PlayPlusTVIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:www\.)?playplus\.(?:com|tv)/VOD/(?P<project_id>[0-9]+)/(?P<id>[0-9a-f]{32})'
19 'url': 'https://www.playplus.tv/VOD/7572/db8d274a5163424e967f35a30ddafb8e',
20 'md5': 'd078cb89d7ab6b9df37ce23c647aef72',
22 'id': 'db8d274a5163424e967f35a30ddafb8e',
24 'title': 'CapĂtulo 179 - Final',
25 'description': 'md5:01085d62d8033a1e34121d3c3cabc838',
26 'timestamp': 1529992740,
27 'upload_date': '20180626',
29 'skip': 'Requires account credential',
31 _NETRC_MACHINE
= 'playplustv'
32 _GEO_COUNTRIES
= ['BR']
36 def _call_api(self
, resource
, video_id
=None, query
=None):
37 return self
._download
_json
('https://api.playplus.tv/api/media/v2/get' + resource
, video_id
, headers
={
38 'Authorization': 'Bearer ' + self
._token
,
41 def _real_initialize(self
):
42 email
, password
= self
._get
_login
_info
()
44 self
.raise_login_required()
47 'https://api.playplus.tv/api/web/login', json
.dumps({
51 'Content-Type': 'application/json; charset=utf-8',
55 self
._token
= self
._download
_json
(req
, None)['token']
56 except ExtractorError
as e
:
57 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 401:
58 raise ExtractorError(self
._parse
_json
(
59 e
.cause
.read(), None)['errorMessage'], expected
=True)
62 self
._profile
= self
._call
_api
('Profiles')['list'][0]['_id']
64 def _real_extract(self
, url
):
65 project_id
, media_id
= self
._match
_valid
_url
(url
).groups()
66 media
= self
._call
_api
(
68 'profileId': self
._profile
,
69 'projectId': project_id
,
72 title
= media
['title']
75 for f
in media
.get('files', []):
79 file_info
= f
.get('fileInfo') or {}
82 'width': int_or_none(file_info
.get('width')),
83 'height': int_or_none(file_info
.get('height')),
85 self
._sort
_formats
(formats
)
88 for thumb
in media
.get('thumbs', []):
89 thumb_url
= thumb
.get('url')
94 'width': int_or_none(thumb
.get('width')),
95 'height': int_or_none(thumb
.get('height')),
102 'thumbnails': thumbnails
,
103 'description': clean_html(media
.get('description')) or media
.get('shortDescription'),
104 'timestamp': int_or_none(media
.get('publishDate'), 1000),
105 'view_count': int_or_none(media
.get('numberOfViews')),
106 'comment_count': int_or_none(media
.get('numberOfComments')),
107 'tags': media
.get('tags'),