注明:此贴版权来自如下帖子的楼主:http://forum.ubuntu.org.cn/viewtopic.php?f=73&t=344921
本文仅为整理转载
原理:利用flvcd网站解析视频的功能来实现标题目的
前提:1.ubuntu系统安装了firefox + mplayer
2.firefox安装了open with插件
步骤:用文本编辑器保存下面代码任意取个文件夹名
代码如下
#!/bin/bash #thanks http://www.flvcd.com # 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=$2 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=$(($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`" } 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 mv /tmp/play.m3u /tmp/playlist.title notify-send "playing $file" mplayer -playlist /tmp/playlist.title -title $file elif [ -s /tmp/url ]; then mv /tmp/url /tmp/playlist mplayer -playlist /tmp/playlist 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
然后打开firefox浏览器open with界面
点击添加然后找到你刚才保存的脚本,完成后如下图:
然后如下图就可以直接播放flv视频了 ,支持一切flvcd网站解析的视频网站
上面的图都是借用,下面副我电脑上的效果图(可以看出浏览器的广告还没完毕,这里早就开始播放后面的图是效果对比)
Comments (14)
Comments are closed.