]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/orf.py 
d432e344977d1fbef9a52049ce0ba16fd1573489
   2  from  __future__ 
import  unicode_literals
   6  from  . common 
import  InfoExtractor
   7  from  .. compat 
import  compat_str
  22  class  ORFTVthekIE ( InfoExtractor
):   23      IE_NAME 
=  'orf:tvthek'   24      IE_DESC 
=  'ORF TVthek'   25      _VALID_URL 
=  r
'https?://tvthek\.orf\.at/(?:[^/]+/)+(?P<id>\d+)'   28          'url' :  'http://tvthek.orf.at/program/Aufgetischt/2745173/Aufgetischt-Mit-der-Steirischen-Tafelrunde/8891389' ,   30              'md5' :  '2942210346ed779588f428a92db88712' ,   34                  'title' :  'Aufgetischt: Mit der Steirischen Tafelrunde' ,   35                  'description' :  'md5:c1272f0245537812d4e36419c207b67d' ,   37                  'upload_date' :  '20141208' ,   40          'skip' :  'Blocked outside of Austria / Germany' ,   42          'url' :  'http://tvthek.orf.at/topic/Im-Wandel-der-Zeit/8002126/Best-of-Ingrid-Thurnher/7982256' ,   46              'title' :  'Best of Ingrid Thurnher' ,   47              'upload_date' :  '20140527' ,   48              'description' :  'Viele Jahre war Ingrid Thurnher das "Gesicht" der ZIB 2. Vor ihrem Wechsel zur ZIB 2 im Jahr 1995 moderierte sie unter anderem "Land und Leute", "Österreich-Bild" und "Niederösterreich heute".' ,   51              'skip_download' :  True ,   # rtsp downloads   53          'skip' :  'Blocked outside of Austria / Germany' ,   55          'url' :  'http://tvthek.orf.at/topic/Fluechtlingskrise/10463081/Heimat-Fremde-Heimat/13879132/Senioren-betreuen-Migrantenkinder/13879141' ,   56          'only_matching' :  True ,   58          'url' :  'http://tvthek.orf.at/profile/Universum/35429' ,   59          'only_matching' :  True ,   62      def  _real_extract ( self
,  url
):   63          playlist_id 
=  self
._ match
_ id
( url
)   64          webpage 
=  self
._ download
_ webpage
( url
,  playlist_id
)   66          data_jsb 
=  self
._ parse
_ json
(   68                  r
'<div[^>]+class=(["\' ]).* ?VideoPlaylist
.* ?\
1 [ ^
>]+ data
- jsb
=([ " \' ])(?P<json>.+?)\2',   69                  webpage, 'playlist', group='json'),   70              playlist_id, transform_source=unescapeHTML)['playlist']['videos']   74              video_id, title = sd.get('id'), sd.get('title')   75              if not video_id or not title:   77              video_id = compat_str(video_id)   79              for fd in sd['sources']:   80                  src = url_or_none(fd.get('src'))   84                  for key in ('delivery', 'quality', 'quality_string'):   87                          format_id_list.append(value)   88                  format_id = '-'.join(format_id_list)   89                  if determine_ext(fd['src']) == 'm3u8':   90                      formats.extend(self._extract_m3u8_formats(   91                          fd['src'], video_id, 'mp4', m3u8_id=format_id))   92                  elif determine_ext(fd['src']) == 'f4m':   93                      formats.extend(self._extract_f4m_formats(   94                          fd['src'], video_id, f4m_id=format_id))   97                          'format_id': format_id,   99                          'protocol': fd.get('protocol'),  102              # Check for geoblocking.  103              # There is a property is_geoprotection, but that's always false  104              geo_str = sd.get('geoprotection_string')  110                          if re.match(r'^https?://.*\.mp4$', f['url']))  111                  except StopIteration:  114                      req = HEADRequest(http_url)  115                      self._request_webpage(  117                          note='Testing for geoblocking',  119                              'This video seems to be blocked outside of  %s . '  120                              'You may want to try the streaming-* formats.')  124              self._check_formats(formats, video_id)  125              self._sort_formats(formats)  128              for sub in sd.get('subtitles', []):  129                  sub_src = sub.get('src')  132                  subtitles.setdefault(sub.get('lang', 'de-AT'), []).append({  136              upload_date = unified_strdate(sd.get('created_date'))  142                  'subtitles': subtitles,  143                  'description': sd.get('description'),  144                  'duration': int_or_none(sd.get('duration_in_seconds')),  145                  'upload_date': upload_date,  146                  'thumbnail': sd.get('image_full_url'),  156  class ORFRadioIE(InfoExtractor):  157      def _real_extract(self, url):  158          mobj = re.match(self._VALID_URL, url)  159          station = mobj.group('station')  160          show_date = mobj.group('date')  161          show_id = mobj.group('show')  164              show_id = '4 %s ' % show_id  166          data = self._download_json(  167              'http://audioapi.orf.at/ %s /api/json/current/broadcast/ %s / %s ' % (station, show_id, show_date),  171          def extract_entry_dict(info, title, subtitle):  173                  'id': info['loopStreamId'].replace('.mp3', ''),  174                  'url': 'http://loopstream01.apa.at/?channel= %s &id= %s ' % (station, info['loopStreamId']),  176                  'description': subtitle,  177                  'duration': (info['end'] - info['start']) / 1000,  178                  'timestamp': info['start'] / 1000,  182          entries = [extract_entry_dict(t, data['title'], data['subtitle']) for t in data['streams']]  187              'title': data['title'],  188              'description': data['subtitle'],  193  class ORFFM4IE(ORFRadioIE):  195      IE_DESC = 'radio FM4'  196      _VALID_URL = r'https?://(?P<station>fm4)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'  199          'url': 'http://fm4.orf.at/player/20170107/CC',  200          'md5': '2b0be47375432a7ef104453432a19212',  202              'id': '2017-01-07_2100_tl_54_7DaysSat18_31295',  204              'title': 'Solid Steel Radioshow',  205              'description': 'Die Mixshow von Coldcut und Ninja Tune.',  207              'timestamp': 1483819257,  208              'upload_date': '20170107',  210          'skip': 'Shows from ORF radios are only available for 7 days.'  214  class ORFOE1IE(ORFRadioIE):  216      IE_DESC = 'Radio Österreich 1'  217      _VALID_URL = r'https?://(?P<station>oe1)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'  220          'url': 'http://oe1.orf.at/player/20170108/456544',  221          'md5': '34d8a6e67ea888293741c86a099b745b',  223              'id': '2017-01-08_0759_tl_51_7DaysSun6_256141',  225              'title': 'Morgenjournal',  227              'timestamp': 1483858796,  228              'upload_date': '20170108',  230          'skip': 'Shows from ORF radios are only available for 7 days.'  234  class ORFIPTVIE(InfoExtractor):  236      IE_DESC = 'iptv.ORF.at'  237      _VALID_URL = r'https?://iptv\.orf\.at/(?:#/)?stories/(?P<id>\d+)'  240          'url': 'http://iptv.orf.at/stories/2275236/',  241          'md5': 'c8b22af4718a4b4af58342529453e3e5',  245              'title': 'Weitere Evakuierungen um Vulkan Calbuco',  246              'description': 'md5:d689c959bdbcf04efeddedbf2299d633',  248              'thumbnail': r're:^https?://.*\.jpg$',  249              'upload_date': '20150425',  253      def _real_extract(self, url):  254          story_id = self._match_id(url)  256          webpage = self._download_webpage(  257              'http://iptv.orf.at/stories/ %s ' % story_id, story_id)  259          video_id = self._search_regex(  260              r'data-video(?:id)?=" ( \d
+) "', webpage, 'video id')  262          data = self._download_json(  263              'http://bits.orf.at/filehandler/static-api/json/current/data.json?file= %s ' % video_id,  266          duration = float_or_none(data['duration'], 1000)  268          video = data['sources']['default']  269          load_balancer_url = video['loadBalancerUrl']  270          abr = int_or_none(video.get('audioBitrate'))  271          vbr = int_or_none(video.get('bitrate'))  272          fps = int_or_none(video.get('videoFps'))  273          width = int_or_none(video.get('videoWidth'))  274          height = int_or_none(video.get('videoHeight'))  275          thumbnail = video.get('preview')  277          rendition = self._download_json(  278              load_balancer_url, video_id, transform_source=strip_jsonp)  289          for format_id, format_url in rendition['redirect'].items():  290              if format_id == 'rtmp':  294                      'format_id': format_id,  297              elif determine_ext(format_url) == 'f4m':  298                  formats.extend(self._extract_f4m_formats(  299                      format_url, video_id, f4m_id=format_id))  300              elif determine_ext(format_url) == 'm3u8':  301                  formats.extend(self._extract_m3u8_formats(  302                      format_url, video_id, 'mp4', m3u8_id=format_id))  305          self._sort_formats(formats)  307          title = remove_end(self._og_search_title(webpage), ' - iptv.ORF.at')  308          description = self._og_search_description(webpage)  309          upload_date = unified_strdate(self._html_search_meta(  310              'dc.date', webpage, 'upload date'))  315              'description': description,  316              'duration': duration,  317              'thumbnail': thumbnail,  318              'upload_date': upload_date,  323  class ORFFM4StoryIE(InfoExtractor):  324      IE_NAME = 'orf:fm4:story'  325      IE_DESC = 'fm4.orf.at stories'  326      _VALID_URL = r'https?://fm4\.orf\.at/stories/(?P<id>\d+)'  329          'url': 'http://fm4.orf.at/stories/2865738/',  331              'md5': 'e1c2c706c45c7b34cf478bbf409907ca',  335                  'title': 'Manu Delago und Inner Tongue live',  336                  'description': 'Manu Delago und Inner Tongue haben bei der FM4 Soundpark Session live alles gegeben. Hier gibt es Fotos und die gesamte Session als Video.',  338                  'thumbnail': r're:^https?://.*\.jpg$',  339                  'upload_date': '20170913',  342              'md5': 'c6dd2179731f86f4f55a7b49899d515f',  346                  'title': 'Manu Delago und Inner Tongue live (2)',  348                  'thumbnail': r're:^https?://.*\.jpg$',  349                  'upload_date': '20170913',  350                  'description': 'Manu Delago und Inner Tongue haben bei der FM4 Soundpark Session live alles gegeben. Hier gibt es Fotos und die gesamte Session als Video.',  355      def _real_extract(self, url):  356          story_id = self._match_id(url)  357          webpage = self._download_webpage(url, story_id)  360          all_ids = orderedSet(re.findall(r'data-video(?:id)?=" ( \d
+) "', webpage))  361          for idx, video_id in enumerate(all_ids):  362              data = self._download_json(  363                  'http://bits.orf.at/filehandler/static-api/json/current/data.json?file= %s ' % video_id,  366              duration = float_or_none(data['duration'], 1000)  368              video = data['sources']['q8c']  369              load_balancer_url = video['loadBalancerUrl']  370              abr = int_or_none(video.get('audioBitrate'))  371              vbr = int_or_none(video.get('bitrate'))  372              fps = int_or_none(video.get('videoFps'))  373              width = int_or_none(video.get('videoWidth'))  374              height = int_or_none(video.get('videoHeight'))  375              thumbnail = video.get('preview')  377              rendition = self._download_json(  378                  load_balancer_url, video_id, transform_source=strip_jsonp)  389              for format_id, format_url in rendition['redirect'].items():  390                  if format_id == 'rtmp':  394                          'format_id': format_id,  397                  elif determine_ext(format_url) == 'f4m':  398                      formats.extend(self._extract_f4m_formats(  399                          format_url, video_id, f4m_id=format_id))  400                  elif determine_ext(format_url) == 'm3u8':  401                      formats.extend(self._extract_m3u8_formats(  402                          format_url, video_id, 'mp4', m3u8_id=format_id))  405              self._sort_formats(formats)  407              title = remove_end(self._og_search_title(webpage), ' - fm4.ORF.at')  409                  # Titles are duplicates, make them unique  410                  title += ' (' + str(idx + 1) + ')'  411              description = self._og_search_description(webpage)  412              upload_date = unified_strdate(self._html_search_meta(  413                  'dc.date', webpage, 'upload date'))  418                  'description': description,  419                  'duration': duration,  420                  'thumbnail': thumbnail,  421                  'upload_date': upload_date,  425          return self.playlist_result(entries)