-
Notifications
You must be signed in to change notification settings - Fork 0
/
rmbx2m3u.py
executable file
·48 lines (41 loc) · 1.71 KB
/
rmbx2m3u.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/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()