Skip to content

Commit

Permalink
It works!
Browse files Browse the repository at this point in the history
Woot woot.
  • Loading branch information
d8ahazard committed Oct 23, 2019
1 parent 2424b77 commit 739a933
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 60 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# deluge-extractor
Plugin for the [deluge](http://deluge-torrent.org/) torrent client that extracts compressed files upon torrent completion.
Plugin for the [deluge](http://deluge-torrent.org/) *V2* torrent client that extracts compressed files upon torrent completion.

This is a modified version of the "Extractor" plugin, with the added option to extract in place.

This is updated to work on Deluge V2. I'm not sure if it'll work with V1 versions...you tell me. I think it should.0

* Target folder for extracting the torrent can be specified
* A sub folder (name of torrent) can be created within the target folder
* In-place extraction of the torrent in the torrent's download folder is possible as well

## Has been tested on:

* Deluge 1.3.x on macOS and Debian Linux / CentOS 7
* Deluge 1.3.5 on Windows 7
* Deluge 2.0.3


## Supported File formats:

Expand Down Expand Up @@ -70,3 +74,10 @@ For example in the setup below you will have to install the py2.6 egg on the des
* Linux server with Python 2.7 running deluged

#### Note: The Windows installer comes bundled with python: either python 2.6 or 2.7 depending on the intstaller you used.


### Support my work?

If you dig this plugin and want to say thanks, the best way to do it is by sending a paypal donation to [email protected]

All donations are appreciated...but none are required :D
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
__plugin_name__ = 'SimpleExtractor'
__author__ = 'Digitalhigh'
__author_email__ = '[email protected]'
__version__ = '0.7'
__version__ = '0.8'
__url__ = 'github.com/d8ahazard/deluge-extractor'
__license__ = 'GPLv3'
__description__ = 'Extract files upon torrent completion'
Expand All @@ -30,7 +30,7 @@
Note: Will not extract with 'Move Completed' enabled
"""
__pkg_data__ = {'deluge_' + __plugin_name__.lower(): ['data/*']}
__pkg_data__ = {__plugin_name__.lower(): ['template/*', 'data/*']}

setup(
name=__plugin_name__,
Expand All @@ -41,15 +41,15 @@
url=__url__,
license=__license__,
long_description=__long_description__ if __long_description__ else __description__,
packages=find_packages(),
packages=[__plugin_name__.lower()],
package_data=__pkg_data__,
entry_points="""
[deluge.plugin.core]
%s = deluge_%s:CorePlugin
%s = %s:CorePlugin
[deluge.plugin.gtk3ui]
%s = deluge_%s:GtkUIPlugin
%s = %s:GtkUIPlugin
[deluge.plugin.web]
%s = deluge_%s:WebUIPlugin
%s = %s:WebUIPlugin
"""
% ((__plugin_name__, __plugin_name__.lower()) * 3),
)
56 changes: 18 additions & 38 deletions simpleextractor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,60 +1,40 @@
#
# __init__.py
# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <[email protected]>
# Copyright (C) 2015 Chris Yereaztian <[email protected]>
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <[email protected]>
# Copyright (C) 2007-2009 Andrew Resch <[email protected]>
#
# 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)
2 changes: 1 addition & 1 deletion simpleextractor/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@


def get_resource(filename):
return resource_filename(__package__, os.path.join('data', filename))
return resource_filename("simpleextractor", os.path.join('data', filename))
20 changes: 11 additions & 9 deletions simpleextractor/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

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 = [
Expand Down Expand Up @@ -128,6 +128,7 @@ def _on_torrent_finished(self, torrent_id):

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:
Expand All @@ -152,17 +153,18 @@ def _on_torrent_finished(self, torrent_id):
# 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.
Expand Down
6 changes: 3 additions & 3 deletions simpleextractor/gtkui.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def enable(self):
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
Expand All @@ -50,7 +50,7 @@ def enable(self):
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
)
Expand All @@ -60,7 +60,7 @@ def disable(self):
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:
Expand Down

0 comments on commit 739a933

Please sign in to comment.