[qcineoob] search by id
[qcookboob] undo previous modif on backends, exceptions are handled by app
This commit is contained in:
parent
95953d3217
commit
5e247db743
9 changed files with 90 additions and 31 deletions
|
|
@ -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()))
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>708</width>
|
||||
<height>292</height>
|
||||
<height>261</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2"/>
|
||||
|
|
@ -212,6 +212,44 @@
|
|||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Search by id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="idEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="idTypeCombo">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>movie</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>person</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>torrent</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>subtitle</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue