1 # -*- coding: utf-8 -*-
3 ###########################################################################
5 # Copyright (C) 2010 Simón Pena <spenap@gmail.com>
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 3 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 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, see <http://www.gnu.org/licenses/>.
19 ###########################################################################
27 gobject.threads_init()
30 MINFO_PROVIDER_INTERFACE = 'com.simonpena.maevies.minfoprovider'
31 MINFO_PROVIDER_BUS_NAME = 'com.simonpena.maevies.minfoprovider'
32 TMDB_MOVIE_INTERFACE = 'com.simonpena.maevies.movie'
33 TMDB_MOVIE_BUS_NAME = 'com.simonpena.maevies.tmdbmovie'
39 def __init__(self, callback):
40 self.bus = dbus.SessionBus()
42 self.minfo_provider = self.bus.get_object(MINFO_PROVIDER_BUS_NAME,
44 self.minfo_interface = dbus.Interface(self.minfo_provider,
45 dbus_interface = MINFO_PROVIDER_INTERFACE)
46 self.minfo_interface.connect_to_signal("ResponseReceived",
47 self._on_response_received)
48 self.callback = callback
50 def query(self, movie_name = '', query_type = TMDB):
51 self.minfo_interface.Query(query_type, movie_name)
53 def _on_response_received(self, object_paths, sender = None):
55 for path in object_paths:
56 movies.append(self._create_from_path(path))
60 def _create_from_path(self, object_path):
61 dbus_movie = self.bus.get_object(TMDB_MOVIE_BUS_NAME,
63 return MovieDecorator(dbus_movie.GetTitle(dbus_interface = TMDB_MOVIE_INTERFACE))
67 def __init__(self, name):
75 return "%sh:%sm" % (random.randrange(1, 2), random.randrange(0, 59))
78 return "%s" % (random.randrange(6, 9))
81 return "<b>%s</b>\n<small><i>Length: </i>%s || <i>Score: </i>%s</small>" % (
87 return self._get_placeholder_pixbuf()
89 def _get_placeholder_pixbuf(self):
90 pixbuf = gtk.IconTheme().load_icon('general_video_file', 48, 0)