[allocine] handles showtimelist in allocine
This commit is contained in:
parent
aca28a3d5a
commit
0ec91edc37
3 changed files with 135 additions and 11 deletions
|
|
@ -16,7 +16,10 @@
|
|||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
import re
|
||||
|
||||
from weboob.capabilities.base import UserError
|
||||
from weboob.capabilities.calendar import CapCalendarEvent, CATEGORIES, BaseCalendarEvent
|
||||
from weboob.capabilities.video import CapVideo, BaseVideo
|
||||
from weboob.capabilities.collection import CapCollection, CollectionNotFound, Collection
|
||||
from weboob.capabilities.cinema import CapCinema, Person, Movie
|
||||
|
|
@ -27,7 +30,7 @@ from .browser import AllocineBrowser
|
|||
__all__ = ['AllocineModule']
|
||||
|
||||
|
||||
class AllocineModule(Module, CapCinema, CapVideo, CapCollection):
|
||||
class AllocineModule(Module, CapCinema, CapVideo, CapCalendarEvent, CapCollection):
|
||||
NAME = 'allocine'
|
||||
MAINTAINER = u'Julien Veyssier'
|
||||
EMAIL = 'julien.veyssier@aiur.fr'
|
||||
|
|
@ -35,6 +38,7 @@ class AllocineModule(Module, CapCinema, CapVideo, CapCollection):
|
|||
DESCRIPTION = u'AlloCiné French cinema database service'
|
||||
LICENSE = 'AGPLv3+'
|
||||
BROWSER = AllocineBrowser
|
||||
ASSOCIATED_CATEGORIES = [CATEGORIES.CINE]
|
||||
|
||||
def get_movie(self, id):
|
||||
return self.browser.get_movie(id)
|
||||
|
|
@ -117,7 +121,7 @@ class AllocineModule(Module, CapCinema, CapVideo, CapCollection):
|
|||
video = self.get_video(self, video.id)
|
||||
|
||||
if hasattr(video, '_video_code'):
|
||||
video.url = self.browser.get_video_url(video._video_code)
|
||||
video.url = unicode(self.browser.get_video_url(video._video_code))
|
||||
|
||||
if 'thumbnail' in fields and video and video.thumbnail:
|
||||
with self.browser:
|
||||
|
|
@ -174,8 +178,29 @@ class AllocineModule(Module, CapCinema, CapVideo, CapCollection):
|
|||
|
||||
raise CollectionNotFound(collection.split_path)
|
||||
|
||||
def search_events(self, query):
|
||||
with self.browser:
|
||||
if CATEGORIES.CINE in query.categories:
|
||||
if query.city and re.match('\d{5}', query.city):
|
||||
events = list(self.browser.search_events(query))
|
||||
events.sort(key=lambda x: x.start_date, reverse=False)
|
||||
return events
|
||||
else:
|
||||
raise UserError('You must enter a zip code in city field')
|
||||
|
||||
def get_event(self, id):
|
||||
return self.browser.get_event(id)
|
||||
|
||||
def fill_event(self, event, fields):
|
||||
if 'description' in fields:
|
||||
movieCode = event.id.split('#')[2]
|
||||
movie = self.get_movie(movieCode)
|
||||
event.description = movie.pitch
|
||||
return event
|
||||
|
||||
OBJECTS = {
|
||||
Person: fill_person,
|
||||
Movie: fill_movie,
|
||||
BaseVideo: fill_video
|
||||
BaseVideo: fill_video,
|
||||
BaseCalendarEvent: fill_event
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue