mirror of
https://github.com/soimort/you-get.git
synced 2025-02-03 00:33:58 +03:00
[Showroom] Add support via HLS M3U
This commit is contained in:
parent
2fdea30d8d
commit
5a99b2f42f
@ -62,6 +62,7 @@ SITES = {
|
|||||||
'pptv' : 'pptv',
|
'pptv' : 'pptv',
|
||||||
'qianmo' : 'qianmo',
|
'qianmo' : 'qianmo',
|
||||||
'qq' : 'qq',
|
'qq' : 'qq',
|
||||||
|
'showroom-live' : 'showroom',
|
||||||
'sina' : 'sina',
|
'sina' : 'sina',
|
||||||
'smgbb' : 'bilibili',
|
'smgbb' : 'bilibili',
|
||||||
'sohu' : 'sohu',
|
'sohu' : 'sohu',
|
||||||
@ -912,7 +913,7 @@ def download_url_ffmpeg(url,title, ext,params={}, total_size=0, output_dir='.',
|
|||||||
ffmpeg_play_stream(player, url, params)
|
ffmpeg_play_stream(player, url, params)
|
||||||
return
|
return
|
||||||
|
|
||||||
from .processor.ffmpeg import has_ffmpeg_installed, ffmpeg_download_streaming
|
from .processor.ffmpeg import has_ffmpeg_installed, ffmpeg_download_stream
|
||||||
assert has_ffmpeg_installed(), "FFmpeg not installed."
|
assert has_ffmpeg_installed(), "FFmpeg not installed."
|
||||||
ffmpeg_download_stream(url, title, ext, params, output_dir)
|
ffmpeg_download_stream(url, title, ext, params, output_dir)
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ from .pptv import *
|
|||||||
from .qianmo import *
|
from .qianmo import *
|
||||||
from .qie import *
|
from .qie import *
|
||||||
from .qq import *
|
from .qq import *
|
||||||
|
from .showroom import *
|
||||||
from .sina import *
|
from .sina import *
|
||||||
from .sohu import *
|
from .sohu import *
|
||||||
from .soundcloud import *
|
from .soundcloud import *
|
||||||
|
67
src/you_get/extractors/showroom.py
Executable file
67
src/you_get/extractors/showroom.py
Executable file
@ -0,0 +1,67 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
__all__ = ['showroom_download']
|
||||||
|
|
||||||
|
from ..common import *
|
||||||
|
import urllib.error
|
||||||
|
from json import loads
|
||||||
|
from time import time
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
def showroom_get_roomid_by_room_url_key(room_url_key):
|
||||||
|
"""str->str"""
|
||||||
|
fake_headers_mobile = {
|
||||||
|
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||||
|
'Accept-Charset': 'UTF-8,*;q=0.5',
|
||||||
|
'Accept-Encoding': 'gzip,deflate,sdch',
|
||||||
|
'Accept-Language': 'en-US,en;q=0.8',
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36'
|
||||||
|
}
|
||||||
|
webpage_url = 'https://www.showroom-live.com/' + room_url_key
|
||||||
|
html = get_content(webpage_url, headers = fake_headers_mobile)
|
||||||
|
roomid = match1(html, r'room\?room_id\=(\d+)')
|
||||||
|
assert roomid
|
||||||
|
return roomid
|
||||||
|
|
||||||
|
def showroom_download_by_room_id(room_id, output_dir = '.', merge = False, info_only = False, **kwargs):
|
||||||
|
'''Source: Android mobile'''
|
||||||
|
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?')
|
||||||
|
|
||||||
|
#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]
|
||||||
|
|
||||||
|
assert stream_url
|
||||||
|
|
||||||
|
#title
|
||||||
|
title = ''
|
||||||
|
profile_api = 'https://www.showroom-live.com/api/room/profile?room_id={room_id}'.format(room_id = room_id)
|
||||||
|
html = loads(get_content(profile_api))
|
||||||
|
try:
|
||||||
|
title = html['main_name']
|
||||||
|
except KeyError:
|
||||||
|
title = 'Showroom_{room_id}'.format(room_id = room_id)
|
||||||
|
|
||||||
|
type_, ext, size = url_info(stream_url)
|
||||||
|
print_info(site_info, title, type_, size)
|
||||||
|
if not info_only:
|
||||||
|
download_url_ffmpeg(url=stream_url, title=title, ext= 'mp4', output_dir=output_dir)
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
def showroom_download(url, output_dir = '.', merge = False, info_only = False, **kwargs):
|
||||||
|
""""""
|
||||||
|
if re.match( r'(\w+)://www.showroom-live.com/(\w*)', url):
|
||||||
|
room_url_key = match1(url, r'\w+://www.showroom-live.com/(\w*)')
|
||||||
|
room_id = showroom_get_roomid_by_room_url_key(room_url_key)
|
||||||
|
showroom_download_by_room_id(room_id, output_dir, merge,
|
||||||
|
info_only)
|
||||||
|
|
||||||
|
site_info = "Showroom"
|
||||||
|
download = showroom_download
|
||||||
|
download_playlist = playlist_not_supported('showroom')
|
Loading…
Reference in New Issue
Block a user