Exaile 音乐播放器 中文乱码 补丁 (更新到 0.2)

Totem,mplayer,sopcast,realplayer,bmp
头像
huangjiahua
帖子: 3294
注册时间: 2005-03-30 0:27
联系:

Exaile 音乐播放器 中文乱码 补丁 (更新到 0.2)

#1

帖子 huangjiahua » 2007-11-24 17:56

Exaile 是一个很棒的音乐播放器,
有方便的播放列表,自动分类,文件浏览和搜索

图片

不过默认的 Exaile 没有考虑国内 GBK 标签的 MP3,
我给写了个 dirty 的中文补丁,

这个是 0.2 的补丁

https://bugs.launchpad.net/exaile/+bug/223547
http://launchpadlibrarian.net/13981853/ ... pport.diff

代码: 全选

diff -Nur exaile-0.2.11.1.orig/xl/media/mp3.py exaile-0.2.11.1/xl/media/mp3.py
--- exaile-0.2.11.1.orig/xl/media/mp3.py	2007-11-08 00:12:54.000000000 +0800
+++ exaile-0.2.11.1/xl/media/mp3.py	2008-04-28 16:38:15.000000000 +0800
@@ -29,6 +29,21 @@
         "WOAR": "website",
         }
 
+_unicode = unicode
+def unicode(string, encoding='utf8', errors='strict'):
+    """converts ID3 tags from legacy encodings to Unicode
+    """
+    try:
+        string =  string.decode('utf8').encode('iso8859-1')
+    except:
+        return _unicode(string)
+    for enc in ('utf8', 'gb2312', 'big5', 'gb18030', 'big5hkscs', 'euc-jp', 'euc_kr', 'cp1251', 'utf16'):
+        try:
+            return string.decode(enc)
+        except:
+            pass
+    return string
+
 def get_tag(id3, t):
     """
         Reads a specific id3 tag from the file
旧的:

代码: 全选

--- xl/media/mp3.py.orig        2007-11-24 17:07:35.000000000 +0800
+++ xl/media/mp3.py     2007-11-24 17:12:25.000000000 +0800
@@ -19,6 +19,8 @@ def get_tag(id3, t):
     """
     if not id3.has_key(t): return ""
     text = unicode(id3[t])
+    try: text = id3[t].text[0].encode('iso-8859-1').decode('gb18030')
+    except: pass
 
     text = text.replace('\n', ' ').replace('\r', ' ')
     return text


使用补丁::
可以先 apt 或从 www.getdeb.net 安装 Exaile 音乐播放器,
然后在终端里边执行

代码: 全选

 grep -q gb18030 /usr/share/exaile/xl/media/mp3.py || sudo sed -i '/unicode(id3/a\ \ \ \ try: text = id3[t].text[0].encode('iso-8859-1').decode('gb18030')\n\ \ \ \ except: pass'  /usr/share/exaile/xl/media/mp3.py
附件
exaile.png
上次由 huangjiahua 在 2008-04-30 12:44,总共编辑 1 次。
跃过无数的时间断层,只为了在
头像
wyg1258
帖子: 654
注册时间: 2006-09-12 19:44
来自: whu

#2

帖子 wyg1258 » 2007-11-24 18:12

看来 hiweed 要用Exaile 替代 bmp 啰
linux 学习记录 你的 我的 大家的

http://wyg1258.cublog.cn
头像
huangjiahua
帖子: 3294
注册时间: 2005-03-30 0:27
联系:

#3

帖子 huangjiahua » 2007-11-24 19:07

考虑怎么来显示歌词好
跃过无数的时间断层,只为了在
头像
内存不足
论坛版主
帖子: 3277
注册时间: 2005-08-18 18:43
联系:

#4

帖子 内存不足 » 2007-11-24 19:49

为何不用 Quod Libet :P
功能 中文化方面都比这个要好些
໌→ iCookie Gtk Theme
໌→DropPlusBluetheme
กรัก กรัก`菠萝
头像
huangjiahua
帖子: 3294
注册时间: 2005-03-30 0:27
联系:

#5

帖子 huangjiahua » 2007-11-24 20:35

Quod Libet 不方便
跃过无数的时间断层,只为了在
头像
内存不足
论坛版主
帖子: 3277
注册时间: 2005-08-18 18:43
联系:

#6

帖子 内存不足 » 2007-11-24 20:43

.......................... :em39
໌→ iCookie Gtk Theme
໌→DropPlusBluetheme
กรัก กรัก`菠萝
头像
dogfox
论坛版主
帖子: 5311
注册时间: 2006-09-02 14:18
来自: 汉桑城
联系:

#7

帖子 dogfox » 2007-12-25 16:33

如何使用补丁?
全世界linux爱好者联合起来 !
头像
huangjiahua
帖子: 3294
注册时间: 2005-03-30 0:27
联系:

#8

帖子 huangjiahua » 2007-12-25 16:50

dogfox 写了:如何使用补丁?
不懂狗胡的 Gentoo 下怎么搞,
反正就是找他的 xl/media/mp3.py 文件修改
跃过无数的时间断层,只为了在
头像
ciel-bleu
帖子: 173
注册时间: 2007-12-03 16:02

#9

帖子 ciel-bleu » 2007-12-25 18:17

试用了一下下,不错,看来rhythmbox可以下岗了。
头像
dogfox
论坛版主
帖子: 5311
注册时间: 2006-09-02 14:18
来自: 汉桑城
联系:

#10

帖子 dogfox » 2007-12-25 19:43

好不到 text = unicode(id3[t]) 啊?

代码: 全选

import mutagen, mutagen.id3, mutagen.mp3
from xl import xlmisc

TYPE = 'mp3'
IDS = { 
        "TIT2": "title",
        "TIT3": "version",
        "TPE1": "artist",
        "TPE2": "performer",
        "TPE3": "conductor",
        "TPE4": "arranger",
        "TEXT": "lyricist",
        "TCOM": "composer",
        "TCON": "genre",
        "TENC": "encodedby",
        "TALB": "album",
        "TRCK": "tracknumber",
        "TPOS": "discnumber",
        "TSRC": "isrc",
        "TCOP": "copyright",
        "TPUB": "organization",
        "TSST": "part",
        "TOLY": "author",
        "TBPM": "bpm",
        "TDRC": "date",
        "TDOR": "originaldate",
        "TOAL": "originalalbum",
        "TOPE": "originalartist",
        "WOAR": "website",
        }

def get_tag(id3, t):
    """
        Reads a specific id3 tag from the file
    """
    if not id3.has_key(t): return [] 
    field = id3.getall(t)

    ret = []
    if t == 'TDRC' or t == 'TDOR': # values are ID3TimeStamps
        for value in field:
            ret.extend([unicode(x) for x in value.text])
    else:
        for value in field:
            try:
                ret.extend([unicode(x.replace('\n','').replace('\r','')) \
                    for x in value.text])
            except:
                xlmisc.log("Can't parse ID3 field")
                xlmisc.log_exception()
    return ret

def write_tag(tr):
    try:
        id3 = mutagen.id3.ID3(tr.io_loc)
    except mutagen.id3.ID3NoHeaderError:
        id3 = mutagen.id3.ID3()

    for id3name, key in IDS.items():
        id3.delall(id3name)

    for k, v in IDS.iteritems():
        if tr.tags[v]:
            try:
                frame = mutagen.id3.Frames[k](encoding=3,
                    text = tr.tags[v])
                id3.loaded_frame(frame)
            except:
                xlmisc.log_exception()

    id3.save(tr.io_loc)    

def can_change(tag):
    return tag in IDS.values()

def is_multi():
    return True

def fill_tag_from_path(tr):
    try:
        info = mutagen.mp3.MP3(tr.io_loc)
    except:
        xlmisc.log("Couldn't read tags from file: " + tr.loc)
        return

    tr.length = info.info.length
    tr.bitrate = info.info.bitrate

    try:    
        id3 = mutagen.id3.ID3(tr.io_loc)

        for id3_tag, tag in IDS.iteritems():
            tr.tags[tag] = get_tag(id3, id3_tag)
            
    except OverflowError:
        pass
    except mutagen.id3.ID3NoHeaderError:
        pass
    except IOError:
        pass
    except:
        xlmisc.log_exception()

全世界linux爱好者联合起来 !
头像
huangjiahua
帖子: 3294
注册时间: 2005-03-30 0:27
联系:

#11

帖子 huangjiahua » 2007-12-26 15:53

狗胡什么版本的 exaile 啊
跃过无数的时间断层,只为了在
头像
dogfox
论坛版主
帖子: 5311
注册时间: 2006-09-02 14:18
来自: 汉桑城
联系:

#12

帖子 dogfox » 2007-12-26 16:46

huangjiahua 写了:狗胡什么版本的 exaile 啊
另外
getdeb上找不到exaile啊
附件
dogfox-exaile.png
全世界linux爱好者联合起来 !
头像
huangjiahua
帖子: 3294
注册时间: 2005-03-30 0:27
联系:

#13

帖子 huangjiahua » 2007-12-26 16:58

代码: 全选

huahua@huahua:ISO$ acw exaile
Package: exaile
Priority: optional
Section: universe/sound
Installed-Size: 2012
Maintainer: Ubuntu MOTU Developers <ubuntu-motu@lists.ubuntu.com>
Original-Maintainer: François Févotte <francois.fevotte@ensta.org>
Architecture: i386
Version: 0.2.10+debian-1.1ubuntu2
Depends: python (>= 2.5), python (<< 2.6), python-support (>= 0.2), libatk1.0-0 (>= 1.13.2), libc6 (>= 2.6-1), libcairo2 (>= 1.4.0), libfontconfig1 (>= 2.4.0), libglib2.0-0 (>= 2.14.0), libgtk2.0-0 (>= 2.12.0), libpango1.0-0 (>= 1.18.2), libx11-6, libxcomposite1 (>= 1:0.3-1), libxcursor1 (>> 1.1.2), libxdamage1 (>= 1:1.1), libxext6, libxfixes3 (>= 1:4.0.1), libxi6, libxinerama1, libxrandr2 (>= 2:1.2.0), libxrender1, python-pysqlite2, libgstreamer0.10-0, gstreamer0.10-plugins-base, gstreamer0.10-plugins-good, python-gst0.10, gstreamer0.10-alsa | gstreamer0.10-esd, python-gtk2, python-glade2, python-dbus, python-pyvorbis, python-mutagen, python-elementtree
Recommends: gstreamer0.10-plugins-ugly, python-gnome2-extras, python-cddb, streamripper, python-gpod, python-gamin, python-notify, python-gtkhtml2
Filename: pool/universe/e/exaile/exaile_0.2.10+debian-1.1ubuntu2_i386.deb
Size: 448474
MD5sum: ff0af5cf0ab534b19f0bddf310539f14
SHA1: 73232288f8d815b8411f296f8958f826fdb813a1
SHA256: af0f1153d243ecab0608892457c5fff702df75d05d5d559a8522c750cb76518b
Description: flexible audio player, similar to Amarok, but written in GTK+
 Exaile is a media player aiming to be similar to KDE's Amarok, but for
 GTK+. It incorporates many of the cool things from Amarok (and other
 media players) like automatic fetching of album art, handling of large
 libraries, lyrics fetching, artist/album information via the wikipedia,
 last.fm support, optional iPod support (assuming you have python-gpod
 installed).
 .
 In addition, Exaile also includes a built-in shoutcast directory
 browser, tabbed playlists (so you can have more than one playlist open
 at a time), blacklisting of tracks (so they don't get scanned into your
 library), downloading of guitar tablature from fretplay.com, and
 submitting played tracks on your iPod to last.fm.
 .
  Homepage: http://www.exaile.org/
Bugs: mailto:ubuntu-users@lists.ubuntu.com
Origin: Ubuntu
跃过无数的时间断层,只为了在
头像
内存不足
论坛版主
帖子: 3277
注册时间: 2005-08-18 18:43
联系:

#14

帖子 内存不足 » 2007-12-26 17:08

专辑封面都是乱下载的....... haha
໌→ iCookie Gtk Theme
໌→DropPlusBluetheme
กรัก กรัก`菠萝
头像
dogfox
论坛版主
帖子: 5311
注册时间: 2006-09-02 14:18
来自: 汉桑城
联系:

#15

帖子 dogfox » 2007-12-26 17:31

代码: 全选

truth@dogfox:~$ exaile --version
0.2.11
Exaile version: 0.2.11
全世界linux爱好者联合起来 !
回复