rbmx2m3u: Rhythmbox to m3u playlist conversion script

Tomáš Hnyk <[email protected]>
Newsgroups gmane.comp.gnome.apps.rhythmbox.devel
Message-ID <op.wa8ks0u7trbvx2@steve>
Hello,
it has been couple of years since someone has posted a script to convert  
rhythmbox playlists to m3u[1].

I needed it to automatically copy uptodate playlists to my N900, so I  
created a  new python version that works with current  
~/.local/share/rhythmbox/playlists.xml

In case anyone is interested, the script is on github[2] (it is small so I  
attach it here too).

Regards,
Tomas


[1]  
http://mail.gnome.org/archives/rhythmbox-devel/2005-February/msg00051.html
[2] https://github.com/felagund/rbmx2m3u

_______________________________________________
rhythmbox-devel mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/rhythmbox-devel
rmbx2m3u.py (application/octet-stream, 1.7 KB)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# rbmx2m3u
# Version 1.O
#
# Convert Rhytmbox playlist to m3u
#
# Tomáš Hnyk <tomashnyk2gmail.com>

# Copyright (c) 2012 by Tomáš Hnyk <tomashnyk2gmail.com>
#
# 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, see <http://www.gnu.org/licenses/>.

import xml.etree.cElementTree as et
import urllib
import os

playlistPath = os.path.expanduser('~/.local/share/rhythmbox/playlists.xml')
#rhythmboxLibraryPath = os.path.expanduser('~/Music') 
rhythmboxLibraryPath = '/home/drew/Hudba' 
rhythmboxPlaylistName = ['Oblibene']
n900LibraryPath = '/home/user/MyDocs/Music'

rhythmboxPlaylistFile = open(playlistPath ,"r")
rhythmboxPlaylist = ''.join(rhythmboxPlaylistFile.readlines())
rhythmboxPlaylistFile.close()

tree=et.fromstring(rhythmboxPlaylist) 

for playlist in rhythmboxPlaylistName:
    n900playlistFile = open('' + rhythmboxLibraryPath + '/' + playlist + '.m3u' ,'w+')
    for i in tree.findall('playlist'):
        if i.get('name') == playlist:
            for j in  i.findall('location'):
                n900playlistFile.write(urllib.url2pathname(j.text)[7:].replace(rhythmboxLibraryPath, n900LibraryPath) + '\n')
    n900playlistFile.close()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.