def on_itemAddVideoChannel_activate(self, widget, *args):
gPodderVideoService().run()
####..... some more code
def add_new_channel( self, result = None, ask_download_new = True):
result = util.normalize_feed_url( result)
if result:
for old_channel in self.channels:
if old_channel.url == result:
self.show_message( _('You have already subscribed to this channel: %s') % ( saxutils.escape( old_channel.title), ), _('Already added'))
log( 'Channel already exists: %s', result)
# Select the existing channel in combo box
for i in range( len( self.channels)):
if self.channels[i] == old_channel:
self.treeChannels.get_selection().select_path( (i,))
return
log( 'Adding new channel: %s', result)
try:
channel = podcastChannel.get_by_url( url = result, force_update = True)
except:
log('Error in podcastChannel.get_by_url(%s)', result, sender=self)
channel = None
if channel:
self.channels.append( channel)
save_channels( self.channels)
# download changed channels
self.update_feed_cache(force_update=False)
(username, password) = util.username_password_from_url( result)
if username and self.show_confirmation( _('You have supplied <b>%s</b> as username and a password for this feed. Would you like to use the same authentication data for downloading episodes?') % ( saxutils.escape( username), ), _('Password authentication')):
channel.username = username
channel.password = password
log('Saving authentication data for episode downloads..', sender = self)
channel.save_settings()
# ask user to download some new episodes
self.treeChannels.get_selection().select_path( (len( self.channels)-1,))
self.active_channel = channel
self.updateTreeView()
if ask_download_new:
self.on_btnDownloadNewer_clicked( None)
else:
title = _('Error adding channel')
message = _('The channel could not be added. Please check the spelling of the URL or try again later.')
self.show_message( message, title)
else:
if result:
title = _('URL scheme not supported')
message = _('gPodder currently only supports URLs starting with <b>http://</b>, <b>feed://</b> or <b>ftp://</b>.')
self.show_message( message, title)
def update_feed_cache_callback(self, progressbar, position, count):
title = self.channels[position].title
progression = _('Updating %s (%d/%d)')%(title, position+1, count)
progressbar.set_text(progression)
if self.tray_icon:
self.tray_icon.set_status(self.tray_icon.STATUS_UPDATING_FEED_CACHE, progression)
if count > 0:
progressbar.set_fraction(float(position)/float(count))
class gPodderVideoService(GladeWidget):
def new(self):
#Just a debug line, when it still was not working :)
print("Thank God this works")
def on_buttonCloseAddVideo_clicked(self, widget):
self.gPodderVideoService.destroy()
def on_buttonAddVideo_clicked(self, widget, *args):
vidservice = self.comboboxVideoService.get_active_text()
querystring = string.replace(self.entrySearchQuery.get_text(), ' ', '+')
if vidservice == "None":
self.notification(_('Please specify a Video Service'), _('No Video Service Specified'))
if vidservice == "Youtube":
url = "http://gdata.youtube.com/feeds/api/videos?vq=" + querystring + "&start-index=20&max-results=10&alt=rss"
#url = self.entryAddChannel.get_text()
#THis is where I have no idea what to do #########################################
gPodderInstance.add_new_channel(url)
self.on_buttonCloseAddVideo_clicked(widget, *args)
def main():
gobject.threads_init()
gtk.window_set_default_icon_name( 'gpodder')
gPodder().run