summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/HookManager.py6
-rw-r--r--module/plugins/Hook.py3
-rw-r--r--module/plugins/crypter/RelinkUs.py46
-rw-r--r--module/plugins/hooks/ExternalScripts.py14
-rw-r--r--module/plugins/hooks/UnRar.py1
-rw-r--r--module/setup.py2
6 files changed, 45 insertions, 27 deletions
diff --git a/module/HookManager.py b/module/HookManager.py
index c4e8c28a2..a6a8e4005 100644
--- a/module/HookManager.py
+++ b/module/HookManager.py
@@ -124,5 +124,11 @@ class HookManager():
if plugin.isActivated():
plugin.afterReconnecting(ip)
+ @lock
+ def unrarFinished(self, folder, fname):
+
+ for plugin in self.plugins:
+ plugin.unrarFinished(folder, fname)
+
def startThread(self, function, pyfile):
t = HookThread(self.core.threadManager, function, pyfile)
diff --git a/module/plugins/Hook.py b/module/plugins/Hook.py
index fafa95efe..93454b131 100644
--- a/module/plugins/Hook.py
+++ b/module/plugins/Hook.py
@@ -82,3 +82,6 @@ class Hook():
def periodical(self):
pass
+
+ def unrarFinished(self, folder, fname):
+ pass
diff --git a/module/plugins/crypter/RelinkUs.py b/module/plugins/crypter/RelinkUs.py
index bf92168ee..ddecaf280 100644
--- a/module/plugins/crypter/RelinkUs.py
+++ b/module/plugins/crypter/RelinkUs.py
@@ -1,14 +1,14 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from Crypto.Cipher import AES
-from module import JsEngine
-from module.plugins.Crypter import Crypter
import base64
import binascii
import re
import urllib
+from Crypto.Cipher import AES
+
+from module.plugins.Crypter import Crypter
class RelinkUs(Crypter):
__name__ = "RelinkUs"
@@ -18,33 +18,33 @@ class RelinkUs(Crypter):
__description__ = """Relink.us Container Plugin"""
__author_name__ = ("Sleeper-", "spoob", "fragonib")
__author_mail__ = ("@nonymous", "spoob@pyload.org", "fragonib@yahoo.es")
-
+
# Constants
_JK_KEY_ = "jk"
_CRYPTED_KEY_ = "crypted"
def decrypt(self, pyfile):
-
+
# Request page
self.html = self.load(pyfile.url)
if not self.file_exists():
self.offline()
-
- # Get package name and folder
+
+ # Get package name and folder
(package_name, folder_name) = self.getNameAndFolder()
-
+
# Get package links
(crypted, jk) = self.getCipherParams()
package_links = self.getLinks(crypted, jk)
- # Pack
+ # Pack
self.packages = [(package_name, package_links, folder_name)]
def file_exists(self):
if "sorry.png" in self.html:
return False
return True
-
+
def getCipherParams(self):
# Get vars dict
@@ -55,41 +55,39 @@ class RelinkUs(Crypter):
for pair in pairs:
index = pair.index('=')
vars[pair[:index]] = pair[index + 1:]
-
- # Extract cipher pair
+
+ # Extract cipher pair
jk = urllib.unquote(vars[RelinkUs._JK_KEY_].replace("+", " "))
crypted = vars[RelinkUs._CRYPTED_KEY_]
-
+
return (crypted, jk)
-
+
def getNameAndFolder(self):
title_re = r'<td class="top">Title</td><td class="top">\|</td><td><span class="info_view_id"><i>(?P<title>.*)</i></span></td>'
m = re.search(title_re, self.html)
if m is not None:
title = m.group('title')
- return (title, title)
+ return (title, title)
return (self.pyfile.package().name, self.pyfile.package().folder)
-
+
def getLinks(self, crypted, jk):
-
+
# Get key
- rt = JsEngine.JsEngine()
- jreturn = rt.eval("%s f()" % jk)
+ jreturn = self.js.eval("%s f()" % jk)
key = binascii.unhexlify(jreturn)
-
+
# Decode crypted
crypted = base64.standard_b64decode(crypted)
-
+
# Decrypt
Key = key
IV = key
obj = AES.new(Key, AES.MODE_CBC, IV)
text = obj.decrypt(crypted)
-
+
# Extract links
text = text.replace("\x00", "").replace("\r", "")
links = text.split("\n")
links = filter(lambda x: x != "", links)
-
+
return links
- \ No newline at end of file
diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py
index 111b60d22..8d749b5bd 100644
--- a/module/plugins/hooks/ExternalScripts.py
+++ b/module/plugins/hooks/ExternalScripts.py
@@ -40,7 +40,8 @@ class ExternalScripts(Hook):
join(pypath,'scripts','download_finished'),
join(pypath,'scripts','package_finished'),
join(pypath,'scripts','before_reconnect'),
- join(pypath,'scripts','after_reconnect')]
+ join(pypath,'scripts','after_reconnect'),
+ join(pypath,'scripts','unrar_finished')]
folder = core.path("scripts")
@@ -56,6 +57,7 @@ class ExternalScripts(Hook):
self.scripts['package_finished'] = filter(f, listdir(join(folder, 'package_finished')))
self.scripts['before_reconnect'] = filter(f, listdir(join(folder, 'before_reconnect')))
self.scripts['after_reconnect'] = filter(f, listdir(join(folder, 'after_reconnect')))
+ self.scripts['unrar_finished'] = filter(f, listdir(join(folder, 'unrar_finished')))
for script_type, script_name in self.scripts.iteritems():
if script_name != []:
@@ -103,6 +105,14 @@ class ExternalScripts(Hook):
def afterReconnecting(self, ip):
for script in self.scripts['after_reconnect']:
try:
- out = subprocess.Popen([join(self.folder, 'download_preparing', script), ip], stdout=subprocess.PIPE)
+ out = subprocess.Popen([join(self.folder, 'after_reconnect', script), ip], stdout=subprocess.PIPE)
except:
pass
+
+ def unrarFinished(self, folder, fname):
+ for script in self.scripts["unrar_finished"]:
+ try:
+ out = subprocess.Popen([join(self.folder, 'unrar_finished', script), folder, fname], stdout=subprocess.PIPE)
+ except:
+ pass
+
diff --git a/module/plugins/hooks/UnRar.py b/module/plugins/hooks/UnRar.py
index 88da0b64d..f47c08e89 100644
--- a/module/plugins/hooks/UnRar.py
+++ b/module/plugins/hooks/UnRar.py
@@ -161,6 +161,7 @@ class UnRar(Hook):
if success:
self.core.log.info(_("Unrar of %s ok") % fname)
self.removeFiles(pack, fname)
+ self.core.hookManager.unrarFinished(folder, fname)
else:
self.core.log.info(_("Unrar of %s failed (wrong password)") % fname)
finally:
diff --git a/module/setup.py b/module/setup.py
index 1991f0af4..2c3250dab 100644
--- a/module/setup.py
+++ b/module/setup.py
@@ -179,7 +179,7 @@ class Setup():
python = False
- if sys.version_info > (2, 7):
+ if sys.version_info > (2, 8):
print _("Your python version is to new, Please use Python 2.6/2.7")
python = False
elif sys.version_info < (2, 5):