优酷视频mplayer自动连播脚本

上网、浏览、聊天、下载等
回复
头像
ctrl-fairy
帖子: 116
注册时间: 2011-04-28 18:05

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

#31

帖子 ctrl-fairy » 2011-10-05 22:28

我使用第一次,成功,然后按ctrl-c终端后就始终挂掉了,显示第四句出错,修改也没用,倒是生成了playlist.title,地址也正确,为什么就不能看啊。 :em20
原来mplayer给我弄挂了……,悲剧。

代码: 全选

linux和windows对我等菜鸟,都是浮云!
头像
angelsky123321
帖子: 485
注册时间: 2011-04-02 19:18
系统: windows8.1
来自: QD

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

#32

帖子 angelsky123321 » 2011-10-05 22:53

好东西啊,避开adobe,, :em11
ACER 4740G
i3 330M
4G DDR3
500G HDD
Windows8.1
yangkyo821
帖子: 52
注册时间: 2011-03-23 23:30

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

#33

帖子 yangkyo821 » 2011-11-05 7:16

非常强大加好用, :em11 顶了

27楼的下载的代码也很好用,不过我改进了一下:
1.绝对路径改为相对路径,可以直接使用不需修改
2.相对于youku之类有超清版的优先下载超清版
3.视频的命令小小改了下:)

代码: 全选

#!/bin/bash
UA="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
wurl=$1
fmt=super
parser="http://www.flvcd.com/parse.php?flag=&format=$fmt&kw=$wurl&sbt=%BF%AA%CA%BCGO%21"
wget $parser -q -U "$UA" -O /tmp/dump
iconv -f gbk -t utf-8 /tmp/dump -o /tmp/dump

get_m3u() {
   line=`cat /tmp/dump |wc -l`
   m3u_start=`grep "m3u" /tmp/dump -n`
   start_line=${m3u_start%%:*}
   m3u_end=`grep "M3U" /tmp/dump -n`
   end_line=${m3u_end%%:*}
   cut_line=$(($line-$end_line+2))

   tac /tmp/dump |sed -e "1,$cut_line d" |tac >/tmp/url

   sed -i "1,$start_line d" /tmp/url

   sed -i '/1/s/<input type="hidden" name="inf" value="//g' /tmp/url
}

get_url() {
   grep "<U>" /tmp/dump > /tmp/url
   sed -i 's/<U>//g' /tmp/url
}

get_title() {
grep "<N>" /tmp/dump >/tmp/title
sed -i 's/<N>//g' /tmp/title

file="`sed -n '1p' /tmp/title` "
file=$(echo $file|sed 's/.....$//')

}

get_playlist() {
   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
   mv /tmp/url /tmp/play.m3u
   sed -i "1i#EXTM3U" /tmp/play.m3u
}

download() {
mkdir -p ~/Downloads/$file
if [ -s /tmp/play.m3u ]; then
   cat /tmp/play.m3u|sed '/http/!d' > /tmp/playlist.title
   rm /tmp/play.m3u
   t=$(cat /tmp/playlist.title)
   j=1
   for i in $t
   #notify-send "playing $file"
    do
     wget -U "$UA"  $i -O ~/Downloads/$file/$file$j.flv
    j=$((j+1))
    done
elif [ -s /tmp/url ]; then
   cat /tmp/url|sed '/http/!d' >/tmp/playlist
   rm /tmp/url
   t=$(cat /tmp/playlist)
   j=1
   for i in $t
   #notify-send "playing $file"
    do
    wget -U "$UA"  $i -O ~/Downloads/$file/$file$j.flv
    j=$((j+1))
    done
    fi

}


if [ "`grep m3u /tmp/dump`" != "" ] ; then

   get_m3u
else
   
   get_url
fi

get_title

u_length=`cat /tmp/url |wc -l`
t_length=`cat /tmp/title |wc -l`
get_playlist
rm /tmp/title /tmp/dump
download
上次由 yangkyo821 在 2011-11-05 9:23,总共编辑 1 次。
yangkyo821
帖子: 52
注册时间: 2011-03-23 23:30

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

#34

帖子 yangkyo821 » 2011-11-05 8:26

:em03 貌似mplayer标题乱码是不太好解决,不过可以把代码中mplayer后面都参数“-title $file”去掉,然后标题就还原为mplayer了,达到掩耳盗铃、眼不见为净的效果,推荐大家试下 :em06
头像
qq420100523
帖子: 1684
注册时间: 2009-07-31 18:56
系统: windows、ubuntu
来自: 广东阳江

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

#35

帖子 qq420100523 » 2011-11-05 8:28

不错,这脚本要顶一下。
头像
widon1104
帖子: 846
注册时间: 2008-07-17 10:55

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

#37

帖子 widon1104 » 2011-11-17 23:47

我把playlist.list改成playlist.m3u

smplayer -playlist /tmp/playlist.m3u -title $file
改成
smplayer /tmp/playlist.m3u -title $file
才能正确显示播放列表。。。。
tracybrser
帖子: 11
注册时间: 2011-08-19 13:54
联系:

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

#38

帖子 tracybrser » 2011-11-18 13:39

的确是不错
杯具的5650
帖子: 20
注册时间: 2012-01-16 10:23

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

#39

帖子 杯具的5650 » 2012-01-16 17:37

挺好用的,但是不能播放土豆的视频,奇怪
头像
rapistor
帖子: 1983
注册时间: 2009-01-19 15:09

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

#40

帖子 rapistor » 2012-02-11 10:47

mark之,以备重装系统时用。
坚守在linux的天堂!
头像
guaicai
帖子: 169
注册时间: 2012-01-29 9:30
系统: Fedora19 Xfce

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

#41

帖子 guaicai » 2012-02-11 12:37

杯具的5650 写了:挺好用的,但是不能播放土豆的视频,奇怪
这个是flvcd.com网站解析视频真实地址错误导致的,没办法改。。
===============================
XP XP XP XP XP XP XP XP XP XP XP XP
??现在的人问问题都是让人来猜吗??
XP XP XP XP XP XP XP XP XP XP XP XP
===============================
头像
到处看看
论坛版主
帖子: 8486
注册时间: 2010-01-17 13:05
系统: ubuntu

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

#42

帖子 到处看看 » 2012-02-11 21:58

感觉用vlc播放效果更好

代码: 全选

#!/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")
wurl=$1
fmt=super
UA="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
parser="http://www.flvcd.com/parse.php?flag=&format=$fmt&kw=$wurl&sbt=%BF%AA%CA%BCGO%21"

get_m3u() {
   line=`cat /tmp/dump |wc -l`
   m3u_start=`grep "m3u" /tmp/dump -n`
   start_line=${m3u_start%%:*}
   m3u_end=`grep "M3U" /tmp/dump -n`
   end_line=${m3u_end%%:*}
cut_line=$(($end_line-2))
sed "$cut_line,$ d" /tmp/dump >/tmp/url

   sed -i "1,$start_line d" /tmp/url

   sed -i '/1/s/<input type="hidden" name="inf" value="//g' /tmp/url
}

get_url() {
   grep "<U>" /tmp/dump > /tmp/url
   sed -i 's/<U>//g' /tmp/url
}

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

get_playlist() {
   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
   mv /tmp/url /tmp/play.m3u
   sed -i "1i#EXTM3U" /tmp/play.m3u
}

play() {
if [ -s /tmp/play.m3u ]; then
   notify-send "playing $file"
   vlc /tmp/play.m3u
elif [ -s /tmp/url ]; then
   vlc -playlist /tmp/play
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 [ "`grep m3u /tmp/dump`" != "" ] ; then

   get_m3u
else
   
   get_url
fi

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 [ $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 or /tmp/playlist.title"
fi




1.jpeg
2.jpeg
头像
rapistor
帖子: 1983
注册时间: 2009-01-19 15:09

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

#43

帖子 rapistor » 2012-02-11 22:55

vlc能拖动进度吗?smplayer可以,但占资源多,gmplayer占资源少,但不能拖动进度。
所以没找到个理想的播放器。
坚守在linux的天堂!
头像
到处看看
论坛版主
帖子: 8486
注册时间: 2010-01-17 13:05
系统: ubuntu

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

#44

帖子 到处看看 » 2012-02-11 23:17

可以啊 还有播放列表呢
头像
rapistor
帖子: 1983
注册时间: 2009-01-19 15:09

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

#45

帖子 rapistor » 2012-02-12 14:35

感谢到处看看 ,用vlc较理想的播放器,资源占用较少,也能显示名称,没乱码。全屏正常,youku视频转换到下一节时还是全屏。
只是我用来看youku和m1905时不可以拖动进度。
smplayer可以拖动进度,但占资源太大,且转换到下一节时即退出全屏。
gmplayer不能拖动,且全屏时不正常。
还有请问vlc缓存在哪设置?
坚守在linux的天堂!
回复