693 lines
28 KiB
Diff
693 lines
28 KiB
Diff
From 5a4827ec34892ec99448233202fadec32448c7d7 Mon Sep 17 00:00:00 2001
|
||
From: leigh123linux <leigh123linux@googlemail.com>
|
||
Date: Sat, 12 May 2018 10:16:27 +0100
|
||
Subject: [PATCH 1/9] Load python3 loader
|
||
|
||
---
|
||
src/plugins/xplayer-plugins-engine.c | 2 +-
|
||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||
|
||
diff --git a/src/plugins/xplayer-plugins-engine.c b/src/plugins/xplayer-plugins-engine.c
|
||
index 0b0c827..42345a0 100644
|
||
--- a/src/plugins/xplayer-plugins-engine.c
|
||
+++ b/src/plugins/xplayer-plugins-engine.c
|
||
@@ -121,7 +121,7 @@ xplayer_plugins_engine_get_default (XplayerObject *xplayer)
|
||
}
|
||
g_strfreev (paths);
|
||
|
||
- peas_engine_enable_loader (PEAS_ENGINE (engine), "python");
|
||
+ peas_engine_enable_loader (PEAS_ENGINE (engine), "python3");
|
||
|
||
g_object_add_weak_pointer (G_OBJECT (engine),
|
||
(gpointer) &engine);
|
||
|
||
From 76b87191a3e885e1c5170ce5a461f18b44e6be13 Mon Sep 17 00:00:00 2001
|
||
From: leigh123linux <leigh123linux@googlemail.com>
|
||
Date: Sat, 12 May 2018 10:19:28 +0100
|
||
Subject: [PATCH 2/9] Port dbusservice to python3
|
||
|
||
---
|
||
src/plugins/dbusservice/dbusservice.plugin.in | 2 +-
|
||
src/plugins/dbusservice/dbusservice.py | 10 +++++-----
|
||
2 files changed, 6 insertions(+), 6 deletions(-)
|
||
|
||
diff --git a/src/plugins/dbusservice/dbusservice.plugin.in b/src/plugins/dbusservice/dbusservice.plugin.in
|
||
index 68e5fc1..30d9ca7 100644
|
||
--- a/src/plugins/dbusservice/dbusservice.plugin.in
|
||
+++ b/src/plugins/dbusservice/dbusservice.plugin.in
|
||
@@ -1,5 +1,5 @@
|
||
[Plugin]
|
||
-Loader=python
|
||
+Loader=python3
|
||
Module=dbusservice
|
||
IAge=1
|
||
_Name=D-Bus Service
|
||
diff --git a/src/plugins/dbusservice/dbusservice.py b/src/plugins/dbusservice/dbusservice.py
|
||
index 552212c..24fc5c2 100644
|
||
--- a/src/plugins/dbusservice/dbusservice.py
|
||
+++ b/src/plugins/dbusservice/dbusservice.py
|
||
@@ -94,7 +94,7 @@ def __calculate_metadata (self):
|
||
'mpris:trackid': dbus.String (self.xplayer.props.current_mrl,
|
||
variant_level = 1),
|
||
'mpris:length': dbus.Int64 (
|
||
- self.xplayer.props.stream_length * 1000L,
|
||
+ self.xplayer.props.stream_length * 1000,
|
||
variant_level = 1),
|
||
}
|
||
|
||
@@ -152,7 +152,7 @@ def __do_notify_seekable (self, xplayer, prop):
|
||
def __do_notify_current_time (self, xplayer, prop):
|
||
# Only notify of seeks if we've skipped more than 3 seconds
|
||
if abs (xplayer.props.current_time - self.current_position) > 3:
|
||
- self.Seeked (xplayer.props.current_time * 1000L)
|
||
+ self.Seeked (xplayer.props.current_time * 1000)
|
||
|
||
self.current_position = xplayer.props.current_time
|
||
|
||
@@ -198,7 +198,7 @@ def GetAll (self, interface_name):
|
||
'Shuffle': shuffle, # TODO: Notifications
|
||
'Metadata': self.__calculate_metadata (),
|
||
'Volume': self.xplayer.get_volume (), # TODO: Notifications
|
||
- 'Position': self.xplayer.props.current_time * 1000L,
|
||
+ 'Position': self.xplayer.props.current_time * 1000,
|
||
'CanGoNext': True, # TODO
|
||
'CanGoPrevious': True, # TODO
|
||
'CanPlay': (self.xplayer.props.current_mrl != None),
|
||
@@ -315,13 +315,13 @@ def Play (self):
|
||
in_signature = 'x', # pylint: disable-msg=C0103
|
||
out_signature = '')
|
||
def Seek (self, offset):
|
||
- self.xplayer.action_seek_relative (offset / 1000L, False)
|
||
+ self.xplayer.action_seek_relative (offset / 1000, False)
|
||
|
||
@dbus.service.method (dbus_interface = 'org.mpris.MediaPlayer2.Player',
|
||
in_signature = 'ox', # pylint: disable-msg=C0103
|
||
out_signature = '')
|
||
def SetPosition (self, track_id, position):
|
||
- position = position / 1000L
|
||
+ position = position / 1000
|
||
|
||
# Bail if the position is not in the permitted range
|
||
if position < 0 or position > self.xplayer.props.stream_length:
|
||
|
||
From 8028cb2f2808a9dcc09e37afed06e8c38b7befc7 Mon Sep 17 00:00:00 2001
|
||
From: leigh123linux <leigh123linux@googlemail.com>
|
||
Date: Sat, 12 May 2018 10:29:01 +0100
|
||
Subject: [PATCH 3/9] Port opensubtitles to python3
|
||
|
||
---
|
||
src/plugins/opensubtitles/hash.py | 6 ++---
|
||
.../opensubtitles/opensubtitles.plugin.in | 2 +-
|
||
src/plugins/opensubtitles/opensubtitles.py | 22 +++++++++----------
|
||
3 files changed, 14 insertions(+), 16 deletions(-)
|
||
|
||
diff --git a/src/plugins/opensubtitles/hash.py b/src/plugins/opensubtitles/hash.py
|
||
index 26aa0d9..aac056a 100644
|
||
--- a/src/plugins/opensubtitles/hash.py
|
||
+++ b/src/plugins/opensubtitles/hash.py
|
||
@@ -21,9 +21,9 @@ def hash_file (name):
|
||
if filesize < 65536 * 2:
|
||
return SIZE_ERROR, 0
|
||
|
||
- file_handle = file (file_to_hash.get_path (), "rb")
|
||
+ file_handle = open (file_to_hash.get_path (), "rb")
|
||
|
||
- for _ in range (65536 / bytesize):
|
||
+ for _ in range(int(65536 / bytesize)):
|
||
buf = file_handle.read (bytesize)
|
||
(l_value,) = struct.unpack (longlongformat, buf)
|
||
file_hash += l_value
|
||
@@ -34,7 +34,7 @@ def hash_file (name):
|
||
if file_handle.tell() != max (0, filesize - 65536):
|
||
return SEEK_ERROR, 0
|
||
|
||
- for _ in range (65536/bytesize):
|
||
+ for _ in range(int(65536/bytesize)):
|
||
buf = file_handle.read (bytesize)
|
||
(l_value,) = struct.unpack (longlongformat, buf)
|
||
file_hash += l_value
|
||
diff --git a/src/plugins/opensubtitles/opensubtitles.plugin.in b/src/plugins/opensubtitles/opensubtitles.plugin.in
|
||
index c348a94..4df9c33 100644
|
||
--- a/src/plugins/opensubtitles/opensubtitles.plugin.in
|
||
+++ b/src/plugins/opensubtitles/opensubtitles.plugin.in
|
||
@@ -1,5 +1,5 @@
|
||
[Plugin]
|
||
-Loader=python
|
||
+Loader=python3
|
||
Module=opensubtitles
|
||
IAge=1
|
||
_Name=Subtitle Downloader
|
||
diff --git a/src/plugins/opensubtitles/opensubtitles.py b/src/plugins/opensubtitles/opensubtitles.py
|
||
index b81aa80..44e56c4 100644
|
||
--- a/src/plugins/opensubtitles/opensubtitles.py
|
||
+++ b/src/plugins/opensubtitles/opensubtitles.py
|
||
@@ -1,9 +1,9 @@
|
||
# -*- coding: utf-8 -*-
|
||
|
||
-from gi.repository import GObject, Peas, Gtk, Gdk # pylint: disable-msg=E0611
|
||
-from gi.repository import GLib, Gio, Pango, Xplayer # pylint: disable-msg=E0611
|
||
+from gi.repository import GLib, GObject, Peas, Gtk, Gdk # pylint: disable-msg=E0611
|
||
+from gi.repository import Gio, Pango, Xplayer # pylint: disable-msg=E0611
|
||
|
||
-import xmlrpclib
|
||
+import xmlrpc.client
|
||
import threading
|
||
import xdg.BaseDirectory
|
||
from os import sep, path, mkdir
|
||
@@ -16,8 +16,6 @@
|
||
D_ = gettext.dgettext
|
||
_ = gettext.gettext
|
||
|
||
-GObject.threads_init ()
|
||
-
|
||
USER_AGENT = 'Xplayer'
|
||
OK200 = '200 OK'
|
||
XPLAYER_REMOTE_COMMAND_REPLACE = 14
|
||
@@ -273,7 +271,7 @@ def _log_in (self, username='', password=''):
|
||
# We have already logged-in before, check the connection
|
||
try:
|
||
result = self._server.NoOperation (self._token)
|
||
- except (xmlrpclib.Fault, xmlrpclib.ProtocolError):
|
||
+ except (xmlrpc.client.Fault, xmlrpc.client.ProtocolError):
|
||
pass
|
||
if result and result['status'] != OK200:
|
||
return (True, '')
|
||
@@ -281,7 +279,7 @@ def _log_in (self, username='', password=''):
|
||
try:
|
||
result = self._server.LogIn (username, password, self.lang,
|
||
USER_AGENT)
|
||
- except (xmlrpclib.Fault, xmlrpclib.ProtocolError):
|
||
+ except (xmlrpc.client.Fault, xmlrpc.client.ProtocolError):
|
||
pass
|
||
|
||
if result and result.get ('status') == OK200:
|
||
@@ -321,7 +319,7 @@ def search_subtitles (self, movie_hash, movie_size):
|
||
try:
|
||
result = self._server.SearchSubtitles (self._token,
|
||
[searchdata])
|
||
- except xmlrpclib.ProtocolError:
|
||
+ except xmlrpc.client.ProtocolError:
|
||
message = _(u'Could not contact the OpenSubtitles website.')
|
||
|
||
if result.get ('data'):
|
||
@@ -348,7 +346,7 @@ def download_subtitles (self, subtitle_id):
|
||
try:
|
||
result = self._server.DownloadSubtitles (self._token,
|
||
[subtitle_id])
|
||
- except xmlrpclib.ProtocolError:
|
||
+ except xmlrpc.client.ProtocolError:
|
||
message = error_message
|
||
|
||
if result and result.get ('status') == OK200:
|
||
@@ -424,7 +422,7 @@ def do_activate (self):
|
||
self._xplayer.connect ('file-closed', self.__on_xplayer__file_closed)
|
||
|
||
# Obtain the ServerProxy and init the model
|
||
- server = xmlrpclib.Server ('http://api.opensubtitles.org/xml-rpc')
|
||
+ server = xmlrpc.client.Server ('http://api.opensubtitles.org/xml-rpc')
|
||
self._model = OpenSubtitlesModel (server)
|
||
|
||
def do_deactivate (self):
|
||
@@ -586,10 +584,10 @@ def _get_results (self, movie_hash, movie_size):
|
||
|
||
thread = SearchThread (self._model, movie_hash, movie_size)
|
||
thread.start ()
|
||
- GObject.idle_add (self._populate_treeview, thread)
|
||
+ GLib.idle_add (self._populate_treeview, thread)
|
||
|
||
self._progress.set_text (_(u'Searching subtitles…'))
|
||
- GObject.timeout_add (350, self._progress_bar_increment, thread)
|
||
+ GLib.timeout_add (350, self._progress_bar_increment, thread)
|
||
|
||
def _populate_treeview (self, search_thread):
|
||
if not search_thread.done:
|
||
|
||
From ac41711f4e228709146e7c6d63273158b676f90a Mon Sep 17 00:00:00 2001
|
||
From: leigh123linux <leigh123linux@googlemail.com>
|
||
Date: Sat, 12 May 2018 10:42:34 +0100
|
||
Subject: [PATCH 4/9] Port python console to python 3
|
||
|
||
---
|
||
src/plugins/pythonconsole/console.py | 48 +++++++++----------
|
||
.../pythonconsole/pythonconsole.plugin.in | 2 +-
|
||
src/plugins/pythonconsole/pythonconsole.py | 38 +++++++--------
|
||
3 files changed, 41 insertions(+), 47 deletions(-)
|
||
|
||
diff --git a/src/plugins/pythonconsole/console.py b/src/plugins/pythonconsole/console.py
|
||
index f7d22ca..d5cc281 100644
|
||
--- a/src/plugins/pythonconsole/console.py
|
||
+++ b/src/plugins/pythonconsole/console.py
|
||
@@ -36,7 +36,7 @@
|
||
import sys
|
||
import re
|
||
import traceback
|
||
-from gi.repository import GObject, Pango, Gtk, Gdk # pylint: disable-msg=E0611
|
||
+from gi.repository import GLib, Pango, Gtk, Gdk # pylint: disable-msg=E0611
|
||
|
||
class PythonConsole(Gtk.ScrolledWindow):
|
||
def __init__(self, namespace = {}, destroy_cb = None):
|
||
@@ -59,7 +59,7 @@ def __init__(self, namespace = {}, destroy_cb = None):
|
||
self.command = buffer.create_tag("command")
|
||
self.command.set_property("foreground", "blue")
|
||
|
||
- self.__spaces_pattern = re.compile(r'^\s+')
|
||
+ self.__spaces_pattern = re.compile(r'^\s+')
|
||
self.namespace = namespace
|
||
|
||
self.block_command = False
|
||
@@ -82,8 +82,8 @@ def __init__(self, namespace = {}, destroy_cb = None):
|
||
# Signals
|
||
self.view.connect("key-press-event", self.__key_press_event_cb)
|
||
buffer.connect("mark-set", self.__mark_set_cb)
|
||
-
|
||
-
|
||
+
|
||
+
|
||
def __key_press_event_cb(self, view, event):
|
||
modifier_mask = Gtk.accelerator_get_default_mod_mask()
|
||
event_state = event.state & modifier_mask
|
||
@@ -114,7 +114,7 @@ def __key_press_event_cb(self, view, event):
|
||
cur = buffer.get_end_iter()
|
||
|
||
buffer.place_cursor(cur)
|
||
- GObject.idle_add(self.scroll_to_end)
|
||
+ GLib.idle_add(self.scroll_to_end)
|
||
return True
|
||
|
||
elif event.keyval == Gdk.KEY_Return:
|
||
@@ -158,21 +158,21 @@ def __key_press_event_cb(self, view, event):
|
||
cur = buffer.get_end_iter()
|
||
buffer.move_mark(inp_mark, cur)
|
||
buffer.place_cursor(cur)
|
||
- GObject.idle_add(self.scroll_to_end)
|
||
+ GLib.idle_add(self.scroll_to_end)
|
||
return True
|
||
|
||
elif event.keyval == Gdk.KEY_KP_Down or event.keyval == Gdk.KEY_Down:
|
||
# Next entry from history
|
||
view.emit_stop_by_name("key_press_event")
|
||
self.history_down()
|
||
- GObject.idle_add(self.scroll_to_end)
|
||
+ GLib.idle_add(self.scroll_to_end)
|
||
return True
|
||
|
||
elif event.keyval == Gdk.KEY_KP_Up or event.keyval == Gdk.KEY_Up:
|
||
# Previous entry from history
|
||
view.emit_stop_by_name("key_press_event")
|
||
self.history_up()
|
||
- GObject.idle_add(self.scroll_to_end)
|
||
+ GLib.idle_add(self.scroll_to_end)
|
||
return True
|
||
|
||
elif event.keyval == Gdk.KEY_KP_Left or event.keyval == Gdk.KEY_Left or \
|
||
@@ -243,22 +243,22 @@ def write(self, text, tag = None):
|
||
else:
|
||
buf.insert_with_tags(buf.get_end_iter(), text, tag)
|
||
|
||
- GObject.idle_add(self.scroll_to_end)
|
||
-
|
||
- def eval(self, command, display_command = False):
|
||
+ GLib.idle_add(self.scroll_to_end)
|
||
+
|
||
+ def eval(self, command, display_command = False):
|
||
buffer = self.view.get_buffer()
|
||
lin = buffer.get_mark("input-line")
|
||
buffer.delete(buffer.get_iter_at_mark(lin),
|
||
buffer.get_end_iter())
|
||
-
|
||
+
|
||
if isinstance(command, list) or isinstance(command, tuple):
|
||
- for c in command:
|
||
- if display_command:
|
||
- self.write(">>> " + c + "\n", self.command)
|
||
- self.__run(c)
|
||
+ for c in command:
|
||
+ if display_command:
|
||
+ self.write(">>> " + c + "\n", self.command)
|
||
+ self.__run(c)
|
||
else:
|
||
- if display_command:
|
||
- self.write(">>> " + c + "\n", self.command)
|
||
+ if display_command:
|
||
+ self.write(">>> " + c + "\n", self.command)
|
||
self.__run(command)
|
||
|
||
cur = buffer.get_end_iter()
|
||
@@ -268,17 +268,17 @@ def eval(self, command, display_command = False):
|
||
buffer.move_mark_by_name("input", cur)
|
||
self.view.scroll_to_iter(buffer.get_end_iter(), 0.0, False, 0.5, 0.5)
|
||
|
||
- def __run(self, command):
|
||
+ def __run(self, command):
|
||
sys.stdout, self.stdout = self.stdout, sys.stdout
|
||
sys.stderr, self.stderr = self.stderr, sys.stderr
|
||
-
|
||
+
|
||
try:
|
||
try:
|
||
r = eval(command, self.namespace, self.namespace)
|
||
if r is not None:
|
||
- print `r`
|
||
+ print(r)
|
||
except SyntaxError:
|
||
- exec command in self.namespace
|
||
+ exec(command, self.namespace)
|
||
except:
|
||
if hasattr(sys, 'last_type') and sys.last_type == SystemExit:
|
||
self.destroy()
|
||
@@ -308,6 +308,6 @@ def readline(self): return ''
|
||
def readlines(self): return []
|
||
def write(self, s): self.console.write(s, self.tag)
|
||
def writelines(self, l): self.console.write(l, self.tag)
|
||
- def seek(self, a): raise IOError, (29, 'Illegal seek')
|
||
- def tell(self): raise IOError, (29, 'Illegal seek')
|
||
+ def seek(self, a): raise IOError((29, 'Illegal seek'))
|
||
+ def tell(self): raise IOError((29, 'Illegal seek'))
|
||
truncate = tell
|
||
diff --git a/src/plugins/pythonconsole/pythonconsole.plugin.in b/src/plugins/pythonconsole/pythonconsole.plugin.in
|
||
index 7061cc8..37d4d5a 100644
|
||
--- a/src/plugins/pythonconsole/pythonconsole.plugin.in
|
||
+++ b/src/plugins/pythonconsole/pythonconsole.plugin.in
|
||
@@ -1,5 +1,5 @@
|
||
[Plugin]
|
||
-Loader=python
|
||
+Loader=python3
|
||
Module=pythonconsole
|
||
IAge=1
|
||
_Name=Python Console
|
||
diff --git a/src/plugins/pythonconsole/pythonconsole.py b/src/plugins/pythonconsole/pythonconsole.py
|
||
index 177fafb..07136fc 100644
|
||
--- a/src/plugins/pythonconsole/pythonconsole.py
|
||
+++ b/src/plugins/pythonconsole/pythonconsole.py
|
||
@@ -82,37 +82,35 @@ def do_activate (self):
|
||
data = dict ()
|
||
manager = self.xplayer.get_ui_manager ()
|
||
|
||
- data['action_group'] = Gtk.ActionGroup (name = 'Python')
|
||
+ self.action_group = Gtk.ActionGroup (name = 'Python')
|
||
|
||
action = Gtk.Action (name = 'Python', label = 'Python',
|
||
- tooltip = _(u'Python Console Menu'),
|
||
+ tooltip = _('Python Console Menu'),
|
||
stock_id = None)
|
||
- data['action_group'].add_action (action)
|
||
+ self.action_group.add_action (action)
|
||
|
||
action = Gtk.Action (name = 'PythonConsole',
|
||
- label = _(u'_Python Console'),
|
||
- tooltip = _(u"Show Xplayer's Python console"),
|
||
+ label = _('_Python Console'),
|
||
+ tooltip = _("Show Xplayer's Python console"),
|
||
stock_id = 'gnome-mime-text-x-python')
|
||
action.connect ('activate', self._show_console)
|
||
- data['action_group'].add_action (action)
|
||
+ self.action_group.add_action (action)
|
||
|
||
action = Gtk.Action (name = 'PythonDebugger',
|
||
- label = _(u'Python Debugger'),
|
||
- tooltip = _(u"Enable remote Python debugging "\
|
||
+ label = _('Python Debugger'),
|
||
+ tooltip = _("Enable remote Python debugging "\
|
||
"with rpdb2"),
|
||
stock_id = None)
|
||
if HAVE_RPDB2:
|
||
action.connect ('activate', self._enable_debugging)
|
||
else:
|
||
action.set_visible (False)
|
||
- data['action_group'].add_action (action)
|
||
+ self.action_group.add_action (action)
|
||
|
||
- manager.insert_action_group (data['action_group'], 0)
|
||
- data['ui_id'] = manager.add_ui_from_string (UI_STR)
|
||
+ manager.insert_action_group (self.action_group, 0)
|
||
+ self.ui_id = manager.add_ui_from_string (UI_STR)
|
||
manager.ensure_update ()
|
||
|
||
- self.xplayer.PythonConsolePluginInfo = data
|
||
-
|
||
def _show_console (self, _action):
|
||
if not self.window:
|
||
console = PythonConsole (namespace = {
|
||
@@ -122,11 +120,11 @@ def _show_console (self, _action):
|
||
}, destroy_cb = self._destroy_console)
|
||
|
||
console.set_size_request (600, 400) # pylint: disable-msg=E1101
|
||
- console.eval ('print "%s" %% xplayer_object' % _(u"You can access "\
|
||
+ console.eval ('print("%s" %% xplayer_object)' % _("You can access "\
|
||
"the Xplayer.Object through \'xplayer_object\' :\\n%s"), False)
|
||
|
||
self.window = Gtk.Window ()
|
||
- self.window.set_title (_(u'Xplayer Python Console'))
|
||
+ self.window.set_title (_('Xplayer Python Console'))
|
||
self.window.add (console)
|
||
self.window.connect ('destroy', self._destroy_console)
|
||
self.window.show_all ()
|
||
@@ -136,7 +134,7 @@ def _show_console (self, _action):
|
||
|
||
@classmethod
|
||
def _enable_debugging (cls, _action):
|
||
- msg = _(u"After you press OK, Xplayer will wait until you connect to it "\
|
||
+ msg = _("After you press OK, Xplayer will wait until you connect to it "\
|
||
"with winpdb or rpdb2. If you have not set a debugger "\
|
||
"password in DConf, it will use the default password "\
|
||
"('xplayer').")
|
||
@@ -158,14 +156,10 @@ def _destroy_console (self, *_args):
|
||
self.window = None
|
||
|
||
def do_deactivate (self):
|
||
- data = self.xplayer.PythonConsolePluginInfo
|
||
-
|
||
manager = self.xplayer.get_ui_manager ()
|
||
- manager.remove_ui (data['ui_id'])
|
||
- manager.remove_action_group (data['action_group'])
|
||
+ manager.remove_ui (self.ui_id)
|
||
+ manager.remove_action_group (self.action_group)
|
||
manager.ensure_update ()
|
||
|
||
- self.xplayer.PythonConsolePluginInfo = None
|
||
-
|
||
if self.window is not None:
|
||
self.window.destroy ()
|
||
|
||
From 83f2c1cf2d79b065b1769e161ec48c6c0c46ec4e Mon Sep 17 00:00:00 2001
|
||
From: leigh123linux <leigh123linux@googlemail.com>
|
||
Date: Sat, 12 May 2018 10:45:47 +0100
|
||
Subject: [PATCH 5/9] dbusservice: do not use unicode which does not exists in
|
||
python 3
|
||
|
||
---
|
||
src/plugins/dbusservice/dbusservice.py | 20 ++++++++++----------
|
||
1 file changed, 10 insertions(+), 10 deletions(-)
|
||
|
||
diff --git a/src/plugins/dbusservice/dbusservice.py b/src/plugins/dbusservice/dbusservice.py
|
||
index 24fc5c2..54d8b80 100644
|
||
--- a/src/plugins/dbusservice/dbusservice.py
|
||
+++ b/src/plugins/dbusservice/dbusservice.py
|
||
@@ -57,9 +57,9 @@ def __init__ (self, name, xplayer):
|
||
self.xplayer = xplayer
|
||
|
||
self.null_metadata = {
|
||
- 'year' : u'', 'tracknumber' : '', 'location' : '',
|
||
- 'title' : u'', 'album' : u'', 'time' : u'', 'genre' : u'',
|
||
- 'artist' : u''
|
||
+ 'year' : '', 'tracknumber' : '', 'location' : '',
|
||
+ 'title' : '', 'album' : '', 'time' : '', 'genre' : '',
|
||
+ 'artist' : ''
|
||
}
|
||
self.current_metadata = self.null_metadata.copy ()
|
||
self.current_position = 0
|
||
@@ -120,11 +120,11 @@ def __do_update_metadata (self, xplayer, artist, # pylint: disable-msg=R0913
|
||
title, album, num):
|
||
self.current_metadata = self.null_metadata.copy ()
|
||
if title:
|
||
- self.current_metadata['title'] = unicode (title, 'utf-8')
|
||
+ self.current_metadata['title'] = title
|
||
if artist:
|
||
- self.current_metadata['artist'] = unicode (artist, 'utf-8')
|
||
+ self.current_metadata['artist'] = artist
|
||
if album:
|
||
- self.current_metadata['album'] = unicode (album, 'utf-8')
|
||
+ self.current_metadata['album'] = album
|
||
if num:
|
||
self.current_metadata['tracknumber'] = num
|
||
|
||
@@ -210,7 +210,7 @@ def GetAll (self, interface_name):
|
||
|
||
raise dbus.exceptions.DBusException (
|
||
'org.mpris.MediaPlayer2.UnknownInterface',
|
||
- _(u'The MediaPlayer2 object does not implement the ‘%s’ interface')
|
||
+ _('The MediaPlayer2 object does not implement the ‘%s’ interface')
|
||
% interface_name)
|
||
|
||
@dbus.service.method (dbus_interface = dbus.PROPERTIES_IFACE,
|
||
@@ -219,7 +219,7 @@ def Set (self, interface_name, property_name, new_value):
|
||
if interface_name == 'org.mpris.MediaPlayer2':
|
||
raise dbus.exceptions.DBusException (
|
||
'org.mpris.MediaPlayer2.ReadOnlyProperty',
|
||
- _(u'The property ‘%s’ is not writeable.'))
|
||
+ _('The property ‘%s’ is not writeable.'))
|
||
elif interface_name == 'org.mpris.MediaPlayer2.Player':
|
||
if property_name == 'LoopStatus':
|
||
self.xplayer.action_remote_set_setting (
|
||
@@ -235,12 +235,12 @@ def Set (self, interface_name, property_name, new_value):
|
||
|
||
raise dbus.exceptions.DBusException (
|
||
'org.mpris.MediaPlayer2.ReadOnlyProperty',
|
||
- _(u'Unknown property ‘%s’ requested of a MediaPlayer 2 object')
|
||
+ _('Unknown property ‘%s’ requested of a MediaPlayer 2 object')
|
||
% interface_name)
|
||
|
||
raise dbus.exceptions.DBusException (
|
||
'org.mpris.MediaPlayer2.UnknownInterface',
|
||
- _(u'The MediaPlayer2 object does not implement the ‘%s’ interface')
|
||
+ _('The MediaPlayer2 object does not implement the ‘%s’ interface')
|
||
% interface_name)
|
||
|
||
@dbus.service.signal (dbus_interface = dbus.PROPERTIES_IFACE,
|
||
|
||
From 1e83806ae109818c0d2b47438ef377f44d99e444 Mon Sep 17 00:00:00 2001
|
||
From: leigh123linux <leigh123linux@googlemail.com>
|
||
Date: Sat, 12 May 2018 14:41:09 +0100
|
||
Subject: [PATCH 6/9] Switch peas loader depends
|
||
|
||
---
|
||
debian/control | 2 +-
|
||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||
|
||
diff --git a/debian/control b/debian/control
|
||
index 3913a16..83b7018 100644
|
||
--- a/debian/control
|
||
+++ b/debian/control
|
||
@@ -135,7 +135,7 @@ Depends: ${misc:Depends},
|
||
gir1.2-xplayer-1.0 (= ${binary:Version}),
|
||
python-gi (>= 2.90.3),
|
||
python-xdg,
|
||
- libpeas-1.0-0-python2loader | libpeas-common( << 1.16 )
|
||
+ libpeas-1.0-0-python3loader | libpeas-common( << 1.16 )
|
||
Suggests: gromit
|
||
Description: Plugins for the Xplayer media player
|
||
Xplayer is a simple yet featureful media player which can read
|
||
|
||
From 77cf4b624c85e0372e35c7e8473868bbf7c57fef Mon Sep 17 00:00:00 2001
|
||
From: leigh123linux <leigh123linux@googlemail.com>
|
||
Date: Sun, 13 May 2018 08:43:56 +0100
|
||
Subject: [PATCH 7/9] opensubtitles: Stop using PyXDG
|
||
|
||
---
|
||
debian/control | 6 +++---
|
||
src/plugins/opensubtitles/opensubtitles.py | 12 ++----------
|
||
2 files changed, 5 insertions(+), 13 deletions(-)
|
||
|
||
diff --git a/debian/control b/debian/control
|
||
index 83b7018..3d2a2a8 100644
|
||
--- a/debian/control
|
||
+++ b/debian/control
|
||
@@ -133,9 +133,9 @@ Depends: ${misc:Depends},
|
||
gir1.2-pango-1.0,
|
||
gir1.2-peas-1.0,
|
||
gir1.2-xplayer-1.0 (= ${binary:Version}),
|
||
- python-gi (>= 2.90.3),
|
||
- python-xdg,
|
||
- libpeas-1.0-0-python3loader | libpeas-common( << 1.16 )
|
||
+ python3,
|
||
+ python3-gi,
|
||
+ libpeas-1.0-0-python3loader | debian-system-adjustments,
|
||
Suggests: gromit
|
||
Description: Plugins for the Xplayer media player
|
||
Xplayer is a simple yet featureful media player which can read
|
||
diff --git a/src/plugins/opensubtitles/opensubtitles.py b/src/plugins/opensubtitles/opensubtitles.py
|
||
index 44e56c4..8e7f408 100644
|
||
--- a/src/plugins/opensubtitles/opensubtitles.py
|
||
+++ b/src/plugins/opensubtitles/opensubtitles.py
|
||
@@ -5,7 +5,6 @@
|
||
|
||
import xmlrpc.client
|
||
import threading
|
||
-import xdg.BaseDirectory
|
||
from os import sep, path, mkdir
|
||
import gettext
|
||
|
||
@@ -618,19 +617,12 @@ def _save_selected_subtitle (self, filename=None):
|
||
subtitle_format = model.get_value (subtitle_iter, 1)
|
||
|
||
if not filename:
|
||
- bpath = xdg.BaseDirectory.xdg_cache_home + sep
|
||
+ bpath = GLib.get_user_cache_dir() + sep
|
||
bpath += 'xplayer' + sep
|
||
|
||
directory = Gio.file_new_for_path (bpath + 'subtitles' + sep)
|
||
-
|
||
if not directory.query_exists (None):
|
||
- if not path.exists (bpath):
|
||
- mkdir (bpath)
|
||
- if not path.exists (bpath + 'subtitles' + sep):
|
||
- mkdir (bpath + 'subtitles' + sep)
|
||
- # FIXME: We can't use this function until we depend on
|
||
- # GLib (PyGObject) 2.18
|
||
- # directory.make_directory_with_parents ()
|
||
+ directory.make_directory_with_parents (None);
|
||
|
||
subtitle_file = Gio.file_new_for_path (self._filename)
|
||
movie_name = subtitle_file.get_basename ().rpartition ('.')[0]
|
||
|
||
From 9eeb6eb3de50f1b682f64a7e7f6c64a87a6882a1 Mon Sep 17 00:00:00 2001
|
||
From: leigh123linux <leigh123linux@googlemail.com>
|
||
Date: Sun, 13 May 2018 08:50:58 +0100
|
||
Subject: [PATCH 8/9] opensubtitles: Fix downloading subtitles with newer
|
||
Python
|
||
|
||
---
|
||
src/plugins/opensubtitles/opensubtitles.py | 1 +
|
||
1 file changed, 1 insertion(+)
|
||
|
||
diff --git a/src/plugins/opensubtitles/opensubtitles.py b/src/plugins/opensubtitles/opensubtitles.py
|
||
index 8e7f408..1a7d12f 100644
|
||
--- a/src/plugins/opensubtitles/opensubtitles.py
|
||
+++ b/src/plugins/opensubtitles/opensubtitles.py
|
||
@@ -342,6 +342,7 @@ def download_subtitles (self, subtitle_id):
|
||
(log_in_success, log_in_message) = self._log_in ()
|
||
|
||
if log_in_success:
|
||
+ result = None
|
||
try:
|
||
result = self._server.DownloadSubtitles (self._token,
|
||
[subtitle_id])
|
||
|
||
From c85414eb962fa524760adb779662a6c86b8b0d30 Mon Sep 17 00:00:00 2001
|
||
From: leigh123linux <leigh123linux@googlemail.com>
|
||
Date: Mon, 27 Aug 2018 17:02:22 +0100
|
||
Subject: [PATCH 9/9] opensubtitles: Make decoding download items work
|
||
|
||
---
|
||
src/plugins/opensubtitles/opensubtitles.py | 8 +++-----
|
||
1 file changed, 3 insertions(+), 5 deletions(-)
|
||
|
||
diff --git a/src/plugins/opensubtitles/opensubtitles.py b/src/plugins/opensubtitles/opensubtitles.py
|
||
index 1a7d12f..7b6cc02 100644
|
||
--- a/src/plugins/opensubtitles/opensubtitles.py
|
||
+++ b/src/plugins/opensubtitles/opensubtitles.py
|
||
@@ -5,6 +5,7 @@
|
||
|
||
import xmlrpc.client
|
||
import threading
|
||
+import zlib
|
||
from os import sep, path, mkdir
|
||
import gettext
|
||
|
||
@@ -356,14 +357,11 @@ def download_subtitles (self, subtitle_id):
|
||
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
|
||
|