歌词滚动显示LyricBoxen(支持Rhy, Quod, Auda)(v0.1.4)[支持audacious 2.1]

Totem,mplayer,sopcast,realplayer,bmp
回复
头像
phyware
帖子: 157
注册时间: 2009-08-22 8:47

歌词滚动显示LyricBoxen(支持Rhy, Quod, Auda)(v0.1.4)[支持audacious 2.1]

#1

帖子 phyware » 2009-08-23 11:27

LyricBoxen目前适用于rhythmbox, quodlibet, audacious的歌词显示,使用Python,pygtk编写

下载:
LyricBoxen-0.1.4.tar.gz
0.1.4版
(32.28 KiB) 已下载 197 次
0.1.4相对0.1.3的主要变化:
mainly bug fixing;
1,修改dbus相关代码,使与audacious2.1可正确通信
2,修正了install*.sh相关文件的几个错误:~;Desktop dir;已可正确识别桌面所在路径。

0.1.4使用方法:
直接运行lyricboxen即可
如果需要在桌面建立快捷方式,则运行installDesktop.sh
如果需要实现同播放器同启同退:
1,运行installService.sh(作用是:复制LyricBoxen的dbus service文件到/usr/share/dbus-1/services/,所以需要sudo)
2,运行对应播放器的install文件.(例:rhythmbox->installRhyPlugin.py)
audacious的插件暂缺,期盼有哪位能够帮忙写.我C忘的差不多了,而且对audacious插件编写不了解,最近也没时间
3,在播放器中激活相应插件

功能包括:
1,滚动显示歌词(纵向或横向)
2,支持鼠标拖拽歌词,调整播放位置
3,本地未搜索到歌词,则从bzmtv, 我爱记歌词网站, 百度Cache下载歌词
4,随时检测到播放器,即可与其建立连接(通过dbus).LyricBoxen与播放器启动顺序任意

搜索歌词的顺序是(case insensitive):
1,$LyricDir/$artist - $title.lrc
2,$LyricDir/$title.lrc
3,$LyricDir/$artist/$artist - $title.lrc
4,$LyricDir/$artist/$title.lrc
5,bzmtv, 我爱记歌词网站,百度歌词搜索,下载保存本地


有一些配置可修改,目前可通过编辑~/.config/lyricboxen/lyricboxen.conf文件来实现

各选项如下:
LyricDir lrc文件所在文件夹 默认:~/lyric
StayAtTop 歌词窗口总在最上 默认:True
BackgroundColor 窗口背景颜色 默认:dark turquoise
ShowWindow 激活插件时是否显示歌词窗口 默认:True
LineSpacing 歌词行间距 默认:2
Font 歌词字体
CurColor 正在播放行的字体颜色 默认:snow
OtherColor 其他行字体颜色 默认:blue
UImode 垂直,水平滚动 默认:Vertical

需要了解各颜色名称所对应颜色,可运行TestColor.py来查看

在google code整了个页面http://code.google.com/p/lyricboxen/

0.1.3相对0.1.2的主要变化:
1,通过播放器插件与dbus的通信,实现播放器与LyricBoxen的同步自动启动和关闭(感谢 djygdut 的提议)
2,增加改变窗口透明度选项(感谢 lerosua)

0.1.2相对0.1.1版变化:
1,增加从 http://lrc.bzmtv.com/ 下载歌词
2,bug fixed:修复 无法保存窗体关闭时的位置和大小 (感谢 牛奶夹心饼)
3,bug fixed:修复 无法在桌面建立起动器(感谢 牛奶夹心饼)
4,bug fixed:给TestColor.py加上执行属性(感谢 Bill Lee)

0.1.1版相对0.1.0版的主要变化:
1,增加并优先从 我爱记歌词 网站下载歌词,大大扩充了歌词下载库
2,向lerosua学习,把配置文件放在~/.config/lyricboxen下
3,bug fixed:关闭打开的文件,网络连接
4,把源文件整理至各个文件夹
0.1.0版相对0.0.2版的主要变化:
1,改为使用dbus
2,加入对quodlibet,audacious的支持
3,bug fixed:修复有些歌词不能滚动的bug
---------------------------------------------------以下为0.0.*版-------------------------
0.0.*版使用方法:
假设附件LyricBoxen.tar.gz保存到文件夹 ~/Desktop
在终端下:
cd ~/Desktop
mkdir -p ~/.gnome2/rhythmbox/plugins/
tar -xvf LyricBoxen.tar.gz -C ~/.gnome2/rhythmbox/plugins

然后打开rhythmbox,Edit->Plugins,在LyricBoxen上打勾

欢迎拍砖.

Changlog:
1,本地搜索歌词时,不区分区分英文大小写
2,bug fixed:测试$LyricDir 是否存在,不存在则新建
3,bug fixed:百度搜索歌词模块,修正了一个错误,本地模拟测试无问题,希望能够正常工作了
4,时间标签,offset标签计算方法修正
5,bug fixed:修正了百度歌词模块无法正常工作的问题(LiveCD 还挺好用)
6,bug fixed:百度歌词模块采用gbk encoding,万恶的,百度竟然在html文件中写着charset=gb2312
7,加入横向滚动功能;加入记忆窗体位置和大小

TODO:
改用'elapsed-nano-second',替换'elapsed-changed'
该signal在rhythmbox version 0.12.3引入,可以使歌词滚动更加平滑
但由于我的ubuntu上不了网,无法通过网络更新至0.12.3,暂时无法测试改signal

各位如果发现插件不能正常工作,请在终端下运行,然后把输出贴上来,谢谢。
附件
LyricBoxen-0.1.3.tar.gz
0.1.3版
(16.5 KiB) 已下载 178 次
LyricBoxen_0.1.2.tar.gz
0.1.2版
outdated
(14.04 KiB) 已下载 121 次
LyricBoxen_0.1.1.tar.gz
扩充了歌词下载库
outdated
(12.76 KiB) 已下载 74 次
LyricBoxen_0.1.0.tar.gz
自此版之后采用dbus
outdated
(12.36 KiB) 已下载 46 次
LyricBoxen_0.0.2.tar.gz
对0.0.2的一点小改正。
原来Vertical,Horizontal意思和显示的对应可能有些令人不解
outdated
(11.29 KiB) 已下载 52 次
LyricBoxen_0.0.2.tar.gz
outdated
(11.28 KiB) 已下载 34 次
LyricBoxen.tar.gz
outdated
(9.63 KiB) 已下载 53 次
LyricBoxen.tar.gz
outdated
(9.2 KiB) 已下载 35 次
LyricBoxen.tar.gz
outdated
(9.03 KiB) 已下载 36 次
上次由 phyware 在 2009-11-19 23:19,总共编辑 32 次。
Futurama
头像
phyware
帖子: 157
注册时间: 2009-08-22 8:47

Re: 歌词滚动显示插件LyricBoxen发布

#2

帖子 phyware » 2009-08-23 11:32

忘了上图 :em06
附件
用audacious的话,可能比较适合的一种配色方案:<br />BackgroundColor = 'black'<br />CurColor = 'snow'<br />OtherColor = 'slate blue'
用audacious的话,可能比较适合的一种配色方案:
BackgroundColor = 'black'
CurColor = 'snow'
OtherColor = 'slate blue'
调整大小
调整大小
横向滚动
横向滚动
纵向滚动
纵向滚动
上次由 phyware 在 2009-10-01 23:01,总共编辑 3 次。
Futurama
头像
ptpt52
帖子: 717
注册时间: 2008-07-27 8:51
系统: Ubuntu/Windows
来自: 广西玉林|广东深圳
联系:

Re: 歌词滚动显示插件LyricBoxen发布

#3

帖子 ptpt52 » 2009-08-23 12:49

很不错 :em11 :em11
走过去了也便有了路
http://www.ptpt52.com/
头像
Lavande
论坛版主
帖子: 5352
注册时间: 2008-12-21 15:27
来自: TARDIS

Re: 歌词滚动显示插件LyricBoxen发布

#4

帖子 Lavande » 2009-08-23 12:56

不错是不错,可惜我不用rhy……
头像
tangyuancn
帖子: 40
注册时间: 2009-08-01 15:43

Re: 歌词滚动显示插件LyricBoxen发布

#5

帖子 tangyuancn » 2009-08-23 13:43

下来试试看~~~~
lmwlovewy
帖子: 6
注册时间: 2009-06-25 17:36

Re: 歌词滚动显示插件LyricBoxen发布

#6

帖子 lmwlovewy » 2009-08-23 13:45

我提示:
插件错误 无法激活插件
头像
lerosua
论坛版主
帖子: 8455
注册时间: 2007-11-29 9:41
联系:

Re: 歌词滚动显示插件LyricBoxen发布

#7

帖子 lerosua » 2009-08-23 13:49

等这个等了N年,先顶后试再测评。楼主太好了
头像
mickeywaley
帖子: 1427
注册时间: 2009-03-19 9:19
系统: ubuntu
来自: 江苏
联系:

Re: 歌词滚动显示插件LyricBoxen发布

#8

帖子 mickeywaley » 2009-08-23 13:50

试下去 :em11
歌词不出来怎么回事
Screenshot-26.png
头像
lerosua
论坛版主
帖子: 8455
注册时间: 2007-11-29 9:41
联系:

Re: 歌词滚动显示插件LyricBoxen发布

#9

帖子 lerosua » 2009-08-23 14:06

很不错,就是有些歌词不能滚动。

不能上网啊,那真是可惜。提个建议,搜索歌词用千千静听的服务器可能命中高些。
百度提示连不上服务器...
头像
mickeywaley
帖子: 1427
注册时间: 2009-03-19 9:19
系统: ubuntu
来自: 江苏
联系:

Re: 歌词滚动显示插件LyricBoxen发布

#10

帖子 mickeywaley » 2009-08-23 14:11

改成搜索千千静听的服务器歌词怎么改,我的百度没反应

代码: 全选

# -*- coding: UTF-8 -*-
#
# Copyright (C) 2009 - Phyware Chen
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# The Rhythmbox authors hereby grant permission for non-GPL compatible
# GStreamer plugins to be used and distributed together with GStreamer
# and Rhythmbox. This permission is above and beyond the permissions granted
# by the GPL license by which Rhythmbox is covered. If you modify this code
# you may extend this exception to your version of the code, but you are not
# obligated to do so. If you do not wish to do so, delete this exception
# statement from your version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.

import re
import codecs
import sys
import urllib
import os.path

class BaiduLrc:
	def __init__(self, plugin):
		self.plugin = plugin
		self.callback = plugin.lrcGot

		self.pattern = re.compile(u"文件格式" + '.*?LRC/Lyric.*?' + 'a href="(?P<url>.+?)".*?' + u'HTML版')
		self.patDiv = re.compile(r'<div style="position: relative;">')
		self.patBr = re.compile(r'<br>')	#<br>
		self.patDel = re.compile(r'<.*?>')	#pattern to delete
		self.patWhite = re.compile(r'^\s*')	#delete whitespace character at the beginning of a line

		#timeout = 10	#have switched to use rb.Loader().get_url()
		#socket.setdefaulttimeout(timeout)
		#self.user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
		#self.headers = { 'User-Agent' : self.user_agent }
		
	def getLrc(self, title, artist, dir):
		self.dir =dir
		#the name to search is different from the name to store
		songNameList =[artist + ' - ' + title, title]	#the name to store
		if artist == 'unKnown':
			artist = ''
		else:
			artist = ' - ' + artist 
		nameList = [title + artist , title]	#the name to search

		name = None
		canEncoded = False
		index = 0
		for name in nameList:
			try:
				name = name.encode('gbk')
			except UnicodeEncodeError:
				index = index + 1
				continue
			else:
				canEncoded = True
				break

		if canEncoded == False:
			self.plugin.showState('Can\'t encode song information')
			return
		self.songName = songNameList[index]
		data = {}
		data['wd'] = name + ' filetype:lrc'
	
		urlValue = urllib.urlencode(data)
		url = 'http://www.baidu.com/s?' + urlValue

		self.plugin.get_url(url, self.htmlCB)

	def htmlCB(self, data):		#html file from 'http://www.baidu.com/s?'
		if data == None:
			self.plugin.showState('can\'t connect to the Baidu Server')
			return
		self.urlList = self.getUrl(data)
		self.length = len(urlList)
		self.i = 0
		self.lrcCB(None)	#fetch the lrc File
		
	def lrcCB(self, data):
		if data != None:
			songFile = open(os.path.join(self.dir, self.songName + '.lrc'), 'w')
			for line in data:
				if self.patDiv.search(line) != None:
					break
			for line in data:
				line = self.patBr.sub('\n', line)
				line = self.patDel.sub('', line)
				line = self.patWhite.sub('',line)
				if(line == ''):
					continue
				songFile.write(line)
			fileName = songFile.name
			songFile.close()
			if self.callback(fileName) == True:
				return

		if self.i >= self.length:	#all lrc links have been checked
			self.pluging.showState('can\'t download valid lrc file')
			return
		url = self.urlList[self.i]
		self.i = self.i + 1
		self.plugin.get_url(url, self.lrcCB)
			
	def getUrl(self, response):
		url = []
		for line in response:
			line = line.decode('gbk')
			result = self.pattern.findall(line)
			url = url + result
		return url
		

#for testing		
if __name__ == "__main__":
	lrc = BaiduLrc(None)
	lrc.dir = ''
	lrc.songName = 'test'
	file = open('mylove.htm', 'r')
	lrc.lrcCB(file)
#	file = open('search_qinghuaci.htm', 'r')
#	lrcList = lrc.getUrl(file)
#	for item in lrcList:
#		print repr(item)
#		print
头像
phyware
帖子: 157
注册时间: 2009-08-22 8:47

Re: 歌词滚动显示插件LyricBoxen发布

#11

帖子 phyware » 2009-08-24 9:25

lmwlovewy 写了:我提示:
插件错误 无法激活插件
我更新了插件,请重新下载
如果还不能运行,请在终端中输入rhythmbox运行,然后把输出贴上来
Futurama
头像
phyware
帖子: 157
注册时间: 2009-08-22 8:47

Re: 歌词滚动显示插件LyricBoxen发布

#12

帖子 phyware » 2009-08-24 9:27

mickeywaley 写了:试下去 :em11
歌词不出来怎么回事
Screenshot-26.png
如果你本地$LyricDir中没有歌词,因为昨天的版本百度歌词模块不能正常工作,也无法下载到歌词。就会这样。
请重新下载今天更新的版本,帮忙测试
Futurama
头像
lerosua
论坛版主
帖子: 8455
注册时间: 2007-11-29 9:41
联系:

Re: 歌词滚动显示插件LyricBoxen发布(updated:20090824)

#13

帖子 lerosua » 2009-08-24 9:35

好的,回去试试
头像
phyware
帖子: 157
注册时间: 2009-08-22 8:47

Re: 歌词滚动显示插件LyricBoxen发布

#14

帖子 phyware » 2009-08-24 9:42

lerosua 写了:很不错,就是有些歌词不能滚动。

不能上网啊,那真是可惜。提个建议,搜索歌词用千千静听的服务器可能命中高些。
百度提示连不上服务器...
有些歌词不能滚动,是指有些歌词行,还是真个歌词文件都不行。
如果是前者,可能是由于我现在使用的是'elapsed-changed'signal,播放节奏快的歌曲时可能有些歌词行直接就跳过去了。

百度歌词搜索我觉得还好。暂时不会采用千千静听的,毕竟人家没有公开表示开放歌词下载
Futurama
头像
lerosua
论坛版主
帖子: 8455
注册时间: 2007-11-29 9:41
联系:

Re: 歌词滚动显示插件LyricBoxen发布

#15

帖子 lerosua » 2009-08-24 10:43

phyware 写了:
lerosua 写了:很不错,就是有些歌词不能滚动。

不能上网啊,那真是可惜。提个建议,搜索歌词用千千静听的服务器可能命中高些。
百度提示连不上服务器...
有些歌词不能滚动,是指有些歌词行,还是真个歌词文件都不行。
如果是前者,可能是由于我现在使用的是'elapsed-changed'signal,播放节奏快的歌曲时可能有些歌词行直接就跳过去了。

百度歌词搜索我觉得还好。暂时不会采用千千静听的,毕竟人家没有公开表示开放歌词下载
引擎方面问题不大。 那个歌词不能滚动是整个文件。 歌词正常显示了,但一开始就不会动。
回复