Support for streaming instead of downloading (bug 93)

With the configuration option "enable_streaming" enabled,
gPodder will now allow you to stream podcasts from the
server instead of downloading it locally first.

Streamed episodes will look as if they have been
downloaded and afterwards deleted. "Played" status is now
display on deleted episodes, too for this reason.
This commit is contained in:
Thomas Perl 2008-11-19 16:25:27 +01:00
parent 085e899e56
commit 168966522e
5 changed files with 33 additions and 12 deletions

View File

@ -121,6 +121,7 @@ gPodderSettings = {
'podcast_list_icon_size': (int, 32),
'cmd_all_downloads_complete': (str, ''),
'cmd_download_complete': (str, ''),
'enable_streaming': (bool, False),
'max_simulaneous_feeds_updating': (int, 3),
'color_updating_feeds': (str, '#7db023'),
'log_sqlite': (bool, False),

View File

@ -977,7 +977,7 @@ class gPodder(GladeWidget):
item.connect('activate', lambda w: self.mark_selected_episodes_new())
menu.append(self.set_finger_friendly(item))
if can_play:
if can_play and not can_download:
menu.append( gtk.SeparatorMenuItem())
item = gtk.ImageMenuItem(_('Save to disk'))
item.set_image(gtk.image_new_from_stock(gtk.STOCK_SAVE_AS, gtk.ICON_SIZE_MENU))
@ -1078,8 +1078,8 @@ class gPodder(GladeWidget):
if len(gl.config.cmd_all_downloads_complete) > 0:
Thread(target=gl.ext_command_thread, args=(self.notification,gl.config.cmd_all_downloads_complete)).start()
def playback_episode(self, episode):
(success, application) = gl.playback_episode(episode)
def playback_episode(self, episode, stream=False):
(success, application) = gl.playback_episode(episode, stream)
if not success:
self.show_message( _('The selected player application cannot be found. Please check your media player settings in the preferences dialog.'), _('Error opening player: %s') % ( saxutils.escape( application), ))
self.updateComboBox(only_selected_channel=True)
@ -1142,8 +1142,8 @@ class gPodder(GladeWidget):
can_download = True
can_download = can_download and not can_cancel
can_play = can_play and not can_cancel and not can_download
can_transfer = can_play and gl.config.device_type != 'none'
can_play = gl.config.enable_streaming or (can_play and not can_cancel and not can_download)
can_transfer = can_play and gl.config.device_type != 'none' and not can_cancel and not can_download
if open_instead_of_play:
self.toolPlay.set_stock_id(gtk.STOCK_OPEN)
@ -1167,9 +1167,14 @@ class gPodder(GladeWidget):
if can_play:
if open_instead_of_play:
self.itemOpenSelected.show_all()
self.itemPlaySelected.hide_all()
else:
self.itemPlaySelected.show_all()
self.itemDeleteSelected.show_all()
self.itemOpenSelected.hide_all()
if not can_download:
self.itemDeleteSelected.show_all()
else:
self.itemDeleteSelected.hide_all()
self.item_toggle_played.show_all()
self.item_toggle_lock.show_all()
self.separator9.show_all()
@ -2331,6 +2336,8 @@ class gPodder(GladeWidget):
if os.path.exists(episode.local_filename()):
episode.channel.addDownloadedItem(episode)
self.playback_episode(episode)
elif gl.config.enable_streaming:
self.playback_episode(episode, stream=True)
elif do_epdialog:
play_callback = lambda: self.playback_episode(episode)
download_callback = lambda: self.download_episode_list([episode])

View File

@ -341,9 +341,15 @@ class gPodderLib(object):
return True
def playback_episode(self, episode):
def playback_episode(self, episode, stream=False):
if stream:
# A streamed file acts as if it has been deleted
episode.state = db.STATE_DELETED
db.save_episode(episode)
filename = episode.url
else:
filename = episode.local_filename()
db.mark_episode(episode.url, is_played=True)
filename = episode.local_filename()
if gpodder.interface == gpodder.MAEMO and not self.config.maemo_allow_custom_player:
# Use the built-in Nokia Mediaplayer here
@ -351,7 +357,9 @@ class gPodderLib(object):
osso_rpc = osso.Rpc(self.osso_c)
service = 'com.nokia.mediaplayer'
path = '/com/nokia/mediaplayer'
osso_rpc.rpc_run(service, path, service, 'mime_open', ('file://'+filename,))
if not '://' in filename:
filename = 'file://' + filename
osso_rpc.rpc_run(service, path, service, 'mime_open', (filename,))
return (True, service)
# Determine the file type and set the player accordingly.

View File

@ -385,7 +385,7 @@ class podcastChannel(object):
else:
status_icon = util.get_tree_icon('unknown', not episode.is_played, episode.is_locked, not episode.file_exists(), self.icon_cache, icon_size)
elif episode.state == db.STATE_DELETED or episode.state == db.STATE_DOWNLOADED:
status_icon = util.get_tree_icon(ICON_DELETED, icon_cache=self.icon_cache, icon_size=icon_size)
status_icon = util.get_tree_icon(ICON_DELETED, not episode.is_played, icon_cache=self.icon_cache, icon_size=icon_size)
else:
log('Warning: Cannot determine status icon.', sender=self)
status_icon = None

View File

@ -592,9 +592,14 @@ def format_desktop_command( command, filename):
See http://standards.freedesktop.org/desktop-entry-spec/1.0/ar01s06.html
"""
if '://' in filename:
filename_url = filename
else:
filename_url = 'file://%s' % filename
items = {
'%U': 'file://%s' % filename,
'%u': 'file://%s' % filename,
'%U': filename_url,
'%u': filename_url,
'%F': filename,
'%f': filename,
}