mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-12 20:44:50 +00:00
remove organize plugin
This commit is contained in:
parent
88d12ef63b
commit
c5ad6d7e5a
@ -98,7 +98,7 @@ class PluginManagerBase:
|
|||||||
def enable_plugin(self, plugin_name):
|
def enable_plugin(self, plugin_name):
|
||||||
"""Enables a plugin"""
|
"""Enables a plugin"""
|
||||||
if plugin_name not in self.available_plugins:
|
if plugin_name not in self.available_plugins:
|
||||||
log.warning("Cannot enable non-existant plugin %s", name)
|
log.warning("Cannot enable non-existant plugin %s", plugin_name)
|
||||||
return
|
return
|
||||||
|
|
||||||
plugin_name = plugin_name.replace(" ", "-")
|
plugin_name = plugin_name.replace(" ", "-")
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
#
|
|
||||||
# __init__.py
|
|
||||||
#
|
|
||||||
# Copyright (C) 2007 Andrew Resch ('andar') <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 2 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.
|
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
|
||||||
from deluge.plugins.init import PluginBase
|
|
||||||
|
|
||||||
class CorePlugin(PluginBase):
|
|
||||||
def __init__(self, plugin_api, plugin_name):
|
|
||||||
# Load the Core portion of the plugin
|
|
||||||
try:
|
|
||||||
from core import Core
|
|
||||||
self.plugin = Core(plugin_api, plugin_name)
|
|
||||||
except Exception, e:
|
|
||||||
log.debug("Did not load a Core plugin: %s", e)
|
|
||||||
"""
|
|
||||||
class GtkUIPlugin(PluginBase):
|
|
||||||
def __init__(self, plugin_api, plugin_name):
|
|
||||||
# Load the GtkUI portion of the plugin
|
|
||||||
try:
|
|
||||||
from gtkui import GtkUI
|
|
||||||
self.plugin = GtkUI(plugin_api, plugin_name)
|
|
||||||
except Exception, e:
|
|
||||||
log.debug("Did not load a GtkUI plugin: %s", e)
|
|
||||||
"""
|
|
||||||
|
|
@ -1,135 +0,0 @@
|
|||||||
"""
|
|
||||||
torrent-organize core plugin.
|
|
||||||
|
|
||||||
adds a status field for tracker.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
|
||||||
from deluge.plugins.corepluginbase import CorePluginBase
|
|
||||||
|
|
||||||
from urlparse import urlparse
|
|
||||||
|
|
||||||
STATE_FILTERS = {
|
|
||||||
'Allocating': lambda t: (t.state == 'Allocating'),
|
|
||||||
'Checking': lambda t: (t.state == 'Checking'),
|
|
||||||
'Downloading': lambda t: (t.state == 'Downloadig'),
|
|
||||||
'Seeding':lambda t: (t.state == 'Seeding'),
|
|
||||||
'Paused':lambda t: (t.state == 'Paused'),
|
|
||||||
'Error':lambda t: (t.state == 'Error'),
|
|
||||||
'Queued':lambda t: (t.state == 'Queued')
|
|
||||||
#'Traffic':lambda t: (t.download_payload_rate > 0 or t.upload_payload_rate > 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
class Core(CorePluginBase):
|
|
||||||
def enable(self):
|
|
||||||
log.info("*** START Organize plugin***")
|
|
||||||
|
|
||||||
self.plugin.register_status_field("tracker_name", self._status_get_tracker)
|
|
||||||
log.debug("Organize plugin enabled..")
|
|
||||||
|
|
||||||
#__init__....
|
|
||||||
core = self.plugin.get_core()
|
|
||||||
self.torrents = core.torrents.torrents
|
|
||||||
|
|
||||||
def disable(self):
|
|
||||||
# De-register the label field
|
|
||||||
|
|
||||||
self.plugin.deregister_status_field("tracker_name")
|
|
||||||
|
|
||||||
def update(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
## Utils ##
|
|
||||||
def get_tracker(self, torrent):
|
|
||||||
"returns 1st tracker."
|
|
||||||
log.debug(torrent)
|
|
||||||
log.debug(torrent.trackers)
|
|
||||||
if not torrent.trackers:
|
|
||||||
return 'tracker-less'
|
|
||||||
url = urlparse(torrent.trackers[0]['url'])
|
|
||||||
if hasattr(url,'hostname'):
|
|
||||||
return (url.hostname or 'unknown?')
|
|
||||||
return 'No-tracker?'
|
|
||||||
|
|
||||||
## Filters ##
|
|
||||||
def filter_state(self, torrents, state):
|
|
||||||
"in/out: a list of torrent objects."
|
|
||||||
filter_func = STATE_FILTERS[state]
|
|
||||||
return [t for t in torrents if filter_func(t)]
|
|
||||||
|
|
||||||
def filter_tracker(self, torrents, tracker):
|
|
||||||
"in/out: a list of torrent objects."
|
|
||||||
return [t for t in torrents if self.get_tracker(t) == tracker]
|
|
||||||
|
|
||||||
def filter_keyword(self, torrents, keyword):
|
|
||||||
"in/out: a list of torrent objects."
|
|
||||||
return [t for t in torrents if keyword in t.filename.lower()]
|
|
||||||
|
|
||||||
## Public ##
|
|
||||||
def export_state_filter_items(self):
|
|
||||||
"""
|
|
||||||
returns a sorted list of tuples:
|
|
||||||
[(state, count), ...]
|
|
||||||
"""
|
|
||||||
#maybe I should explain this.. ..
|
|
||||||
#or just fix it to be less generic, and more readable.
|
|
||||||
return [("All", len(self.torrents))] + [
|
|
||||||
(state, len(self.filter_state(self.torrents.values(), state)))
|
|
||||||
for state in STATE_FILTERS]
|
|
||||||
|
|
||||||
def export_tracker_filter_items(self):
|
|
||||||
"""
|
|
||||||
returns a sorted list of tuples:
|
|
||||||
[(tracker_name, count), ...]
|
|
||||||
"""
|
|
||||||
trackers = [self.get_tracker(t) for t in self.torrents.values()]
|
|
||||||
tcounter = {}
|
|
||||||
for tracker in trackers:
|
|
||||||
tcounter[tracker] = tcounter.get(tracker,0) + 1
|
|
||||||
#tcounter= {'tracker-name':count, ...}
|
|
||||||
return sorted([x for x in tcounter.iteritems()])
|
|
||||||
|
|
||||||
def export_all_filter_items(self):
|
|
||||||
"""
|
|
||||||
for sclient, returns:{
|
|
||||||
'tracker':<tracker_items>,
|
|
||||||
'state':<state_items>}
|
|
||||||
"""
|
|
||||||
return {
|
|
||||||
'tracker':self.export_tracker_filter_items(),
|
|
||||||
'state':self.export_state_filter_items()
|
|
||||||
}
|
|
||||||
|
|
||||||
def export_get_session_state(self,filter_dict):
|
|
||||||
"""
|
|
||||||
in: a dict of filters:
|
|
||||||
{
|
|
||||||
'keyword':'a keyword',
|
|
||||||
'state':'Seeding',
|
|
||||||
'tracker':'tracker.aelitis.com'
|
|
||||||
}
|
|
||||||
returns a list of torrent_id's
|
|
||||||
"""
|
|
||||||
torrents = self.torrents.values()
|
|
||||||
|
|
||||||
if 'keyword' in filter_dict:
|
|
||||||
filter_dict['keyword'] = filter_dict['keyword'].lower()
|
|
||||||
torrents = self.filter_keyword(torrents, filter_dict['keyword'])
|
|
||||||
|
|
||||||
if 'state' in filter_dict and filter_dict['state'] <> "All":
|
|
||||||
torrents = self.filter_state(torrents, filter_dict['state'])
|
|
||||||
|
|
||||||
if 'tracker' in filter_dict:
|
|
||||||
torrents = self.filter_tracker(torrents, filter_dict['tracker'])
|
|
||||||
|
|
||||||
return [t.torrent_id for t in torrents]
|
|
||||||
|
|
||||||
|
|
||||||
## Status fields ##
|
|
||||||
def _status_get_tracker(self, torrent_id):
|
|
||||||
return self.get_tracker(self.torrents[torrent_id])
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
import test
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
|||||||
from deluge.ui.client import sclient
|
|
||||||
|
|
||||||
sclient.set_core_uri()
|
|
||||||
|
|
||||||
ids = sclient.get_session_state()
|
|
||||||
|
|
||||||
for t in sclient.get_torrents_status(ids, ['name','tracker_name','tracker']).itervalues():
|
|
||||||
print t
|
|
||||||
|
|
||||||
for tracker,count in sclient.organize_tracker_filter_items():
|
|
||||||
print tracker, count
|
|
||||||
|
|
||||||
for state,count in sclient.organize_state_filter_items():
|
|
||||||
print state, count
|
|
||||||
|
|
||||||
print sclient.organize_all_filter_items()
|
|
||||||
|
|
||||||
|
|
||||||
print 'tracker.aelitis.com:'
|
|
||||||
print sclient.organize_get_session_state({'tracker':'tracker.aelitis.com'} )
|
|
||||||
|
|
||||||
print 'no results'
|
|
||||||
print sclient.organize_get_session_state({'tracker':'no results'} )
|
|
||||||
|
|
||||||
|
|
||||||
print 'seeding'
|
|
||||||
print sclient.organize_get_session_state({'state':'Seeding'} )
|
|
||||||
|
|
||||||
print 'paused'
|
|
||||||
print sclient.organize_get_session_state({'state':'Paused'} )
|
|
||||||
|
|
||||||
print 'seeding+tracker.aelitis.com'
|
|
||||||
print sclient.organize_get_session_state({
|
|
||||||
'tracker':'tracker.aelitis.com',
|
|
||||||
'state':'Seeding'})
|
|
||||||
|
|
||||||
print 'on keyword:'
|
|
||||||
print sclient.organize_get_session_state({'keyword':'client'})
|
|
||||||
|
|
||||||
print 'on keyword:no results'
|
|
||||||
print sclient.organize_get_session_state({'keyword':'lasjhdinewhjdeg'})
|
|
@ -1,55 +0,0 @@
|
|||||||
# setup.py
|
|
||||||
#
|
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
# any later version.
|
|
||||||
#
|
|
||||||
# This program 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 this program. 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.
|
|
||||||
|
|
||||||
"""
|
|
||||||
Organize plugin.
|
|
||||||
|
|
||||||
Offers filters on state,tracker and keyword.
|
|
||||||
Core only for now, moving builtin webui stuff to a plugin.
|
|
||||||
|
|
||||||
Future: Labels/Tags
|
|
||||||
"""
|
|
||||||
|
|
||||||
from setuptools import setup
|
|
||||||
|
|
||||||
__author__ = "Martijn Voncken"
|
|
||||||
|
|
||||||
setup(
|
|
||||||
name="Organize",
|
|
||||||
version="0.1",
|
|
||||||
description=__doc__,
|
|
||||||
author=__author__,
|
|
||||||
packages=["organize"],
|
|
||||||
#package_data = {"testp": ["glade/*.glade"]},
|
|
||||||
entry_points="""
|
|
||||||
[deluge.plugin.core]
|
|
||||||
Organize = organize:CorePlugin
|
|
||||||
"""
|
|
||||||
)
|
|
Loading…
x
Reference in New Issue
Block a user