summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/plugins/accounts/BitshareCom.py44
-rw-r--r--module/plugins/hooks/MergeFiles.py93
-rw-r--r--module/plugins/hoster/ArchivTo.py46
-rw-r--r--module/plugins/hoster/BitshareCom.py116
-rw-r--r--module/plugins/hoster/FilesonicCom.py4
-rw-r--r--module/plugins/hoster/MegauploadCom.py17
-rw-r--r--module/plugins/hoster/RapidshareCom.py4
7 files changed, 314 insertions, 10 deletions
diff --git a/module/plugins/accounts/BitshareCom.py b/module/plugins/accounts/BitshareCom.py
new file mode 100644
index 000000000..b0cd1efcd
--- /dev/null
+++ b/module/plugins/accounts/BitshareCom.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+
+"""
+ 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 3 of the License,
+ 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, see <http://www.gnu.org/licenses/>.
+
+ @author: pking
+"""
+
+from module.plugins.Account import Account
+
+class BitshareCom(Account):
+ __name__ = "BitshareCom"
+ __version__ = "0.1"
+ __type__ = "account"
+ __description__ = """Bitshare account plugin"""
+ __author_name__ = ("Paul King")
+
+ def loadAccountInfo(self, user, req):
+ page = req.load("http://bitshare.com/mysettings.html")
+
+ if "\"http://bitshare.com/myupgrade.html\">Free" in page:
+ return {"validuntil": -1, "trafficleft":-1, "premium": False}
+
+ if not '<input type="checkbox" name="directdownload" checked="checked" />' in page:
+ self.core.log.warning(_("Activate direct Download in your Bitshare Account"))
+
+ return {"validuntil": -1, "trafficleft": -1, "premium": True}
+
+
+ def login(self, user, data, req):
+ page = req.load("http://bitshare.com/login.html", post={ "user" : user, "pass" : data["password"], "submit" :"1"}, cookies=True)
+ if "Wrong Username or Password" in page:
+ self.wrongPassword()
diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py
new file mode 100644
index 000000000..02ed9fcb7
--- /dev/null
+++ b/module/plugins/hooks/MergeFiles.py
@@ -0,0 +1,93 @@
+# -*- coding: utf-8 -*-
+
+"""
+ 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 3 of the License,
+ 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, see <http://www.gnu.org/licenses/>.
+
+ @author: and9000
+"""
+
+from module.plugins.Hook import Hook
+
+import os
+import re
+import sys
+import traceback
+
+BUFFER_SIZE = 4096
+
+class MergeFiles(Hook):
+ __name__ = "MergeFiles"
+ __version__ = "0.1"
+ __description__ = "Merges parts splitted with hjsplit"
+ __config__ = [
+ ("activated" , "bool" , "Activated" , "True" ),
+ ]
+ __threaded__ = ["packageFinished"]
+ __author_name__ = ("and9000")
+ __author_mail__ = ("me@has-no-mail.com")
+
+ def setup(self):
+ # nothing to do
+ pass
+
+ def packageFinished(self, pack):
+ files = {}
+ fid_dict = {}
+ for fid, data in pack.getChildren().iteritems():
+ if re.search("\.[0-9]{3}$", data["name"]):
+ if data["name"][:-4] not in files:
+ files[data["name"][:-4]] = []
+ files[data["name"][:-4]].append(data["name"])
+ files[data["name"][:-4]].sort()
+ fid_dict[data["name"]] = fid
+
+ download_folder = self.core.config['general']['download_folder']
+
+ if self.core.config['general']['folder_per_package']:
+ download_folder = os.path.join(download_folder, pack.folder.decode(sys.getfilesystemencoding()))
+
+ for name, file_list in files.iteritems():
+ self.core.log.info("Starting merging of %s" % name)
+ final_file = open(os.path.join(download_folder, name), "wb")
+
+ for splitted_file in file_list:
+ self.core.log.debug("Merging part %s" % splitted_file)
+ pyfile = self.core.files.getFile(fid_dict[splitted_file])
+ pyfile.setStatus("processing")
+ pyfile.progress.setRange(0, 100)
+ try:
+ s_file = open(os.path.join(download_folder, splitted_file), "rb")
+ size_written = 0
+ s_file_size = int(os.path.getsize(os.path.join(download_folder, splitted_file)))
+ while True:
+ f_buffer = s_file.read(BUFFER_SIZE)
+ if f_buffer:
+ final_file.write(f_buffer)
+ size_written += BUFFER_SIZE
+ pyfile.progress.setValue((size_written*100)/s_file_size)
+ else:
+ break
+ s_file.close()
+ self.core.log.debug("Finished merging part %s" % splitted_file)
+ except Exception, e:
+ print traceback.print_exc()
+ finally:
+ pyfile.progress.setValue(100)
+ pyfile.setStatus("finished")
+ pyfile.release()
+
+ final_file.close()
+ self.core.log.info("Finished merging of %s" % name)
+
+
diff --git a/module/plugins/hoster/ArchivTo.py b/module/plugins/hoster/ArchivTo.py
new file mode 100644
index 000000000..02ff207ab
--- /dev/null
+++ b/module/plugins/hoster/ArchivTo.py
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+
+import re
+from module.plugins.Hoster import Hoster
+from module.unescape import unescape
+
+class ArchivTo(Hoster):
+ __name__ = "ArchivTo"
+ __type__ = "hoster"
+ __pattern__ = r"http://(www\.)?archiv.to/view/divx/"
+ __version__ = "0.1"
+ __description__ = """Archiv.to Video Download Hoster"""
+ __author_name__ = ("Petersilie")
+ __author_mail__ = ("None")
+
+ def setup(self):
+ self.html = None
+
+ def process(self, pyfile):
+ self.pyfile = pyfile
+ self.download_html()
+ pyfile.name = self.get_file_name()
+ self.download(self.get_file_url())
+
+ def download_html(self):
+ # open url (save cookies needed for download)
+ self.html = self.load(self.pyfile.url, cookies=True)
+
+ def get_file_url(self):
+ # get actual file url for downloading
+ file_url = re.search(r"autoplay=\"true\" custommode=\"none\" src=\"(http://.*?)\"", self.html).group(1)
+ return file_url
+
+ def get_file_name(self):
+ file_name = re.search(r"style=\"color:black;text-decoration:none;font-size:14px;font-weight:bold\">(.*?)</a>", self.html)
+ if not file_name:
+ file_name = re.search(r"movietitle=\"(.*?)\"", self.html)
+ return unescape(file_name.group(1))
+
+ def file_exists(self):
+ # check if file still exists
+ self.download_html()
+ self.load(str(self.pyfile.url), cookies=False)
+ if self.get_file_name():
+ return True
+ return False
diff --git a/module/plugins/hoster/BitshareCom.py b/module/plugins/hoster/BitshareCom.py
new file mode 100644
index 000000000..d092ad2dc
--- /dev/null
+++ b/module/plugins/hoster/BitshareCom.py
@@ -0,0 +1,116 @@
+# -*- coding: utf-8 -*-
+from __future__ import with_statement
+
+import re
+
+from os import remove
+
+from module.plugins.Hoster import Hoster
+from module.plugins.ReCaptcha import ReCaptcha
+
+from module.network.RequestFactory import getURL
+
+def getInfo(urls):
+ result = []
+
+ for url in urls:
+
+ # Get html
+ html = getURL(url)
+ if re.search(r'<h1>Error - File not available</h1>', html):
+ result.append((url, 0, 1, url))
+
+ attribs = re.search('<h1>Downloading (.+?) - (\d+) (..)yte</h1>', html)
+ # Name
+ name = attribs.group(1)
+
+ # Size
+ units = float(attribs.group(2))
+ pow = {'KB' : 1, 'MB' : 2, 'GB' : 3}[attribs.group(3)]
+ size = int(units*1024**pow)
+
+ # Return info
+ result.append((name, size, 2, url))
+
+ yield result
+
+class BitshareCom(Hoster):
+ __name__ = "BitshareCom"
+ __type__ = "hoster"
+ __pattern__ = r"http://(www\.)?bitshare\.com/(files/[a-zA-Z0-9]+|\?f=[a-zA-Z0-9]+)"
+ __version__ = "0.1"
+ __description__ = """Bitshare.Com File Download Hoster"""
+ __author_name__ = ("paul", "king")
+
+ def setup(self):
+ self.multiDL = False
+
+ def process(self, pyfile):
+
+ self.pyfile = pyfile
+
+ if re.search(r"bitshare\.com/\?f=",self.pyfile.url):
+ self.file_id = re.search(r"bitshare\.com/\?f=([a-zA-Z0-9]+)?", self.pyfile.url).group(1)
+ else:
+ self.file_id = re.search(r"bitshare\.com/files/([a-zA-Z0-9]+)?", self.pyfile.url).group(1)
+
+ self.log.debug("%s: file_id is %s" % (self.__name__,self.file_id))
+ self.pyfile.url = r"http://bitshare.com/?f=" + self.file_id
+
+ self.html = self.load(self.pyfile.url, ref=False, utf8=True)
+
+ if re.search(r'<h1>Error - File not available</h1>', self.html) is not None:
+ self.offline()
+
+ self.pyfile.name = re.search(r'<h1>Downloading (.+?) - (\d+) (..)yte</h1>', self.html).group(1)
+
+ self.ajaxid = re.search("var ajaxdl = \"(.*?)\";",self.html).group(1)
+
+ self.log.debug("%s: AjaxId %s" % (self.__name__,self.ajaxid))
+
+ self.handleFree()
+
+ def handleFree(self):
+
+ action = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html",
+ post={"request" : "generateID", "ajaxid" : self.ajaxid})
+ self.log.debug("%s: result of generateID %s" % (self.__name__,action))
+ parts = action.split(":")
+
+ if parts[0] == "ERROR":
+ self.fail(parts[1])
+
+ filetype = parts[0]
+ wait = int(parts[1])
+ captcha = int(parts[2])
+
+ if wait > 0:
+ self.log.info("%s: Waiting %d seconds." % (self.__name__, wait))
+ self.setWait(wait, True)
+ self.wait()
+
+ if captcha == 1:
+ id = re.search(r"http://api\.recaptcha\.net/challenge\?k=(.*?) ", self.html).group(1)
+ self.log.debug("%s: ReCaptcha key %s" % (self.__name__, id))
+ for i in range(3): # Try upto 3 times
+ recaptcha = ReCaptcha(self)
+ challenge, code = recaptcha.challenge(id)
+ action = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html",
+ post={"request" : "validateCaptcha", "ajaxid" : self.ajaxid, "recaptcha_challenge_field" : challenge, "recaptcha_response_field" : code})
+ parts = action.split(":")
+ if parts[0] != "SUCCESS":
+ self.invalidCaptcha()
+ else:
+ break
+
+ action = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html",
+ post={"request" : "getDownloadURL", "ajaxid" : self.ajaxid})
+
+ parts = action.split("#")
+
+ if parts[0] == "ERROR":
+ self.fail(parts[1])
+
+ # this may either download our file or forward us to an error page
+ self.log.debug("%s: download url %s" % (self.__name__, parts[1]))
+ dl = self.download(parts[1])
diff --git a/module/plugins/hoster/FilesonicCom.py b/module/plugins/hoster/FilesonicCom.py
index 97060d36e..ce441f482 100644
--- a/module/plugins/hoster/FilesonicCom.py
+++ b/module/plugins/hoster/FilesonicCom.py
@@ -25,7 +25,7 @@ class FilesonicCom(Hoster):
__name__ = "FilesonicCom"
__type__ = "hoster"
__pattern__ = r"http://[\w\.]*?(sharingmatrix|filesonic)\.(com|net)/.*?file/([0-9]+(/.+)?|[a-z0-9]+/[0-9]+(/.+)?)"
- __version__ = "0.2"
+ __version__ = "0.21"
__description__ = """FilesonicCom und Sharingmatrix Download Hoster"""
__author_name__ = ("jeix")
__author_mail__ = ("jeix@hasnomail.de")
@@ -133,3 +133,5 @@ class FilesonicCom(Hoster):
if "An Error Occurred" in self.html:
self.fail("A server error occured.")
+ if "This file was deleted" in self.html:
+ self.offline()
diff --git a/module/plugins/hoster/MegauploadCom.py b/module/plugins/hoster/MegauploadCom.py
index 9158e929e..9e5081fd3 100644
--- a/module/plugins/hoster/MegauploadCom.py
+++ b/module/plugins/hoster/MegauploadCom.py
@@ -30,17 +30,20 @@ def getInfo(urls):
for data in api:
if data[0].startswith("id"):
tmp = [x.split("=") for x in data]
- if tmp[2][1] == "3":
- status = 3
- elif tmp[0][1] == "0":
+ if tmp[0][1] == "0":
status = 2
elif tmp[0][1] == "1":
status = 1
+ elif tmp[2][1] == "3":
+ status = 3
else:
status = 3
-
- name = unescape(tmp[3][1])
- size = tmp[1][1]
+
+ name = None
+ size = 0
+ if status != 1:
+ name = unescape(tmp[3][1])
+ size = tmp[1][1]
result.append( (name, size, status, urls[i] ) )
i += 1
@@ -51,7 +54,7 @@ class MegauploadCom(Hoster):
__name__ = "MegauploadCom"
__type__ = "hoster"
__pattern__ = r"http://[\w\.]*?(megaupload)\.com/.*?(\?|&)d=[0-9A-Za-z]+"
- __version__ = "0.2"
+ __version__ = "0.21"
__description__ = """Megaupload.com Download Hoster"""
__author_name__ = ("spoob")
__author_mail__ = ("spoob@pyload.org")
diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py
index d98017d7b..2bc395a86 100644
--- a/module/plugins/hoster/RapidshareCom.py
+++ b/module/plugins/hoster/RapidshareCom.py
@@ -46,8 +46,8 @@ def getInfo(urls):
class RapidshareCom(Hoster):
__name__ = "RapidshareCom"
__type__ = "hoster"
- __pattern__ = r"http://[\w\.]*?rapidshare.com/(?:files/(?P<id>\d*?)/(?P<name>[^?]+)|#!download\|(?:\w+)\|(?P<id_new>\d+)\|(?P<name_new>[^|]+))"
- __version__ = "1.33"
+ __pattern__ = r"https?://[\w\.]*?rapidshare.com/(?:files/(?P<id>\d*?)/(?P<name>[^?]+)|#!download\|(?:\w+)\|(?P<id_new>\d+)\|(?P<name_new>[^|]+))"
+ __version__ = "1.34"
__description__ = """Rapidshare.com Download Hoster"""
__config__ = [["server", "Cogent;Deutsche Telekom;Level(3);Level(3) #2;GlobalCrossing;Level(3) #3;Teleglobe;GlobalCrossing #2;TeliaSonera #2;Teleglobe #2;TeliaSonera #3;TeliaSonera", "Preferred Server", "None"]]
__author_name__ = ("spoob", "RaNaN", "mkaay")