2 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 class LimeLightBaseIE(InfoExtractor):
15 def get_playlist_service(self, id, method):
16 return self._download_json(self.PLAYLIST_SERVICE_URL % (id, method), id)
18 def get_api(self, orgId, id, method):
19 return self._download_json(self.API_URL % (orgId, id, method), id)
21 def process_data(self, mobileUrls, streams, properties):
22 video_id = properties['media_id']
25 for mobileUrl in mobileUrls:
26 if '.m3u8' in mobileUrl['mobileUrl']:
27 formats.extend(self._extract_m3u8_formats(mobileUrl['mobileUrl'], video_id))
29 formats.append({'url': mobileUrl['mobileUrl']})
31 for stream in streams:
32 if '.f4m' in stream['url']:
33 formats.extend(self._extract_f4m_formats(stream['url'], video_id))
36 'url': stream.get('url'),
37 'abr': stream.get('audioBitRate'),
38 'vbr': stream.get('videoBitRate'),
39 'fps': stream.get('videoFrameRate'),
40 'width': stream.get('videoWidthInPixels'),
41 'height': stream.get('videoHeightInPixels'),
42 'ext': determine_ext(stream.get('url'))
44 rtmp = re.search(r'^(?P<url>rtmp://[^/]+/(?P<app>.+))/(?P<playpath>mp4:.+)$', stream['url'])
47 'url': rtmp.group('url'),
48 'play_path': rtmp.group('playpath'),
49 'app': rtmp.group('app'),
53 self._sort_formats(formats)
55 title = properties['title']
56 description = properties.get('description')
57 timestamp = properties.get('create_date')
58 duration = int_or_none(properties.get('duration_in_milliseconds'))
59 filesize = properties.get('total_storage_in_bytes')
60 categories = [properties.get('category')]
62 'url': thumbnail.get('url'),
63 'width': int_or_none(thumbnail.get('width')),
64 'height': int_or_none(thumbnail.get('height')),
65 } for thumbnail in properties.get('thumbnails')]
66 subtitles = {caption.get('language_code'): [{'url': caption.get('url')}] for caption in properties.get('captions')}
71 'description': description,
73 'timestamp': timestamp,
76 'categories': categories,
77 'thumbnails': thumbnails,
78 'subtitles': subtitles,
82 class LimeLightMediaIE(LimeLightBaseIE):
84 _VALID_URL = r'http://link\.videoplatform\.limelight\.com/media/?.*mediaId=(?P<id>[a-z0-9]{32})'
86 'url': 'http://link.videoplatform.limelight.com/media/?mediaId=3ffd040b522b4485b6d84effc750cd86',
87 'md5': '3213605088be599705677ef785db6972',
89 'id': '3ffd040b522b4485b6d84effc750cd86',
91 'title': 'HaP and the HB Prince Trailer',
92 'description': 'As Harry Potter begins his 6th year at Hogwarts School of Witchcraft and Wizardry, he discovers an old book marked mysteriously "This book is the property of the Half-Blood Prince" and begins to learn more about Lord Voldemort\'s dark past.',
93 'thumbnail': 're:^https?://.*\.jpeg$',
95 'timestamp': 1244136834,
96 "upload_date": "20090604",
99 PLAYLIST_SERVICE_URL = 'http://production-ps.lvp.llnw.net/r/PlaylistService/media/%s/%s'
100 API_URL = 'http://api.video.limelight.com/rest/organizations/%s/media/%s/%s.json'
102 def _real_extract(self, url):
103 video_id = self._match_id(url)
105 mobile_json_data = self.get_playlist_service(video_id, 'getMobilePlaylistByMediaId')
106 pc_json_data = self.get_playlist_service(video_id, 'getPlaylistByMediaId')
107 properties = self.get_api(pc_json_data['orgId'], video_id, 'properties')
109 return self.process_data(mobile_json_data['mediaList'][0]['mobileUrls'], pc_json_data['playlistItems'][0]['streams'], properties)
112 class LimeLightChannelIE(LimeLightBaseIE):
113 IE_NAME = 'limelight:channel'
114 _VALID_URL = r'http://link\.videoplatform\.limelight\.com/media/?.*channelId=(?P<id>[a-z0-9]{32})'
116 'url': 'http://link.videoplatform.limelight.com/media/?channelId=ab6a524c379342f9b23642917020c082',
118 'id': 'ab6a524c379342f9b23642917020c082',
119 'title': 'Javascript Sample Code',
121 'playlist_mincount': 3,
123 PLAYLIST_SERVICE_URL = 'http://production-ps.lvp.llnw.net/r/PlaylistService/channel/%s/%s'
124 API_URL = 'http://api.video.limelight.com/rest/organizations/%s/channels/%s/%s.json'
126 def _real_extract(self, url):
127 channel_id = self._match_id(url)
129 mobile_json_data = self.get_playlist_service(channel_id, 'getMobilePlaylistWithNItemsByChannelId?begin=0&count=-1')
130 pc_json_data = self.get_playlist_service(channel_id, 'getPlaylistByChannelId')
131 medias = self.get_api(pc_json_data['orgId'], channel_id, 'media')
134 for i in range(len(medias['media_list'])):
135 entries.append(self.process_data(mobile_json_data['mediaList'][i]['mobileUrls'], pc_json_data['playlistItems'][i]['streams'], medias['media_list'][i]))
139 'title': pc_json_data['title'],
145 class LimeLightChannelListIE(LimeLightBaseIE):
146 IE_NAME = 'limelight:channel_list'
147 _VALID_URL = r'http://link\.videoplatform\.limelight\.com/media/?.*channelListId=(?P<id>[a-z0-9]{32})'
149 'url': 'http://link.videoplatform.limelight.com/media/?channelListId=301b117890c4465c8179ede21fd92e2b',
151 'id': '301b117890c4465c8179ede21fd92e2b',
152 'title': 'Website - Hero Player',
154 'playlist_mincount': 2,
156 PLAYLIST_SERVICE_URL = 'http://production-ps.lvp.llnw.net/r/PlaylistService/channel_list/%s/%s'
158 def _real_extract(self, url):
159 channel_list_id = self._match_id(url)
161 json_data = self.get_playlist_service(channel_list_id, 'getMobileChannelListById')
164 for channel in json_data['channelList']:
166 'url': 'http://link.videoplatform.limelight.com/media/?channelId=%s' % channel['id'],
168 'ie_key': 'LimeLightChannel',
172 'id': channel_list_id,
173 'title': json_data['title'],