~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/PluginMoviePTGate.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: PluginMoviePTGate.py 1154 2009-02-08 23:20:39Z piotrek $'
4
 
 
5
 
# Copyright (c) 2005-2009 Vasco Nunes, Piotr Ozarowski
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
 
import gutils
25
 
import movie
26
 
import string
27
 
import re
28
 
 
29
 
plugin_name         = "PTGate"
30
 
plugin_description  = "Cinema PTGate"
31
 
plugin_url          = "cinema.ptgate.pt"
32
 
plugin_language     = _("Portuguese")
33
 
plugin_author       = "Vasco Nunes"
34
 
plugin_author_email = "<vasco.m.nunes@gmail.com>"
35
 
plugin_version      = "0.5"
36
 
 
37
 
class Plugin(movie.Movie):
38
 
    def __init__(self, id):
39
 
        self.encode   ='iso-8859-1'
40
 
        self.movie_id = id
41
 
        self.url      = "http://cinema.ptgate.pt/filmes/" + str(self.movie_id)
42
 
 
43
 
    def initialize(self):
44
 
        self.page = gutils.convert_entities(self.page)
45
 
        self.page = self.page.replace(u'\x93', u'"')
46
 
        self.page = self.page.replace(u'\x94', u'"')
47
 
        self.page = self.page.replace(u'\x96', u'-')
48
 
 
49
 
    def get_image(self):
50
 
        self.image_url = 'http://cinema.ptgate.pt/Movies/' + str(self.movie_id) + '.jpg'
51
 
 
52
 
    def get_o_title(self):
53
 
        self.o_title = gutils.trim(gutils.after(self.page, u'<h2>'), u'›', u'<br />') # <--  &#8250;
54
 
        self.o_title = self.o_title.encode(self.encode)
55
 
 
56
 
    def get_title(self):
57
 
        self.title = gutils.trim(self.page, u'<h2>', u'</h2>')
58
 
        self.title = self.title.encode(self.encode)
59
 
 
60
 
    def get_director(self):
61
 
        self.director = gutils.trim(self.page, u'<b>realização</b><br />', u'<br />')
62
 
        self.director = self.director.encode(self.encode)
63
 
 
64
 
    def get_plot(self):
65
 
        self.plot = gutils.trim(self.page, u'<b>sinopse</b><br />', u'<br />')
66
 
        self.plot = self.plot.encode(self.encode)
67
 
        self.plot = string.replace(self.plot, "'", "\"")
68
 
        self.plot = string.replace(self.plot, "'", "\"")
69
 
 
70
 
    def get_year(self):
71
 
        self.year = gutils.trim(self.page, u'<b>ano</b>: ', u'<br />')
72
 
 
73
 
    def get_runtime(self):
74
 
        self.runtime = ''
75
 
 
76
 
    def get_genre(self):
77
 
        self.genre = gutils.trim(self.page, u'<b>género</b>: ', u'<br />')
78
 
        self.genre = self.genre.encode(self.encode)
79
 
 
80
 
    def get_cast(self):
81
 
        self.cast = gutils.trim(self.page, u'pretes</b><br />', u'<br />')
82
 
        self.cast = gutils.strip_tags(self.cast)
83
 
        self.cast = string.replace(self.cast, ', ', '\n')
84
 
 
85
 
    def get_classification(self):
86
 
        self.classification = ''
87
 
 
88
 
    def get_studio(self):
89
 
        self.studio = ''
90
 
 
91
 
    def get_o_site(self):
92
 
        self.o_site = ''
93
 
        tmp = string.find(self.page, u'(site oficial)')
94
 
        if tmp >= 0:
95
 
            index = string.rfind(self.page[:tmp], u'<a href="')
96
 
            if index >= 0:
97
 
                self.o_site = gutils.before(self.page[index + 9:], '"')
98
 
 
99
 
    def get_site(self):
100
 
        self.site = ''
101
 
        tmp = string.find(self.page, u'www.imdb.com/title/')
102
 
        if tmp >= 0:
103
 
            self.site = u'http://www.imdb.com/title/' + gutils.before(self.page[tmp:], '"')
104
 
 
105
 
    def get_trailer(self):
106
 
        self.trailer = ''
107
 
        tmp = string.find(self.page, u'(trailers)')
108
 
        if tmp >= 0:
109
 
            index = string.rfind(self.page[:tmp], u'<a href="')
110
 
            if index >= 0:
111
 
                self.trailer = gutils.before(self.page[index + 9:], '"')
112
 
 
113
 
    def get_country(self):
114
 
        self.country = gutils.trim(self.page, u'<b>país</b>: ', '<br />')
115
 
        self.country = self.country.encode(self.encode)
116
 
        
117
 
    def get_notes(self):
118
 
        self.notes = gutils.trim(self.page,"prémios e nomeações</b><br /><b>", "<td width=6 background='Images/group_r.gif'")
119
 
        self.notes = gutils.strip_tags(self.notes)
120
 
 
121
 
    def get_rating(self):
122
 
        tmp = re.findall('[0-9.]+', string.replace(gutils.clean('<' + gutils.trim(self.page, u'imgs/blank.gif"', u'</small>')), u'&nbsp;', ''))
123
 
        if tmp and len(tmp) > 0:
124
 
            self.rating = float(tmp[0])
125
 
            if self.rating:
126
 
                self.rating = round(self.rating * 2)
127
 
        else:
128
 
            self.rating = ''
129
 
 
130
 
class SearchPlugin(movie.SearchMovie):
131
 
    def __init__(self):
132
 
        self.original_url_search   = 'http://cinema.ptgate.pt/pesquisa/?q='
133
 
        self.translated_url_search = 'http://cinema.ptgate.pt/pesquisa/?q='
134
 
        self.encode                = 'iso-8859-1'
135
 
 
136
 
    def search(self,parent_window):
137
 
        self.open_search(parent_window)
138
 
        return self.page
139
 
 
140
 
    def get_searches(self):
141
 
        elements = string.split(self.page, '<a href="/filmes/')
142
 
        self.number_results = elements[-1]
143
 
 
144
 
        if len(elements[0]):
145
 
            for element in elements:
146
 
                id = gutils.digits_only(gutils.before(element, '"'))
147
 
                title = gutils.clean(re.sub('</div>.*', '', string.replace(gutils.before(gutils.after(element, '>'), '</small>'), '<small>', ' / ')))
148
 
                if id and title and title[0] != '<':
149
 
                    self.ids.append(id)
150
 
                    self.titles.append(gutils.convert_entities(title))
151
 
        else:
152
 
            self.number_results = 0