summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hooks')
-rw-r--r--module/plugins/hooks/Checksum.py4
-rw-r--r--module/plugins/hooks/ExtractArchive.py12
-rw-r--r--module/plugins/hooks/IRCInterface.py4
-rw-r--r--module/plugins/hooks/TransmissionRPC.py84
-rw-r--r--module/plugins/hooks/XFileSharingPro.py12
5 files changed, 101 insertions, 15 deletions
diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py
index da4d35df1..64c5fa3ff 100644
--- a/module/plugins/hooks/Checksum.py
+++ b/module/plugins/hooks/Checksum.py
@@ -38,7 +38,7 @@ def compute_checksum(local_file, algorithm):
class Checksum(Addon):
__name__ = "Checksum"
__type__ = "hook"
- __version__ = "0.20"
+ __version__ = "0.21"
__status__ = "testing"
__config__ = [("check_checksum", "bool" , "Check checksum? (If False only size will be verified)", True ),
@@ -114,7 +114,7 @@ class Checksum(Addon):
api_size = int(data['size'])
file_size = os.path.getsize(local_file)
- if api_size is not file_size:
+ if api_size != file_size:
self.log_warning(_("File %s has incorrect size: %d B (%d expected)") % (pyfile.name, file_size, api_size))
self.check_failed(pyfile, local_file, "Incorrect file size")
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index eab196160..87cd38ade 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -51,7 +51,7 @@ except ImportError:
pass
from module.plugins.internal.Addon import Addon, Expose, threaded
-from module.plugins.internal.Plugin import replace_patterns
+from module.plugins.internal.Plugin import exists, replace_patterns
from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError
from module.utils import fs_encode, save_join as fs_join, uniqify
@@ -107,7 +107,7 @@ class ArchiveQueue(object):
class ExtractArchive(Addon):
__name__ = "ExtractArchive"
__type__ = "hook"
- __version__ = "1.49"
+ __version__ = "1.50"
__status__ = "testing"
__config__ = [("activated" , "bool" , "Activated" , True ),
@@ -288,7 +288,7 @@ class ExtractArchive(Addon):
if subfolder:
out = fs_join(out, pypack.folder)
- if not os.path.exists(out):
+ if not exists(out):
os.makedirs(out)
matched = False
@@ -313,7 +313,7 @@ class ExtractArchive(Addon):
for fname, fid, fout in targets:
name = os.path.basename(fname)
- if not os.path.exists(fname):
+ if not exists(fname):
self.log_debug(name, "File not found")
continue
@@ -356,7 +356,7 @@ class ExtractArchive(Addon):
for filename in new_files:
file = fs_encode(fs_join(os.path.dirname(archive.filename), filename))
- if not os.path.exists(file):
+ if not exists(file):
self.log_debug("New file %s does not exists" % filename)
continue
@@ -476,7 +476,7 @@ class ExtractArchive(Addon):
deltotrash = self.get_config('deltotrash')
for f in delfiles:
file = fs_encode(f)
- if not os.path.exists(file):
+ if not exists(file):
continue
if not deltotrash:
diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py
index 08b1bad0c..5d8928a57 100644
--- a/module/plugins/hooks/IRCInterface.py
+++ b/module/plugins/hooks/IRCInterface.py
@@ -18,7 +18,7 @@ from module.utils import formatSize
class IRCInterface(Thread, Addon):
__name__ = "IRCInterface"
__type__ = "hook"
- __version__ = "0.15"
+ __version__ = "0.16"
__status__ = "testing"
__config__ = [("host" , "str" , "IRC-Server Address" , "Enter your server here!"),
@@ -40,7 +40,7 @@ class IRCInterface(Thread, Addon):
def __init__(self, core, manager):
Thread.__init__(self)
Addon.__init__(self, core, manager)
- self.set_daemon(True)
+ self.setDaemon(True)
def activate(self):
diff --git a/module/plugins/hooks/TransmissionRPC.py b/module/plugins/hooks/TransmissionRPC.py
new file mode 100644
index 000000000..2ca06a9ad
--- /dev/null
+++ b/module/plugins/hooks/TransmissionRPC.py
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+
+import random
+import re
+
+import pycurl
+
+from module.common.json_layer import json_loads, json_dumps
+from module.network.HTTPRequest import BadHeader
+from module.network.RequestFactory import getRequest as get_request
+from module.plugins.internal.Addon import Addon
+
+
+class TransmissionRPC(Addon):
+ __name__ = "TransmissionRPC"
+ __type__ = "hook"
+ __version__ = "0.12"
+ __status__ = "testing"
+
+ __pattern__ = r"https?://.+\.torrent|magnet:\?.+"
+ __config__ = [("rpc_url", "str", "Transmission RPC URL", "http://127.0.0.1:9091/transmission/rpc")]
+
+ __description__ = """Send torrent and magnet URLs to Transmission Bittorent daemon via RPC"""
+ __license__ = "GPLv3"
+ __authors__ = [("GammaC0de", None)]
+
+
+ def init(self):
+ self.event_map = {'linksAdded': "links_added"}
+
+
+ def links_added(self, links, pid):
+ pattern = re.compile(self.__pattern__)
+ urls = [link for link in links if pattern.match(link)]
+
+ for url in urls:
+ self.log_debug("Sending link: %s" % url)
+ self.send_to_transmission(url)
+ links.remove(url)
+
+
+ def send_to_transmission(self, url):
+ transmission_rpc_url = self.get_config('rpc_url')
+ client_request_id = self.__name__ + "".join(random.choice('0123456789ABCDEF') for _i in xrange(4))
+ req = get_request()
+
+ try:
+ response = self.load(transmission_rpc_url,
+ post=json_dumps({'arguments': {'filename': url},
+ 'method' : 'torrent-add',
+ 'tag' : client_request_id}),
+ req=req)
+
+ except BadHeader, e:
+ if e.code == 409:
+ headers = dict(re.findall(r"(?P<name>.+?): (?P<value>.+?)\r?\n", req.header))
+ session_id = headers['X-Transmission-Session-Id']
+ req.c.setopt(pycurl.HTTPHEADER, ["X-Transmission-Session-Id: %s" % session_id])
+ try:
+ response = self.load(transmission_rpc_url,
+ post=json_dumps({'arguments': {'filename': url},
+ 'method' : 'torrent-add',
+ 'tag' : client_request_id}),
+ req=req)
+
+ except Exception, e:
+ self.log_error(e)
+ return
+
+ else:
+ self.log_error(e)
+ return
+
+ except Exception, e:
+ self.log_error(e)
+ return
+
+ try:
+ res = json_loads(response)
+ if "result" in res:
+ self.log_debug("Result: %s" % res['result'])
+
+ except Exception, e:
+ self.log_error(e)
diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py
index 7567a31a3..9b9c7f0ad 100644
--- a/module/plugins/hooks/XFileSharingPro.py
+++ b/module/plugins/hooks/XFileSharingPro.py
@@ -29,18 +29,20 @@ class XFileSharingPro(Hook):
r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:user|folder)s?/\w+')}
HOSTER_BUILTIN = [#WORKING HOSTERS:
- "ani-stream.com", "backin.net", "cloudsix.me", "eyesfile.ca", "file4safe.com",
- "fileband.com", "filedwon.com", "fileparadox.in", "filevice.com",
- "hostingbulk.com", "junkyvideo.com", "linestorage.com", "ravishare.com",
+ "ani-stream.com", "backin.net", "cloudsix.me", "eyesfile.ca",
+ "file4safe.com", "fileband.com", "filedwon.com", "fileparadox.in",
+ "filevice.com", "hostingbulk.com", "junkyvideo.com", "ravishare.com",
"ryushare.com", "salefiles.com", "sendmyway.com", "sharebeast.com",
- "sharesix.com", "thefile.me", "verzend.be", "worldbytez.com", "xvidstage.com",
+ "sharesix.com", "thefile.me", "verzend.be", "worldbytez.com",
+ "xvidstage.com",
#: NOT TESTED:
"101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com",
"linkzhost.com", "mightyupload.com", "rockdizfile.com", "sharerepo.com",
"shareswift.com", "uploadbaz.com", "uploadc.com", "vidbull.com",
"zalaa.com", "zomgupload.com",
#: NOT WORKING:
- "amonshare.com", "banicrazy.info", "boosterking.com", "host4desi.com", "laoupload.com", "rd-fs.com"]
+ "amonshare.com", "banicrazy.info", "boosterking.com", "host4desi.com",
+ "laoupload.com", "rd-fs.com"]
CRYPTER_BUILTIN = ["junocloud.me", "rapidfileshare.net"]