Make the my.g.o service URL configurable

This commit is contained in:
Thomas Perl 2009-10-20 22:51:08 +02:00
parent 555070c1e7
commit 5526d3691a
3 changed files with 11 additions and 8 deletions

View file

@ -225,6 +225,8 @@ gPodderSettings = {
'my_gpodder_autoupload': (bool, False,
("Upload the user's podcast list to the gPodder web services when "
"gPodder is closed.")),
'my_gpodder_service': (str, 'http://my.gpodder.org',
('The base URL of the my.gpodder.org service.')),
# Paned position
'paned_position': ( int, 200,

View file

@ -2573,7 +2573,8 @@ class gPodder(BuilderWidget, dbus.service.Object):
def on_download_from_mygpo(self, widget=None):
if self.require_my_gpodder_authentication():
client = my.MygPodderClient(self.config.my_gpodder_username, self.config.my_gpodder_password)
client = my.MygPodderClient(self.config.my_gpodder_service, \
self.config.my_gpodder_username, self.config.my_gpodder_password)
opml_data = client.download_subscriptions()
if len(opml_data) > 0:
fp = open(gpodder.subscription_file, 'w')
@ -2603,7 +2604,8 @@ class gPodder(BuilderWidget, dbus.service.Object):
def on_upload_to_mygpo(self, widget):
if self.require_my_gpodder_authentication():
client = my.MygPodderClient(self.config.my_gpodder_username, self.config.my_gpodder_password)
client = my.MygPodderClient(self.config.my_gpodder_service, \
self.config.my_gpodder_username, self.config.my_gpodder_password)
self.save_channels_opml()
success, messages = client.upload_subscriptions(gpodder.subscription_file)
if widget is not None:

View file

@ -84,14 +84,13 @@ def build_request(theurl, fields, files, txheaders=None):
class MygPodderClient(object):
WEBSERVICE = 'http://my.gpodder.org'
def __init__(self, username, password):
def __init__(self, service_uri, username, password):
self.service_uri = service_uri
self.username = username
self.password = password
def download_subscriptions(self):
theurl = self.WEBSERVICE+"/getlist"
theurl = self.service_uri+"/getlist"
args = {'username': self.username, 'password': self.password}
args = '&'.join(('%s=%s' % a for a in args.items()))
url = theurl + '?' + args
@ -99,7 +98,7 @@ class MygPodderClient(object):
return opml_data
def upload_subscriptions(self, filename):
theurl = self.WEBSERVICE+'/upload'
theurl = self.service_uri+'/upload'
action = 'update-subscriptions'
fields = {'username': self.username, 'password': self.password, 'action': 'update-subscriptions', 'protocol': '0'}
opml_file = ('opml', 'subscriptions.opml', open(filename).read())
@ -110,7 +109,7 @@ class MygPodderClient(object):
success = False
if '@GOTOMYGPODDER' in result:
webbrowser.open(self.WEBSERVICE, new=1)
webbrowser.open(self.service_uri, new=1)
messages.append(_('Please have a look at the website for more information.'))
if '@SUCCESS' in result: