[cineoob] new command 'releases' showing releases dates
This commit is contained in:
parent
595e33b1fa
commit
79192e288c
7 changed files with 72 additions and 8 deletions
|
|
@ -56,6 +56,10 @@ List persons in common between two movies.
|
|||
\fBbiography\fR \fIID\fR
|
||||
.br
|
||||
Show the complete biography of a person.
|
||||
.TP
|
||||
\fBreleases\fR \fIID\fR \fI[COUNTRY]\fR
|
||||
.br
|
||||
Get releases dates of a movie. If COUNTRY is given, show release in this country.
|
||||
.SH WEBOOB COMMANDS
|
||||
.TP
|
||||
\fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]...
|
||||
|
|
|
|||
|
|
@ -63,9 +63,12 @@ class ImdbBackend(BaseBackend, ICapCinema):
|
|||
def iter_movie_persons_ids(self, id):
|
||||
return self.browser.iter_movie_persons_ids(id)
|
||||
|
||||
def get_person_biography(self,id):
|
||||
def get_person_biography(self, id):
|
||||
return self.browser.get_person_biography(id)
|
||||
|
||||
def get_movie_releases(self, id, country=None):
|
||||
return self.browser.get_movie_releases(id,country)
|
||||
|
||||
def fill_person(self, person, fields):
|
||||
if 'real_name' in fields or 'birth_place' in fields\
|
||||
or 'death_date' in fields or 'nationality' in fields\
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ from weboob.capabilities.base import NotAvailable, NotLoaded
|
|||
from weboob.capabilities.cinema import Movie, Person
|
||||
from weboob.tools.json import json
|
||||
|
||||
from .pages import PersonPage, MovieCrewPage, BiographyPage, FilmographyPage
|
||||
from .pages import PersonPage, MovieCrewPage, BiographyPage, FilmographyPage, ReleasePage
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
|
|
@ -37,6 +37,7 @@ class ImdbBrowser(BaseBrowser):
|
|||
USER_AGENT = BaseBrowser.USER_AGENTS['wget']
|
||||
PAGES = {
|
||||
'http://www.imdb.com/title/tt[0-9]*/fullcredits.*': MovieCrewPage,
|
||||
'http://www.imdb.com/title/tt[0-9]*/releaseinfo.*': ReleasePage,
|
||||
'http://www.imdb.com/name/nm[0-9]*/*': PersonPage,
|
||||
'http://www.imdb.com/name/nm[0-9]*/bio.*': BiographyPage,
|
||||
'http://www.imdb.com/name/nm[0-9]*/filmo.*': FilmographyPage,
|
||||
|
|
@ -181,6 +182,11 @@ class ImdbBrowser(BaseBrowser):
|
|||
for person in self.page.iter_persons_ids():
|
||||
yield person
|
||||
|
||||
def get_movie_releases(self,id, country):
|
||||
self.location('http://www.imdb.com/title/%s/releaseinfo'%id)
|
||||
assert self.is_on_page(ReleasePage)
|
||||
return self.page.get_movie_releases(country)
|
||||
|
||||
|
||||
dict_hex = {'á': u'á',
|
||||
'é': u'é',
|
||||
|
|
@ -191,6 +197,7 @@ dict_hex = {'á': u'á',
|
|||
'ú': u'ú',
|
||||
'ü': u'ü',
|
||||
'&': u'&',
|
||||
''': u"'",
|
||||
'ç': u'ç'
|
||||
}
|
||||
def latin2unicode(word):
|
||||
|
|
|
|||
|
|
@ -25,7 +25,25 @@ from weboob.tools.browser import BasePage
|
|||
from datetime import datetime
|
||||
|
||||
|
||||
__all__ = ['PersonPage','MovieCrewPage','BiographyPage','FilmographyPage']
|
||||
__all__ = ['PersonPage','MovieCrewPage','BiographyPage','FilmographyPage','ReleasePage']
|
||||
|
||||
|
||||
class ReleasePage(BasePage):
|
||||
''' Page containing releases of a movie
|
||||
'''
|
||||
def get_movie_releases(self,country_filter):
|
||||
result = unicode()
|
||||
links = self.parser.select(self.document.getroot(),'b a')
|
||||
for a in links:
|
||||
href = a.attrib.get('href','')
|
||||
if href.strip('/').split('/')[0] == 'calendar' and\
|
||||
(country_filter == None or href.split('region=')[-1].lower() == country_filter):
|
||||
country = a.text
|
||||
date = self.parser.select(a.getparent().getparent().getparent(),'td')[1].text_content()
|
||||
result += '%s : %s\n' % (country,date)
|
||||
if result == u'':
|
||||
result = NotAvailable
|
||||
return result.strip()
|
||||
|
||||
|
||||
class BiographyPage(BasePage):
|
||||
|
|
|
|||
|
|
@ -59,3 +59,8 @@ class ImdbTest(BackendTest):
|
|||
bio = self.backend.get_person_biography('nm0223033')
|
||||
assert bio != ''
|
||||
assert bio != None
|
||||
|
||||
def test_get_movie_releases(self):
|
||||
rel = self.backend.get_movie_releases('tt0079980')
|
||||
assert rel != ''
|
||||
assert rel != None
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ class Cineoob(ReplApplication):
|
|||
'persons_in_common':'person_list'
|
||||
}
|
||||
ROLE_LIST = ['actor','director','writer','composer','producer']
|
||||
COUNTRY_LIST = ['us','fr','de','jp']
|
||||
|
||||
def complete_filmography(self, text, line, *ignored):
|
||||
args = line.split(' ')
|
||||
|
|
@ -375,3 +376,29 @@ class Cineoob(ReplApplication):
|
|||
print '%s :\n\n%s' % (person.name,bio)
|
||||
if bio != NotAvailable:
|
||||
self.flush()
|
||||
|
||||
def complete_releases(self, text, line, *ignored):
|
||||
args = line.split(' ')
|
||||
if len(args) == 3:
|
||||
return self.COUNTRY_LIST
|
||||
|
||||
def do_releases(self, line):
|
||||
"""
|
||||
releases movie_ID [COUNTRY]
|
||||
|
||||
Get releases dates of a movie.
|
||||
If COUNTRY is given, show release in this country.
|
||||
"""
|
||||
id, country = self.parse_command_args(line, 2, 1)
|
||||
# TODO try without getting object
|
||||
movie = self.get_object(id, 'get_movie')
|
||||
|
||||
if not movie:
|
||||
print >>sys.stderr, 'Movie not found: %s' % id
|
||||
return 3
|
||||
|
||||
for backend, release in self.do('get_movie_releases', movie.id, country):
|
||||
print '%s :\n\n%s' % (movie.original_title,release)
|
||||
if release != NotAvailable:
|
||||
self.flush()
|
||||
|
||||
|
|
|
|||
|
|
@ -87,17 +87,17 @@ class ICapCinema(IBaseCap):
|
|||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_movie_persons(self, _id):
|
||||
def get_movie_releases(self, _id, country=None):
|
||||
"""
|
||||
Get the list of persons who are actors in a movie.
|
||||
Get a list of a movie releases from an ID.
|
||||
|
||||
:param _id: ID of movie
|
||||
:type _id: str
|
||||
:rtype: iter[:class:`Person`]
|
||||
:rtype: :class:`String`
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def iter_movie_persons(self, _id):
|
||||
def iter_movie_persons(self, _id, role=None):
|
||||
"""
|
||||
Get the list of persons who are related to a movie.
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ class ICapCinema(IBaseCap):
|
|||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def iter_person_movies(self, _id):
|
||||
def iter_person_movies(self, _id, role=None):
|
||||
"""
|
||||
Get the list of movies related to a person.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue