- configJSON = self._download_webpage(configUrl, videoId,
- u'Downloading configuration',
- u'unable to download configuration')
-
- # Technically, it's JavaScript, not JSON
- configJSON = configJSON.replace("'", '"')
-
+ formats = []
+
+ def _add_format(name, cfgurl, quality):
+ config = self._download_json(
+ cfgurl, video_id,
+ 'Downloading ' + name + ' configuration',
+ 'Unable to download ' + name + ' configuration',
+ transform_source=lambda s: s.replace("'", '"'))
+
+ playlist = config['playlist']
+ formats.append({
+ 'url': playlist[1]['url'],
+ 'format_id': name,
+ 'quality': quality,
+ })
+
+ _add_format('normal', configUrl, quality=0)
+ hq_url = (configUrl +
+ ('&hq=1' if '?' in configUrl else configUrl + '?hq=1'))