Griffith - media collection manager
May 23, 2012, 09:41:55 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: New mailing lists,
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: New Plugin for FilmScoop.it  (Read 1450 times)
andre77
Newbie
*
Offline Offline

Posts: 1


View Profile
« on: August 19, 2009, 04:51:07 PM »

Hi, sorry for my bad english..
I have modified the Cinematografo plugin for work with Italian Film database www.filmscoop.it
I have called him PluginMovieFilmScoop.py
It works but it should be modified for a best coded..

If you want it this is the file

Quote

# -*- coding: UTF-8 -*-

__revision__ = '$Id: PluginMovieFilmScoop.py 1183 2009-04-05 18:55:46Z mikej06 $'

# Copyright (c) 2005-2009 Andrea Squeri
#
# 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

import gutils, movie, string, re

plugin_name         = "FilmScoop"
plugin_description  = "FilmScoop"
plugin_url          = "http://www.filmscoop.it"
plugin_language     = _("Italian")
plugin_author       = "Squeri Andrea"
plugin_author_email = "andrea.squeri@gmail.com"
plugin_version      = "0.1"

class Plugin(movie.Movie):
   def __init__(self, id):
      self.encode   = 'iso-8859-1'
      self.movie_id = id
      #print "ciao ciao " + str(self.movie_id)
      self.url      = "http://www.filmscoop.it/film_al_cinema/%s.asp" % str(self.movie_id)
      #print self.url

   def get_image(self):
      # Find the film's poster image
               
      self.image_url = gutils.trim(self.page, "http://www.filmscoop.it/locandine/", "\"")
      self.image_url = "http://www.filmscoop.it/locandine/" + self.image_url
      

   def get_o_title(self):
      # Find the film's original title
      self.o_title = gutils.trim(self.page, "<strong>Titolo Originale</strong>: <em>", "</em>")
      self.o_title = string.capwords(self.o_title)
      # if nothing found, use the title
      if self.o_title == '':
      
         self.o_title = gutils.trim(self.page, "<a href=\"/film_al_cinema/%s.asp\">" % str(self.movie_id), "</a>")
         #self.o_title = gutils.trim(self.o_title, "<b>", "</b>")

   def get_title(self):
      # Find the film's local title.
      # Probably the original title translation
      self.title = gutils.trim(self.page, "<a href=\"/film_al_cinema/%s.asp\">" % str(self.movie_id), "</a>")
      #print "ciao" + self.title
      #self.title = gutils.trim(self.title, "<b>", "</b>")

   def get_director(self):
      # Find the film's director
      tmp = gutils.trim(self.page, "<h2><strong>Regia</strong>:&nbsp;", "</h2>")
                self.director =""
                elements = string.split(tmp, "</a>")
      

      if (elements[0] != ''):
         for element in elements:
            
                                self.director += gutils.trim(element, "<a href=\"/ricerca/risultati.asp?r=", "&amp;o=Titolo")+","
            
      else:
         number_results = 0
               
      self.director=self.director[0:-2]
      
   def get_plot(self):
      # Find the film's plot
      self.plot = gutils.trim(self.page, '<p style="margin-top:0;margin-left:0;padding-top:0;padding-left:0;">', "</p>")

   def get_year(self):
      # Find the film's year
      self.year = gutils.trim(self.page, "Al cinema", "</a>")
               # self.year = gutils.trim(self.year, "<a href=\"/ricerca/risultati.asp?an", "rel=\"nofollow\"")
                #self.year = gutils.trim(self.year, ">", "<")
      #print "ciao" + self.year
      self.year = gutils.digits_only(gutils.clean(self.year))

   def get_runtime(self):
      # Find the film's running time
      self.runtime = gutils.trim(self.page, "<strong>Durata</strong>:&nbsp;h ", "<br />")
                self.runtime = self.runtime.replace(".",",")
      lista=self.runtime.split(",")
      self.runtime=int(lista[0])*60+int(lista[1])
      

   def get_genre(self):
      # Find the film's genre
      self.genre = gutils.trim(self.page, "<strong>Genere</strong>:&nbsp;<a href=\"/ricerca/risultati.asp?g", "<br />")
                self.genre = gutils.trim(self.genre, ">", "</a>")


   def get_cast(self):
      
      tmp = gutils.trim(self.page, "<h2><strong>Interpreti</strong>:&nbsp;", "</h2>")
      self.cast =""
                elements = string.split(tmp, "</a>")
      

      if (elements[0] != ''):
         for element in elements:
            
                                self.cast += gutils.trim(element, "<a href=\"/ricerca/risultati.asp?i=", "&amp;o=Titolo")+","
            
      else:
         number_results = 0
               
      self.cast=self.cast[0:-2]
      #print self.cast

      


   def get_classification(self):
      # Find the film's classification
      self.classification = ''

   def get_studio(self):
      # Find the studio
      self.studio = ""

   def get_o_site(self):
      # Find the film's oficial site
      self.o_site = ''

   def get_site(self):
      # Find the film's imdb details page
      self.site = self.url

   def get_trailer(self):
      # Find the film's trailer page or location
      self.trailer = ""

   def get_country(self):
      # Find the film's country
      self.country = gutils.trim(self.page, "title=\"Altri film con nazionalit&agrave; ", "\"")

   def get_rating(self):
      # Find the film's rating. From 0 to 10.
      # Convert if needed when assigning.
      self.rating = gutils.trim(self.page, "td nowrap=\"nowrap\">Voto Visitatori:</td>", "</tr>")
                self.rating = gutils.trim(self.rating, "&nbsp;&nbsp;&nbsp;", " / 10")

   def regextrim(self,text,key1,key2):
      obj = re.search(key1, text)
      if obj is None:
         return ''
      else:
         p1 = obj.end()
      obj = re.search(key2, text[p1:])
      if obj is None:
         return ''
      else:
         p2 = p1 + obj.start()
      return text[p1:p2]

class SearchPlugin(movie.SearchMovie):
   # A movie search object
   def __init__(self):
      self.encode                = 'iso-8859-1'
      self.original_url_search   = 'http://www.filmscoop.it/ricerca/risultati.asp?tiporicerca=t&ricercabarra=ricercabarra&s=s&Submit=Cerca&parola='
      self.translated_url_search = self.original_url_search

   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, '<table width="100%" border="0" cellspacing="0" cellpadding="2" style="margin-top:25px;">', '</table>')

   def get_searches(self):
      # Try to find both id and film title for each search result
      elements = string.split(self.page, "<tr>")
      self.number_results = elements[-1]

      if (elements[0] != ''):
         for element in elements:
            id = gutils.trim(element, "/film_al_cinema/", ".asp")
            if id <> '':
               self.ids.append(id)
               self.titles.append(gutils.strip_tags(gutils.convert_entities(gutils.trim(element, "<strong>", "</strong>"))))
      else:
         self.number_results = 0




Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2006-2007, Simple Machines Valid XHTML 1.0! Valid CSS!