该Rhythmbox音乐播放器-女妖-导入脚本将迁移播放次数和收视率。感谢@xiphosurus。但是,要使脚本起作用,您需要告诉它女妖和节奏盒数据库在哪里。
准备脚本
找到您的rhythmbox和banshee db文件。默认位置为:
/home/YOUR_USERNAME/.local/share/rhythmbox/rhythmdb.xml
/home/YOUR_USERNAME/.config/banshee-1/banshee.db
支持他们!我再说一遍。进行备份。
现在,将banshee.db文件复制到rhythmbox-banshee-import脚本所在的文件夹中。然后修改rhythmbox-banshee-import脚本,其中该行显示:
RB_DB = 'rhythmdb.xml'
插入路径/到/您的/rhythmboxdb.xml文件,例如:
RB_DB = '/home/YOUR_USERNAME/.local/share/rhythmbox/rhythmdb.xml'
现在运行脚本,所有播放计数和播放列表都将更新。
故障排除
没有名为lxml的模块
如果遇到错误... ImportError: No module named lxml ...
,则需要安装Python Xml Parsers:
sudo apt-get install python-lxml
没有权限
如果您收到“权限被拒绝”,则是由于您没有足够的权限来访问其他用户目录中的文件,或者是因为该文件不可执行。要使其可执行,请运行:
chmod +x /path/to/your/rhythmbox-banshee-import-script
附录
rhythmbox-banshee-import脚本
#!/usr/bin/python
"""
Copyright (c) 2009 Wolfgang Steitz
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 3 of the License, or
(at your option) any later 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
"""
import sys
import sqlite3
from lxml import etree
RB_DB = 'rhythmdb.xml'
BA_DB = 'banshee.db'
class banshee_db():
def __init__(self, file):
self.con = sqlite3.connect(file)
def get_song_info(self, url):
try:
res = self.con.execute('select Rating, Playcount from CoreTracks where uri = ?', (url,) ).fetchone()
if res is None:
return None, None
else:
return res
except:
return None, None
banshee = banshee_db(BA_DB)
tree = etree.parse(RB_DB)
root = tree.getroot()
for song in root:
if song.get("type") == 'song':
rating = None
playcount = None
for attr in song:
if attr.tag == 'location':
location = attr.text
if attr.tag == 'rating':
rating = attr.text
if attr.tag == 'play-count':
playcount = int(attr.text)
song.remove(attr)
rating_banshee, playcount_banshee = banshee.get_song_info(location)
if rating is None:# noch kein rating in db
if not (rating_banshee == 0 or rating_banshee is None):
rating = rating_banshee
if not (playcount_banshee == 0 or playcount_banshee is None):
if playcount is None:
playcount = playcount_banshee
else:
playcount += playcount_banshee
#insert rating into rb db
if rating is not None:
element = etree.Element('rating')
element.text = str(rating)
song.append( element)
#update playcount
if playcount is not None:
element = etree.Element('play-count')
element.text = str(playcount)
song.append( element)
tree.write(RB_DB)