[totem] opensubtitles: Make the hash and size parameters of the SearchThread
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] opensubtitles: Make the hash and size parameters of the SearchThread
- Date: Sat, 9 Apr 2011 14:12:25 +0000 (UTC)
commit a2ab4da3308d7e79747f4847d925625a6ddc4472
Author: Philip Withnall <philip tecnocode co uk>
Date: Sat Apr 9 15:05:58 2011 +0100
opensubtitles: Make the hash and size parameters of the SearchThread
They don't belong as instance variables of the OpenSubtitlesModel.
src/plugins/opensubtitles/opensubtitles.py | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/src/plugins/opensubtitles/opensubtitles.py b/src/plugins/opensubtitles/opensubtitles.py
index b81417a..8a1e287 100644
--- a/src/plugins/opensubtitles/opensubtitles.py
+++ b/src/plugins/opensubtitles/opensubtitles.py
@@ -145,8 +145,10 @@ class SearchThread (threading.Thread):
"""
This is the thread started when the dialog is searching for subtitles
"""
- def __init__ (self, model):
+ def __init__ (self, model, movie_hash, movie_size):
self._model = model
+ self._movie_hash = movie_hash
+ self._movie_size = movie_size
self._done = False
self._results = []
self._lock = threading.Lock ()
@@ -155,7 +157,9 @@ class SearchThread (threading.Thread):
def run (self):
self._lock.acquire (True)
- (self._results, self._message) = self._model.search_subtitles ()
+ (self._results,
+ self._message) = self._model.search_subtitles (self._movie_hash,
+ self._movie_size)
self._done = True
self._lock.release ()
@@ -252,9 +256,6 @@ class OpenSubtitlesModel (object):
except (ImportError, IndexError, AttributeError):
self.lang = 'eng'
- self.hash = None
- self.size = 0
-
self._lock = threading.Lock ()
def _log_in (self, username='', password=''):
@@ -304,7 +305,7 @@ class OpenSubtitlesModel (object):
return result
- def search_subtitles (self):
+ def search_subtitles (self, movie_hash, movie_size):
self._lock.acquire (True)
message = ''
@@ -313,8 +314,8 @@ class OpenSubtitlesModel (object):
if log_in_success:
searchdata = {'sublanguageid': self.lang,
- 'moviehash' : self.hash,
- 'moviebytesize': str (self.size)}
+ 'moviehash' : movie_hash,
+ 'moviebytesize': str (movie_size)}
try:
result = self._server.SearchSubtitles (self._token,
[searchdata])
@@ -573,7 +574,7 @@ class OpenSubtitles (GObject.Object, Peas.Activatable):
self._manager.remove_action_group (self._action_group)
self._manager.remove_ui (self._menu_id)
- def _get_results (self):
+ def _get_results (self, movie_hash, movie_size):
self._list_store.clear ()
self._tree_view.set_headers_visible (False)
self._apply_button.set_sensitive (False)
@@ -582,7 +583,7 @@ class OpenSubtitles (GObject.Object, Peas.Activatable):
cursor = Gdk.Cursor.new (Gdk.CursorType.WATCH)
self._dialog.get_window ().set_cursor (cursor)
- thread = SearchThread (self._model)
+ thread = SearchThread (self._model, movie_hash, movie_size)
thread.start ()
GObject.idle_add (self._populate_treeview, thread)
@@ -771,7 +772,7 @@ class OpenSubtitles (GObject.Object, Peas.Activatable):
self._apply_button.set_sensitive (False)
self._find_button.set_sensitive (False)
self._filename = self._totem.get_current_mrl ()
- self._model.hash , self._model.size = hash_file (self._filename)
+ (movie_hash, movie_size) = hash_file (self._filename)
- self._get_results ()
+ self._get_results (movie_hash, movie_size)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]