优酷视频mplayer自动连播脚本

上网、浏览、聊天、下载等
回复
lulusee
帖子: 69
注册时间: 2009-05-14 0:51

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

#91

帖子 lulusee » 2012-08-06 12:17

到处看看 写了:
lulusee 写了:不知道chrome浏览器怎么用这个脚本
以前有个扩展就叫chrome下载助手可以关联 不过这个不知道什么原因被从商店里删掉了 你在网上搜下还能找到
十分感谢

找到了, 现在chrome里也能用了 :em06

有需要可以下载附件的扩展.

扩展安装方法:
下载后,直接解压缩
chrome打开至扩展页面,打开开发模式,再点载入正在开发的扩展,选择刚刚解包的文件夹.
附件
extension_5_0_2.zip
(224.66 KiB) 已下载 105 次
lulusee
帖子: 69
注册时间: 2009-05-14 0:51

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

#92

帖子 lulusee » 2012-08-06 12:29

到处看看 写了:
lulusee 写了:不知道chrome浏览器怎么用这个脚本
以前有个扩展就叫chrome下载助手可以关联 不过这个不知道什么原因被从商店里删掉了 你在网上搜下还能找到
你的vlc脚本我这边不能播放, 按87楼的改下就可以了
头像
rapistor
帖子: 1983
注册时间: 2009-01-19 15:09

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

#93

帖子 rapistor » 2012-08-06 12:54

谢谢87楼
坚守在linux的天堂!
funicorn
帖子: 1318
注册时间: 2005-09-13 4:56
系统: Ubuntu Jammy Jellyfi

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

#94

帖子 funicorn » 2012-08-09 1:28

贴个带下载的吧,免得老有人问。注意使用方法有所变化:

vsplay [play|dump|test] [url] [format]

比如

代码: 全选

vsplay dump http://v.youku.com/v_show/id_XNDMyNTIzNDI4.html
然后打开~/Videos/看看

[bash]
#!/bin/bash
# Thanks to http://www.flvcd.com

# usage: vsplay [play|dump|test] [url] [fmt]
# One can [test] this script with certain url to make it work better

# example: vsplay play http://v.youku.com/v_show/id_XMzAwMjI3MDI0.html

# fmt could be: 'normal', 'high', 'super' or 'real'(without the quotation mark),
# denoting 260p, 360p, 4 80p and the original image respectively, yet depending on the stream source.
# Leaving it blank leads to the default video quality provided by flvcd.

wurl=$(urlencode "$2") # target url
fmt=$3 # video format
UA="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" # fake user-agent
parser="http://www.flvcd.com/parse.php?flag=&fo ... CA%BCGO%21" # flvcd default


get_url() {
sed -ne 's/^<U>//p' /tmp/dump >/tmp/url
}

get_title() {
sed -ne 's/^<N>//p' /tmp/dump >/tmp/title
}

make_playlist() {
mkdir -p /tmp/playlists
for ((i=1; i<=$u_length; ++i))
do
ttl=`sed -n "$i p" /tmp/title`
sed -i "$((2*i-1)) i #EXTINF:PART $i in $u_length, $ttl" /tmp/url
done
sed -i "1i#EXTM3U" /tmp/url
mv /tmp/url "/tmp/playlists/${title}.m3u"
}


# script to play the stream
play() {
if [ -s "/tmp/playlists/${title}.m3u" ]; then
notify-send "playing ${title}"
mplayer -user-agent "$UA" -playlist "/tmp/playlists/${title}.m3u" -title "${title}"
elif [ -s /tmp/url ]; then
notify-send "playing ${title}"
mv /tmp/url "/tmp/playlists/${title-dump}.url" # in case title is null.
mplayer -user-agent "$UA" -playlist "/tmp/playlists/${title-dump}.url" -title "${title}"
fi
}

# script to download the stream
dump(){

mkdir -p "$HOME/Videos/${title-dump}"

for ((i=1; i<=$u_length; ++i))
do
uri=$(sed -n "$i p" /tmp/url)
if pgrep notify-osd |grep '[0-9]'>/dev/null
then
killall notify-osd
fi
notify-send "dumping ${title-dump}-$i of $u_length"
mplayer -user-agent "$UA" -dumpstream -dumpfile "$HOME/Videos/${title-dump}/${title-dump}-$i" "$uri"
done
}


# ==============================================
# =========== work starts here =================
# ==============================================
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

get_url

get_title

u_length=`cat /tmp/url |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 [ $t_length -gt 0 ] ; then
title=$(sed -n '1p' /tmp/title |awk -F '[-]' '{print $1}')
fi

case "$1" in

play)

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

if ! play ; then
echo "can not play, check the url's in /tmp/playlists"
exit 1
fi
;;

dump)

if ! dump ; then
echo "dump failed, check the url's in /tmp/url"
exit 1
fi
;;

test)

notify-send "OK" "$u_length url items, $t_length title items."
;;
esac

[/bash]
上次由 funicorn 在 2012-08-09 11:54,总共编辑 1 次。
头像
到处看看
论坛版主
帖子: 8486
注册时间: 2010-01-17 13:05
系统: ubuntu

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

#95

帖子 到处看看 » 2012-08-09 7:46

lulusee 写了:
到处看看 写了:
lulusee 写了:不知道chrome浏览器怎么用这个脚本
以前有个扩展就叫chrome下载助手可以关联 不过这个不知道什么原因被从商店里删掉了 你在网上搜下还能找到
你的vlc脚本我这边不能播放, 按87楼的改下就可以了

试了下确实不能用了 已经改过来了 :em11
头像
missom
帖子: 15
注册时间: 2008-10-14 21:33

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

#96

帖子 missom » 2012-08-10 0:28

chrome安装了下载助手扩展后,要怎么关联脚本呢?
头像
youzhiyili
帖子: 2422
注册时间: 2012-03-22 20:42
系统: ubuntu22.04

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

#97

帖子 youzhiyili » 2012-08-10 3:15

mjp123 写了:
rapistor 写了:
mjp123 写了:
rapistor 写了:今天用openwith插件 一个视频都打不开了,不知道是什么原因 ?
有在用的朋友吗?请帮忙试一下。
前几天火狐13.0版本,openwith应该是5.1.1版本,还正常使用。
今天是14.0版本,openwith更新 到5.2.1,然后就不会正常使用了。
提示地址错误,用flvcd可以解析出来,但是一连串的字母,不是平常的汉字的列表。
不用openwith,用flashgot,感觉比openwith好。
你说的只能下载,不能直接播放啊。 :em06
举个例子,你看下。
谢谢哦,已经搞定。但是现在改用chromium。。 :em03
@自由建客 @qy117121 @枫叶饭团 @cikekid @YeLee @jtshs256 @eexpress @ljj_jjl2008 @zhw2101024 @TeliuTe @月下叹逍遥 @leeaman @懒蜗牛Gentoo @灰色小狼 @photor @adagio @JiangHui @phoenixlzx @oneleaf
lulusee
帖子: 69
注册时间: 2009-05-14 0:51

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

#98

帖子 lulusee » 2012-08-10 11:31

missom 写了:chrome安装了下载助手扩展后,要怎么关联脚本呢?
添加:[path to 脚本]\脚本 $URL
add后 save
fatevictor
帖子: 64
注册时间: 2010-11-17 19:25

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

#99

帖子 fatevictor » 2012-08-10 21:26

vlc+42楼代码可以用
mplayer没反应
是软件源里的mplayer有问题吗
还是用法没对 。。。
开始新一轮的折腾

windows病毒多
ubuntu bug多
orz...
头像
missom
帖子: 15
注册时间: 2008-10-14 21:33

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

#100

帖子 missom » 2012-08-10 21:27

42楼+vlc 可以播了。 :em11
fatevictor
帖子: 64
注册时间: 2010-11-17 19:25

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

#101

帖子 fatevictor » 2012-08-10 22:39

可以用vlc看sohu了,但是很卡。。。。
用mplayer的同学
用mplayer看sohu也卡吗
开始新一轮的折腾

windows病毒多
ubuntu bug多
orz...
k2jiaozi
帖子: 25
注册时间: 2010-05-16 3:52

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

#102

帖子 k2jiaozi » 2012-08-13 20:42

为什么我运行不了呢?

终端里运行
k2jiaozi@NERV-k2jiaozi:~$ ~/vsplay play http://v.youku.com/v_show/id_XNDMzMDkwMDM2.html
/home/k2jiaozi/vsplay: 行 14: urlencode: 未找到命令
/home/k2jiaozi/vsplay: 行 91: notify-send: 未找到命令
k2jiaozi@NERV-k2jiaozi:~$

/home/k2jiaozi/vsplay: 行 91: notify-send: 未找到命令
sudo apt-get install libnotify-bin 装了个软件包解决了 就是右边的消息泡泡
/home/k2jiaozi/vsplay: 行 14: urlencode: 未找到命令
这个是怎么回事啊?? 我用到是11.04 难道版本问题?
头像
chenjietao
帖子: 130
注册时间: 2010-09-21 1:50

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

#103

帖子 chenjietao » 2012-08-15 23:47

发个下载并自动合并视频的脚本:
[bash]#!/bin/bash
#thanks http://www.flvcd.com
#example: downvideo.sh super http://v.youku.com/v_show/id_XNDIzOTMxOTg4.html -r -d ~/Videos/
#Usage: downvideo.sh [FMT] [-d path] [-r] [cantonese|canton|yueyu] url
# [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.
# [-d path] : the files will download to the directory of "path".
# [-r] : remove the videos except final merged video.
# [cantonese|canton|yueyu] : if possible, download the cantonese version of the video.

UA="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
FMT=high
currentdir="$PWD"
targetdir="./"

while [ -n "$1" ]; do
case "$1" in
normal|high|super|real)
FMT=$1
shift 1
;;
http*)
wurl=$1
shift 1
;;
yueyu|canton|cantonese)
cantonese=yes
shift 1
;;
-d)
targetdir="$2"
shift 2
;;
-r)
removable=yes
shift 1
;;
*)
shift 1
;;
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/urls
sed -i "1,$start_line d" /tmp/urls
sed -i 's/^.*http/http/g' /tmp/urls
}

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

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


download() {
for (( line=1; line<=$u_length; line++ ));do
addrs=`sed -n "$line p" /tmp/urls`
partvideo=`sed -n "$line p" /tmp/title`
wget $addrs -U "$UA" -O $partvideo
done
}

merger() {
mencoder $(< /tmp/title) -oac faac -ovc copy -o $outputname
}

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/urls |wc -l`

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

cd $targetdir

if ! download ; then
notify-send "can not download, check the url's in /tmp/urls"
fi

if [[ $u_length != 1 ]]; then
merger
fi

[[ $removable = "yes" ]] && [[ $u_length != 1 ]] && rm $(< /tmp/title)
rm /tmp/title /tmp/dump /tmp/urls

cd $currentdir[/bash]

合并视频需要安装mencoder。
bobby_winon
帖子: 236
注册时间: 2008-01-31 12:39

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

#104

帖子 bobby_winon » 2012-08-20 11:54

lulusee 写了:
到处看看 写了:
lulusee 写了:不知道chrome浏览器怎么用这个脚本
以前有个扩展就叫chrome下载助手可以关联 不过这个不知道什么原因被从商店里删掉了 你在网上搜下还能找到
十分感谢

找到了, 现在chrome里也能用了 :em06

有需要可以下载附件的扩展.

扩展安装方法:
下载后,直接解压缩
chrome打开至扩展页面,打开开发模式,再点载入正在开发的扩展,选择刚刚解包的文件夹.
我刚刚想问chrome下面有没有类似的功能,就看到你的帖子了,谢谢啦。话说firefox右键有问题的朋友,其实应该可以参考一下。
jujiangjun
帖子: 34
注册时间: 2007-08-29 21:12

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

#105

帖子 jujiangjun » 2012-09-03 12:10

好东西 保留后用 谢谢
回复