]>
Commit | Line | Data |
---|---|---|
d1ea5e17 | 1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import re | |
5 | ||
6 | from .common import InfoExtractor | |
7 | from ..utils import int_or_none | |
8 | ||
9 | ||
10 | class PlaysTVIE(InfoExtractor): | |
3d272951 S |
11 | _VALID_URL = r'https?://(?:www\.)?plays\.tv/(?:video|embeds)/(?P<id>[0-9a-f]{18})' |
12 | _TESTS = [{ | |
8b1aeadc | 13 | 'url': 'https://plays.tv/video/56af17f56c95335490/when-you-outplay-the-azir-wall', |
d1ea5e17 | 14 | 'md5': 'dfeac1198506652b5257a62762cec7bc', |
15 | 'info_dict': { | |
16 | 'id': '56af17f56c95335490', | |
17 | 'ext': 'mp4', | |
8b1aeadc | 18 | 'title': 'Bjergsen - When you outplay the Azir wall', |
d1ea5e17 | 19 | 'description': 'Posted by Bjergsen', |
20 | } | |
3d272951 S |
21 | }, { |
22 | 'url': 'https://plays.tv/embeds/56af17f56c95335490', | |
23 | 'only_matching': True, | |
24 | }] | |
d1ea5e17 | 25 | |
26 | def _real_extract(self, url): | |
27 | video_id = self._match_id(url) | |
3d272951 S |
28 | webpage = self._download_webpage( |
29 | 'https://plays.tv/video/%s' % video_id, video_id) | |
30 | ||
31 | info = self._search_json_ld(webpage, video_id,) | |
d1ea5e17 | 32 | |
d1ea5e17 | 33 | mpd_url, sources = re.search( |
34 | r'(?s)<video[^>]+data-mpd="([^"]+)"[^>]*>(.+?)</video>', | |
8b1aeadc | 35 | webpage).groups() |
d1ea5e17 | 36 | formats = self._extract_mpd_formats( |
37 | self._proto_relative_url(mpd_url), video_id, mpd_id='DASH') | |
38 | for format_id, height, format_url in re.findall(r'<source\s+res="((\d+)h?)"\s+src="([^"]+)"', sources): | |
39 | formats.append({ | |
40 | 'url': self._proto_relative_url(format_url), | |
41 | 'format_id': 'http-' + format_id, | |
42 | 'height': int_or_none(height), | |
43 | }) | |
44 | self._sort_formats(formats) | |
45 | ||
3d272951 | 46 | info.update({ |
d1ea5e17 | 47 | 'id': video_id, |
d1ea5e17 | 48 | 'description': self._og_search_description(webpage), |
3d272951 | 49 | 'thumbnail': info.get('thumbnail') or self._og_search_thumbnail(webpage), |
d1ea5e17 | 50 | 'formats': formats, |
3d272951 S |
51 | }) |
52 | ||
53 | return info |