diff --git a/modules/btmon/browser.py b/modules/btmon/browser.py index f1504aa6..af987ce9 100644 --- a/modules/btmon/browser.py +++ b/modules/btmon/browser.py @@ -43,5 +43,5 @@ class BtmonBrowser(BaseBrowser): def get_torrent(self, id): self.location('http://www.btmon.com/%s.html' % id) - assert self.is_on_page(TorrentPage) - return self.page.get_torrent() + if self.is_on_page(TorrentPage): + return self.page.get_torrent() diff --git a/modules/cuisineaz/browser.py b/modules/cuisineaz/browser.py index fb33b907..929429c1 100644 --- a/modules/cuisineaz/browser.py +++ b/modules/cuisineaz/browser.py @@ -18,7 +18,7 @@ # along with weboob. If not, see . -from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound +from weboob.tools.browser import BaseBrowser from .pages import RecipePage, ResultsPage @@ -43,11 +43,6 @@ class CuisineazBrowser(BaseBrowser): return self.page.iter_recipes() def get_recipe(self, id): - try: - self.location('http://www.cuisineaz.com/recettes/%s.aspx' % id) - except BrowserHTTPNotFound: - return + self.location('http://www.cuisineaz.com/recettes/%s.aspx' % id) if self.is_on_page(RecipePage): return self.page.get_recipe(id) - else: - return diff --git a/modules/imdb/browser.py b/modules/imdb/browser.py index 41175aa3..02905cbd 100644 --- a/modules/imdb/browser.py +++ b/modules/imdb/browser.py @@ -75,7 +75,7 @@ class ImdbBrowser(BaseBrowser): for cat in ['name_popular', 'name_exact', 'name_approx']: if cat in jres: for p in jres[cat]: - person = Person(p['id'], latin2unicode(p['name'])) + person = Person(p['id'], latin2unicode(unicode(p['name']))) person.real_name = NotLoaded person.birth_place = NotLoaded person.birth_date = NotLoaded @@ -218,6 +218,7 @@ dict_hex = {'á': u'á', 'à': u'à', 'À': u'À', 'â': u'â', + 'É': u'É', 'ç': u'ç' } diff --git a/modules/isohunt/browser.py b/modules/isohunt/browser.py index 292a23e8..1ab235d0 100644 --- a/modules/isohunt/browser.py +++ b/modules/isohunt/browser.py @@ -46,5 +46,5 @@ class IsohuntBrowser(BaseBrowser): def get_torrent(self, id): self.location('https://isohunt.com/torrent_details/%s/?tab=summary' % id) - assert self.is_on_page(TorrentPage) - return self.page.get_torrent(id) + if self.is_on_page(TorrentPage): + return self.page.get_torrent(id) diff --git a/modules/marmiton/browser.py b/modules/marmiton/browser.py index d39b9c60..ba234676 100644 --- a/modules/marmiton/browser.py +++ b/modules/marmiton/browser.py @@ -18,7 +18,7 @@ # along with weboob. If not, see . -from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound +from weboob.tools.browser import BaseBrowser from .pages import RecipePage, ResultsPage @@ -42,11 +42,6 @@ class MarmitonBrowser(BaseBrowser): return self.page.iter_recipes() def get_recipe(self, id): - try: - self.location('http://www.marmiton.org/recettes/recette_%s.aspx' % id) - except BrowserHTTPNotFound: - return + self.location('http://www.marmiton.org/recettes/recette_%s.aspx' % id) if self.is_on_page(RecipePage): return self.page.get_recipe(id) - else: - return diff --git a/modules/piratebay/browser.py b/modules/piratebay/browser.py index 8914f992..e621c9a0 100644 --- a/modules/piratebay/browser.py +++ b/modules/piratebay/browser.py @@ -49,9 +49,6 @@ class PiratebayBrowser(BaseBrowser): return self.page.iter_torrents() def get_torrent(self, id): - try: - self.location('https://thepiratebay.se/torrent/%s/' % id) - except: - return None + self.location('https://thepiratebay.se/torrent/%s/' % id) assert self.is_on_page(TorrentPage) return self.page.get_torrent(id) diff --git a/weboob/applications/qcineoob/main_window.py b/weboob/applications/qcineoob/main_window.py index bc311923..ae94e0ac 100644 --- a/weboob/applications/qcineoob/main_window.py +++ b/weboob/applications/qcineoob/main_window.py @@ -28,6 +28,7 @@ from weboob.capabilities.torrent import ICapTorrent from weboob.capabilities.subtitle import ICapSubtitle from weboob.tools.application.qt import QtMainWindow, QtDo from weboob.tools.application.qt.backendcfg import BackendCfg +from weboob.tools.browser import BrowserHTTPNotFound, BrokenPageError from weboob.applications.suboob.suboob import LANGUAGE_CONV from weboob.applications.qcineoob.ui.main_window_ui import Ui_MainWindow @@ -64,7 +65,7 @@ class MainWindow(QtMainWindow): self.ui.backButton.hide() self.connect(self.ui.searchEdit, SIGNAL("returnPressed()"), self.search) - self.connect(self.ui.typeCombo, SIGNAL("returnPressed()"), self.search) + self.connect(self.ui.idEdit, SIGNAL("returnPressed()"), self.searchId) self.connect(self.ui.typeCombo, SIGNAL("currentIndexChanged(QString)"), self.typeComboChanged) self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig) @@ -384,6 +385,37 @@ class MainWindow(QtMainWindow): self.ui.info_content.layout().addWidget(wsubtitle) self.current_info_widget = wsubtitle + def searchId(self): + QApplication.setOverrideCursor(Qt.WaitCursor) + stype = unicode(self.ui.idTypeCombo.currentText()) + title_field = 'name' + if stype == 'movie': + cap = ICapCinema + title_field = 'original_title' + elif stype == 'person': + cap = ICapCinema + elif stype == 'torrent': + cap = ICapTorrent + elif stype == 'subtitle': + cap = ICapSubtitle + id = unicode(self.ui.idEdit.text()) + if '@' in id: + backend_name = id.split('@')[1] + id = id.split('@')[0] + else: + backend_name = None + for backend in self.weboob.iter_backends(): + if backend.has_caps(cap) and ((backend_name and backend.name == backend_name) or not backend_name): + try: + exec('object = backend.get_%s(id)' % (stype)) + except (BrowserHTTPNotFound, BrokenPageError): + object = None + if object: + func_display = 'self.display' + stype[0].upper() + stype[1:] + exec("self.doAction('Details of %s \"%%s\"' %% object.%s, %s, [object, backend])" % + (stype, title_field, func_display)) + QApplication.restoreOverrideCursor() + def closeEvent(self, ev): self.config.set('settings', 'backend', str(self.ui.backendEdit.itemData( self.ui.backendEdit.currentIndex()).toString())) diff --git a/weboob/applications/qcineoob/ui/main_window.ui b/weboob/applications/qcineoob/ui/main_window.ui index dcf213df..18d4375a 100644 --- a/weboob/applications/qcineoob/ui/main_window.ui +++ b/weboob/applications/qcineoob/ui/main_window.ui @@ -179,7 +179,7 @@ 0 0 708 - 292 + 261 @@ -212,6 +212,44 @@ + + + + + + Search by id: + + + + + + + + + + + movie + + + + + person + + + + + torrent + + + + + subtitle + + + + + + diff --git a/weboob/applications/qcookboob/main_window.py b/weboob/applications/qcookboob/main_window.py index 96a92b0c..85d96e1e 100644 --- a/weboob/applications/qcookboob/main_window.py +++ b/weboob/applications/qcookboob/main_window.py @@ -26,6 +26,7 @@ from PyQt4.QtGui import QApplication, QCompleter from weboob.capabilities.recipe import ICapRecipe from weboob.tools.application.qt import QtMainWindow, QtDo from weboob.tools.application.qt.backendcfg import BackendCfg +from weboob.tools.browser import BrowserHTTPNotFound, BrokenPageError from weboob.applications.qcookboob.ui.main_window_ui import Ui_MainWindow @@ -199,14 +200,14 @@ class MainWindow(QtMainWindow): id = id.split('@')[0] else: backend_name = None - fail = True for backend in self.weboob.iter_backends(): - if (backend_name != None and backend.name == backend_name) or backend_name == None: - recipe = backend.get_recipe(id) + if (backend_name and backend.name == backend_name) or not backend_name: + try: + recipe = backend.get_recipe(id) + except (BrowserHTTPNotFound, BrokenPageError): + recipe = None if recipe: - fail = False - self.doAction('Details of recipe "%s"' % - recipe.title, self.displayRecipe, [recipe, backend]) + self.doAction('Details of recipe "%s"' % recipe.title, self.displayRecipe, [recipe, backend]) QApplication.restoreOverrideCursor() def closeEvent(self, ev):