From 664e4cc094f4e8c07b3cd2569f1b7627433a507b Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Sun, 5 Feb 2012 13:39:24 +0100 Subject: [PATCH] Python 2.5 compatibility --- modules/gazelle/pages/torrents.py | 7 ++++++- modules/radiofrance/browser.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/gazelle/pages/torrents.py b/modules/gazelle/pages/torrents.py index 329b5c6dee..79b5b7679d 100644 --- a/modules/gazelle/pages/torrents.py +++ b/modules/gazelle/pages/torrents.py @@ -22,6 +22,11 @@ import urlparse from logging import warning, debug +try: + from urlparse import parse_qs +except ImportError: + from cgi import parse_qs + from weboob.tools.misc import html2text, get_bytes_size from weboob.capabilities.torrent import Torrent from weboob.capabilities.base import NotLoaded @@ -84,7 +89,7 @@ def iter_torrents(self): else: title = tds[i].find('a').text url = urlparse.urlparse(tds[i].find('a').attrib['href']) - params = urlparse.parse_qs(url.query) + params = parse_qs(url.query) if 'torrentid' in params: id = '%s.%s' % (params['id'][0], params['torrentid'][0]) else: diff --git a/modules/radiofrance/browser.py b/modules/radiofrance/browser.py index a3f766382a..ee277188f5 100644 --- a/modules/radiofrance/browser.py +++ b/modules/radiofrance/browser.py @@ -31,6 +31,11 @@ except ImportError: import simplejson as json +try: + from urlparse import parse_qs +except ImportError: + from cgi import parse_qs + __all__ = ['RadioFranceBrowser', 'RadioFranceVideo'] @@ -57,7 +62,7 @@ class PlayerPage(BasePage): def get_url(self): radio_id = self.groups[0] player = self.parser.select(self.document.getroot(), '#rfPlayer embed', 1) - urlparams = urlparse.parse_qs(player.attrib['src']) + urlparams = parse_qs(player.attrib['src']) return 'http://www.%s.fr/%s' % (radio_id, urlparams['urlAOD'][0]) -- GitLab