mirror of
https://github.com/soimort/you-get.git
synced 2025-02-03 08:43:58 +03:00
refactor rtmp processor to support rtmp parameters
This commit is contained in:
parent
60458e3c46
commit
e286d91a09
@ -675,21 +675,22 @@ def download_urls_chunked(urls, title, ext, total_size, output_dir='.', refer=No
|
|||||||
|
|
||||||
print()
|
print()
|
||||||
|
|
||||||
def download_rtmp_url(url, playpath, title, ext, total_size=0, output_dir='.', refer=None, merge=True, faker=False):
|
def download_rtmp_url(url,title, ext,params={}, total_size=0, output_dir='.', refer=None, merge=True, faker=False):
|
||||||
assert url
|
assert url
|
||||||
if dry_run:
|
if dry_run:
|
||||||
print('Real URL:\n%s\n' % [url])
|
print('Real URL:\n%s\n' % [url])
|
||||||
print('Real Playpath:\n%s\n' % [playpath])
|
if params.get("-y",False): #None or unset ->False
|
||||||
|
print('Real Playpath:\n%s\n' % [params.get("-y")])
|
||||||
return
|
return
|
||||||
|
|
||||||
if player:
|
if player:
|
||||||
from .processor.rtmpdump import play_rtmpdump_stream
|
from .processor.rtmpdump import play_rtmpdump_stream
|
||||||
play_rtmpdump_stream(player, url, playpath)
|
play_rtmpdump_stream(player, url, params)
|
||||||
return
|
return
|
||||||
|
|
||||||
from .processor.rtmpdump import has_rtmpdump_installed, download_rtmpdump_stream
|
from .processor.rtmpdump import has_rtmpdump_installed, download_rtmpdump_stream
|
||||||
assert has_rtmpdump_installed(), "RTMPDump not installed."
|
assert has_rtmpdump_installed(), "RTMPDump not installed."
|
||||||
download_rtmpdump_stream(url, playpath, title, ext, output_dir)
|
download_rtmpdump_stream(url, title, ext,params, output_dir)
|
||||||
|
|
||||||
def playlist_not_supported(name):
|
def playlist_not_supported(name):
|
||||||
def f(*args, **kwargs):
|
def f(*args, **kwargs):
|
||||||
|
@ -26,6 +26,7 @@ from .letv import *
|
|||||||
from .magisto import *
|
from .magisto import *
|
||||||
from .miomio import *
|
from .miomio import *
|
||||||
from .mixcloud import *
|
from .mixcloud import *
|
||||||
|
from .mtv81 import *
|
||||||
from .netease import *
|
from .netease import *
|
||||||
from .nicovideo import *
|
from .nicovideo import *
|
||||||
from .pptv import *
|
from .pptv import *
|
||||||
|
@ -46,6 +46,7 @@ def url_to_module(url):
|
|||||||
'magisto': magisto,
|
'magisto': magisto,
|
||||||
'miomio': miomio,
|
'miomio': miomio,
|
||||||
'mixcloud': mixcloud,
|
'mixcloud': mixcloud,
|
||||||
|
'mtv81':mtv81,
|
||||||
'nicovideo': nicovideo,
|
'nicovideo': nicovideo,
|
||||||
'pptv': pptv,
|
'pptv': pptv,
|
||||||
'qq': qq,
|
'qq': qq,
|
||||||
|
35
src/you_get/extractor/mtv81.py
Normal file
35
src/you_get/extractor/mtv81.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
__all__ = ['mtv81_download']
|
||||||
|
|
||||||
|
from ..common import *
|
||||||
|
from html.parser import unescape
|
||||||
|
from xml.dom.minidom import parseString
|
||||||
|
|
||||||
|
def mtv81_download(url, output_dir = '.', merge = True, info_only = False):
|
||||||
|
html=get_content(url)
|
||||||
|
title=unescape("|".join(match1(html,r"<title>(.*?)</title>").split("|")[:-2]))
|
||||||
|
|
||||||
|
#mgid%3Auma%3Avideo%3Amtv81.com%3A897974
|
||||||
|
vid=match1(html,r'getTheVideo\("(.*?)"')
|
||||||
|
xml=parseString(get_content("http://intl.esperanto.mtvi.com/www/xml/media/mediaGen.jhtml?uri={}&flashPlayer=LNX%2013,0,0,206&geo=CN&sid=123456".format(vid)))
|
||||||
|
|
||||||
|
url=sorted(map(lambda x:x.firstChild.nodeValue,xml.getElementsByTagName("src")),key=lambda x:int(match1(x,r'_(\d+?)_')))[-1]
|
||||||
|
|
||||||
|
mediatype, ext, size = 'mp4', 'mp4', 0
|
||||||
|
print_info(site_info, title, mediatype, size)
|
||||||
|
##
|
||||||
|
# rtmpdump -r 'rtmpe://cp30865.edgefcs.net/ondemand/mtviestor/_!/intlod/MTVInternational/MBUS/GeoLocals/00JP/VIAMTVI/PYC/201304/7122HVAQ4/00JPVIAMTVIPYC7122HVAQ4_640x_360_1200_m30.mp4' -o "title.mp4" --swfVfy http://media.mtvnservices.com/player/prime/mediaplayerprime.1.10.8.swf
|
||||||
|
##
|
||||||
|
# because rtmpdump is unstable,may try serveral times
|
||||||
|
##
|
||||||
|
if not info_only:
|
||||||
|
# import pdb
|
||||||
|
# pdb.set_trace()
|
||||||
|
download_rtmp_url(url=url, title=title, ext=ext, params={"--swfVfy":"http://media.mtvnservices.com/player/prime/mediaplayerprime.1.10.8.swf"}, output_dir=output_dir)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
site_info = "mtv81.com"
|
||||||
|
download = mtv81_download
|
||||||
|
download_playlist = playlist_not_supported('mtv81')
|
@ -17,7 +17,7 @@ def theplatform_download_by_pid(pid, title, output_dir='.', merge=True, info_onl
|
|||||||
|
|
||||||
print_info(site_info, title, type, size)
|
print_info(site_info, title, type, size)
|
||||||
if not info_only:
|
if not info_only:
|
||||||
download_rtmp_url(url=smil_base, playpath=ext+':'+smil_video, title=title, ext=ext, output_dir=output_dir)
|
download_rtmp_url(url=smil_base, title=title, ext=ext,params={"-y":ext+':'+smil_video}, output_dir=output_dir)
|
||||||
|
|
||||||
site_info = "thePlatform.com"
|
site_info = "thePlatform.com"
|
||||||
download = theplatform_download_by_pid
|
download = theplatform_download_by_pid
|
||||||
|
@ -16,20 +16,40 @@ RTMPDUMP = get_usable_rtmpdump('rtmpdump')
|
|||||||
def has_rtmpdump_installed():
|
def has_rtmpdump_installed():
|
||||||
return RTMPDUMP is not None
|
return RTMPDUMP is not None
|
||||||
|
|
||||||
def download_rtmpdump_stream(url, playpath, title, ext, output_dir='.'):
|
#
|
||||||
|
#params ={"-y":"playlist","-q":None,}
|
||||||
|
#if Only Key ,Value should be None
|
||||||
|
#-r -o should not be included in params
|
||||||
|
|
||||||
|
def download_rtmpdump_stream(url, title, ext,params={},output_dir='.'):
|
||||||
filename = '%s.%s' % (title, ext)
|
filename = '%s.%s' % (title, ext)
|
||||||
filepath = os.path.join(output_dir, filename)
|
filepath = os.path.join(output_dir, filename)
|
||||||
|
|
||||||
params = [RTMPDUMP, '-r']
|
cmdline = [RTMPDUMP, '-r']
|
||||||
params.append(url)
|
cmdline.append(url)
|
||||||
params.append('-y')
|
cmdline.append('-o')
|
||||||
params.append(playpath)
|
cmdline.append(filepath)
|
||||||
params.append('-o')
|
|
||||||
params.append(filepath)
|
|
||||||
|
|
||||||
subprocess.call(params)
|
for key in params.keys():
|
||||||
|
cmdline.append(key)
|
||||||
|
if params[key]!=None:
|
||||||
|
cmdline.append(params[key])
|
||||||
|
|
||||||
|
# cmdline.append('-y')
|
||||||
|
# cmdline.append(playpath)
|
||||||
|
print("Call rtmpdump:\n"+" ".join(cmdline)+"\n")
|
||||||
|
subprocess.call(cmdline)
|
||||||
return
|
return
|
||||||
|
|
||||||
def play_rtmpdump_stream(player, url, playpath):
|
#
|
||||||
os.system("rtmpdump -r '%s' -y '%s' -o - | %s -" % (url, playpath, player))
|
#To be refactor
|
||||||
|
#
|
||||||
|
def play_rtmpdump_stream(player, url, params={}):
|
||||||
|
cmdline="rtmpdump -r '%s' "%url
|
||||||
|
for key in params.keys():
|
||||||
|
cmdline+=key+" "+params[key] if params[key]!=None else ""+" "
|
||||||
|
cmdline+=" -o - | %s -"%player
|
||||||
|
print(cmdline)
|
||||||
|
os.system(cmdline)
|
||||||
|
# os.system("rtmpdump -r '%s' -y '%s' -o - | %s -" % (url, playpath, player))
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user