Plugins: rhythm2quod

File rhythm2quod, 1.8 kB (added by drewp, 7 months ago)

standalone convertor of rhythmbox net radio stations to QL

Line 
1 #!/usr/bin/python
2 """
3 Add 'iradio' entries from rhythmdb.xml to quodlibet 'stations' file.
4 This program is very similar to
5 http://www.sacredchao.net/quodlibet/attachment/wiki/Plugins/rhythmdbloader.py
6 except this one converts internet radio stations.
7
8 Quit quodlibet before running this program. It is not a plugin; it
9 simply rewrites your ~/.quodlibet/stations file.
10 """
11
12 """
13 rhythm2quod
14 Copyright (C) 2007 Drew Perttula
15
16 This program is free software: you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation, either version 3 of the License, or
19 (at your option) any later version.
20
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 GNU General Public License for more details.
25
26 You should have received a copy of the GNU General Public License
27 along with this program.  If not, see <http://www.gnu.org/licenses/>.
28 """
29
30 import __builtin__, cPickle, sys
31 from elementtree.ElementTree import ElementTree
32 __builtin__.__dict__["_"] = lambda x: x
33
34 sys.path.append("/usr/share/quodlibet")
35 from browsers.iradio import IRFile
36
37 rb = ElementTree(file=open(".gnome2/rhythmbox/rhythmdb.xml"))
38
39 stations = cPickle.load(open(".quodlibet/stations"))
40 origLength = len(stations)
41 for entry in rb.getroot().findall("entry"):
42     if entry.get('type') == 'iradio':
43         f = IRFile(entry.find('location').text)
44         f['title'] = entry.find('title').text
45         stations.append(f)
46     else:
47         pass#print "skipping unsupported %r entry" % entry.get('type')
48
49 print "added %s entries to quodlibet stations file, which now has %s" % (
50     len(stations) - origLength, len(stations))
51
52 cPickle.dump(stations, open(".quodlibet/stations", "w"), protocol=2)