]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/sendtonews.py
2 from __future__
import unicode_literals
6 from . common
import InfoExtractor
17 class SendtoNewsIE ( InfoExtractor
):
18 _VALID_URL
= r
'https?://embed\.sendtonews\.com/player2/embedplayer\.php\?.*\bSC=(?P<id>[0-9A-Za-z-]+)'
21 # From http://cleveland.cbslocal.com/2016/05/16/indians-score-season-high-15-runs-in-blowout-win-over-reds-rapid-reaction/
22 'url' : 'http://embed.sendtonews.com/player2/embedplayer.php?SC=GxfCe0Zo7D-175909-5588&type=single&autoplay=on&sound=YES' ,
24 'id' : 'GxfCe0Zo7D-175909-5588'
27 # test the first video only to prevent lengthy tests
32 'title' : 'Indians introduce Encarnacion' ,
33 'description' : 'Indians president of baseball operations Chris Antonetti and Edwin Encarnacion discuss the slugger \' s three-year contract with Cleveland' ,
35 'thumbnail' : r
're:https?://.*\.jpg$' ,
36 'upload_date' : '20170105' ,
37 'timestamp' : 1483649762 ,
42 'skip_download' : True ,
46 _URL_TEMPLATE
= '//embed.sendtonews.com/player2/embedplayer.php?SC= %s '
49 def _extract_url ( cls
, webpage
):
50 mobj
= re
. search ( r
'''(?x)<script[^>]+src=([\' "])
51 (?:https?:)?//embed\.sendtonews\.com/player/responsiveembed\.php \?
52 .* \b SC=(?P<SC>[0-9a-zA-Z-]+).*
56 return cls._URL_TEMPLATE % sc
58 def _real_extract(self, url):
59 playlist_id = self._match_id(url)
61 data_url = update_url_query(
62 url.replace('embedplayer.php', 'data_read.php'),
63 {'cmd': 'loadInitial'})
64 playlist_data = self._download_json(data_url, playlist_id)
67 for video in playlist_data['playlistData'][0]:
68 info_dict = self._parse_jwplayer_data(
69 video['jwconfiguration'],
70 require_title=False, m3u8_id='hls', rtmp_params={'no_resume': True})
72 for f in info_dict['formats']:
75 tbr = int_or_none(self._search_regex(
76 r'/(\d+)k/', f['url'], 'bitrate', default=None))
80 'format_id': ' %s-%d ' % (determine_protocol(f), tbr),
83 self._sort_formats(info_dict['formats'], ('tbr', 'height', 'width', 'format_id'))
86 if video.get('thumbnailUrl'):
89 'url': video['thumbnailUrl'],
91 if video.get('smThumbnailUrl'):
94 'url': video['smThumbnailUrl'],
97 'title': video['S_headLine'].strip(),
98 'description': unescapeHTML(video.get('S_fullStory')),
99 'thumbnails': thumbnails,
100 'duration': float_or_none(video.get('SM_length')),
101 'timestamp': parse_iso8601(video.get('S_sysDate'), delimiter=' '),
103 entries.append(info_dict)
105 return self.playlist_result(entries, playlist_id)