you-get/src/you_get/extractors/quanmin.py

30 lines
1.1 KiB
Python
Raw Normal View History

2017-01-04 01:58:56 +03:00
#!/usr/bin/env python
__all__ = ['quanmin_download']
from ..common import *
import json
import time
def quanmin_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
2017-01-29 13:37:10 +03:00
roomid = url.split('/')[3].split('?')[0] #add ?parameter.split and change the unstable url(from the back) rfind to split(from the front)
#json_request_url = 'http://www.quanmin.tv/json/rooms/{}/info4.json'.format(roomid) #"http://www.quanmin.tv/json/rooms/308137/info4.json" switch to "http://m.quanmin.tv/json/rooms/308137/noinfo6.json"
json_request_url = 'http://m.quanmin.tv/json/rooms/{}/noinfo6.json'.format(roomid)
2017-01-04 01:58:56 +03:00
content = get_html(json_request_url)
data = json.loads(content)
title = data["title"]
2017-01-29 13:37:10 +03:00
2017-01-04 15:56:32 +03:00
if not data["play_status"]:
raise ValueError("The live stream is not online!")
2017-01-04 01:58:56 +03:00
real_url = "http://flv.quanmin.tv/live/{}.flv".format(roomid)
print_info(site_info, title, 'flv', float('inf'))
if not info_only:
download_urls([real_url], title, 'flv', None, output_dir, merge = merge)
site_info = "quanmin.tv"
download = quanmin_download
download_playlist = playlist_not_supported('quanmin')