[totem] opensubtitles: Make decoding download items work
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] opensubtitles: Make decoding download items work
- Date: Thu, 30 Jan 2014 10:51:06 +0000 (UTC)
commit 9d6a14fc25515772048ef07a2dc7343241277a43
Author: Bastien Nocera <hadess hadess net>
Date: Thu Jan 30 11:48:56 2014 +0100
opensubtitles: Make decoding download items work
Stop using StringIO, gzip and base64 modules, and use GLib for
the base64 decoding, and zlib for the decompression.
https://bugzilla.gnome.org/show_bug.cgi?id=723074
src/plugins/opensubtitles/opensubtitles.py | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
---
diff --git a/src/plugins/opensubtitles/opensubtitles.py b/src/plugins/opensubtitles/opensubtitles.py
index 111b68e..1d98404 100644
--- a/src/plugins/opensubtitles/opensubtitles.py
+++ b/src/plugins/opensubtitles/opensubtitles.py
@@ -6,6 +6,7 @@ from gi.repository import Gio, Pango, Totem # pylint: disable-msg=E0611
import xmlrpc.client
import threading
+import zlib
from os import sep, path, mkdir
import gettext
@@ -354,14 +355,11 @@ class OpenSubtitlesModel (object):
self._lock.release ()
return (None, error_message)
- import StringIO, gzip, base64
- subtitle_decoded = base64.decodestring (subtitle64)
- subtitle_gzipped = StringIO.StringIO (subtitle_decoded)
- subtitle_gzipped_file = gzip.GzipFile (fileobj=subtitle_gzipped)
+ subtitle_unzipped = zlib.decompress(GLib.base64_decode (subtitle64), 47)
self._lock.release ()
- return (subtitle_gzipped_file.read (), message)
+ return (subtitle_unzipped, message)
else:
message = log_in_message
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]