It works!
Woot woot.
This commit is contained in:
@@ -1,60 +1,40 @@
|
||||
#
|
||||
# __init__.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
# Copyright (C) 2015 Chris Yereaztian <chris.yereaztian@gmail.com>
|
||||
#
|
||||
# Basic plugin template created by:
|
||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
|
||||
# the additional special exception to link portions of this program with the OpenSSL library.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from deluge.plugins.init import PluginInitBase
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from deluge.plugins.init import PluginInitBase
|
||||
|
||||
|
||||
class CorePlugin(PluginInitBase):
|
||||
def __init__(self, plugin_name):
|
||||
from core import Core as _plugin_cls
|
||||
self._plugin_cls = _plugin_cls
|
||||
from .core import Core as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(CorePlugin, self).__init__(plugin_name)
|
||||
|
||||
|
||||
class GtkUIPlugin(PluginInitBase):
|
||||
def __init__(self, plugin_name):
|
||||
from gtkui import GtkUI as _plugin_cls
|
||||
self._plugin_cls = _plugin_cls
|
||||
from .gtkui import GtkUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
||||
|
||||
|
||||
class WebUIPlugin(PluginInitBase):
|
||||
def __init__(self, plugin_name):
|
||||
from webui import WebUI as _plugin_cls
|
||||
self._plugin_cls = _plugin_cls
|
||||
from .webui import WebUI as _pluginCls
|
||||
|
||||
self._plugin_cls = _pluginCls
|
||||
super(WebUIPlugin, self).__init__(plugin_name)
|
||||
|
||||
@@ -20,4 +20,4 @@ from pkg_resources import resource_filename
|
||||
|
||||
|
||||
def get_resource(filename):
|
||||
return resource_filename(__package__, os.path.join('data', filename))
|
||||
return resource_filename("simpleextractor", os.path.join('data', filename))
|
||||
|
||||
@@ -28,7 +28,7 @@ from deluge.plugins.pluginbase import CorePluginBase
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
DEFAULT_PREFS = {'extract_path': '', 'use_name_folder': True, 'in_place_extraction': True}
|
||||
DEFAULT_PREFS = {'extract_path': '', 'use_name_folder': False, 'in_place_extraction': True}
|
||||
|
||||
if windows_check():
|
||||
win_7z_exes = [
|
||||
@@ -128,6 +128,7 @@ class Core(CorePluginBase):
|
||||
|
||||
files = tid.get_files()
|
||||
for f in files:
|
||||
log.debug("Handling file %s", f['path'])
|
||||
file_root, file_ext = os.path.splitext(f['path'])
|
||||
file_ext_sec = os.path.splitext(file_root)[1]
|
||||
if file_ext_sec and file_ext_sec + file_ext in EXTRACT_COMMANDS:
|
||||
@@ -152,17 +153,18 @@ class Core(CorePluginBase):
|
||||
# Override destination if in_place_extraction is set
|
||||
if self.config["in_place_extraction"]:
|
||||
name = tid_status["name"]
|
||||
save_path = tid_status["save_path"]
|
||||
dest = os.path.join(save_path,name)
|
||||
save_path = tid_status["download_location"]
|
||||
dest = os.path.join(save_path, name)
|
||||
log.debug("Save path is %s, dest is %s, fpath is %s", save_path, dest, fpath)
|
||||
|
||||
# Create the destination folder if it doesn't exist
|
||||
if not os.path.exists(dest):
|
||||
try:
|
||||
os.makedirs(dest)
|
||||
except OSError as ex:
|
||||
if not (ex.errno == errno.EEXIST and os.path.isdir(dest)):
|
||||
log.error('Error creating destination folder: %s', ex)
|
||||
break
|
||||
try:
|
||||
os.makedirs(dest)
|
||||
except OSError as ex:
|
||||
if not (ex.errno == errno.EEXIST and os.path.isdir(dest)):
|
||||
log.error('Error creating destination folder: %s', ex)
|
||||
break
|
||||
|
||||
def on_extract(result, torrent_id, fpath):
|
||||
# Check command exit code.
|
||||
|
||||
@@ -39,7 +39,7 @@ class GtkUI(Gtk3PluginBase):
|
||||
self.builder.add_from_file(get_resource('extractor_prefs.ui'))
|
||||
|
||||
component.get('Preferences').add_page(
|
||||
_('Extractor'), self.builder.get_object('extractor_prefs_box')
|
||||
_('SimpleExtractor'), self.builder.get_object('extractor_prefs_box')
|
||||
)
|
||||
component.get('PluginManager').register_hook(
|
||||
'on_apply_prefs', self.on_apply_prefs
|
||||
@@ -50,7 +50,7 @@ class GtkUI(Gtk3PluginBase):
|
||||
self.on_show_prefs()
|
||||
|
||||
def disable(self):
|
||||
component.get('Preferences').remove_page(_('Extractor'))
|
||||
component.get('Preferences').remove_page(_('SimpleExtractor'))
|
||||
component.get('PluginManager').deregister_hook(
|
||||
'on_apply_prefs', self.on_apply_prefs
|
||||
)
|
||||
@@ -60,7 +60,7 @@ class GtkUI(Gtk3PluginBase):
|
||||
del self.builder
|
||||
|
||||
def on_apply_prefs(self):
|
||||
log.debug('applying prefs for Extractor')
|
||||
log.debug('applying prefs for Simple Extractor')
|
||||
if client.is_localhost():
|
||||
path = self.builder.get_object('folderchooser_path').get_filename()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user