[cineoob] biography command improved
This commit is contained in:
parent
de5018ab1f
commit
5cead53d47
4 changed files with 62 additions and 25 deletions
|
|
@ -17,7 +17,7 @@
|
||||||
# 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/>.
|
||||||
|
|
||||||
from weboob.capabilities.cinema import ICapCinema
|
from weboob.capabilities.cinema import ICapCinema, Person
|
||||||
from weboob.tools.backend import BaseBackend
|
from weboob.tools.backend import BaseBackend
|
||||||
|
|
||||||
from .browser import ImdbBrowser
|
from .browser import ImdbBrowser
|
||||||
|
|
@ -76,7 +76,10 @@ class ImdbBackend(BaseBackend, ICapCinema):
|
||||||
or 'birth_date' in fields\
|
or 'birth_date' in fields\
|
||||||
or 'gender' in fields or fields == None:
|
or 'gender' in fields or fields == None:
|
||||||
return self.get_person(person.id)
|
return self.get_person(person.id)
|
||||||
else:
|
|
||||||
|
if 'biography' in fields:
|
||||||
|
person.biography = self.get_person_biography(person.id)
|
||||||
|
|
||||||
return person
|
return person
|
||||||
|
|
||||||
def fill_movie(self, movie, fields):
|
def fill_movie(self, movie, fields):
|
||||||
|
|
@ -87,3 +90,7 @@ class ImdbBackend(BaseBackend, ICapCinema):
|
||||||
return self.get_movie(movie.id)
|
return self.get_movie(movie.id)
|
||||||
else:
|
else:
|
||||||
return movie
|
return movie
|
||||||
|
|
||||||
|
OBJECTS = {
|
||||||
|
Person:fill_person
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,6 @@ from weboob.tools.backend import BaseBackend
|
||||||
|
|
||||||
from .browser import ParolesmusiqueBrowser
|
from .browser import ParolesmusiqueBrowser
|
||||||
|
|
||||||
from urllib import quote_plus
|
|
||||||
|
|
||||||
__all__ = ['ParolesmusiqueBackend']
|
__all__ = ['ParolesmusiqueBackend']
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,13 @@ from datetime import datetime
|
||||||
|
|
||||||
from weboob.applications.weboorrents.weboorrents import TorrentInfoFormatter, TorrentListFormatter
|
from weboob.applications.weboorrents.weboorrents import TorrentInfoFormatter, TorrentListFormatter
|
||||||
from weboob.applications.suboob.suboob import SubtitleInfoFormatter, SubtitleListFormatter
|
from weboob.applications.suboob.suboob import SubtitleInfoFormatter, SubtitleListFormatter
|
||||||
from weboob.capabilities.torrent import ICapTorrent
|
from weboob.capabilities.torrent import ICapTorrent, MagnetOnly
|
||||||
from weboob.capabilities.cinema import ICapCinema
|
from weboob.capabilities.cinema import ICapCinema
|
||||||
from weboob.capabilities.subtitle import ICapSubtitle
|
from weboob.capabilities.subtitle import ICapSubtitle
|
||||||
from weboob.capabilities.base import NotAvailable,NotLoaded
|
from weboob.capabilities.base import NotAvailable,NotLoaded
|
||||||
from weboob.tools.application.repl import ReplApplication
|
from weboob.tools.application.repl import ReplApplication
|
||||||
from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter
|
from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter
|
||||||
|
from weboob.core import CallErrors
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['Cineoob']
|
__all__ = ['Cineoob']
|
||||||
|
|
@ -142,6 +143,17 @@ class PersonListFormatter(PrettyFormatter):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
class PersonBiographyFormatter(PrettyFormatter):
|
||||||
|
MANDATORY_FIELDS = ('id', 'name', 'biography')
|
||||||
|
|
||||||
|
def get_title(self, obj):
|
||||||
|
return u'Biography of %s'%obj.name
|
||||||
|
|
||||||
|
def get_description(self, obj):
|
||||||
|
result = obj.biography
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class Cineoob(ReplApplication):
|
class Cineoob(ReplApplication):
|
||||||
APPNAME = 'cineoob'
|
APPNAME = 'cineoob'
|
||||||
VERSION = '0.f'
|
VERSION = '0.f'
|
||||||
|
|
@ -155,6 +167,7 @@ class Cineoob(ReplApplication):
|
||||||
'movie_info': MovieInfoFormatter,
|
'movie_info': MovieInfoFormatter,
|
||||||
'person_list': PersonListFormatter,
|
'person_list': PersonListFormatter,
|
||||||
'person_info': PersonInfoFormatter,
|
'person_info': PersonInfoFormatter,
|
||||||
|
'person_bio': PersonBiographyFormatter,
|
||||||
'torrent_list': TorrentListFormatter,
|
'torrent_list': TorrentListFormatter,
|
||||||
'torrent_info': TorrentInfoFormatter,
|
'torrent_info': TorrentInfoFormatter,
|
||||||
'subtitle_list': SubtitleListFormatter,
|
'subtitle_list': SubtitleListFormatter,
|
||||||
|
|
@ -166,6 +179,7 @@ class Cineoob(ReplApplication):
|
||||||
'info_person': 'person_info',
|
'info_person': 'person_info',
|
||||||
'casting': 'person_list',
|
'casting': 'person_list',
|
||||||
'filmography': 'movie_list',
|
'filmography': 'movie_list',
|
||||||
|
'biography': 'person_bio',
|
||||||
'movies_in_common':'movie_list',
|
'movies_in_common':'movie_list',
|
||||||
'persons_in_common':'person_list',
|
'persons_in_common':'person_list',
|
||||||
'search_torrent': 'torrent_list',
|
'search_torrent': 'torrent_list',
|
||||||
|
|
@ -291,7 +305,7 @@ class Cineoob(ReplApplication):
|
||||||
Get information about a person.
|
Get information about a person.
|
||||||
"""
|
"""
|
||||||
# TODO understand core to get a call to Backend.fill_person when get_object is called
|
# TODO understand core to get a call to Backend.fill_person when get_object is called
|
||||||
#person = self.get_object(id, 'get_person',None)
|
#person = self.get_object(id, 'get_person')
|
||||||
person = None
|
person = None
|
||||||
_id, backend = self.parse_id(id)
|
_id, backend = self.parse_id(id)
|
||||||
for _backend, result in self.do('get_person', _id, backends=backend, caps=ICapCinema):
|
for _backend, result in self.do('get_person', _id, backends=backend, caps=ICapCinema):
|
||||||
|
|
@ -303,8 +317,6 @@ class Cineoob(ReplApplication):
|
||||||
print >>sys.stderr, 'Person not found: %s' % id
|
print >>sys.stderr, 'Person not found: %s' % id
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
#backend.fillobj(person, ('birth_date','short_biography'))
|
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
self.format(person)
|
self.format(person)
|
||||||
self.flush()
|
self.flush()
|
||||||
|
|
@ -381,14 +393,23 @@ class Cineoob(ReplApplication):
|
||||||
|
|
||||||
Show the complete biography of a person.
|
Show the complete biography of a person.
|
||||||
"""
|
"""
|
||||||
person = self.get_object(person_id, 'get_person')
|
# TODO understand how to handle short id trying to be get by wrong backends and validate this line !
|
||||||
|
# in other words, find a way to select CAP when 'get_object' to avoid useless errors and clarify the following code
|
||||||
|
#person = self.get_object(person_id,'get_person',('name','biography'))
|
||||||
|
|
||||||
|
person = None
|
||||||
|
_id, backend = self.parse_id(person_id)
|
||||||
|
for _backend, result in self.do('get_person', _id, backends=backend, caps=ICapCinema):
|
||||||
|
if result:
|
||||||
|
backend = _backend
|
||||||
|
person = result
|
||||||
if not person:
|
if not person:
|
||||||
print >>sys.stderr, 'Person not found: %s' % id
|
print >>sys.stderr, 'Person not found: %s' % _id
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
for backend, bio in self.do('get_person_biography', person.id, caps=ICapCinema):
|
backend.fillobj(person,('biography'))
|
||||||
print '%s :\n\n%s' % (person.name,bio)
|
self.start_format()
|
||||||
if bio != NotAvailable:
|
self.format(person)
|
||||||
self.flush()
|
self.flush()
|
||||||
|
|
||||||
def complete_releases(self, text, line, *ignored):
|
def complete_releases(self, text, line, *ignored):
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,8 @@ class Person(CapBaseObject):
|
||||||
gender = StringField('Gender of a person')
|
gender = StringField('Gender of a person')
|
||||||
nationality = StringField('Nationality of a person')
|
nationality = StringField('Nationality of a person')
|
||||||
short_biography = StringField('Short biography of a person')
|
short_biography = StringField('Short biography of a person')
|
||||||
short_description = StringField('Short description of a person')
|
biography = StringField('Full biography 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)
|
||||||
|
|
||||||
def __init__(self, id, name):
|
def __init__(self, id, name):
|
||||||
|
|
@ -156,3 +157,13 @@ class ICapCinema(IBaseCap):
|
||||||
:rtype: iter[str]
|
:rtype: iter[str]
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def get_person_biography(self, id):
|
||||||
|
"""
|
||||||
|
Get the person full biography.
|
||||||
|
|
||||||
|
:param _id: ID of person
|
||||||
|
:type _id: str
|
||||||
|
:rtype: str
|
||||||
|
"""
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue