2 from __future__ import unicode_literals
7 from .common import InfoExtractor
8 from ..compat import compat_HTTPError
17 class PlayPlusTVIE(InfoExtractor):
18 _VALID_URL = r'https?://(?:www\.)?playplus\.(?:com|tv)/VOD/(?P<project_id>[0-9]+)/(?P<id>[0-9a-f]{32})'
20 'url': 'https://www.playplus.tv/VOD/7572/db8d274a5163424e967f35a30ddafb8e',
21 'md5': 'd078cb89d7ab6b9df37ce23c647aef72',
23 'id': 'db8d274a5163424e967f35a30ddafb8e',
25 'title': 'CapĂtulo 179 - Final',
26 'description': 'md5:01085d62d8033a1e34121d3c3cabc838',
27 'timestamp': 1529992740,
28 'upload_date': '20180626',
30 'skip': 'Requires account credential',
32 _NETRC_MACHINE = 'playplustv'
33 _GEO_COUNTRIES = ['BR']
37 def _call_api(self, resource, video_id=None, query=None):
38 return self._download_json('https://api.playplus.tv/api/media/v2/get' + resource, video_id, headers={
39 'Authorization': 'Bearer ' + self._token,
42 def _real_initialize(self):
43 email, password = self._get_login_info()
45 self.raise_login_required()
48 'https://api.playplus.tv/api/web/login', json.dumps({
52 'Content-Type': 'application/json; charset=utf-8',
56 self._token = self._download_json(req, None)['token']
57 except ExtractorError as e:
58 if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401:
59 raise ExtractorError(self._parse_json(
60 e.cause.read(), None)['errorMessage'], expected=True)
63 self._profile = self._call_api('Profiles')['list'][0]['_id']
65 def _real_extract(self, url):
66 project_id, media_id = re.match(self._VALID_URL, url).groups()
67 media = self._call_api(
69 'profileId': self._profile,
70 'projectId': project_id,
73 title = media['title']
76 for f in media.get('files', []):
80 file_info = f.get('fileInfo') or {}
83 'width': int_or_none(file_info.get('width')),
84 'height': int_or_none(file_info.get('height')),
86 self._sort_formats(formats)
89 for thumb in media.get('thumbs', []):
90 thumb_url = thumb.get('url')
95 'width': int_or_none(thumb.get('width')),
96 'height': int_or_none(thumb.get('height')),
103 'thumbnails': thumbnails,
104 'description': clean_html(media.get('description')) or media.get('shortDescription'),
105 'timestamp': int_or_none(media.get('publishDate'), 1000),
106 'view_count': int_or_none(media.get('numberOfViews')),
107 'comment_count': int_or_none(media.get('numberOfComments')),
108 'tags': media.get('tags'),