1
# -*- coding: UTF-8 -*-
3
__revision__ = '$Id: PluginMovieAllRovi.py 1605 2011-12-18 22:35:25Z piotrek $'
5
# Copyright (c) 2009-2011
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.
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.
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
21
# You may use and distribute this software under the terms of the
22
# GNU General Public License, version 2 or later
29
plugin_description = "rovi"
30
plugin_url = "www.allrovi.com"
31
plugin_language = _("English")
32
plugin_author = "Michael Jahn"
33
plugin_author_email = "griffith@griffith.cc"
34
plugin_version = "2.0"
36
class Plugin(movie.Movie):
37
def __init__(self, id):
40
self.url = 'http://www.allrovi.com/movies/movie/' + str(self.movie_id)
43
self.page_cast = self.open_page(url = 'http://www.allrovi.com/movies/movie/' + str(self.movie_id) + '/cast_crew')
46
self.image_url = gutils.trim(self.page, '<img class="cover-art" src="', '"')
48
def get_o_title(self):
49
self.o_title = gutils.regextrim(self.page, '<div class="page-heading">', '(</div>|<span>)')
52
self.title = gutils.regextrim(self.page, '<div class="page-heading">', '(</div>|<span>)')
54
def get_director(self):
55
self.director = gutils.trim(self.page, '<dt>directed by</dt>', '</ul>')
58
self.plot = gutils.trim(self.page, '>synopsis', '</p>')
61
self.year = gutils.after(gutils.trim(self.page, '<dt>release date</dt>', '</div>'), ',')
63
def get_runtime(self):
67
self.genre = gutils.trim(self.page, '<dt>genres</dt>', '</ul>')
71
tmp = gutils.trim(self.page_cast, '<h2>cast</h2>', '</table>')
72
elements = string.split(tmp, '<td class="name">')
73
for element in elements:
74
element = string.replace(element, '</a>', '$$$')
75
self.cast = self.cast + string.replace(re.sub('[$][$][$]$', '', re.sub('[ ]+', ' ', string.replace(gutils.clean(element), '\n', ''))), '$$$', _(' as ')) + '\n'
77
def get_classification(self):
78
self.classification = ''
81
self.studio = gutils.regextrim(self.page, '<dt>produced by</dt>', '(</div>|<dt>)')
89
def get_trailer(self):
92
def get_country(self):
93
self.country = gutils.regextrim(self.page, '<dt>countries</dt>', '(</div>|<dt>)')
96
self.rating = (len(string.split(gutils.trim(self.page, '<dt>rovi rating</dt>', '</div>'), '"star full"')) - 1) * 2
101
def get_cameraman(self):
103
tmp = gutils.trim(self.page_cast, '<h2>crew</h2>', '</dl>')
104
elements = string.split(tmp, '<dt>')
105
for element in elements:
106
if string.find(element, 'Cinematographer') > 0:
107
self.cameraman = gutils.clean(gutils.before(element, '</a>'))
109
def get_screenplay(self):
111
tmp = gutils.trim(self.page_cast, '<h2>crew</h2>', '</dl>')
112
elements = string.split(tmp, '<dt>')
113
for element in elements:
114
if string.find(element, 'Screenwriter') > 0:
115
self.screenplay = gutils.clean(gutils.before(element, '</a>'))
117
def get_barcode(self):
121
class SearchPlugin(movie.SearchMovie):
123
self.original_url_search = "http://www.allrovi.com/search/ajax_more_results/movies/%s/0/100"
124
self.translated_url_search = "http://www.allrovi.com/search/ajax_more_results/movies/%s/0/100"
125
self.encode = 'utf-8'
127
def search(self,parent_window):
128
if not self.open_search(parent_window):
132
def get_searches(self):
133
elements = re.split('<tr>', self.page)
134
for index in range(1, len(elements), 1):
135
element = elements[index]
136
titleandid = gutils.trim(element, '<td class="title">', '</td>')
137
title = gutils.clean(titleandid)
138
id = gutils.trim(titleandid, 'href="', '"')
139
idstart = string.rfind(id, '/')
140
id = id[idstart + 1:]
141
year = gutils.trim(element, '<td class="year">', '</td>')
143
self.titles.append(title + ' (' + gutils.clean(year)+ ')')
148
class SearchPluginTest(SearchPlugin):
150
# Configuration for automated tests:
151
# dict { movie_id -> [ expected result count for original url, expected result count for translated url ] }
153
test_configuration = {
154
'Rocky' : [ 57, 57 ],
159
# Configuration for automated tests:
160
# dict { movie_id -> dict { arribute -> value } }
162
# value: * True/False if attribute only should be tested for any value
163
# * or the expected value
165
test_configuration = {
166
'rocky-balboa-v337682' : {
167
'title' : 'Rocky Balboa',
168
'o_title' : 'Rocky Balboa',
169
'director' : 'Sylvester Stallone',
171
'cast' : 'Sylvester Stallone' + _(' as ') + ' Rocky Balboa\n\
172
Burt Young' + _(' as ') + ' Paulie\n\
173
Antonio Tarver' + _(' as ') + ' Mason "The Line" Dixon\n\
174
Geraldine Hughes' + _(' as ') + ' Marie\n\
175
Milo Ventimiglia' + _(' as ') + ' Rocky Balboa Jr.\n\
176
Tony Burton' + _(' as ') + ' Duke\n\
177
A.J. Benza' + _(' as ') + ' L.C.\n\
178
James Francis Kelly III' + _(' as ') + ' Steps\n\
180
Mike Tyson' + _(' as ') + ' Himself\n\
191
Bert Randolph Sugar\n\
197
'classification' : False,
198
'studio' : 'Columbia Pictures, MGM, Revolution Studios, Chartoff Winkler Productions',
200
'site' : 'http://www.allrovi.com/movies/movie/rocky-balboa-v337682',
207
'cameraman' : 'Clark Mathis',
208
'screenplay' : 'Sylvester Stallone',