commit 8cf46e25621646ea9d0363dbd3bcf479553ba9ac
parent b50190c304523c19f8ca8d6673e20723d29e789a
Author: Kris Maglione <kris@suckless.org>
Date: Fri, 5 Aug 2011 12:39:10 -0400
A few updates.
Diffstat:
5 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/README b/README
@@ -7,6 +7,8 @@ ordinary media URL and procedes as normal. If no url is
provided, it is read from the X11 clipboard. It accepts the
following options:
+ -b Pre-buffer the video for players with bad streaming
+ support.
-e Echo the resulting URL and exit.
-f Fetch the resulting stream rather than playing
it.
diff --git a/vp b/vp
@@ -3,9 +3,10 @@
. vp-base $0 $*
vp_subscript = 1
-getflags 'e,f,F format,o output-file' $args
+getflags 'b,e,f,F format,o output-file' $args
ifs=, { vp_format = `{echo -n $flagF} }
+vp_prebuffer = $flagb
vp_result = $argv(1)
vp_default vp_result `{vp_paste}
vp_orig = $vp_result
diff --git a/vp-base b/vp-base
@@ -37,7 +37,7 @@ if(~ $vp_base_loaded '') {
# 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 $* }
+ fn vp_player { mplayer -cache 5120 -cache-min 20 -cookies -cookies-file $vp_cookie_jar $* }
vp_have_rtmpplayer_cookies = ()
fn vp_rtmpplayer { vlc `{vp_rtmpurl $*} }
@@ -68,7 +68,7 @@ if(~ $vp_base_loaded '') {
fn vp_play {
hget = ()
- if(test -n $"vp_need_cookies -a -z $"vp_have_player_cookies)
+ if(test -n $"vp_prebuffer -o -n $"vp_need_cookies -a -z $"vp_have_player_cookies)
vp_savevideo = $vp_vidtemp
if(test -n $"vp_savevideo) {
echo >[1=2] vp: Saving to $vp_savevideo
diff --git a/vp-xhamster b/vp-xhamster
@@ -4,8 +4,8 @@
. vp-base $0 $*
-vp_result `{vp_data $* | awk -F '^ *''|'': *''|''[,\r]' '
+vp_result `{vp_data $* | awk -F '^ *''|'' *: *''|''[,\r]' '
END { print a["srv"] "/" a["type"] "2/" a["file"] }
- /^[ ]*''[a-z]+'':/ { a[$2] = $3 }
+ /^[ ]*''[a-z]+'' *:/ { a[$2] = $3 }
'}
diff --git a/vp-youtube b/vp-youtube
@@ -1,6 +1,6 @@
#!/usr/bin/env rc
#
-# Pattern: ^http://(www\d*\.)?youtube\.com/(v/|(watch(\.php|_videos)?))(\?|#!|#%21)
+# Pattern: ^https?://(www\d*\.)?youtube\.com/(v/|(watch(\.php|_videos)?))(\?|#!|#%21)
#
# Formats:
# Resolution Ext Video / Audio Rate Title
@@ -27,6 +27,12 @@ vp_data `{echo $* | sed 's/#(!|%21)v=/?v=/'} | vp_awk '
split($0, a, /.*flashvars=\\"|\\"/)
urlparse(a[2], swfargs)
}
+ /flashvars="/ {
+ split($0, a, /.*flashvars="|"/)
+ gsub(/"/, "\"", a[2])
+ gsub(/&/, "\\&", a[2])
+ urlparse(a[2], swfargs)
+ }
/setAvailableFormat\(/ {
split($0, a, /.*setAvailableFormat\("|", "|"\)/)
fmt_url_map[a[5]] = a[2]
@@ -34,6 +40,13 @@ vp_data `{echo $* | sed 's/#(!|%21)v=/?v=/'} | vp_awk '
END {
urlparse(ENVIRON["swfargs"], swfargs)
urlparse(swfargs["fmt_url_map"], fmt_url_map, ",", "|")
+
+ n = split(swfargs["url_encoded_fmt_stream_map"], a, /,/)
+ for (i=i; i < n; i++) {
+ urlparse(a[i], fmt)
+ fmt_url_map[fmt["itag"]] = fmt["url"]
+ }
+
split("' $vp_format $vp_youtube_formats '", fmt)
for(i=1; i <= length(fmt); i++)
if(fmt[i] in fmt_url_map) {