diff -Nru rhythmbox-plugin-radio-browser-0.5.1/board_handler.py rhythmbox-plugin-radio-browser-0.5.2/board_handler.py --- rhythmbox-plugin-radio-browser-0.5.1/board_handler.py 2015-10-29 23:22:53.000000000 +0000 +++ rhythmbox-plugin-radio-browser-0.5.2/board_handler.py 2016-05-22 21:33:13.000000000 +0000 @@ -25,6 +25,8 @@ from feed import FeedAction from feed import FeedStationAction +from constants import _Const +CONST = _Const() class BoardHandler(xml.sax.handler.ContentHandler): def __init__(self): @@ -49,6 +51,8 @@ self.entry.negativevotes = attributes.get("negativevotes") self.entry.homepage = attributes.get("homepage") self.entry.icon_src = attributes.get("favicon") + self.entry.bitrate = attributes.get("bitrate") + self.entry.server_type = attributes.get("codec") try: self.entry.clickcount = attributes.get("clickcount") except: @@ -118,7 +122,6 @@ self.set_position(Gtk.WindowPosition.CENTER) self.show_all() - class FeedBoard(Feed): def __init__(self, cache_dir, status_change_handler): Feed.__init__(self) @@ -126,7 +129,7 @@ self.handler = BoardHandler() self.cache_dir = cache_dir self.filename = os.path.join(self.cache_dir, "board.xml") - self.uri = "http://www.radio-browser.info/xml.php" + self.uri = CONST.BOARD_ROOT + "xml/stations" self.status_change_handler = status_change_handler def name(self): @@ -156,8 +159,7 @@ "Do you really want to vote for this station? It means, that you like it, and you want more people to know, that this is a good station.")) response = message.run() if response == Gtk.ResponseType.YES: - params = urllib.parse.urlencode({'action': 'vote', 'id': station.id}) - f = urllib.request.urlopen("http://www.radio-browser.info/?%s" % params) + f = urllib.request.urlopen(urllib.request.Request(CONST.BOARD_ROOT + "xml/vote/%d" % station.getId(), headers={'User-Agent': CONST.USER_AGENT})) f.read() source.refill_list() message.destroy() @@ -235,9 +237,9 @@ continue params = urllib.parse.urlencode( - {'action': 'add', 'name': Name, 'url': URL, 'homepage': Homepage, 'favicon': Favicon, 'tags': Tags, + {'name': Name, 'url': URL, 'homepage': Homepage, 'favicon': Favicon, 'tags': Tags, 'language': Language, 'country': Country}) - f = urllib.request.urlopen("http://www.radio-browser.info/?%s" % params) + f = urllib.request.urlopen(urllib.request.Request(CONST.BOARD_ROOT + "add?%s" % params, headers={'User-Agent': CONST.USER_AGENT})) f.read() show_message(_("Station successfully posted")) diff -Nru rhythmbox-plugin-radio-browser-0.5.1/constants.py rhythmbox-plugin-radio-browser-0.5.2/constants.py --- rhythmbox-plugin-radio-browser-0.5.1/constants.py 1970-01-01 00:00:00.000000000 +0000 +++ rhythmbox-plugin-radio-browser-0.5.2/constants.py 2016-05-22 21:33:13.000000000 +0000 @@ -0,0 +1,17 @@ +def constant(f): + def fset(self, value): + raise TypeError + def fget(self): + return f() + return property(fget, fset) + +class _Const(object): + @constant + def VERSION(): + return "3.0" + @constant + def USER_AGENT(): + return "Rhythmbox Radio Browser 3.0" + @constant + def BOARD_ROOT(): + return "http://www.radio-browser.info/webservice/" diff -Nru rhythmbox-plugin-radio-browser-0.5.1/debian/changelog rhythmbox-plugin-radio-browser-0.5.2/debian/changelog --- rhythmbox-plugin-radio-browser-0.5.1/debian/changelog 2015-11-14 20:25:34.000000000 +0000 +++ rhythmbox-plugin-radio-browser-0.5.2/debian/changelog 2016-05-22 21:34:21.000000000 +0000 @@ -1,3 +1,10 @@ +rhythmbox-plugin-radio-browser (0.5.2-1~rb3) trusty; urgency=medium + + * upstream release v0.5.2 + - new board api + + -- fossfreedom Sun, 22 May 2016 22:33:19 +0100 + rhythmbox-plugin-radio-browser (0.5.1-1~rb3ubuntu3) trusty; urgency=medium * more package fixes diff -Nru rhythmbox-plugin-radio-browser-0.5.1/feed.py rhythmbox-plugin-radio-browser-0.5.2/feed.py --- rhythmbox-plugin-radio-browser-0.5.1/feed.py 2015-10-29 23:22:53.000000000 +0000 +++ rhythmbox-plugin-radio-browser-0.5.2/feed.py 2016-05-22 21:33:13.000000000 +0000 @@ -25,6 +25,8 @@ from radio_station import RadioStation +from constants import _Const +CONST = _Const() class FeedAction: def __init__(self, feed, name, func): @@ -80,7 +82,7 @@ pass try: - remotefile = urllib.request.urlopen(self.uri) + remotefile = urllib.request.urlopen(urllib.request.Request(self.uri, headers={'User-Agent': CONST.USER_AGENT})) chunksize = 100 data = "" current = 0 @@ -109,7 +111,7 @@ try: urlparts = urlparse(self.uri) conn = http.client.HTTPConnection(urlparts.netloc) - conn.request("HEAD", urlparts.path) + conn.request("HEAD", urlparts.path, headers={'User-Agent': CONST.USER_AGENT}) res = conn.getresponse() for key, value in res.getheaders(): if key == "last-modified": diff -Nru rhythmbox-plugin-radio-browser-0.5.1/radio_browser_source.py rhythmbox-plugin-radio-browser-0.5.2/radio_browser_source.py --- rhythmbox-plugin-radio-browser-0.5.1/radio_browser_source.py 2015-10-29 23:22:53.000000000 +0000 +++ rhythmbox-plugin-radio-browser-0.5.2/radio_browser_source.py 2016-05-22 21:33:13.000000000 +0000 @@ -50,7 +50,9 @@ from radiotime_handler import FeedRadioTime from radiotime_handler import FeedRadioTimeLocal -BOARD_ROOT = "http://www.radio-browser.info/" +from constants import _Const +CONST = _Const() + RECENTLY_USED_FILENAME = "recently2.bin" BOOKMARKS_FILENAME = "bookmarks2.bin" @@ -307,7 +309,7 @@ # download statistics statisticsStr = "" try: - remotefile = urllib.request.urlopen("http://www.radio-browser.info/topclick.php?limit=10") + remotefile = urllib.request.urlopen(urllib.request.Request(CONST.BOARD_ROOT + "xml/stations/topclick/25", headers={'User-Agent': CONST.USER_AGENT})) statisticsStr = remotefile.read() except Exception as e: @@ -347,10 +349,10 @@ data = self.load_from_file(os.path.join(self.cache_dir, BOOKMARKS_FILENAME)) if data is None: data = {} - + if station.server_name not in data: data[station.server_name] = station - + self.save_to_file(os.path.join(self.cache_dir, BOOKMARKS_FILENAME), data) self.refill_favourites() @@ -865,11 +867,11 @@ def transmit_station(self, station): print("transmit_station") - params = urllib.parse.urlencode( - {'action': 'clicked', 'name': station.server_name, 'url': station.getRealURL(), 'source': station.type}) - f = urllib.request.urlopen(BOARD_ROOT + "?%s" % params) - f.read() - print("Transmit station '" + str(station.server_name) + "' OK") + if station.type == "Board": + """ this gets the decoded url, and also does register the click for statistics """ + f = urllib.request.urlopen(urllib.request.Request(CONST.BOARD_ROOT + "xml/url/"+ station.id, headers={'User-Agent': CONST.USER_AGENT})) + f.read() + print("Transmit station '" + str(station.server_name) + "' OK") """ transmits title information to board """ """def transmit_title(self,title): @@ -1298,9 +1300,10 @@ br = station.bitrate try: br_int = int(br) - br = str((((br_int - 1) / 32) + 1) * 32) if br_int > 512: br = _("Invalid") + if br_int == 0: + br = _("Invalid") except: pass if br not in bitrates: @@ -1442,4 +1445,3 @@ GObject.type_register(RadioBrowserSource) -