Add youtube-dl-x protocol, reduces CPU usage MASSIVELY

This commit is contained in:
root 2018-10-04 17:57:39 +00:00
parent 144cc07189
commit acf358317d
1 changed files with 44 additions and 0 deletions

View File

@ -8,6 +8,50 @@ set("server.telnet.bind_addr", "0.0.0.0")
set("decoder.file_extensions.gstreamer",["wav", "webm"]) set("decoder.file_extensions.gstreamer",["wav", "webm"])
set("decoder.mime_types.gstreamer",["audio/x-wav", "audio/wav", "video/webm"]) set("decoder.mime_types.gstreamer",["audio/x-wav", "audio/wav", "video/webm"])
register(name="Youtube_dl-x protocol settings","protocol.youtube-dl-x",())
register(name="Youtube-dl path","protocol.youtube-dl-x.path","youtube-dl -x --audio-format wav --postprocessor-args \"-y\"")
# Register the youtube-dl protocol, using youtube-dl.
# Syntax: youtube-d-xl:<ID>
# @flag hidden
def youtube_dl_x_protocol(~rlog,~maxtime,arg)
binary = get(default="youtube-dl","protocol.youtube-dl-x.path")
log = log(label="protocol.youtube-dl-x")
def log(~level,s) =
rlog(s)
log(level=level,s)
end
delay = maxtime - gettimeofday()
cmd = "#{binary} -x --audio-format wav --get-title --get-filename -- #{quote(arg)}"
log(level=4,"Executing #{cmd}")
x = get_process_lines(timeout=delay,cmd)
x =
if list.length(x) >= 2 then
x
else
["",".osb"]
end
ext = "wav"
title = list.hd(default="",x)
cmd = "rm -f $(output) && #{binary} -x --audio-format wav -q -f bestaudio/best --no-playlist --exec \"mv {} $(output)\" -- #{quote(arg)}"
process = process_uri(extname=ext,cmd)
if title != "" then
["annotate:title=#{quote(title)}:#{process}"]
else
[process]
end
end
add_protocol("youtube-dl-x", youtube_dl_x_protocol,
doc="Resolve a request using youtube-dl.",
syntax="youtube-dl-x:uri")
def crossfade(a,b) def crossfade(a,b)
add(normalize=false, add(normalize=false,
[ sequence([ blank(duration=5.), [ sequence([ blank(duration=5.),