[qcineoob] thumbnail for person and movie
This commit is contained in:
parent
7a917e879c
commit
d874a3087a
8 changed files with 41 additions and 144 deletions
|
|
@ -73,7 +73,7 @@ class ImdbBackend(BaseBackend, ICapCinema):
|
||||||
if 'real_name' in fields or 'birth_place' in fields\
|
if 'real_name' in fields or 'birth_place' in fields\
|
||||||
or 'death_date' in fields or 'nationality' in fields\
|
or 'death_date' in fields or 'nationality' in fields\
|
||||||
or 'short_biography' in fields or 'roles' in fields\
|
or 'short_biography' in fields or 'roles' in fields\
|
||||||
or 'birth_date' in fields\
|
or 'birth_date' in fields or 'thumbnail_url' in fields\
|
||||||
or 'gender' in fields or fields == None:
|
or 'gender' in fields or fields == None:
|
||||||
per = self.get_person(person.id)
|
per = self.get_person(person.id)
|
||||||
person.real_name = per.real_name
|
person.real_name = per.real_name
|
||||||
|
|
@ -85,6 +85,7 @@ class ImdbBackend(BaseBackend, ICapCinema):
|
||||||
person.short_biography = per.short_biography
|
person.short_biography = per.short_biography
|
||||||
person.short_description = per.short_description
|
person.short_description = per.short_description
|
||||||
person.roles = per.roles
|
person.roles = per.roles
|
||||||
|
person.thumbnail_url = per.thumbnail_url
|
||||||
|
|
||||||
if 'biography' in fields:
|
if 'biography' in fields:
|
||||||
person.biography = self.get_person_biography(person.id)
|
person.biography = self.get_person_biography(person.id)
|
||||||
|
|
@ -94,7 +95,8 @@ class ImdbBackend(BaseBackend, ICapCinema):
|
||||||
def fill_movie(self, movie, fields):
|
def fill_movie(self, movie, fields):
|
||||||
if 'other_titles' in fields or 'release_date' in fields\
|
if 'other_titles' in fields or 'release_date' in fields\
|
||||||
or 'duration' in fields or 'country' in fields\
|
or 'duration' in fields or 'country' in fields\
|
||||||
or 'roles' in fields or 'note' in fields:
|
or 'roles' in fields or 'note' in fields\
|
||||||
|
or 'thumbnail_url' in fields:
|
||||||
mov = self.get_movie(movie.id)
|
mov = self.get_movie(movie.id)
|
||||||
movie.other_titles = mov.other_titles
|
movie.other_titles = mov.other_titles
|
||||||
movie.release_date = mov.release_date
|
movie.release_date = mov.release_date
|
||||||
|
|
@ -104,6 +106,7 @@ class ImdbBackend(BaseBackend, ICapCinema):
|
||||||
movie.note = mov.note
|
movie.note = mov.note
|
||||||
movie.roles = mov.roles
|
movie.roles = mov.roles
|
||||||
movie.short_description= mov.short_description
|
movie.short_description= mov.short_description
|
||||||
|
movie.thumbnail_url = mov.thumbnail_url
|
||||||
|
|
||||||
if 'all_release_dates' in fields:
|
if 'all_release_dates' in fields:
|
||||||
movie.all_release_dates = self.get_movie_releases(movie.id)
|
movie.all_release_dates = self.get_movie_releases(movie.id)
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ class ImdbBrowser(BaseBrowser):
|
||||||
movie.note = NotLoaded
|
movie.note = NotLoaded
|
||||||
movie.roles = NotLoaded
|
movie.roles = NotLoaded
|
||||||
movie.all_release_dates= NotLoaded
|
movie.all_release_dates= NotLoaded
|
||||||
|
movie.thumbnail_url = NotLoaded
|
||||||
yield movie
|
yield movie
|
||||||
|
|
||||||
def iter_persons(self, pattern):
|
def iter_persons(self, pattern):
|
||||||
|
|
@ -82,6 +83,7 @@ class ImdbBrowser(BaseBrowser):
|
||||||
person.short_biography= NotLoaded
|
person.short_biography= NotLoaded
|
||||||
person.short_description= latin2unicode(p['description'])
|
person.short_description= latin2unicode(p['description'])
|
||||||
person.roles = NotLoaded
|
person.roles = NotLoaded
|
||||||
|
person.thumbnail_url = NotLoaded
|
||||||
yield person
|
yield person
|
||||||
|
|
||||||
def get_movie(self, id):
|
def get_movie(self, id):
|
||||||
|
|
@ -209,6 +211,9 @@ dict_hex = {'á': u'á',
|
||||||
'ü': u'ü',
|
'ü': u'ü',
|
||||||
'&': u'&',
|
'&': u'&',
|
||||||
''': u"'",
|
''': u"'",
|
||||||
|
'à': u'à',
|
||||||
|
'À': u'À',
|
||||||
|
'â': u'â',
|
||||||
'ç': u'ç'
|
'ç': u'ç'
|
||||||
}
|
}
|
||||||
def latin2unicode(word):
|
def latin2unicode(word):
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,7 @@ class MovieCrewPage(BasePage):
|
||||||
person.nationality = NotLoaded
|
person.nationality = NotLoaded
|
||||||
person.short_biography= NotLoaded
|
person.short_biography= NotLoaded
|
||||||
person.roles = NotLoaded
|
person.roles = NotLoaded
|
||||||
|
person.thumbnail_url = NotLoaded
|
||||||
yield person
|
yield person
|
||||||
|
|
||||||
for gloss_link in self.parser.select(self.document.getroot(),'table[cellspacing=1] h5 a'):
|
for gloss_link in self.parser.select(self.document.getroot(),'table[cellspacing=1] h5 a'):
|
||||||
|
|
@ -135,6 +136,7 @@ class PersonPage(BasePage):
|
||||||
death_date = NotAvailable
|
death_date = NotAvailable
|
||||||
real_name = NotAvailable
|
real_name = NotAvailable
|
||||||
gender = NotAvailable
|
gender = NotAvailable
|
||||||
|
thumbnail_url = NotAvailable
|
||||||
roles = {}
|
roles = {}
|
||||||
nationality = NotAvailable
|
nationality = NotAvailable
|
||||||
td_overview = self.parser.select(self.document.getroot(),'td#overview-top',1)
|
td_overview = self.parser.select(self.document.getroot(),'td#overview-top',1)
|
||||||
|
|
@ -171,6 +173,10 @@ class PersonPage(BasePage):
|
||||||
dtime.append('1')
|
dtime.append('1')
|
||||||
dtime.append('1')
|
dtime.append('1')
|
||||||
death_date = datetime(int(dtime[0]),int(dtime[1]),int(dtime[2]))
|
death_date = datetime(int(dtime[0]),int(dtime[1]),int(dtime[2]))
|
||||||
|
img_thumbnail = self.parser.select(self.document.getroot(),'td#img_primary img')
|
||||||
|
if len(img_thumbnail) > 0:
|
||||||
|
thumbnail_url = unicode(img_thumbnail[0].attrib.get('src',''))
|
||||||
|
|
||||||
# go to the filmography page
|
# go to the filmography page
|
||||||
self.browser.location('http://www.imdb.com/name/%s/filmotype'%id)
|
self.browser.location('http://www.imdb.com/name/%s/filmotype'%id)
|
||||||
assert self.browser.is_on_page(FilmographyPage)
|
assert self.browser.is_on_page(FilmographyPage)
|
||||||
|
|
@ -186,6 +192,7 @@ class PersonPage(BasePage):
|
||||||
person.short_biography = short_biography
|
person.short_biography = short_biography
|
||||||
person.short_description = short_description
|
person.short_description = short_description
|
||||||
person.roles = roles
|
person.roles = roles
|
||||||
|
person.thumbnail_url = thumbnail_url
|
||||||
return person
|
return person
|
||||||
|
|
||||||
class FilmographyPage(BasePage):
|
class FilmographyPage(BasePage):
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,13 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import urllib
|
||||||
|
|
||||||
from PyQt4.QtGui import QFrame, QImage, QPixmap
|
from PyQt4.QtGui import QFrame, QImage, QPixmap
|
||||||
|
|
||||||
from weboob.tools.application.qt import QtDo
|
from weboob.tools.application.qt import QtDo
|
||||||
from weboob.applications.qcineoob.ui.minimovie_ui import Ui_MiniMovie
|
from weboob.applications.qcineoob.ui.minimovie_ui import Ui_MiniMovie
|
||||||
|
from weboob.capabilities.base import NotAvailable, NotLoaded
|
||||||
|
|
||||||
class MiniMovie(QFrame):
|
class MiniMovie(QFrame):
|
||||||
def __init__(self, weboob, backend, movie, parent=None):
|
def __init__(self, weboob, backend, movie, parent=None):
|
||||||
|
|
@ -34,17 +36,16 @@ class MiniMovie(QFrame):
|
||||||
self.backend = backend
|
self.backend = backend
|
||||||
self.movie = movie
|
self.movie = movie
|
||||||
self.ui.titleLabel.setText(movie.original_title)
|
self.ui.titleLabel.setText(movie.original_title)
|
||||||
|
self.ui.shortDescLabel.setText(movie.short_description)
|
||||||
self.ui.backendLabel.setText(backend.name)
|
self.ui.backendLabel.setText(backend.name)
|
||||||
|
|
||||||
#self.process_thumbnail = QtDo(self.weboob, self.gotThumbnail)
|
self.process_thumbnail = QtDo(self.weboob, self.gotThumbnail)
|
||||||
#self.process_thumbnail.do('fillobj', self.movie, ['thumbnail_url'], backends=backend)
|
self.process_thumbnail.do('fillobj', self.movie, ['thumbnail_url'], backends=backend)
|
||||||
|
|
||||||
def gotThumbnail(self, backend, movie):
|
def gotThumbnail(self, backend, movie):
|
||||||
if not backend:
|
if self.movie.thumbnail_url != NotAvailable:
|
||||||
return
|
data = urllib.urlopen(self.movie.thumbnail_url).read()
|
||||||
|
img = QImage.fromData(data)
|
||||||
if movie.thumbnail_url:
|
|
||||||
img = QImage.fromData(movie.thumbnail.data)
|
|
||||||
self.ui.imageLabel.setPixmap(QPixmap.fromImage(img))
|
self.ui.imageLabel.setPixmap(QPixmap.fromImage(img))
|
||||||
|
|
||||||
def enterEvent(self, event):
|
def enterEvent(self, event):
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,13 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import urllib
|
||||||
|
|
||||||
from PyQt4.QtGui import QFrame, QImage, QPixmap
|
from PyQt4.QtGui import QFrame, QImage, QPixmap
|
||||||
|
|
||||||
from weboob.tools.application.qt import QtDo
|
from weboob.tools.application.qt import QtDo
|
||||||
from weboob.applications.qcineoob.ui.miniperson_ui import Ui_MiniPerson
|
from weboob.applications.qcineoob.ui.miniperson_ui import Ui_MiniPerson
|
||||||
|
from weboob.capabilities.base import NotAvailable, NotLoaded
|
||||||
|
|
||||||
class MiniPerson(QFrame):
|
class MiniPerson(QFrame):
|
||||||
def __init__(self, weboob, backend, person, parent=None):
|
def __init__(self, weboob, backend, person, parent=None):
|
||||||
|
|
@ -34,18 +36,16 @@ class MiniPerson(QFrame):
|
||||||
self.backend = backend
|
self.backend = backend
|
||||||
self.person = person
|
self.person = person
|
||||||
self.ui.nameLabel.setText(person.name)
|
self.ui.nameLabel.setText(person.name)
|
||||||
#self.ui.birthdateLabel.setText(person.birth_date)
|
self.ui.shortDescLabel.setText(person.short_description)
|
||||||
self.ui.backendLabel.setText(backend.name)
|
self.ui.backendLabel.setText(backend.name)
|
||||||
|
|
||||||
#self.process_thumbnail = QtDo(self.weboob, self.gotThumbnail)
|
self.process_thumbnail = QtDo(self.weboob, self.gotThumbnail)
|
||||||
#self.process_thumbnail.do('fillobj', self.person, ['thumbnail_url'], backends=backend)
|
self.process_thumbnail.do('fillobj', self.person, ['thumbnail_url'], backends=backend)
|
||||||
|
|
||||||
def gotThumbnail(self, backend, person):
|
def gotThumbnail(self, backend, person):
|
||||||
if not backend:
|
if self.person.thumbnail_url != NotAvailable:
|
||||||
return
|
data = urllib.urlopen(self.person.thumbnail_url).read()
|
||||||
|
img = QImage.fromData(data)
|
||||||
if person.thumbnail_url:
|
|
||||||
img = QImage.fromData(person.thumbnail.data)
|
|
||||||
self.ui.imageLabel.setPixmap(QPixmap.fromImage(img))
|
self.ui.imageLabel.setPixmap(QPixmap.fromImage(img))
|
||||||
|
|
||||||
def enterEvent(self, event):
|
def enterEvent(self, event):
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>464</width>
|
<width>464</width>
|
||||||
<height>132</height>
|
<height>136</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
|
@ -89,78 +89,18 @@
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Duration</string>
|
<string>Short description:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLabel" name="durationLabel">
|
<widget class="QLabel" name="shortDescLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>TextLabel</string>
|
<string>TextLabel</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_4">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Author</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QLabel" name="authorLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>TextLabel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Date</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QLabel" name="dateLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>TextLabel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Rating</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="1">
|
|
||||||
<widget class="QLabel" name="ratingLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>TextLabel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="0">
|
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
|
|
@ -173,7 +113,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLabel" name="backendLabel">
|
<widget class="QLabel" name="backendLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>TextLabel</string>
|
<string>TextLabel</string>
|
||||||
|
|
|
||||||
|
|
@ -89,78 +89,18 @@
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Duration</string>
|
<string>Short description</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLabel" name="durationLabel">
|
<widget class="QLabel" name="shortDescLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>TextLabel</string>
|
<string>TextLabel</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_4">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Author</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QLabel" name="authorLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>TextLabel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Date</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QLabel" name="dateLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>TextLabel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Rating</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="1">
|
|
||||||
<widget class="QLabel" name="ratingLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>TextLabel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="0">
|
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
|
|
@ -173,7 +113,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLabel" name="backendLabel">
|
<widget class="QLabel" name="backendLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>TextLabel</string>
|
<string>TextLabel</string>
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ class Person(CapBaseObject):
|
||||||
biography = StringField('Full biography of a person')
|
biography = StringField('Full biography of a person')
|
||||||
short_description= StringField('Short description of a person')
|
short_description= StringField('Short description of a person')
|
||||||
roles = Field('Lists of movies related to the person indexed by roles',dict)
|
roles = Field('Lists of movies related to the person indexed by roles',dict)
|
||||||
|
thumbnail_url = StringField('Url of person thumbnail')
|
||||||
|
|
||||||
def __init__(self, id, name):
|
def __init__(self, id, name):
|
||||||
CapBaseObject.__init__(self, id)
|
CapBaseObject.__init__(self, id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue