[cineoob] releases command improved
This commit is contained in:
parent
5cead53d47
commit
8e796cc5c3
3 changed files with 35 additions and 10 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, Person
|
from weboob.capabilities.cinema import ICapCinema, Person, Movie
|
||||||
from weboob.tools.backend import BaseBackend
|
from weboob.tools.backend import BaseBackend
|
||||||
|
|
||||||
from .browser import ImdbBrowser
|
from .browser import ImdbBrowser
|
||||||
|
|
@ -88,9 +88,9 @@ class ImdbBackend(BaseBackend, ICapCinema):
|
||||||
or 'roles' in fields or 'note' in fields\
|
or 'roles' in fields or 'note' in fields\
|
||||||
or fields == None:
|
or fields == None:
|
||||||
return self.get_movie(movie.id)
|
return self.get_movie(movie.id)
|
||||||
else:
|
return movie
|
||||||
return movie
|
|
||||||
|
|
||||||
OBJECTS = {
|
OBJECTS = {
|
||||||
Person:fill_person
|
Person:fill_person,
|
||||||
|
Movie:fill_movie
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,17 @@ class MovieListFormatter(PrettyFormatter):
|
||||||
result = obj.short_description
|
result = obj.short_description
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
class MovieReleasesFormatter(PrettyFormatter):
|
||||||
|
MANDATORY_FIELDS = ('id', 'original_title', 'all_release_dates')
|
||||||
|
|
||||||
|
def get_title(self, obj):
|
||||||
|
return u'Releases of %s'%obj.original_title
|
||||||
|
|
||||||
|
def get_description(self, obj):
|
||||||
|
return u'\n%s'%obj.all_release_dates
|
||||||
|
|
||||||
|
|
||||||
def yearsago(years, from_date=None):
|
def yearsago(years, from_date=None):
|
||||||
if from_date is None:
|
if from_date is None:
|
||||||
from_date = datetime.now()
|
from_date = datetime.now()
|
||||||
|
|
@ -150,7 +161,7 @@ class PersonBiographyFormatter(PrettyFormatter):
|
||||||
return u'Biography of %s'%obj.name
|
return u'Biography of %s'%obj.name
|
||||||
|
|
||||||
def get_description(self, obj):
|
def get_description(self, obj):
|
||||||
result = obj.biography
|
result = u'\n%s'%obj.biography
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -165,6 +176,7 @@ class Cineoob(ReplApplication):
|
||||||
CAPS = (ICapCinema,ICapTorrent,ICapSubtitle)
|
CAPS = (ICapCinema,ICapTorrent,ICapSubtitle)
|
||||||
EXTRA_FORMATTERS = {'movie_list': MovieListFormatter,
|
EXTRA_FORMATTERS = {'movie_list': MovieListFormatter,
|
||||||
'movie_info': MovieInfoFormatter,
|
'movie_info': MovieInfoFormatter,
|
||||||
|
'movie_releases': MovieReleasesFormatter,
|
||||||
'person_list': PersonListFormatter,
|
'person_list': PersonListFormatter,
|
||||||
'person_info': PersonInfoFormatter,
|
'person_info': PersonInfoFormatter,
|
||||||
'person_bio': PersonBiographyFormatter,
|
'person_bio': PersonBiographyFormatter,
|
||||||
|
|
@ -180,6 +192,7 @@ class Cineoob(ReplApplication):
|
||||||
'casting': 'person_list',
|
'casting': 'person_list',
|
||||||
'filmography': 'movie_list',
|
'filmography': 'movie_list',
|
||||||
'biography': 'person_bio',
|
'biography': 'person_bio',
|
||||||
|
'releases': 'movie_releases',
|
||||||
'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',
|
||||||
|
|
@ -425,17 +438,28 @@ class Cineoob(ReplApplication):
|
||||||
If COUNTRY is given, show release in this country.
|
If COUNTRY is given, show release in this country.
|
||||||
"""
|
"""
|
||||||
id, country = self.parse_command_args(line, 2, 1)
|
id, country = self.parse_command_args(line, 2, 1)
|
||||||
# TODO try without getting object
|
|
||||||
movie = self.get_object(id, 'get_movie')
|
movie = None
|
||||||
|
_id, backend = self.parse_id(id)
|
||||||
|
for _backend, result in self.do('get_movie', _id, backends=backend, caps=ICapCinema):
|
||||||
|
if result:
|
||||||
|
backend = _backend
|
||||||
|
movie = result
|
||||||
|
|
||||||
if not movie:
|
if not movie:
|
||||||
print >>sys.stderr, 'Movie not found: %s' % id
|
print >>sys.stderr, 'Movie not found: %s' % id
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
|
# i would like to clarify with fillobj but how could i fill the movie AND choose the country ?
|
||||||
for backend, release in self.do('get_movie_releases', movie.id, country, caps=ICapCinema):
|
for backend, release in self.do('get_movie_releases', movie.id, country, caps=ICapCinema):
|
||||||
print '%s :\n\n%s' % (movie.original_title,release)
|
if release != NotAvailable:
|
||||||
if release != NotAvailable:
|
movie.all_release_dates = u'%s' % (release)
|
||||||
self.flush()
|
else:
|
||||||
|
print >>sys.stderr, 'Movie releases not found: %s' % id
|
||||||
|
return 3
|
||||||
|
self.start_format()
|
||||||
|
self.format(movie)
|
||||||
|
self.flush()
|
||||||
|
|
||||||
#================== TORRENT ==================
|
#================== TORRENT ==================
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ class Movie(CapBaseObject):
|
||||||
original_title = StringField('Original title of the movie')
|
original_title = StringField('Original title of the movie')
|
||||||
other_titles = Field('Titles in other countries',list)
|
other_titles = Field('Titles in other countries',list)
|
||||||
release_date = DateField('Release date of the movie')
|
release_date = DateField('Release date of the movie')
|
||||||
|
all_release_dates= StringField('Release dates list of the movie')
|
||||||
duration = IntField('Duration of the movie in minutes')
|
duration = IntField('Duration of the movie in minutes')
|
||||||
short_description= StringField('Short description of the movie')
|
short_description= StringField('Short description of the movie')
|
||||||
pitch = StringField('Short story description of the movie')
|
pitch = StringField('Short story description of the movie')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue