summaryrefslogtreecommitdiffstats
path: root/pyload/plugin/addon/SkipRev.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2015-02-16 10:46:28 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2015-02-16 10:46:28 +0100
commitce1c2b6b05c08b669357947e61ae40efce7fc50f (patch)
tree0b5f7996960cf35c4eface53a89eba18a37519b7 /pyload/plugin/addon/SkipRev.py
parentFix filename case (diff)
downloadpyload-ce1c2b6b05c08b669357947e61ae40efce7fc50f.tar.xz
module temp
Diffstat (limited to 'pyload/plugin/addon/SkipRev.py')
-rw-r--r--pyload/plugin/addon/SkipRev.py77
1 files changed, 0 insertions, 77 deletions
diff --git a/pyload/plugin/addon/SkipRev.py b/pyload/plugin/addon/SkipRev.py
deleted file mode 100644
index d6908614d..000000000
--- a/pyload/plugin/addon/SkipRev.py
+++ /dev/null
@@ -1,77 +0,0 @@
-# -*- coding: utf-8 -*-
-
-from urllib import unquote
-from urlparse import urlparse
-
-from pyload.plugin.Addon import Addon
-from pyload.plugin.Plugin import SkipDownload
-
-
-class SkipRev(Adoon):
- __name__ = "SkipRev"
- __type__ = "addon"
- __version__ = "0.15"
-
- __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)]
-
- __description__ = """Skip files ending with extension rev"""
- __license__ = "GPLv3"
- __authors__ = [("Walter Purcaro", "vuolter@gmail.com")]
-
-
- def _setup(self):
- super(self.pyfile.plugin, self).setup()
- if self.pyfile.hasStatus("skipped"):
- raise SkipDownload(self.pyfile.getStatusName() or self.pyfile.pluginname)
-
-
- def pyname(self, pyfile):
- url = pyfile.url
- plugin = pyfile.plugin
-
- if hasattr(plugin, "info") and 'name' in plugin.info and plugin.info['name']:
- name = plugin.info['name']
-
- elif hasattr(plugin, "parseInfos"):
- name = next(plugin.parseInfos([url]))['name']
-
- elif hasattr(plugin, "getInfo"): #@NOTE: if parseInfos was not found, getInfo should be missing too
- name = plugin.getInfo(url)['name']
-
- else:
- self.logWarning("Unable to grab file name")
- name = urlparse(unquote(url)).path.split('/')[-1])
-
- return name
-
-
- def downloadPreparing(self, pyfile):
- if pyfile.getStatusName() is "unskipped" or not pyname(pyfile).endswith(".rev"):
- return
-
- tokeep = self.getConfig("tokeep")
-
- if tokeep:
- saved = [True for link in pyfile.package().getChildren() \
- if link.name.endswith(".rev") and (link.hasStatus("finished") or link.hasStatus("downloading"))].count(True)
-
- if not saved or saved < tokeep: #: keep one rev at least in auto mode
- return
-
- pyfile.setCustomStatus("SkipRev", "skipped")
- pyfile.plugin.setup = _setup #: work-around: inject status checker inside the preprocessing routine of the plugin
-
-
- def downloadFailed(self, pyfile):
- tokeep = self.getConfig("tokeep")
-
- if not tokeep:
- return
-
- for link in pyfile.package().getChildren():
- if link.hasStatus("skipped") and link.name.endswith(".rev"):
- if tokeep > -1 or pyfile.name.endswith(".rev"):
- link.setStatus("queued")
- else:
- link.setCustomStatus("unskipped", "queued")
- return