]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/joj.py
   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/ 
  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': 'https://media.joj.sk/embed/9i1cxv', 
  34         'only_matching': True, 
  36         'url': 'joj:a388ec4c-6019-4a4a-9312-b1bee194e932', 
  37         'only_matching': True, 
  40         'only_matching': True, 
  44     def _extract_urls(webpage
): 
  47             for mobj 
in re
.finditer( 
  48                 r
'<iframe\b[^>]+\bsrc=(["\'])(?P
<url
>(?
:https?
:)?
//media\
.joj\
.sk
/embed
/(?
:(?
!\
1).)+)\
1', 
  51     def _real_extract(self, url): 
  52         video_id = self._match_id(url) 
  54         webpage = self._download_webpage( 
  55             'https
://media
.joj
.sk
/embed
/%s' % video_id, video_id) 
  57         title = self._search_regex( 
  58             (r'videoTitle\s
*:\s
*(["\'])(?P<title>(?:(?!\1).)+)\1', 
  59              r'<title>(?P<title>[^<]+)'), webpage, 'title', 
  60             default=None, group='title') or self._og_search_title(webpage) 
  62         bitrates = self._parse_json( 
  64                 r'(?s)(?:src|bitrates)\s*=\s*({.+?});', webpage, 'bitrates', 
  66             video_id, transform_source=js_to_json, fatal=False) 
  69         for format_url in try_get(bitrates, lambda x: x['mp4'], list) or []: 
  70             if isinstance(format_url, compat_str): 
  71                 height = self._search_regex( 
  72                     r'(\d+)[pP]\.', format_url, 'height', default=None) 
  75                     'format_id': '%sp' % height if height else None, 
  76                     'height': int(height), 
  79             playlist = self._download_xml( 
  80                 'https://media.joj.sk/services/Video.php?clip=%s' % video_id, 
  82             for file_el in playlist.findall('./files/file'): 
  83                 path = file_el.get('path') 
  86                 format_id = file_el.get('id') or file_el.get('label') 
  88                     'url': 'http://n16.joj.sk/storage/%s' % path.replace( 
  90                     'format_id': format_id, 
  91                     'height': int_or_none(self._search_regex( 
  92                         r'(\d+)[pP]', format_id or path, 'height', 
  95         self._sort_formats(formats) 
  97         thumbnail = self._og_search_thumbnail(webpage) 
  99         duration = int_or_none(self._search_regex( 
 100             r'videoDuration\s*:\s*(\d+)', webpage, 'duration', fatal=False)) 
 105             'thumbnail': thumbnail, 
 106             'duration': duration,