# -*- coding: UTF-8 -*- __revision__ = '$Id: PluginMovie7arte.py 849 2007-09-01 18:05:11Z iznogoud $' # Copyright (c) 2005-2006 Vasco Nunes, Piotr Ozarowski # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # You may use and distribute this software under the terms of the # GNU General Public License, version 2 or later from gettext import gettext as _ import gutils import movie import string plugin_name = "7arte" plugin_description = "O cinema em Portugal" plugin_url = "7arte.net" plugin_language = _("Portuguese") plugin_author = "Vasco Nunes" plugin_author_email = "" plugin_version = "0.6" class Plugin(movie.Movie): """A movie plugin object""" def __init__(self, id): self.encode='iso-8859-1' self.movie_id = id self.url = "http://7arte.net/cgi-bin/filme.pl?codigo=" + str(self.movie_id) def get_image(self): """Finds the film's poster image""" self.image_url = "http://7arte.net/imagens/filmes/" + str(self.movie_id) + ".jpg" def get_o_title(self): """Finds the film's original title""" self.o_title = string.capwords(gutils.trim(self.page, "
", "
")) def get_title(self): """Finds the film's local title. Probably the original title translation""" self.title = string.capwords(gutils.trim(self.page, "", "")) def get_director(self): """Finds the film's director""" self.director = gutils.trim(self.page, " ", "") self.director = gutils.strip_tags(self.director) def get_plot(self): """Finds the film's plot""" self.plot = gutils.trim(self.page, "Sinopse:
", "[ www.7arte.net ]

") def get_year(self): """Finds the film's year""" self.year = gutils.trim(self.page, "Ano:", "") def get_runtime(self): """Finds the film's running time""" self.runtime = gutils.trim(self.page, "Dura", " minutos") self.runtime = gutils.after(self.runtime, "-1>") def get_genre(self): """Finds the film's genre""" self.genre = gutils.trim(self.page, "nero:", "
") def get_cast(self): self.cast = gutils.trim(self.page, "Actores:", "") self.cast = string.replace(self.cast, "» ", "") def get_classification(self): """Find the film's classification""" self.classification = gutils.trim(self.page, "Idade:", "") def get_studio(self): """Find the studio""" self.studio = gutils.trim(self.page, "Distribuidora:", "") def get_o_site(self): """Find the film's oficial site""" self.o_site = gutils.trim(self.page, \ "", \ "' TARGET=_blank>", \ "' TARGET=_blank> ", "
") def get_rating(self): """Find the film's rating. From 0 to 10. Convert if needed when assigning.""" tmp_rating = gutils.trim(self.page, "ticas por:", "c_critica.pl?id=") if tmp_rating: self.rating = str(float(string.count(tmp_rating, 'estrela.gif'))*2) class SearchPlugin(movie.SearchMovie): """A movie search object""" def __init__(self): self.original_url_search = "http://7arte.net/cgi-bin/arq_search_orig.pl?proc=" self.translated_url_search = "http://7arte.net/cgi-bin/arq_search.pl?proc=" self.encode='iso-8859-1' def search(self, parent_window): """Perform the web search""" self.open_search(parent_window) self.sub_search() return self.page def sub_search(self): """Isolating just a portion (with the data we want) of the results""" self.page = gutils.trim(self.page, \ "Resultados Encontrados", "") def get_searches(self): """Try to find both id and film title for each search result""" elements = string.split(self.page, "

") self.number_results = elements[-1] if (len(elements[0])): for element in elements: self.ids.append(gutils.trim(element, "codigo=", "')")) self.titles.append(gutils.convert_entities \ (gutils.trim(element, "')\">", " )")) + " )") else: self.number_results = 0