~ubuntu-branches/ubuntu/quantal/griffith/quantal

« back to all changes in this revision

Viewing changes to .pc/debian-changes-0.12.1-2/lib/plugins/movie/PluginMovieE-Pipoca.py

  • Committer: Package Import Robot
  • Author(s): Piotr Ożarowski
  • Date: 2011-12-18 21:15:25 UTC
  • mfrom: (1.1.17) (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20111218211525-endbgt82m3jh9gde
Tags: 0.13-1
* New upstream release
* VCS-* fields removed (berlios will be shutdown)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: UTF-8 -*-
2
 
 
3
 
__revision__ = '$Id: PluginMovieE-Pipoca.py 1467 2010-10-14 18:16:49Z mikej06 $'
4
 
 
5
 
# Copyright (c) 2005-2009 Vasco Nunes, Piotr Ożarowski
6
 
#
7
 
# This program is free software; you can redistribute it and/or modify
8
 
# it under the terms of the GNU General Public License as published by
9
 
# the Free Software Foundation; either version 2 of the License, or
10
 
# (at your option) any later version.
11
 
#
12
 
# This program is distributed in the hope that it will be useful,
13
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
# GNU Library General Public License for more details.
16
 
#
17
 
# You should have received a copy of the GNU General Public License
18
 
# along with this program; if not, write to the Free Software
19
 
# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
20
 
 
21
 
# You may use and distribute this software under the terms of the
22
 
# GNU General Public License, version 2 or later
23
 
 
24
 
# Updated on 04/29/2007 by Djohnson "Joe" Lima
25
 
# joe1310@terra.com.br - São Paulo/Brasil
26
 
 
27
 
 
28
 
import gutils, movie, string
29
 
 
30
 
plugin_name         = "E-Pipoca"
31
 
plugin_description  = "E-Pipoca Brasil"
32
 
plugin_url          = "www.epipoca.com.br"
33
 
plugin_language     = _("Brazilian Portuguese")
34
 
plugin_author       = "Vasco Nunes"
35
 
plugin_author_email = "<vasco.m.nunes@gmail.com>"
36
 
plugin_version      = "0.6"
37
 
 
38
 
class Plugin(movie.Movie):
39
 
    "A movie plugin object"
40
 
    def __init__(self, id):
41
 
        self.encode   = 'iso-8859-1'
42
 
        self.movie_id = id
43
 
        self.url      = "http://www.epipoca.com.br/filmes_detalhes.php?idf=" + str(self.movie_id)
44
 
 
45
 
    def initialize(self):
46
 
        self.page_cast = self.open_page(url = 'http://www.epipoca.com.br/filmes_ficha.php?idf=' + str(self.movie_id))
47
 
 
48
 
    def get_image(self):
49
 
        "Find the film's poster image"
50
 
        tmp_pic = gutils.trim(self.page, "images/filmes/poster/poster_", "\"")
51
 
        self.image_url = \
52
 
            "http://www.epipoca.com.br/images/filmes/poster/poster_" + tmp_pic
53
 
 
54
 
    def get_o_title(self):
55
 
        "Find the film's original title"
56
 
        self.o_title = string.capwords(gutils.trim(self.page, "</font><br>(", ", "))
57
 
 
58
 
    def get_title(self):
59
 
        """Find the film's local title.
60
 
        Probably the original title translation"""
61
 
        self.title = gutils.trim(self.page, "<TITLE>", " (")
62
 
 
63
 
    def get_director(self):
64
 
        "Find the film's director"
65
 
        self.director = gutils.trim(self.page, "<b>Diretor(es): </b>", "</a></td>")
66
 
 
67
 
    def get_plot(self):
68
 
        "Find the film's plot"
69
 
        self.plot = gutils.trim(self.page, "<b>SINOPSE</b></font><br><br>", "</td></tr>")
70
 
 
71
 
    def get_year(self):
72
 
        "Find the film's year"
73
 
        self.year = gutils.trim(self.page, "<a href=\"busca_mais.php?opc=ano&busca=", "\">")
74
 
 
75
 
    def get_runtime(self):
76
 
        "Find the film's running time"
77
 
        self.runtime = gutils.trim(self.page, "<td><b>Dura", " min.</td>")
78
 
        self.runtime = self.runtime[9:]
79
 
 
80
 
    def get_genre(self):
81
 
        "Find the film's genre"
82
 
        self.genre = gutils.trim(self.page, "<a href=\"busca_mais.php?opc=genero&busca=", "\">")
83
 
 
84
 
    def get_cast(self):
85
 
        "Find the actors. Try to make it line separated."
86
 
        self.cast = ""
87
 
        tmp = gutils.trim(self.page_cast, '<b>Elenco / Cast</b>', '</table>')
88
 
        elements = tmp.split('<tr>')
89
 
        for index in range(1, len(elements), 1):
90
 
            element = elements[index]
91
 
            self.cast = self.cast + gutils.strip_tags(element.replace(' ... ', _(' as '))) + '\n'
92
 
 
93
 
    def get_classification(self):
94
 
        "Find the film's classification"
95
 
        self.classification = ""
96
 
 
97
 
    def get_studio(self):
98
 
        "Find the studio"
99
 
        self.studio = gutils.trim(self.page, "<b>Distribuidora(s): </b>", "</a></td>")
100
 
 
101
 
    def get_o_site(self):
102
 
        "Find the film's oficial site"
103
 
        self.o_site = "http://www.epipoca.com.br/filmes_web.php?idf=" + str(self.movie_id)
104
 
 
105
 
    def get_site(self):
106
 
        "Find the film's imdb details page"
107
 
        self.site = "http://www.epipoca.com.br/filmes_ficha.php?idf=" + str(self.movie_id)
108
 
 
109
 
    def get_trailer(self):
110
 
        "Find the film's trailer page or location"
111
 
        self.trailer = "http://www.epipoca.com.br/filmes_trailer.php?idf=" + str(self.movie_id)
112
 
            
113
 
    def get_country(self):
114
 
        "Find the film's country"
115
 
        self.country = gutils.trim(self.page, "<a href=\"busca_mais.php?opc=pais&busca=", "\">")
116
 
 
117
 
    def get_rating(self):
118
 
        """Find the film's rating. From 0 to 10.
119
 
        Convert if needed when assigning."""
120
 
        tmp_rating = gutils.trim(self.page, "<br><b>Cota", " (")
121
 
        tmp_rating = gutils.after(tmp_rating, "</b>")
122
 
        if tmp_rating <> "":
123
 
            tmp_rating = string.replace(tmp_rating,',','.')
124
 
            self.rating = str( float(string.strip(tmp_rating)) )
125
 
        else:
126
 
            self.rating = ""
127
 
 
128
 
    def get_screenplay(self):
129
 
        self.screenplay = gutils.trim(self.page_cast, '<b>Roteirista(s) / Writers</b>', '</table>').replace('</tr><tr>', ', ')
130
 
 
131
 
    def get_cameraman(self):
132
 
        self.cameraman = gutils.trim(self.page_cast, u'<b>Fotógrafo(s) / Cinematographers</b>', u'</table>').replace(u'</tr><tr>', u', ')
133
 
 
134
 
class SearchPlugin(movie.SearchMovie):
135
 
    "A movie search object"
136
 
    def __init__(self):
137
 
        self.original_url_search = \
138
 
            "http://www.epipoca.com.br/busca.php?opc=todos&busca="
139
 
        self.translated_url_search = \
140
 
            "http://www.epipoca.com.br/busca.php?opc=todos&busca="
141
 
        self.encode='iso-8859-1'
142
 
 
143
 
    def search(self, parent_window):
144
 
        "Perform the web search"
145
 
        if not self.open_search(parent_window):
146
 
            return None
147
 
        self.sub_search()
148
 
        return self.page
149
 
 
150
 
    def sub_search(self):
151
 
        "Isolating just a portion (with the data we want) of the results"
152
 
        self.page = gutils.trim(self.page, \
153
 
            "&nbsp;Resul","><b>Not") 
154
 
 
155
 
    def get_searches(self):
156
 
        "Try to find both id and film title for each search result"
157
 
        elements = string.split(self.page, "<td width=\"55\" align=\"center\" bgcolor=")
158
 
        self.number_results = elements[-1]
159
 
 
160
 
        if (elements[0] != ''):
161
 
            for element in elements:
162
 
                self.ids.append(gutils.trim(element, "<a href=\"filmes_detalhes.php?idf=", "\">"))
163
 
                self.titles.append(gutils.strip_tags(gutils.trim(element, "<font class=\"titulo\">", "<b>Adicionar aos meus filmes favoritos</b>") ))
164
 
        else:
165
 
            self.number_results = 0
166
 
 
167
 
#
168
 
# Plugin Test
169
 
#
170
 
class SearchPluginTest(SearchPlugin):
171
 
    #
172
 
    # Configuration for automated tests:
173
 
    # dict { movie_id -> [ expected result count for original url, expected result count for translated url ] }
174
 
    #
175
 
    test_configuration = {
176
 
        'Rocky Balboa' : [ 7, 7 ],
177
 
    }
178
 
 
179
 
class PluginTest:
180
 
    #
181
 
    # Configuration for automated tests:
182
 
    # dict { movie_id -> dict { arribute -> value } }
183
 
    #
184
 
    # value: * True/False if attribute only should be tested for any value
185
 
    #        * or the expected value
186
 
    #
187
 
    test_configuration = {
188
 
        '11521' : { 
189
 
            'title'               : 'Rocky Balboa',
190
 
            'o_title'             : 'Rocky Balboa',
191
 
            'director'            : 'Sylvester Stallone',
192
 
            'plot'                : True,
193
 
            'cast'                : 'Sylvester Stallone' + _(' as ') + 'Rocky Balboa\n\
194
 
Burt Young' + _(' as ') + 'Paulie\n\
195
 
Antonio Tarver' + _(' as ') + 'Mason \'The Line\' Dixon\n\
196
 
Geraldine Hughes' + _(' as ') + 'Marie\n\
197
 
Milo Ventimiglia' + _(' as ') + 'Robert Jr.\n\
198
 
Tony Burton' + _(' as ') + 'Duke\n\
199
 
A.J. Benza' + _(' as ') + 'L.C.\n\
200
 
James Francis Kelly III' + _(' as ') + 'Steps\n\
201
 
Talia Shire' + _(' as ') + 'Adrian (imagens de arquivo)\n\
202
 
Lou DiBella' + _(' as ') + 'Lou DiBella\n\
203
 
Mike Tyson (1)' + _(' as ') + 'Mike Tyson\n\
204
 
Henry G. Sanders' + _(' as ') + 'Martin\n\
205
 
Pedro Lovell' + _(' as ') + 'Spider Rico\n\
206
 
Ana Gerena' + _(' as ') + 'Isabel\n\
207
 
Angela Boyd' + _(' as ') + 'Angie\n\
208
 
Louis Giansante' + _(' as ') + 'Bandido do bar\n\
209
 
Maureen Schilling' + _(' as ') + 'Bartender do Lucky\n\
210
 
Lahmard Tate¹' + _(' as ') + 'X-Cell\n\
211
 
Woodrow W. Paige¹' + _(' as ') + 'Comentarista da ESPN\n\
212
 
Skip Bayless' + _(' as ') + 'Comentarista da ESPN\n\
213
 
Jay Crawford' + _(' as ') + 'Comentarista da ESPN\n\
214
 
Brian Kenny' + _(' as ') + 'Apresentador da ESPN\n\
215
 
Dana Jacobson' + _(' as ') + 'Apresentador da ESPN\n\
216
 
Chuck Johnson¹' + _(' as ') + 'Apresentador da ESPN\n\
217
 
James Binns' + _(' as ') + 'Comissário\n\
218
 
Johnnie Hobbs Jr.' + _(' as ') + 'Comissário\n\
219
 
Barney Fitzpatrick' + _(' as ') + 'Comissário\n\
220
 
Jim Lampley' + _(' as ') + 'Comentarista da HBO\n\
221
 
Larry Merchant' + _(' as ') + 'Comentarista da HBO\n\
222
 
Max Kellerman' + _(' as ') + 'Comentarista da HBO\n\
223
 
LeRoy Neiman' + _(' as ') + 'LeRoy Neiman\n\
224
 
Bert Randolph Sugar' + _(' as ') + 'Repórter da Ring Magazine\n\
225
 
Bernard Fernández' + _(' as ') + 'Articulista da Boxing Association of America\n\
226
 
Gunnar Peterson' + _(' as ') + 'Treinador de levantamento de peso\n\
227
 
Yahya' + _(' as ') + 'Oponente de Dixon\n\
228
 
Marc Ratner (1)' + _(' as ') + 'Oficial de luta\n\
229
 
Anthony Lato Jr.' + _(' as ') + 'Inspetor de Rocky\n\
230
 
Jack Lazzarado' + _(' as ') + 'Inspetor de Dixon\n\
231
 
Michael Buffer' + _(' as ') + 'Anunciador de luta\n\
232
 
Joe Cortez' + _(' as ') + 'Árbitro\n\
233
 
Carter Mitchell' + _(' as ') + 'Shamrock Foreman\n\
234
 
Vinod Kumar (1)' + _(' as ') + 'Ravi\n\
235
 
Fran Pultro' + _(' as ') + 'Pai no restaurante\n\
236
 
Frank Stallone Jr.¹' + _(' as ') + 'Cliente do restaurante\n\
237
 
Jody Giambelluca' + _(' as ') + 'Cliente do restaurante\n\
238
 
Tobias Segal' + _(' as ') + 'Amigo de Robert\n\
239
 
Tim Carr' + _(' as ') + 'Amigo de Robert\n\
240
 
Matt Frack' + _(' as ') + 'Amigo de Robert\n\
241
 
Paul Dion Monte' + _(' as ') + 'Amigo de Robert\n\
242
 
Kevin King Templeton' + _(' as ') + 'Amigo de Robert\n\
243
 
Robert Michael Kelly' + _(' as ') + 'Senhor Tomilson\n\
244
 
Rick Buchborn' + _(' as ') + 'Fã de Rocky\n\
245
 
Nick Baker' + _(' as ') + 'Bartender do pub irlandês\n\
246
 
Don Sherman' + _(' as ') + 'Andy\n\
247
 
Stu Nahan' + _(' as ') + 'Comentarista da luta pelo computador\n\
248
 
Gary Compton' + _(' as ') + 'Segurança\n\
249
 
Ricky Cavazos' + _(' as ') + 'Espectador da luta (não creditado)\n\
250
 
Dolph Lundgren' + _(' as ') + 'Capitão Ivan Drago (imagens de arquivo) (não creditado)\n\
251
 
Burgess Meredith' + _(' as ') + 'Mickey (imagens de arquivo) (não creditado)\n\
252
 
Mr. T' + _(' as ') + 'Clubber Lang (imagens de arquivo) (não creditado)\n\
253
 
Carl Weathers' + _(' as ') + 'Apollo Creed (imagens de arquivo) (não creditado)',
254
 
            'country'             : 'EUA',
255
 
            'genre'               : 'Ação',
256
 
            'classification'      : False,
257
 
            'studio'              : 'Fox Film',
258
 
            'o_site'              : 'http://www.epipoca.com.br/filmes_web.php?idf=11521',
259
 
            'site'                : 'http://www.epipoca.com.br/filmes_ficha.php?idf=11521',
260
 
            'trailer'             : 'http://www.epipoca.com.br/filmes_trailer.php?idf=11521',
261
 
            'year'                : 2006,
262
 
            'notes'               : False,
263
 
            'runtime'             : 102,
264
 
            'image'               : True,
265
 
            'rating'              : 9,
266
 
            'cameraman'           : 'J. Clark Mathis',
267
 
            'screenplay'          : 'Sylvester Stallone ... Escrito por, Sylvester Stallone ... Personagens',
268
 
            'barcode'             : False
269
 
        },
270
 
    }