]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/playplustv.py
3 from .common
import InfoExtractor
4 from ..compat
import compat_HTTPError
13 class PlayPlusTVIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?playplus\.(?:com|tv)/VOD/(?P<project_id>[0-9]+)/(?P<id>[0-9a-f]{32})'
16 'url': 'https://www.playplus.tv/VOD/7572/db8d274a5163424e967f35a30ddafb8e',
17 'md5': 'd078cb89d7ab6b9df37ce23c647aef72',
19 'id': 'db8d274a5163424e967f35a30ddafb8e',
21 'title': 'CapĂtulo 179 - Final',
22 'description': 'md5:01085d62d8033a1e34121d3c3cabc838',
23 'timestamp': 1529992740,
24 'upload_date': '20180626',
26 'skip': 'Requires account credential',
28 _NETRC_MACHINE
= 'playplustv'
29 _GEO_COUNTRIES
= ['BR']
33 def _call_api(self
, resource
, video_id
=None, query
=None):
34 return self
._download
_json
('https://api.playplus.tv/api/media/v2/get' + resource
, video_id
, headers
={
35 'Authorization': 'Bearer ' + self
._token
,
38 def _perform_login(self
, username
, password
):
40 'https://api.playplus.tv/api/web/login', json
.dumps({
44 'Content-Type': 'application/json; charset=utf-8',
48 self
._token
= self
._download
_json
(req
, None)['token']
49 except ExtractorError
as e
:
50 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 401:
51 raise ExtractorError(self
._parse
_json
(
52 e
.cause
.read(), None)['errorMessage'], expected
=True)
55 self
._profile
= self
._call
_api
('Profiles')['list'][0]['_id']
57 def _real_initialize(self
):
59 self
.raise_login_required(method
='password')
61 def _real_extract(self
, url
):
62 project_id
, media_id
= self
._match
_valid
_url
(url
).groups()
63 media
= self
._call
_api
(
65 'profileId': self
._profile
,
66 'projectId': project_id
,
69 title
= media
['title']
72 for f
in media
.get('files', []):
76 file_info
= f
.get('fileInfo') or {}
79 'width': int_or_none(file_info
.get('width')),
80 'height': int_or_none(file_info
.get('height')),
82 self
._sort
_formats
(formats
)
85 for thumb
in media
.get('thumbs', []):
86 thumb_url
= thumb
.get('url')
91 'width': int_or_none(thumb
.get('width')),
92 'height': int_or_none(thumb
.get('height')),
99 'thumbnails': thumbnails
,
100 'description': clean_html(media
.get('description')) or media
.get('shortDescription'),
101 'timestamp': int_or_none(media
.get('publishDate'), 1000),
102 'view_count': int_or_none(media
.get('numberOfViews')),
103 'comment_count': int_or_none(media
.get('numberOfComments')),
104 'tags': media
.get('tags'),