]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/saitosan.py
3 from __future__
import unicode_literals
5 from .common
import InfoExtractor
6 from ..utils
import ExtractorError
, try_get
9 class SaitosanIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:www\.)?saitosan\.net/bview.html\?id=(?P<id>[0-9]+)'
13 'url': 'http://www.saitosan.net/bview.html?id=10031846',
19 'thumbnail': 'http://111.171.196.85:8088/921f916f-7f55-4c97-b92e-5d9d0fef8f5f/thumb',
24 'skip_download': True,
26 'skip': 'Broadcasts are ephemeral',
29 'url': 'http://www.saitosan.net/bview.html?id=10031795',
35 'thumbnail': 'http://111.171.196.85:8088/1a3933e1-a01a-483b-8931-af15f37f8082/thumb',
40 'skip_download': True,
42 'skip': 'Broadcasts are ephemeral',
45 def _real_extract(self
, url
):
46 b_id
= self
._match
_id
(url
)
48 base
= 'http://hankachi.saitosan-api.net:8002/socket.io/?transport=polling&EIO=3'
49 sid
= self
._download
_socket
_json
(base
, b_id
, note
='Opening socket').get('sid')
52 self
._download
_webpage
(base
, b_id
, note
='Polling socket')
53 payload
= '420["room_start_join",{"room_id":"%s"}]' % b_id
54 payload
= '%s:%s' % (len(payload
), payload
)
56 self
._download
_webpage
(base
, b_id
, data
=payload
, note
='Polling socket with payload')
57 response
= self
._download
_socket
_json
(base
, b_id
, note
='Polling socket')
58 if not response
.get('ok'):
59 err
= response
.get('error') or {}
61 '%s said: %s - %s' % (self
.IE_NAME
, err
.get('code', '?'), err
.get('msg', 'Unknown')) if err
62 else 'The socket reported that the broadcast could not be joined. Maybe it\'s offline or the URL is incorrect',
63 expected
=True, video_id
=b_id
)
65 self
._download
_webpage
(base
, b_id
, data
='26:421["room_finish_join",{}]', note
='Polling socket')
66 b_data
= self
._download
_socket
_json
(base
, b_id
, note
='Getting broadcast metadata from socket')
67 m3u8_url
= b_data
.get('url')
69 self
._download
_webpage
(base
, b_id
, data
='1:1', note
='Closing socket', fatal
=False)
73 'title': b_data
.get('name'),
74 'formats': self
._extract
_m
3u8_formats
(m3u8_url
, b_id
, 'mp4', live
=True),
75 'thumbnail': m3u8_url
.replace('av.m3u8', 'thumb'),
76 'uploader': try_get(b_data
, lambda x
: x
['broadcast_user']['name']), # same as title