#source /mod/webif/plugin/qtube/qtube.jim alias ::qtube::log ::auto::log alias ::qtube::elapsed ::auto::elapsed set ::logfd $::auto::logfd proc qlog {msg {level 1}} { puts $::qlogfd "[\ clock format [clock seconds] -format "%d/%m/%Y %H:%M:%S"\ ] - $msg" flush $::qlogfd } proc ::qtube::dequeue {q url} { set retcode {"FAILED" "Unknown = check qtube.log"} set opts [$q get args] set ::Qid [$q get id] set logfile "/mod/tmp/qtube.log" set ::qlogfd [open $logfile "a+"] qlog "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" 0 log "Starting queued download URL $url Options $opts QID $::Qid" 0 qlog "Starting queued download URL $url Options $opts QID $::Qid" 0 log "See $logfile for details" 0 # Fix to cmd invocation thanks to @/df # https://hummy.tv/forum/threads/qtube-webif-front-end-for-youtube-dl.8948/page-7#post-139719 set cmd {youtube --newline} lappend cmd {*}$opts $url if {[catch {exec {*}[lmap e $cmd {concat $e}] 2>@$::qlogfd \ | awk {{print strftime("%d/%m/%Y %H:%M:%S -"), $0; fflush(); }} \ >@$::qlogfd } msg catchopts] } { log "Caught error: $msg" 0 log "$catchopts" 2 qlog "Caught error: $msg" 0 qlog "$catchopts" 2 set retcode [list "FAILED" "$msg - check qtube.log"] } else { log "Completed queued download of $url Options $opts" 0 qlog "Completed queued download of $url Options $opts" 0 set retcode {"OK" "Check qtube.log"} } close $::qlogfd return $retcode } ::auto::register qtube 200