2 from __future__ import unicode_literals
4 from .common import InfoExtractor
11 class PeriscopeIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.)?periscope\.tv/w/(?P<id>[^/?#]+)'
14 'url': 'https://www.periscope.tv/w/aJUQnjY3MjA3ODF8NTYxMDIyMDl2zCg2pECBgwTqRpQuQD352EMPTKQjT4uqlM3cgWFA-g==',
15 'md5': '65b57957972e503fcbbaeed8f4fa04ca',
19 'title': 'Bec Boop - ๐ โ๏ธ๐ฌ๐ง Fly above #London in Emirates Air Line cable car at night ๐ฌ๐งโ๏ธ๐ #BoopScope ๐๐',
20 'timestamp': 1438978559,
21 'upload_date': '20150807',
22 'uploader': 'Bec Boop',
23 'uploader_id': '1465763',
25 'skip': 'Expires in 24 hours',
28 def _call_api(self, method, token):
29 return self._download_json(
30 'https://api.periscope.tv/api/v2/%s?token=%s' % (method, token), token)
32 def _real_extract(self, url):
33 token = self._match_id(url)
35 replay = self._call_api('getAccessPublic', token)
36 video_url = replay['replay_url']
38 broadcast_data = self._call_api('getBroadcastPublic', token)
39 broadcast = broadcast_data['broadcast']
40 status = broadcast['status']
42 uploader = broadcast.get('user_display_name') or broadcast_data.get('user', {}).get('display_name')
43 uploader_id = broadcast.get('user_id') or broadcast_data.get('user', {}).get('id')
45 title = '%s - %s' % (uploader, status) if uploader else status
46 timestamp = parse_iso8601(broadcast.get('created_at'))
49 'url': broadcast[image],
50 } for image in ('image_url', 'image_url_small') if broadcast.get(image)]
53 'id': broadcast.get('id') or token,
56 'protocol': 'm3u8_native',
58 'timestamp': timestamp,
60 'uploader_id': uploader_id,
61 'thumbnails': thumbnails,