vp

git clone git://oldgit.suckless.org/vp/
Log | Files | Refs | README

commit eb5a93567cf6e99c3b81224aa0ebb08495063ee7
parent 4da671831028313784417d5c69a464b890758de7
Author: Kris Maglione <kris@suckless.org>
Date:   Thu, 16 Sep 2010 01:58:15 -0400

First go at rtmp support.

Diffstat:
vp | 19+++++++++++++++----
vp-base | 34++++++++++++++++++++++++++++++++--
vp-fora | 33++++++++++++++++++++++++++++-----
3 files changed, 75 insertions(+), 11 deletions(-)

diff --git a/vp b/vp @@ -3,7 +3,7 @@ . vp-base $0 $* vp_subscript = 1 -getflags 'e,f,F format,o output-file' +getflags 'e,f,F format,o output-file' $args ifs=, { vp_format = `{echo -n $flagF} } vp_result = $argv(1) @@ -14,7 +14,10 @@ if(vp_script = `{vp_findscript $vp_result}) . $vp_script $vp_result if(! ~ $flage '') { - echo $vp_result + if (! ~ $vp_rtmpresult '') + vp_rtmpurl $vp_rtmpresult + if not + echo $vp_result exit } @@ -23,7 +26,15 @@ if(~ $flagf '') if not { if(~ $flago '') flago = `{vp_autoname $vp_orig $vp_result} - if(~ $flago '') $vp_hget_loud $vp_hget_autoname $vp_result - if not $vp_hget_loud >$flago $vp_result + if(! ~ $vp_rtmpresult '') { + getflags 's ,r url,t ,y path' $vp_rtmpresult + if (~ $flago '') + ifs=$vp_newline { flago = `{basename $flagy} ^ .flv } + $vp_rtmpget_loud -o$flago $vp_rtmpresult + } + if not { + if(~ $flago '') $vp_hget_loud $vp_hget_autoname $vp_result + if not $vp_hget_loud >$flago $vp_result + } } diff --git a/vp-base b/vp-base @@ -24,14 +24,29 @@ if(~ $vp_base_loaded '') { vp_hget_loud=($vp_hget '-#') vp_hget_silent=($vp_hget -s) + vp_rtmpget = (flvstreamer) + vp_rtmpget_loud = ($vp_rtmpget) + vp_rtmpget_silent = ($vp_rtmpget) + fn vp_autoname { true } fn vp_paste { xsel -o || sselp } + vp_newline=' +' + # IMPORTANT: Unset this if you use a player that does # not read its cookies from $vp_cookie_jar vp_have_player_cookies = 1 fn vp_player { mplayer -cookies -cookies-file $vp_cookie_jar $* } + vp_have_rtmpplayer_cookies = () + fn vp_rtmpplayer { vlc `{vp_rtmpurl $*} } + + fn vp_rtmpurl { + getflags 's ,r url,t ,y path' $* + echo $flagr + } + fn js { builtin js || kjs /dev/stdin } # Plan 9's sed doesn't work with long lines @@ -48,7 +63,7 @@ if(~ $vp_base_loaded '') { } fn getflags { - ifs=() flagfmt=$"* { eval `{builtin getflags $args; echo ';argv=$*'} } + ifs=() flagfmt=$1 *=$* { shift; eval `{builtin getflags $*; echo ';argv=$*'} } } fn vp_play { @@ -63,7 +78,10 @@ if(~ $vp_base_loaded '') { while(! vp_checkmedia $vp_savevideo) sleep 1 } - vp_player $* + if (~ $vp_rtmpresult '') + vp_player $* + else + vp_rtmpplayer $vp_rtmpresult if(test -n $"hget) kill $hget } @@ -74,6 +92,11 @@ if(~ $vp_base_loaded '') { if not vp_result = $* } + fn vp_rtmpresult { + vp_rtmpresult = $* + if(~ $vp_subscript '') + vp_rtmpurl $vp_rtmpresult + } vp_urldec = 'hextab["' ^ (0 1 2 3 4 5 6 7 8 9 a b c d e f) ^ '"] = ' ^ `{seq 0 15} ^ ';' vp_urldec = ' @@ -116,6 +139,13 @@ if(~ $vp_base_loaded '') { function set(var, val) { print var "=" quote(val) >"/dev/fd/3" } + function setary(var, val, ifs) { + if (ifs == "") + ifs = " " + print "ifs=" quote(ifs) "{" \ + var "= `{echo -n " quote(val) "}" \ + "}" >"/dev/fd/3" + } ' ^ $"* >[3=1] >[1=4] # Best not think too much about these # redirections. In short: diff --git a/vp-fora b/vp-fora @@ -12,7 +12,9 @@ vp_data $* | vp_awk ' set("clipid", $4) exit 0 }' -vp_data 'http://fora.tv/fora/fora_player_full?cid='^$"clipid | vp_awk ' + +vp_data 'http://fora.tv/fora/fora_player_full?cid='^$"clipid | + sed 's,</[A-Za-z_]+>,&\n,g' | vp_awk ' { match($0, /<[a-zA-Z-_]+/) tag = substr($0, RSTART+1, RLENGTH-1) @@ -21,10 +23,31 @@ vp_data 'http://fora.tv/fora/fora_player_full?cid='^$"clipid | vp_awk ' tags[tag] = substr(str, 1, RSTART - 1) } END { - name = tags["encode_url"] - sub(/-[^-]+-[0-9]+.flv$/, "", name) - set("vp_result", "http://foratv.vo.llnwd.net/o33/mp4/" name "-" ENVIRON["clipid"] "-new_download.mp4") + if (ENVIRON["vp_format"] == "high" && tags["encode_url_high_available"] == 1) + tags["encode_url"] = tags["encode_url_high"] + sub(/\.flv$/, "", tags["encode_url"]) + + setary("vp_rtmpresult", \ + "-s http://fora.tv/FORA_Player_5.ver_1_51.swf " \ + "-r rtmp://" tags["encode_origin"] "/" tags["encode_application"] "/" tags["encode_url"] " " \ + "-t rtmp://" tags["encode_origin"] "/" tags["encode_application"] " " \ + "-y " tags["encode_url"]) }' -vp_result $vp_result +vp_rtmpresult $vp_rtmpresult +if (false) { + vp_data 'http://fora.tv/fora/fora_player_full?cid='^$"clipid | vp_awk ' + { + match($0, /<[a-zA-Z-_]+/) + tag = substr($0, RSTART+1, RLENGTH-1) + str = substr($0, RSTART + RLENGTH + 1) + match(str, "</" tag) + tags[tag] = substr(str, 1, RSTART - 1) + } + END { + name = tags["encode_url"] + sub(/-[^-]+-[0-9]+.flv$/, "", name) + set("vp_result", "http://foratv.vo.llnwd.net/o33/mp4/" name "-" ENVIRON["clipid"] "-new_download.mp4") + }' +}