Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Kaufmann <humitos@gmail.com>2013-01-30 14:04:46 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2013-03-27 13:59:21 (GMT)
commitd5b6b7c802237c9d0abb717bf9026553d018952f (patch)
treec574cbd77a892129a18dcc2ab025401ca73d80a3
parent5d821ef39b755a2713509bb034d5a253725b6ffc (diff)
Fix: 'Add stream from the Journal (datastore)'
We need to save the 'object_id' for those streams that are inside the datastore because the path is removed every time that Sugar is restarted. So, we need the 'object_id' value to get the real path every time that we are about to play the stream. This bug was introduced in 8f2924e8857cdce725b8c2b2cd64dfb618a28210 Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
-rw-r--r--activity.py5
-rw-r--r--playlist.py37
2 files changed, 35 insertions, 7 deletions
diff --git a/activity.py b/activity.py
index efdaa29..79e9912 100644
--- a/activity.py
+++ b/activity.py
@@ -223,6 +223,8 @@ class JukeboxActivity(activity.Activity):
self.playlist_widget._current_playing = index
path = self.playlist_widget._items[index]['path']
+ if self.playlist_widget.is_from_journal(path):
+ path = self.playlist_widget.get_path_from_journal(path)
self.control.check_if_next_prev()
self.player.set_uri(path)
@@ -234,6 +236,9 @@ class JukeboxActivity(activity.Activity):
# self._switch_canvas(show_video=True)
self.playlist_widget._current_playing = index
+ if self.playlist_widget.is_from_journal(path):
+ path = self.playlist_widget.get_path_from_journal(path)
+
self.control.check_if_next_prev()
self.player.set_uri(path)
diff --git a/playlist.py b/playlist.py
index 6c94fb2..f91110d 100644
--- a/playlist.py
+++ b/playlist.py
@@ -125,6 +125,9 @@ class PlayList(Gtk.ScrolledWindow):
self.treemodel.remove(self.treemodel.get_iter(row))
def check_available_media(self, path):
+ if self.is_from_journal(path):
+ path = self.get_path_from_journal(path)
+
if os.path.exists(path):
return True
else:
@@ -148,15 +151,21 @@ class PlayList(Gtk.ScrolledWindow):
self._add_track(file_path, title)
def load_file(self, jobject, title=None):
- logging.debug('#### jobject: %s', type(jobject))
- if isinstance(jobject, datastore.RawObject) or \
- isinstance(jobject, datastore.DSObject):
- file_path = jobject.file_path
+ if isinstance(jobject, datastore.RawObject):
+ logging.debug('Loading a datastore.RawObject')
+ file_path = mime_path = jobject.file_path
+ title = jobject.metadata['title']
+ elif isinstance(jobject, datastore.DSObject):
+ # This file is stored in the Journal (datastore)
+ logging.debug('Loading a datastore.DSObject')
+ file_path = 'journal://' + jobject.object_id
+ mime_path = datastore.get(jobject.object_id).file_path
title = jobject.metadata['title']
else:
- file_path = jobject
+ logging.debug('Loading a %s', type(jobject))
+ file_path = mime_path = jobject
- mimetype = mime.get_for_file('file://' + file_path)
+ mimetype = mime.get_for_file('file://' + mime_path)
logging.info('read_file mime %s', mimetype)
if mimetype == 'audio/x-mpegurl':
# is a M3U playlist:
@@ -187,12 +196,16 @@ class PlayList(Gtk.ScrolledWindow):
def _read_m3u_playlist(self, file_path):
urls = []
title = ''
+
+ if self.is_from_journal(file_path):
+ file_path = self.get_path_from_journal(file_path)
+
for line in open(file_path).readlines():
line = line.strip()
if line != '':
if line.startswith('#EXTINF:'):
# line with data
- # EXTINF: title
+ # EXTINF:title
title = line[len('#EXTINF:'):]
else:
uri = {}
@@ -220,3 +233,13 @@ class PlayList(Gtk.ScrolledWindow):
jobject.file_path = tempfile.mkstemp(dir=temp_path)[1]
return jobject
+
+ def is_from_journal(self, path):
+ if path.startswith('journal://'):
+ return True
+ else:
+ return False
+
+ def get_path_from_journal(self, path):
+ object_id = path[len('journal://'):]
+ return datastore.get(object_id).file_path