O script rhythmbox-banshee-import migrará contagens e classificações de jogos . Graças a @xiphosurus. No entanto, para que o script funcione, é necessário informar onde estão os bancos de dados banshee e rhythmbox.
Preparando o script
Localize os arquivos rhythmbox e banshee db. Os locais padrão serão:
/home/YOUR_USERNAME/.local/share/rhythmbox/rhythmdb.xml
/home/YOUR_USERNAME/.config/banshee-1/banshee.db
Faça backup deles! Eu direi isso de novo. Faça um backup.
Agora copie o arquivo banshee.db na mesma pasta que o script rhythmbox-banshee-import. E então modifique o script rhythmbox-banshee-import em que a linha diz:
RB_DB = 'rhythmdb.xml'
insira o arquivo path / to / your / rhythmboxdb.xml, por exemplo:
RB_DB = '/home/YOUR_USERNAME/.local/share/rhythmbox/rhythmdb.xml'
Agora execute o script e todas as contagens e listas de reprodução serão atualizadas.
Solução de problemas
Nenhum módulo chamado lxml
Se você receber um erro, ... ImportError: No module named lxml ...
precisará instalar o Python Xml Parsers :
sudo apt-get install python-lxml
Permissão negada
Se você receber "Permissão negada", é porque você não tem permissões suficientes para acessar o arquivo no diretório de outros usuários ou porque o arquivo não é executável. Para torná-lo executável, execute:
chmod +x /path/to/your/rhythmbox-banshee-import-script
Apêndice
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)