mirror of
https://github.com/soimort/you-get.git
synced 2025-02-02 16:24:00 +03:00
Merge pull request #1268 from soimort/showroom-polling
[SHOWROOM] Do polling on offline broadcasts
This commit is contained in:
commit
d9b6491c84
@ -5,7 +5,7 @@ __all__ = ['showroom_download']
|
||||
from ..common import *
|
||||
import urllib.error
|
||||
from json import loads
|
||||
from time import time
|
||||
from time import time, sleep
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def showroom_get_roomid_by_room_url_key(room_url_key):
|
||||
@ -25,13 +25,16 @@ def showroom_get_roomid_by_room_url_key(room_url_key):
|
||||
|
||||
def showroom_download_by_room_id(room_id, output_dir = '.', merge = False, info_only = False, **kwargs):
|
||||
'''Source: Android mobile'''
|
||||
while True:
|
||||
timestamp = str(int(time() * 1000))
|
||||
api_endpoint = 'https://www.showroom-live.com/api/live/streaming_url?room_id={room_id}&_={timestamp}'.format(room_id = room_id, timestamp = timestamp)
|
||||
html = get_content(api_endpoint)
|
||||
html = json.loads(html)
|
||||
#{'streaming_url_list': [{'url': 'rtmp://52.197.69.198:1935/liveedge', 'id': 1, 'label': 'original spec(low latency)', 'is_default': True, 'type': 'rtmp', 'stream_name': '7656a6d5baa1d77075c971f6d8b6dc61b979fc913dc5fe7cc1318281793436ed'}, {'url': 'http://52.197.69.198:1935/liveedge/7656a6d5baa1d77075c971f6d8b6dc61b979fc913dc5fe7cc1318281793436ed/playlist.m3u8', 'is_default': True, 'id': 2, 'type': 'hls', 'label': 'original spec'}, {'url': 'rtmp://52.197.69.198:1935/liveedge', 'id': 3, 'label': 'low spec(low latency)', 'is_default': False, 'type': 'rtmp', 'stream_name': '7656a6d5baa1d77075c971f6d8b6dc61b979fc913dc5fe7cc1318281793436ed_low'}, {'url': 'http://52.197.69.198:1935/liveedge/7656a6d5baa1d77075c971f6d8b6dc61b979fc913dc5fe7cc1318281793436ed_low/playlist.m3u8', 'is_default': False, 'id': 4, 'type': 'hls', 'label': 'low spec'}]}
|
||||
if len(html) < 1:
|
||||
log.wtf('Cannot find any live URL! Maybe the live have ended or haven\'t start yet?')
|
||||
if len(html) >= 1:
|
||||
break
|
||||
log.w('The live show is currently offline.')
|
||||
sleep(1)
|
||||
|
||||
#This is mainly for testing the M3U FFmpeg parser so I would ignore any non-m3u ones
|
||||
stream_url = [i['url'] for i in html['streaming_url_list'] if i['is_default'] and i['type'] == 'hls'][0]
|
||||
|
Loading…
Reference in New Issue
Block a user