diff options
| author | Stefan Pluecken <stefan.pluecken@multimedia-labs.de> | 2006-06-17 20:12:37 +0000 |
|---|---|---|
| committer | Stefan Pluecken <stefan.pluecken@multimedia-labs.de> | 2006-06-17 20:12:37 +0000 |
| commit | f44dfc20f4ed708d67603f767a976c1168393627 (patch) | |
| tree | ed69b038c8c20a4d4a817b2330868319f22301b4 /lib/python | |
| parent | c5d48668f18226413164d84ff808547bb10fcbba (diff) | |
| download | enigma2-f44dfc20f4ed708d67603f767a976c1168393627.tar.gz enigma2-f44dfc20f4ed708d67603f767a976c1168393627.zip | |
save playlist on leaving the media player
Diffstat (limited to 'lib/python')
| -rw-r--r-- | lib/python/Components/Makefile.am | 2 | ||||
| -rw-r--r-- | lib/python/Components/Playlist.py | 52 | ||||
| -rw-r--r-- | lib/python/Components/__init__.py | 2 |
3 files changed, 54 insertions, 2 deletions
diff --git a/lib/python/Components/Makefile.am b/lib/python/Components/Makefile.am index af8d1b9c..560b1ffe 100644 --- a/lib/python/Components/Makefile.am +++ b/lib/python/Components/Makefile.am @@ -16,5 +16,5 @@ install_PYTHON = \ PluginList.py PluginComponent.py RecordingConfig.py About.py UsageConfig.py \ FIFOList.py ServiceEventTracker.py Input.py TimerSanityCheck.py FileList.py \ MultiContent.py MediaPlayer.py TunerInfo.py VideoWindow.py ChoiceList.py \ - Element.py + Element.py Playlist.py diff --git a/lib/python/Components/Playlist.py b/lib/python/Components/Playlist.py new file mode 100644 index 00000000..704b2f84 --- /dev/null +++ b/lib/python/Components/Playlist.py @@ -0,0 +1,52 @@ +from ServiceReference import ServiceReference + +class PlaylistIO: + def __init__(self): + self.list = [] + + # returns a list of services or None if filename is not a valid playlist + def open(self, filename): + return None + + OK = 0 + FILEEXISTS = 1 + WRITEERROR = 2 + ERROR = 3 + UNSUPPORTED_FILES_IN_PLAYLIST = 4 + + def save(self, filename = None): + return self.ERROR + + def clear(self): + del self.list[:] + + def addService(self, service): + self.list.append(service) + + +class PlaylistIOInternal(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 + self.addService(ServiceReference(entry)) + file.close() + return self.list + + def save(self, filename = None): + print "Writing playlist into file", filename + file = open(filename, "w") + for x in self.list: + file.write(str(x) + "\n") + file.close() + + return self.OK
\ No newline at end of file diff --git a/lib/python/Components/__init__.py b/lib/python/Components/__init__.py index 5dd11a82..c303c5a5 100644 --- a/lib/python/Components/__init__.py +++ b/lib/python/Components/__init__.py @@ -7,4 +7,4 @@ __all__ = ["ActionMap", "Button", "Clock", "ConfigList", "EventInfo", "InputDevice", "ServicePosition", "IPAddress", "VariableIP", "IPGateway", "IPNameserver", "Network", "RFmon", "DiskInfo", "NimManager", "TimerEntry", "Lcd", "EpgList" "ScrollLabel", "Timezones", "HelpMenuList", "TimerSanityCheck", - "FileList", "MultiContent", "TunerInfo", "ChoiceList" ] + "FileList", "MultiContent", "TunerInfo", "ChoiceList", "Playlist" ] |
