aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components/Playlist.py
diff options
context:
space:
mode:
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>2006-06-18 22:24:10 +0000
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>2006-06-18 22:24:10 +0000
commitef4faf6f9fc8840b36b5f25206fd0722d5e36e85 (patch)
treebe823c3b2ec67b4fbbdc1675d656681d1cb0dd1b /lib/python/Components/Playlist.py
parent821dbb41e381dec1467de6e628e7878f8b37dfcb (diff)
downloadenigma2-ef4faf6f9fc8840b36b5f25206fd0722d5e36e85.tar.gz
enigma2-ef4faf6f9fc8840b36b5f25206fd0722d5e36e85.zip
add support for opening m3u, pls, extended m3u and extended pls playlists
Diffstat (limited to 'lib/python/Components/Playlist.py')
-rw-r--r--lib/python/Components/Playlist.py62
1 files changed, 61 insertions, 1 deletions
diff --git a/lib/python/Components/Playlist.py b/lib/python/Components/Playlist.py
index 704b2f84..22799692 100644
--- a/lib/python/Components/Playlist.py
+++ b/lib/python/Components/Playlist.py
@@ -1,4 +1,5 @@
from ServiceReference import ServiceReference
+import os
class PlaylistIO:
def __init__(self):
@@ -49,4 +50,63 @@ class PlaylistIOInternal(PlaylistIO):
file.write(str(x) + "\n")
file.close()
- return self.OK \ No newline at end of file
+ return self.OK
+
+class PlaylistIOM3U(PlaylistIO):
+ def __init__(self):
+ PlaylistIO.__init__(self)
+
+ def open(self, filename):
+ self.clear()
+ try:
+ file = open(filename, "r")
+ except IOError:
+ return None
+ while True:
+ entry = file.readline().strip()
+ if entry == "":
+ break
+ if entry[0] != "#":
+ # TODO: use e2 facilities to create a service ref from file
+ if entry[0] == "/":
+ self.addService(ServiceReference("4097:0:0:0:0:0:0:0:0:0:" + entry))
+ else:
+ self.addService(ServiceReference("4097:0:0:0:0:0:0:0:0:0:" + os.path.dirname(filename) + "/" + entry))
+ file.close()
+ return self.list
+
+ def save(self, filename = None):
+ return self.ERROR
+
+class PlaylistIOPLS(PlaylistIO):
+ def __init__(self):
+ PlaylistIO.__init__(self)
+
+ def open(self, filename):
+ self.clear()
+ try:
+ file = open(filename, "r")
+ except IOError:
+ return None
+ entry = file.readline().strip()
+ if entry == "[playlist]": # extended pls
+ while True:
+ entry = file.readline().strip()
+ if entry == "":
+ break
+ if entry[0:4] == "File":
+ pos = entry.find('=') + 1
+ newentry = entry[pos:]
+ # TODO: use e2 facilities to create a service ref from file
+ if newentry[0] == "/":
+ self.addService(ServiceReference("4097:0:0:0:0:0:0:0:0:0:" + newentry))
+ else:
+ self.addService(ServiceReference("4097:0:0:0:0:0:0:0:0:0:" + os.path.dirname(filename) + "/" + newentry))
+ else:
+ playlist = PlaylistIOM3U()
+ return playlist.open(filename)
+ file.close()
+ return self.list
+
+ def save(self, filename = None):
+ return self.ERROR \ No newline at end of file