# -*- coding: UTF-8 -*- __revision__ = '$Id: PluginMovieIMDB-de.py 833 2007-08-16 20:09:25Z mikej06 $' # Copyright (c) 2007 Michael Jahn # # 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, movie import string, re plugin_name = 'IMDb-de' plugin_description = 'Internet Movie Database German' plugin_url = 'german.imdb.com' plugin_language = _('German') plugin_author = 'Michael Jahn' plugin_author_email = 'mikej06@hotmail.com' plugin_version = '1.2' class Plugin(movie.Movie): def __init__(self, id): self.encode = 'iso8859-1' self.movie_id = id self.url = "http://german.imdb.com/title/tt%s" % str(self.movie_id) def initialize(self): self.cast_page = self.open_page(url=self.url + '/fullcredits') self.plot_page = self.open_page(url=self.url + '/plotsummary') def get_image(self): tmp = string.find(self.page, 'a name="poster"') if tmp == -1: # poster not available self.image_url = '' else: self.image_url = gutils.trim(self.page[tmp:], 'src="', '"') def get_o_title(self): self.o_title = gutils.trim(self.page, '

', ' ', ' Alternativ:', ''), ' 1: for element in elements: tmp = gutils.before(gutils.trim(element, '>', '[de]'), '(') if tmp <> '': self.title = tmp break def get_director(self): self.director = gutils.trim(self.page,'
Regie
', '
\n') if self.director == '': self.director = gutils.trim(self.page,'
Regisseur:
', '
\n') self.director = self.__before_more(self.director) self.director = self.director.replace('
', ', ') def get_plot(self): self.plot = gutils.trim(self.page, '
Kurzbeschreibung:
', '') self.plot = self.__before_more(self.plot) elements = string.split(self.plot_page, '

') if len(elements) > 1: self.plot = self.plot + '\n\n' elements[0] = '' for element in elements: if element != '': self.plot = self.plot + gutils.strip_tags(gutils.before(element, '')) + '\n' def get_year(self): self.year = gutils.trim(self.page, '') def get_runtime(self): self.runtime = gutils.trim(self.page, '

Länge:
', ' min') def get_genre(self): self.genre = gutils.trim(self.page, '
Genre:
', '') self.genre = self.__before_more(self.genre) def get_cast(self): self.cast = '' self.cast = gutils.trim(self.cast_page, '', '
') if self.cast == '': self.cast = gutils.trim(self.page, '', '
') self.cast = string.replace(self.cast, ' ... ', _(' as ')) self.cast = string.replace(self.cast, '...', _(' as ')) self.cast = string.replace(self.cast, '', "\n") self.cast = string.replace(self.cast, '', "\n") self.cast = string.replace(self.cast, '', "\n") self.cast = self.__before_more(self.cast) def get_classification(self): self.classification = gutils.trim(gutils.trim(self.page, 'Altersfreigabe:', ''), 'Germany:', '&') def get_studio(self): self.studio = gutils.trim(self.page, '
Company:
', '
') def get_o_site(self): self.o_site = '' def get_site(self): self.site = "http://german.imdb.com/title/tt%s" % self.movie_id def get_trailer(self): self.trailer = "http://german.imdb.com/title/tt%s/trailers" % self.movie_id def get_country(self): self.country = gutils.trim(self.page, '
Produktionsland:
', '') def get_rating(self): self.rating = gutils.trim(self.page, 'Nutzer-Bewertung:', '/10') if self.rating: try: self.rating = str(float(gutils.clean(self.rating))) except: self.rating = '' def get_notes(self): self.notes = '' language = gutils.trim(self.page, '
Sprache:
', '') language = gutils.strip_tags(language) color = gutils.trim(self.page, '
Farbe:
', '') color = gutils.strip_tags(color) sound = gutils.trim(self.page, '
Tonverfahren:
', '') sound = gutils.strip_tags(sound) tagline = gutils.trim(self.page, '
Werbezeile:
', '') tagline = self.__before_more(tagline) tagline = gutils.strip_tags(tagline) if len(language)>0: self.notes = "%s: %s\n" %(_('Language'), language) if len(sound)>0: self.notes += "%s: %s\n" %(gutils.strip_tags(_('Audio')), sound) if len(color)>0: self.notes += "%s: %s\n" %(_('Color'), color) if len(tagline)>0: self.notes += "%s: %s\n" %('Tagline', tagline) def __before_more(self, data): tmp = string.find(data, '>mehr...<') if tmp>0: data = data[:tmp] + '>' return data class SearchPlugin(movie.SearchMovie): PATTERN = re.compile(r"""(.*?)""") def __init__(self): self.original_url_search = 'http://german.imdb.com/find?more=tt&q=' self.translated_url_search = 'http://german.imdb.com/find?more=tt&q=' self.encode = 'iso8859-1' def search(self,parent_window): self.open_search(parent_window) self.page = gutils.trim(self.page, '(Displaying', 'Suggestions For Improving Your Results'); self.page = self.page.decode('iso-8859-1') return self.page def get_searches(self): elements = string.split(self.page, '') if len(elements): for element in elements[1:]: match = self.PATTERN.findall(element) if len(match): tmp = gutils.clean(match[0][1]) self.ids.append(match[0][0]) self.titles.append(tmp)