优酷视频mplayer自动连播脚本

上网、浏览、聊天、下载等
回复
bobby_winon
帖子: 236
注册时间: 2008-01-31 12:39

Re: 优酷视频mplayer自动连播脚本

#61

帖子 bobby_winon » 2012-04-13 16:01

bobby_winon 写了:
Dohko 写了:
Dohko 写了:这个脚本怎么用啊?我保存为flvcd.sh然后改成777,结果还是没反映啊
非常感谢LZ啊,搞定了,稍微修改了下,用gnome-mplayer播放
大哥,你是怎么搞定的,我修改了权限也不行啊。介绍下经验吧。
我知道为什么了,问题在open with 这个插件本身,它默认只调用 /usr/share/applications/下的程序。剩下的,估计大家知道怎么搞了吧。 :em04
zhyma
帖子: 75
注册时间: 2008-06-01 9:02

Re: 优酷视频mplayer自动连播脚本

#62

帖子 zhyma » 2012-04-15 14:56

凡是,mp4的都放不了。
附件
1.png
头像
到处看看
论坛版主
帖子: 8486
注册时间: 2010-01-17 13:05
系统: ubuntu

Re: 优酷视频mplayer自动连播脚本

#63

帖子 到处看看 » 2012-04-15 20:24

应该是视频源的事 我试了下优酷的可以播放
头像
mjp123
帖子: 703
注册时间: 2009-04-09 15:06

Re: 优酷视频mplayer自动连播脚本

#64

帖子 mjp123 » 2012-04-15 22:19

zhyma 写了:凡是,mp4的都放不了。
你可以直接在www.flvcd.com网站解析,看看它怎么说。
zhyma
帖子: 75
注册时间: 2008-06-01 9:02

Re: 优酷视频mplayer自动连播脚本

#65

帖子 zhyma » 2012-05-08 21:17

mjp123 写了:
zhyma 写了:凡是,mp4的都放不了。
你可以直接在www.flvcd.com网站解析,看看它怎么说。
优酷的有视频地址,而搜狐的没有.
附件
1.png
头像
mjp123
帖子: 703
注册时间: 2009-04-09 15:06

Re: 优酷视频mplayer自动连播脚本

#66

帖子 mjp123 » 2012-05-09 10:26

zhyma 写了:
mjp123 写了:
zhyma 写了:凡是,mp4的都放不了。
你可以直接在www.flvcd.com网站解析,看看它怎么说。
优酷的有视频地址,而搜狐的没有.
http://forum.ubuntu.org.cn/viewtopic.php?f=74&t=373840
头像
rapistor
帖子: 1983
注册时间: 2009-01-19 15:09

Re: 优酷视频mplayer自动连播脚本

#67

帖子 rapistor » 2012-07-21 20:32

今天用openwith插件 一个视频都打不开了,不知道是什么原因 ?
有在用的朋友吗?请帮忙试一下。
前几天火狐13.0版本,openwith应该是5.1.1版本,还正常使用。
今天是14.0版本,openwith更新 到5.2.1,然后就不会正常使用了。
提示地址错误,用flvcd可以解析出来,但是一连串的字母,不是平常的汉字的列表。
坚守在linux的天堂!
头像
mjp123
帖子: 703
注册时间: 2009-04-09 15:06

Re: 优酷视频mplayer自动连播脚本

#68

帖子 mjp123 » 2012-07-23 11:09

rapistor 写了:今天用openwith插件 一个视频都打不开了,不知道是什么原因 ?
有在用的朋友吗?请帮忙试一下。
前几天火狐13.0版本,openwith应该是5.1.1版本,还正常使用。
今天是14.0版本,openwith更新 到5.2.1,然后就不会正常使用了。
提示地址错误,用flvcd可以解析出来,但是一连串的字母,不是平常的汉字的列表。
不用openwith,用flashgot,感觉比openwith好。
bobby_winon
帖子: 236
注册时间: 2008-01-31 12:39

Re: 优酷视频mplayer自动连播脚本

#69

帖子 bobby_winon » 2012-07-24 10:31

请问这个脚本能不能用到opera上面,因为我的firefox14.01的右键菜单经常性丢失.请问有没有类似经历的朋友呢?
头像
guyanqiu
帖子: 360
注册时间: 2009-05-05 23:42

Re: 优酷视频mplayer自动连播脚本

#70

帖子 guyanqiu » 2012-07-24 10:42

标记一下,回去试试。开FlashPlayer笔记本上热太快了。
-----------------------
在迷茫中追逐,在追逐中迷茫……
-----------------------
头像
chenjietao
帖子: 130
注册时间: 2010-09-21 1:50

Re: 优酷视频mplayer自动连播脚本

#71

帖子 chenjietao » 2012-07-24 13:37

:em06 也许有人看优酷电视剧或电影喜欢粤语版的,我贡献个自动转粤语的脚本:

~/.scripts/PlayFLV:
[bash]#!/bin/bash
#thanks http://www.flvcd.com
#example: vsplay http://v.youku.com/v_show/id_XMzAwMjI3MDI0.html
# fmt could be: 'normal', 'high', 'super' or 'real'(without the quotation mark), generally denoting 260p, 360p, 480p and the original image respectively, yet depending on the video source defaults though. Leaving it blank leads to the default video quality provided.
#wurl=$(urlencode "$1")
UA="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
fmt=high
player="mplayer -playlist"

for parameter in "$@"; do
case "$parameter" in
normal|high|super|real)
fmt="$parameter"
;;
http*)
wurl="$parameter"
;;
mplayer)
player="mplayer -playlist"
;;
gnome-mplayer|gmplayer)
player="gnome-mplayer"
;;
vlc)
player="vlc"
;;
smplayer)
player="smplayer"
;;
yueyu|canton|cantonese)
cantonese=yes
;;
*)
other="$other $parameter"
;;
esac
done


parser="http://www.flvcd.com/parse.php?flag=&kw ... CA%BCGO%21"

get_cantonese() {
canton=`sed -n '/>粤语版</ p' /tmp/dump`
if [ -n "$canton" ]; then
rm /tmp/dump
cantonurl=`echo $canton |sed 's/^.*http/http/; s/html.*$/html/'`
parser="http://www.flvcd.com/parse.php?kw=$cant ... CA%BCGO%21"
if ! wget $parser -q -U "$UA" -O /tmp/dump; then
notify-send "cannot get parser, exit"
exit 0
fi
iconv -f gbk -t utf-8 /tmp/dump -o /tmp/dump
fi
}

get_m3u() {
start_line=`sed -n '/m3u/=' /tmp/dump`
end_line=`sed -n '/M3U/=' /tmp/dump`
cut_line=$(($end_line-2))

sed -e "$cut_line,$ d" /tmp/dump > /tmp/playlist
sed -i "1,$start_line d" /tmp/playlist
sed -i 's/^.*http/http/g' /tmp/playlist
}

get_url() {
grep "<U>" /tmp/dump > /tmp/playlist
sed -i 's/<U>//g' /tmp/playlist
if [[ -n $(grep "<P>" /tmp/dump |sed -n '/搜狐/p') ]]; then
sed -i 's/^.*&new=/http:\/\/newflv.sohu.ccgslb.net/g' /tmp/playlist
fi
}

get_title() {
grep "<N>" /tmp/dump >/tmp/title
sed -i 's/<N>//g' /tmp/title
file="`sed 's/-0001//' /tmp/title |head -1`"
}

get_playlist() {
for ((i=1; i<=$u_length; ++i))
do
ttl="${file}-${i}/${u_length}"
sed -i "$((2*i-1)) i #EXTINF:PART $i in $u_length, $ttl" /tmp/playlist
done
mv /tmp/playlist /tmp/playlist.m3u
sed -i "1i#EXTM3U" /tmp/playlist.m3u
}

play() {
if [ -s /tmp/playlist.m3u ]; then
notify-send "playing $file"
$player /tmp/playlist.m3u $other
elif [ -s /tmp/playlist ]; then
$player /tmp/playlist $other
fi

}

if ! wget $parser -q -U "$UA" -O /tmp/dump; then

notify-send "cannot get parser, exit"
exit 0
fi

iconv -f gbk -t utf-8 /tmp/dump -o /tmp/dump

if [[ $cantonese = "yes" ]]; then
get_cantonese
fi

if [[ "`grep m3u /tmp/dump`" != "" ]] ; then
get_m3u
else
get_url
fi

get_title

u_length=`cat /tmp/playlist |wc -l`
t_length=`cat /tmp/title |wc -l`

if [ $u_length -eq 0 ]; then
notify-send "stream url is null, exit"
exit 0
fi

if [ $u_length -eq $t_length ]; then
get_playlist
else
notify-send "u_length and t_length not match, generated with no titles. "
fi

rm /tmp/title /tmp/dump

if ! play ; then
echo "can not play, check the url's in /tmp/playlist.m3u or /tmp/playlist"
fi[/bash]
用法:~/.scripts/PlayFLV super smplayer yueyu 网址 -fullscreen ##用smplayer以超清模式全屏播放粤语版(如果有)视频。
支持smplayer、vlc、gnome-mplayer、mplayer,用vlc有标题,其它的没有标题,只有网址;但vlc暂停很久后会断开连接。


再贡献个播放优酷专辑的脚本:
~/.scripts/PlayAlbum
[bash]
#!/bin/bash
##这个脚本可以用来连续播放优酷的专辑,配合“mplayer自动连播脚本”一起使用,输入网址可以是专辑网址,也可以是专辑里的其中一个视频网址,如果是专辑网址,则从第一集开始播放,如果是某个视频网址,则从这个视频开始播放。
##电视剧是按集数顺序播放,综艺节目之类的可能是按日期从新往旧的播放(因为优酷是这样安排的),用户上传的专辑如果不止一页,会自动全部播放,不需要逐页执行。
##该脚本运行时会调用终端来打开,请将lxterminal改成您自己的终端(如gnome-terminal)
##

mkscript() {
cat << EOF
#!/bin/bash

##mplayer自动连播脚本的位置,脚本下载地址:http://forum.ubuntu.org.cn/viewtopic.php?f=73&t=344921
playscript="\$HOME""/.scripts/PlayFLV"
UA="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
format=high

if [ ! -e "\$playscript" ];then
notify-send "播放脚本不存在,请检查playscript的路径是否正确"
exit 0
fi

##处理输入的参数
for parameter in "\$@"; do
case "\$parameter" in
normal|high|super|real)
format="\$parameter"
;;
http*)
current="\$parameter"
;;
*)
other="\$other \$parameter"
;;
esac
done

##判断输入的网址的页面类型
is_album() {
if [[ \`echo \$listpage |sed -n '/show_page/p'\` ]]; then
pagetype="sp"
elif [[ \`echo \$listpage |sed -n '/playlist_show/p'\` ]]; then
pagetype="ps"
elif [[ \`echo \$listpage |sed -n '/v_show/p'\` ]]; then
pagetype=""
elif [[ \`echo \$listpage |sed -n '/user_playlist/p'\` ]]; then
pagetype="up"
else
notify-send "脚本不支持此页面或链接"
exit 0
fi

}

##下载视频所属的专辑页面,并返回专辑页面地址
get_listpage() {
sp=\`cat /tmp/currentpage |sed -n 's/^.*http/http/; s/html.*\$/html/; /show_page/p' |head -1\`
ps=\`cat /tmp/currentpage |sed -n 's/^.*http/http/; s/html.*\$/html/; /playlist_show/p' |head -1\`
up=\`cat /tmp/currentpage |sed -n 's/^.*http/http/; s/html.*\$/html/; /user_playlist/p' |head -1\`

if [ -n "\$sp" ]; then
wget \$sp -q -U "\$UA" -O /tmp/currentpage
listpage="\$sp"
elif [ -n "\$up" ]; then
wget \$up -q -U "\$UA" -O /tmp/currentpage
listpage="\$up"
elif [ -n "\$ps" ]; then
wget \$ps -q -U "\$UA" -O /tmp/currentpage
listpage="\$ps"
else
notify-send "无法获取专辑页面地址,可能该视频没有被收入任何专辑"
exit 0
fi

}

##根据专辑页面类型来生成视频网址列表
get_urllist() {
[ -e /tmp/urllist ] && rm /tmp/urllist
if [[ \$pagetype = "sp" ]]; then
sed -ne 's/^.*http/http/; /zy_bd/,/clear/ s/html.*\$/html/p' /tmp/currentpage > /tmp/urllist
elif [[ \$pagetype = "up" ]]; then
next=Y
while [ -n "\$next" ]; do
grep "PlaylistID" /tmp/currentpage |sed 's/html.*\$/html/; s/^.*http/http/' >> /tmp/urllist
post=\`sed -n '/"current"/=' /tmp/currentpage|head -1\`
post=\`expr \$post + 1\`
next=\`sed -n "\$post p" /tmp/currentpage |sed -n 's/^.*user/user/; s/html.*\$/html/p'\`
if [ -n "\$next" ]; then
wget http://u.youku.com/\$next -q -U "\$UA" -O /tmp/currentpage
fi
done
elif [[ \$pagetype = "ps" ]]; then
next=Y
while [ -n "\$next" ];do
grep "v_link" /tmp/currentpage |sed 's/^.*http/http/; s/html.*\$/html/' >> /tmp/urllist
post=\`sed -n '/"current"/=' /tmp/currentpage|head -1\`
post=\`expr \$post + 1\`
next=\`sed -n "\$post p" /tmp/currentpage |sed -n 's/^.*http/http/; s/html.*\$/html/p'\`
if [ -n "\$next" ]; then
wget \$next -q -U "\$UA" -O /tmp/currentpage
fi
done
else
notify-send "无法获取视频网址列表 "
exit 0
fi

uniq /tmp/urllist > /tmp/urllist.temp
mv /tmp/urllist.temp /tmp/urllist
}

##计算输入的网址在专辑中的序号
get_num() {
id=\`echo "\$current" |sed 's/^.*\///; s/\.html.*\$//'\`
N=\`sed -ne "/\$id/=" /tmp/urllist\`
if [[ -z "\$N" ]];then
N=1
fi

}

##从当前页(或第1集)开始播放
play() {
n=\$(sed -n '\$=' /tmp/urllist)
j=\$N
for (( i=1; i<=n; i++ )); do
if (( i>=j )); then
videopage=\$(sed -n "\$i p" /tmp/urllist)
sh \$playscript \$videopage \$format \$other
fi
done

}



wget \$current -q -U "\$UA" -O /tmp/currentpage
listpage=\$current
is_album
if [[ -n \$pagetype ]]; then
get_urllist
N=1
play
else
get_listpage
is_album
get_urllist
get_num
play
fi
EOF
}

##将脚本写入临时文件里,以便用终端调用
[ -e /tmp/playalbum.sh ] && rm /tmp/playalbum.sh
mkscript > /tmp/playalbum.sh
chmod +x /tmp/playalbum.sh
##调用终端,方便终止脚本
(lxterminal -t "正在播放优酷专辑...不看时请关闭本窗口" --geometry=40x1 -e "/tmp/playalbum.sh $*") &
exit
[/bash]
用法:~/.scripts/PlayAlbum smplayer super 网址 -close-at-end -fullscreen ##用smplayer以超清模式全屏播放优酷专辑,播完一集自动播下一集。


7月30日优化了脚本,参数位置可以任意变换,自动识别画质、网址,可选择是否播放粤语;
可以在参数中选择播放器(默认mplayer,可以用gmplayer,smplay,vlc,其它的自己加上),可添加播放器控制参数;
播放专辑时,推荐添加全屏选项和自动退出选项

8月10日更新:将原来播放专辑的两个脚本合并成一个。其实用了一个很猥琐的方法。
8月16日顺应潮流,添加了搜狐视频支持。其实只需要在get_url函数的最后加上

代码: 全选

	if [[ -n $(grep "<P>" /tmp/dump |sed -n '/搜狐/p') ]]; then
	sed -i 's/^.*&new=/http:\/\/newflv.sohu.ccgslb.net/g' /tmp/url
	fi
就可以让脚本支持搜狐视频了,不用另外写一大堆代码的。[/color] [/size]
上次由 chenjietao 在 2012-09-19 16:51,总共编辑 17 次。
头像
mjp123
帖子: 703
注册时间: 2009-04-09 15:06

Re: 优酷视频mplayer自动连播脚本

#72

帖子 mjp123 » 2012-07-24 15:02

bobby_winon 写了:请问这个脚本能不能用到opera上面,因为我的firefox14.01的右键菜单经常性丢失.请问有没有类似经历的朋友呢?
在opera上更加简单。
直接编辑。
头像
guyanqiu
帖子: 360
注册时间: 2009-05-05 23:42

Re: 优酷视频mplayer自动连播脚本

#73

帖子 guyanqiu » 2012-07-25 20:56

bigsun 写了:结合flashgot也能使用,我将脚本存成了flvcd.sh

我这个怎么没反应啊,使用右键下载此链接,没反应,使用open with也没反应啊,也一点反应也没有啊
哪个兄弟能详细说一下么?
命令行下的反应:

代码: 全选

./vsplay.sh: line 88: notify-send: command not found
VLC media player 1.1.3 The Luggage (revision exported)

 播放列表 (playlist)
      --playlist-autostart, --no-playlist-autostart
                                 自动启动 (默认开启)
      --playlist-skip-ads, --no-playlist-skip-ads
                                 跳过广告 (默认开启)
      --shoutcast-show-adult, --no-shoutcast-show-adult
                                 显示 shoutcast 成人内容 (默认关闭)
用VLC的脚本不行,mpalyer的可以播放,呵呵
但是要复制视频地址,在命令行播放啊
直接右键菜单命令不行啊

右键链接的地址是:http://hz.youku.com/red/click.php?tp=1& ... 2NDMy.html
而视频的地址是:http://v.youku.com/v_show/id_XNDA5OTU2NDMy.html
这个要怎么搞?
对脚本一点也不熟悉啊
-----------------------
在迷茫中追逐,在追逐中迷茫……
-----------------------
头像
chenjietao
帖子: 130
注册时间: 2010-09-21 1:50

Re: 优酷视频mplayer自动连播脚本

#74

帖子 chenjietao » 2012-07-25 21:31

guyanqiu 写了:
bigsun 写了:结合flashgot也能使用,我将脚本存成了flvcd.sh

我这个怎么没反应啊,使用右键下载此链接,没反应,使用open with也没反应啊,也一点反应也没有啊
哪个兄弟能详细说一下么?
命令行下的反应:
./vsplay.sh: line 88: notify-send: command not found 安装libnotify
VLC media player 1.1.3 The Luggage (revision exported)

播放列表 (playlist)
--playlist-autostart, --no-playlist-autostart
自动启动 (默认开启)
--playlist-skip-ads, --no-playlist-skip-ads
跳过广告 (默认开启)
--shoutcast-show-adult, --no-shoutcast-show-adult
显示 shoutcast 成人内容 (默认关闭)
用VLC的脚本不行,mpalyer的可以播放,呵呵 vlc不用加任何参数,只跟列表文件就行了,如果不想要输出OSD标题,加个--no-video-title-show
但是要复制视频地址,在命令行播放啊
直接右键菜单命令不行啊

右键链接的地址是:http://hz.youku.com/red/click.php?tp=1& ... 2NDMy.html
而视频的地址是:http://v.youku.com/v_show/id_XNDA5OTU2NDMy.html
这个要怎么搞? 这个脚本不考虑这种网址,所以没办法
对脚本一点也不熟悉啊
头像
guyanqiu
帖子: 360
注册时间: 2009-05-05 23:42

Re: 优酷视频mplayer自动连播脚本

#75

帖子 guyanqiu » 2012-07-25 21:40

chenjietao 写了:
guyanqiu 写了:
bigsun 写了:结合flashgot也能使用,我将脚本存成了flvcd.sh

我这个怎么没反应啊,使用右键下载此链接,没反应,使用open with也没反应啊,也一点反应也没有啊
哪个兄弟能详细说一下么?
命令行下的反应:
./vsplay.sh: line 88: notify-send: command not found 安装libnotify
VLC media player 1.1.3 The Luggage (revision exported)

播放列表 (playlist)
--playlist-autostart, --no-playlist-autostart
自动启动 (默认开启)
--playlist-skip-ads, --no-playlist-skip-ads
跳过广告 (默认开启)
--shoutcast-show-adult, --no-shoutcast-show-adult
显示 shoutcast 成人内容 (默认关闭)
用VLC的脚本不行,mpalyer的可以播放,呵呵 vlc不用加任何参数,只跟列表文件就行了,如果不想要输出OSD标题,加个--no-video-title-show
但是要复制视频地址,在命令行播放啊
直接右键菜单命令不行啊

右键链接的地址是:http://hz.youku.com/red/click.php?tp=1& ... 2NDMy.html
而视频的地址是:http://v.youku.com/v_show/id_XNDA5OTU2NDMy.html
这个要怎么搞? 这个脚本不考虑这种网址,所以没办法
对脚本一点也不熟悉啊

LibNotify plugin for VLC 装了
Python bindings for libnotify 装了
GObject introspection data for the libnotify library 装了
CLI library for desktop notifications 装了
sends desktop notifications to a notification daemon 装了
-----------------------
在迷茫中追逐,在追逐中迷茫……
-----------------------
回复