]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/joj.py
a764023e9f82a07bc96f6eaab293daf224a1c91a
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
15 class JojIE(InfoExtractor
):
19 https?://media\.joj\.sk/embed/
21 (?P<id>[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})
24 'url': 'https://media.joj.sk/embed/a388ec4c-6019-4a4a-9312-b1bee194e932',
26 'id': 'a388ec4c-6019-4a4a-9312-b1bee194e932',
28 'title': 'NOVÉ BÝVANIE',
29 'thumbnail': r
're:^https?://.*\.jpg$',
33 'url': 'joj:a388ec4c-6019-4a4a-9312-b1bee194e932',
34 'only_matching': True,
38 def _extract_urls(webpage
):
40 r
'<iframe\b[^>]+\bsrc=["\'](?P
<url
>(?
:https?
:)?
//media\
.joj\
.sk
/embed
/[\da
-f
]{8}
-[\da
-f
]{4}
-[\da
-f
]{4}
-[\da
-f
]{4}
-[\da
-f
]{12}
)',
43 def _real_extract(self, url):
44 video_id = self._match_id(url)
46 webpage = self._download_webpage(
47 'https
://media
.joj
.sk
/embed
/%s' % video_id, video_id)
49 title = self._search_regex(
50 (r'videoTitle\s
*:\s
*(["\'])(?P<title>(?:(?!\1).)+)\1',
51 r'<title>(?P<title>[^<]+)'), webpage, 'title',
52 default=None, group='title') or self._og_search_title(webpage)
54 bitrates = self._parse_json(
56 r'(?s)bitrates\s*=\s*({.+?});', webpage, 'bitrates',
58 video_id, transform_source=js_to_json, fatal=False)
61 for format_url in try_get(bitrates, lambda x: x['mp4'], list) or []:
62 if isinstance(format_url, compat_str):
63 height = self._search_regex(
64 r'(\d+)[pP]\.', format_url, 'height', default=None)
67 'format_id': '%sp' % height if height else None,
68 'height': int(height),
71 playlist = self._download_xml(
72 'https://media.joj.sk/services/Video.php?clip=%s' % video_id,
74 for file_el in playlist.findall('./files/file'):
75 path = file_el.get('path')
78 format_id = file_el.get('id') or file_el.get('label')
80 'url': 'http://n16.joj.sk/storage/%s' % path.replace(
82 'format_id': format_id,
83 'height': int_or_none(self._search_regex(
84 r'(\d+)[pP]', format_id or path, 'height',
87 self._sort_formats(formats)
89 thumbnail = self._og_search_thumbnail(webpage)
91 duration = int_or_none(self._search_regex(
92 r'videoDuration\s*:\s*(\d+)', webpage, 'duration', fatal=False))
97 'thumbnail': thumbnail,