From 08034f0e592d915297665175062ce3e849e48dbf Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Sat, 24 Mar 2012 16:56:35 +0100 Subject: icyfiles, bayfiles by godofdream, alldebrid json api, zevera python 2.5 compat. --- module/plugins/accounts/AlldebridCom.py | 39 ++++--- module/plugins/accounts/ZeveraCom.py | 195 ++++++++------------------------ module/plugins/hoster/AlldebridCom.py | 50 ++++++-- module/plugins/hoster/BayfilesCom.py | 13 ++- module/plugins/hoster/FiledinoCom.py | 15 ++- module/plugins/hoster/FilerioCom.py | 20 ++++ module/plugins/hoster/IcyFilesCom.py | 115 +++++++++++++++++++ 7 files changed, 268 insertions(+), 179 deletions(-) create mode 100644 module/plugins/hoster/FilerioCom.py create mode 100644 module/plugins/hoster/IcyFilesCom.py (limited to 'module/plugins') diff --git a/module/plugins/accounts/AlldebridCom.py b/module/plugins/accounts/AlldebridCom.py index 4968e9bdd..f87a1c881 100644 --- a/module/plugins/accounts/AlldebridCom.py +++ b/module/plugins/accounts/AlldebridCom.py @@ -1,27 +1,40 @@ from module.plugins.Account import Account import xml.dom.minidom as dom +from BeautifulSoup import BeautifulSoup from time import time +import re class AlldebridCom(Account): __name__ = "AlldebridCom" - __version__ = "0.1" + __version__ = "0.2" __type__ = "account" __description__ = """AllDebrid.com account plugin""" __author_name__ = ("Andy, Voigt") __author_mail__ = ("spamsales@online.de") def loadAccountInfo(self, user, req): - data = self.getAccountData(user) - page = req.load("http://www.alldebrid.com/api.php?action=info_user&login=%s&pw=%s" % (user, data["password"])) - self.log.debug(page) - xml = dom.parseString(page) - account_info = {"validuntil": (time()+int(xml.getElementsByTagName("date")[0].childNodes[0].nodeValue)*86400), - "trafficleft": -1} - - return account_info + data = self.getAccountData(user) + page = req.load("http://www.alldebrid.com/account/") + soup=BeautifulSoup(page) + #Try to parse expiration date directly from the control panel page (better accuracy) + try: + time_text=soup.find('div',attrs={'class':'remaining_time_text'}).strong.string + self.log.debug("Account expires in: %s" % time_text) + p = re.compile('\d+') + exp_data=p.findall(time_text) + exp_time=time()+int(exp_data[0])*24*60*60+int(exp_data[1])*60*60+(int(exp_data[2])-1)*60 + #Get expiration date from API + except: + data = self.getAccountData(user) + page = req.load("http://www.alldebrid.com/api.php?action=info_user&login=%s&pw=%s" % (user, data["password"])) + self.log.debug(page) + xml = dom.parseString(page) + exp_time=time()+int(xml.getElementsByTagName("date")[0].childNodes[0].nodeValue)*86400 + account_info = {"validuntil": exp_time, "trafficleft": -1} + return account_info def login(self, user, data, req): - page = req.load("http://www.alldebrid.com/register/?action=login&login_login=%s&login_password=%s" % (user, data["password"])) - - if "This login doesn't exist" in page: - self.wrongPassword() + page = req.load("http://www.alldebrid.com/register/?action=login&login_login=%s&login_password=%s" % (user, data["password"])) + + if "This login doesn't exist" in page: + self.wrongPassword() diff --git a/module/plugins/accounts/ZeveraCom.py b/module/plugins/accounts/ZeveraCom.py index 65d1d0bc2..61a66cd89 100644 --- a/module/plugins/accounts/ZeveraCom.py +++ b/module/plugins/accounts/ZeveraCom.py @@ -1,146 +1,49 @@ -# -*- coding: utf-8 -*- -from module.plugins.Account import Account - -import re -from time import mktime, strptime - -class ZeveraCom(Account): - __name__ = "ZeveraCom" - __version__ = "0.20" - __type__ = "account" - __description__ = """Zevera.com account plugin""" - __author_name__ = ("zoidberg") - __author_mail__ = ("zoidberg@mujmail.cz") - - def loadAccountInfo(self, user, req): - data = self.getAPIData(req) - if data == "No traffic": - account_info = {"trafficleft": 0, "validuntil": 0, "premium": False} - else: - account_info = { - "trafficleft": int(data['availabletodaytraffic']) * 1024, - "validuntil": mktime(strptime(data['endsubscriptiondate'],"%Y/%m/%d %H:%M:%S")), - "premium": True - } - return account_info - - def login(self, user, data, req): - self.loginname = user - self.password = data["password"] - if self.getAPIData(req) == "No traffic": - self.wrongPassword() - - def getAPIData(self, req, just_header = False, **kwargs): - get_data = { - 'cmd': 'accountinfo', - 'login': self.loginname, - 'pass': self.password - } - get_data.update(kwargs) - - response = req.load("http://www.zevera.com/jDownloader.ashx", get = get_data, decode = True, just_header = just_header) - self.logDebug(response) - - if ':' in response: - if not just_header: - response = response.replace(',','\n') - return {y.strip().lower(): z.strip() for y,z in [x.split(':',1) for x in response.splitlines() if ':' in x]} - else: - return response - - - - """ - # BitAPI not used - defunct, probably abandoned by Zevera - - def loadAccountInfo(self, user, req): - dataRet = self.loadAPIRequest(req) - account_info = { - "trafficleft": dataRet['AccountInfo']['AvailableTODAYTrafficForUseInMBytes'] * 1024, - "validuntil": -1 #dataRet['AccountInfo']['EndSubscriptionDate'] - } - - return account_info - - def login(self, user, data, req): - self.loginname = user - self.password = data["password"] - if self.loadAPIRequest(req, parse = False) == 'Login Error': - self.wrongPassword() - - - def loadAPIRequest(self, req, parse = True, **kwargs): - get_dict = { - 'cmd': 'download_request', - 'login': self.loginname, - 'pass': self.password - } - get_dict.update(kwargs) - - response = req.load(self.api_url, get = get_dict, decode = True) - self.logDebug(response) - return self.parseAPIRequest(response) if parse else response - - def parseAPIRequest(self, api_response): - - try: - arFields = iter(api_response.split('TAG BEGIN DATA#')[1].split('#END DATA')[0].split('#')) - - retData = { - 'VersionMajor': arFields.next(), - 'VersionMinor': arFields.next(), - 'ErrorCode': int(arFields.next()), - 'ErrorMessage': arFields.next(), - 'Update_Wait': arFields.next() - } - serverInfo = { - 'DateTimeOnServer': mktime(strptime(arFields.next(),"%Y/%m/%d %H:%M:%S")), - 'DAY_Traffic_LimitInMBytes': int(arFields.next()) - } - accountInfo = { - 'EndSubscriptionDate': mktime(strptime(arFields.next(),"%Y/%m/%d %H:%M:%S")), - 'TrafficUsedInMBytesDayToday': int(arFields.next()), - 'AvailableEXTRATrafficForUseInMBytes': int(arFields.next()), - 'AvailableTODAYTrafficForUseInMBytes': int(arFields.next()) - } - fileInfo = { - 'FileID': arFields.next(), - 'Title': arFields.next(), - 'RealFileName': arFields.next(), - 'FileNameOnServer': arFields.next(), - 'StorageServerURL': arFields.next(), - 'Token': arFields.next(), - 'FileSizeInBytes': int(arFields.next()), - 'StatusID': int(arFields.next()) - } - progress = { - 'BytesReceived': int(arFields.next()), - 'TotalBytesToReceive': int(arFields.next()), - 'Percentage': arFields.next(), - 'StatusText': arFields.next(), - 'ProgressText': arFields.next() - } - fileInfo.update({ - 'Progress': progress, - 'FilePassword': arFields.next(), - 'Keywords': arFields.next(), - 'ImageURL4Download': arFields.next(), - 'CategoryID': arFields.next(), - 'CategoryText': arFields.next(), - 'Notes': arFields.next() - }) - retData.update({ - 'ServerInfo': serverInfo, - 'AccountInfo': accountInfo, - 'FileInfo': fileInfo - }) - - #self.infos[self.loginname]['trafficleft'] = accountInfo['AvailableTODAYTrafficForUseInMBytes'] * 1024 - - except Exception, e: - self.logError(e) - return None - - self.logDebug(retData) - return retData - """ \ No newline at end of file +# -*- coding: utf-8 -*- +from module.plugins.Account import Account + +import re +from time import mktime, strptime + +class ZeveraCom(Account): + __name__ = "ZeveraCom" + __version__ = "0.21" + __type__ = "account" + __description__ = """Zevera.com account plugin""" + __author_name__ = ("zoidberg") + __author_mail__ = ("zoidberg@mujmail.cz") + + def loadAccountInfo(self, user, req): + data = self.getAPIData(req) + if data == "No traffic": + account_info = {"trafficleft": 0, "validuntil": 0, "premium": False} + else: + account_info = { + "trafficleft": int(data['availabletodaytraffic']) * 1024, + "validuntil": mktime(strptime(data['endsubscriptiondate'],"%Y/%m/%d %H:%M:%S")), + "premium": True + } + return account_info + + def login(self, user, data, req): + self.loginname = user + self.password = data["password"] + if self.getAPIData(req) == "No traffic": + self.wrongPassword() + + def getAPIData(self, req, just_header = False, **kwargs): + get_data = { + 'cmd': 'accountinfo', + 'login': self.loginname, + 'pass': self.password + } + get_data.update(kwargs) + + response = req.load("http://www.zevera.com/jDownloader.ashx", get = get_data, decode = True, just_header = just_header) + self.logDebug(response) + + if ':' in response: + if not just_header: + response = response.replace(',','\n') + return dict((y.strip().lower(), z.strip()) for (y,z) in [x.split(':',1) for x in response.splitlines() if ':' in x]) + else: + return response \ No newline at end of file diff --git a/module/plugins/hoster/AlldebridCom.py b/module/plugins/hoster/AlldebridCom.py index 56e3a9040..e93e7beb9 100644 --- a/module/plugins/hoster/AlldebridCom.py +++ b/module/plugins/hoster/AlldebridCom.py @@ -1,15 +1,19 @@ #!/usr/nv python # -*- coding: utf-8 -*- -import BeautifulSoup +import re from urllib import quote, unquote from random import randrange +from os import stat from module.plugins.Hoster import Hoster +from module.common.json_layer import json_loads +from module.utils import parseFileSize, fs_encode + class AlldebridCom(Hoster): __name__ = "AlldebridCom" - __version__ = "0.1" + __version__ = "0.2" __type__ = "hoster" __pattern__ = r"https?://.*alldebrid\..*" @@ -33,14 +37,35 @@ class AlldebridCom(Hoster): def process(self, pyfile): - url="http://www.alldebrid.com/service.php?link=%s" %(pyfile.url) - - page = self.load(url) - - soup = BeautifulSoup.BeautifulSoup(page) - for link in soup.findAll("a"): - new_url = link.get("href") + if not self.account: + self.logError(_("Please enter your AllDebrid account or deactivate this plugin")) + self.fail("No AllDebrid account provided") + self.log.debug("AllDebrid: Old URL: %s" % pyfile.url) + if re.match(self.__pattern__, pyfile.url): + new_url = pyfile.url + else: + password = self.getPassword().splitlines() + if not password: password = "" + else: password = password[0] + + url = "http://www.alldebrid.com/service.php?link=%s&json=true&pw=%s" %(pyfile.url, password) + page = self.load(url) + data = json_loads(page) + + self.log.debug("Json data: %s" % str(data)) + + if data["error"]: + if data["error"] == "This link isn't available on the hoster website.": + self.offline() + else: + self.logWarning(data["error"]) + self.tempOffline() + else: + if self.pyfile.name and not self.pyfile.name.endswith('.tmp'): + self.pyfile.name = data["filename"] + self.pyfile.size = parseFileSize(data["filesize"]) + new_url = data["link"] if self.getConfig("https"): new_url = new_url.replace("http://", "https://") @@ -49,7 +74,6 @@ class AlldebridCom(Hoster): self.log.debug("AllDebrid: New URL: %s" % new_url) - if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown"): #only use when name wasnt already set pyfile.name = self.getFilename(new_url) @@ -57,9 +81,11 @@ class AlldebridCom(Hoster): self.download(new_url, disposition=True) check = self.checkDownload( - {"error": "An error occured while processing your request"}) + {"error": "An error occured while processing your request","empty": re.compile(r"^$")}) if check == "error": - #usual this download can safely be retried self.retry(reason="An error occured while generating link.", wait_time=60) + else: + if check == "empty": + self.retry(reason="Downloaded File was empty.", wait_time=60) diff --git a/module/plugins/hoster/BayfilesCom.py b/module/plugins/hoster/BayfilesCom.py index e2c74e5c0..a69dd3ea9 100644 --- a/module/plugins/hoster/BayfilesCom.py +++ b/module/plugins/hoster/BayfilesCom.py @@ -79,6 +79,15 @@ class BayfilesCom(SimpleHoster): def startDownload(self, url): self.logDebug("%s URL: %s" % ("Premium" if self.premium else "Free", url)) - self.download(url) + self.download(url) + # check download + check = self.checkDownload({ + "waitforfreeslots": re.compile(r"^BayFiles$") + }) + if check == "waitforfreeslots": + self.waitForFreeSlot() + + def waitForFreeSlot(self): + self.retry(60, 300, "Wait for free slot") -getInfo = create_getInfo(BayfilesCom) \ No newline at end of file +getInfo = create_getInfo(BayfilesCom) diff --git a/module/plugins/hoster/FiledinoCom.py b/module/plugins/hoster/FiledinoCom.py index 7d1a82df4..6bdd01b51 100644 --- a/module/plugins/hoster/FiledinoCom.py +++ b/module/plugins/hoster/FiledinoCom.py @@ -1,18 +1,21 @@ # -*- coding: utf-8 -*- from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +import re class FiledinoCom(XFileSharingPro): __name__ = "FiledinoCom" __type__ = "hoster" - __pattern__ = r"http://(?:\w*\.)*filedino.com/\w{12}" - __version__ = "0.01" - __description__ = """FileDino.com hoster plugin""" + __pattern__ = r"http://(?:\w*\.)*(file(dino|fat).com)/\w{12}" + __version__ = "0.02" + __description__ = """FileDino / FileFat hoster plugin""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") - FILE_SIZE_PATTERN = r'File Size : (?P.+?)' + FILE_SIZE_PATTERN = r'File Size : <(span|font)[^>]*>(?P.+?)' + DIRECT_LINK_PATTERN = r'http://www\.file(dino|fat)\.com/cgi-bin/dl\.cgi/' - HOSTER_NAME = "filedino.com" - DIRECT_LINK_PATTERN = r'http://www\.filedino\.com/cgi-bin/dl\.cgi/' + def setup(self): + self.HOSTER_NAME = re.search(self.__pattern__, self.pyfile.url).group(1) + self.multiDL = False getInfo = create_getInfo(FiledinoCom) \ No newline at end of file diff --git a/module/plugins/hoster/FilerioCom.py b/module/plugins/hoster/FilerioCom.py new file mode 100644 index 000000000..3d983bedf --- /dev/null +++ b/module/plugins/hoster/FilerioCom.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo + +class FilerioCom(XFileSharingPro): + __name__ = "FilerioCom" + __type__ = "hoster" + __pattern__ = r"http://(?:\w*\.)*file(rio|keen).com/\w{12}" + __version__ = "0.01" + __description__ = """FileRio.com hoster plugin""" + __author_name__ = ("zoidberg") + __author_mail__ = ("zoidberg@mujmail.cz") + + FILE_OFFLINE_PATTERN = '"File Not Found"|File has been removed due to Copyright Claim' + HOSTER_NAME = "filerio.com" + DIRECT_LINK_PATTERN = r'Download Link:.*?. + + @author: godofdream +""" + +import re +from module.plugins.Hoster import Hoster +from module.network.RequestFactory import getURL + +def getInfo(urls): + result = [] + for url in urls: + html = getURL(url, decode=True) + if re.search(IcyFilesCom.FILE_OFFLINE_PATTERN, html): + # File offline + result.append((url, 0, 1, url)) + else: + # Get file info + name = re.search(IcyFilesCom.FILE_NAME_PATTERN, html) + size = re.search(IcyFilesCom.SIZE_PATTERN, html) + if name is not None: + name = name.group(1) + size = size.group(1) + result.append((name, size, 2, url)) + yield result + + +class IcyFilesCom(Hoster): + __name__ = "IcyFilesCom" + __type__ = "hoster" + __pattern__ = r"http://(?:www\.)?icyfiles\.com/.*" + __version__ = "0.01" + __description__ = """IcyFiles.com plugin - free only""" + __author_name__ = ("godofdream") + __author_mail__ = ("soilfiction@gmail.com") + + FILE_NAME_PATTERN = r'
(.*?)
' + SIZE_PATTERN = r'
  • (\d+) Size/mb' + FILE_OFFLINE_PATTERN = r'The requested File cant be found' + WAIT_LONGER_PATTERN = r'All download tickets are in use\. please try it again in a few seconds' + WAIT_PATTERN = r'
    (d+)
    ' + TOOMUCH_PATTERN = r'Sorry dude, you have downloaded too much\. Please wait (\\d+) seconds' + URL_PATTERN = r'http://.*?icyfiles\.com/(.*)' + + def setup(self): + self.multiDL = False + + def process(self, pyfile): + self.html = self.load(pyfile.url, decode=True) + # check if offline + if re.search(self.FILE_OFFLINE_PATTERN, self.html): + self.offline() + # All Downloadtickets in use + timmy = re.search(self.WAIT_LONGER_PATTERN, self.html) + if timmy: + self.waitForFreeSlot() + # Wait the waittime + timmy = re.search(self.WAIT_PATTERN, self.html) + if timmy: + self.waitSeconds(timmy.group(1)) + # Downloaded to much + timmy = re.search(self.TOOMUCH_PATTERN, self.html) + if timmy: + self.waitSeconds(timmy.group(1)) + # Find Name + found = re.search(self.FILE_NAME_PATTERN, self.html) + if found is None: + self.fail("Parse error (NAME)") + pyfile.name = found.group(1) + # Get the URL + url = pyfile.url + found = re.search(self.URL_PATTERN, url) + if found is None: + self.fail("Parse error (URL)") + download_url = "http://icyfiles.com/download.php?key=" + found.group(1) + + self.download(download_url) + + # check download + check = self.checkDownload({ + "notfound": re.compile(r"^404 Not Found$"), + "skippedcountdown": re.compile(r"^Dont skip the countdown$"), + "waitforfreeslots": re.compile(self.WAIT_LONGER_PATTERN), + "downloadedtoomuch": re.compile(self.TOOMUCH_PATTERN) + }) + if check == "skippedcountdown": + self.fail("Countdown error") + elif check == "notfound": + self.fail("404 Not found") + elif check == "waitforfreeslots": + self.waitForFreeSlot() + elif check == "downloadedtoomuch": + self.retry() + + def waitForFreeSlot(self): + self.setWait(900, True) + self.wait() + self.retry(60, 1, "Wait for free slot") + + def waitSeconds(self, seconds): + self.setWait(seconds + 2) + self.wait() -- cgit v1.2.3