diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-06-17 18:59:20 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-06-24 22:42:40 +0200 |
commit | 20b6a2ec022202b0efb6cb69415239fb8f4d1445 (patch) | |
tree | fdbb3ad42854144b1cace0221145a472b36ef84d /module | |
parent | Spare code cosmetics (diff) | |
download | pyload-20b6a2ec022202b0efb6cb69415239fb8f4d1445.tar.xz |
Spare code cosmetics (2)
Diffstat (limited to 'module')
96 files changed, 582 insertions, 585 deletions
diff --git a/module/plugins/accounts/FastshareCz.py b/module/plugins/accounts/FastshareCz.py index d1d79f7b1..54253041c 100644 --- a/module/plugins/accounts/FastshareCz.py +++ b/module/plugins/accounts/FastshareCz.py @@ -40,7 +40,7 @@ class FastshareCz(Account): def login(self, user, data, req): req.cj.setCookie("fastshare.cz", "lang", "en") - self.load('http://www.fastshare.cz/login', req=req) # Do not remove or it will not login + self.load('http://www.fastshare.cz/login', req=req) #: Do not remove or it will not login html = self.load("https://www.fastshare.cz/sql.php", post={'login': user, 'heslo': data['password']}, req=req) diff --git a/module/plugins/accounts/FilecloudIo.py b/module/plugins/accounts/FilecloudIo.py index 300159acf..4d69a2ae2 100644 --- a/module/plugins/accounts/FilecloudIo.py +++ b/module/plugins/accounts/FilecloudIo.py @@ -16,7 +16,7 @@ class FilecloudIo(Account): def loadAccountInfo(self, user, req): - # It looks like the first API request always fails, so we retry 5 times, it should work on the second try + #: It looks like the first API request always fails, so we retry 5 times, it should work on the second try for _i in xrange(5): rep = self.load("https://secure.filecloud.io/api-fetch_apikey.api", post={"username": user, "password": self.getAccountData(user)['password']}) @@ -30,7 +30,7 @@ class FilecloudIo(Account): return {"premium": False} akey = rep['akey'] - self.accounts[user]['akey'] = akey # Saved for hoster plugin + self.accounts[user]['akey'] = akey #: Saved for hoster plugin rep = self.load("http://api.filecloud.io/api-fetch_account_details.api", post={"akey": akey}, req=req) rep = json_loads(rep) diff --git a/module/plugins/accounts/FilerNet.py b/module/plugins/accounts/FilerNet.py index aca09a7ed..9ab900831 100644 --- a/module/plugins/accounts/FilerNet.py +++ b/module/plugins/accounts/FilerNet.py @@ -25,7 +25,7 @@ class FilerNet(Account): def loadAccountInfo(self, user, req): html = self.load("https://filer.net/profile", req=req) - # Free user + #: Free user if re.search(self.FREE_PATTERN, html): return {"premium": False, "validuntil": None, "trafficleft": None} diff --git a/module/plugins/accounts/FourSharedCom.py b/module/plugins/accounts/FourSharedCom.py index 041671b9a..2f79d944c 100644 --- a/module/plugins/accounts/FourSharedCom.py +++ b/module/plugins/accounts/FourSharedCom.py @@ -15,7 +15,7 @@ class FourSharedCom(Account): def loadAccountInfo(self, user, req): - # Free mode only for now + #: Free mode only for now return {"premium": False} diff --git a/module/plugins/accounts/FreeWayMe.py b/module/plugins/accounts/FreeWayMe.py index 5a1f75bf6..b9a0acea7 100644 --- a/module/plugins/accounts/FreeWayMe.py +++ b/module/plugins/accounts/FreeWayMe.py @@ -35,7 +35,7 @@ class FreeWayMe(Account): def login(self, user, data, req): status = self.getAccountStatus(user, req) - # Check if user and password are valid + #: Check if user and password are valid if not status: self.wrongPassword() diff --git a/module/plugins/accounts/LetitbitNet.py b/module/plugins/accounts/LetitbitNet.py index 6b538c1f0..811abd971 100644 --- a/module/plugins/accounts/LetitbitNet.py +++ b/module/plugins/accounts/LetitbitNet.py @@ -30,5 +30,5 @@ class LetitbitNet(Account): def login(self, user, data, req): - # API_KEY is the username and the PREMIUM_KEY is the password + #: API_KEY is the username and the PREMIUM_KEY is the password self.logInfo(_("You must use your API KEY as username and the PREMIUM KEY as password")) diff --git a/module/plugins/accounts/MegaDebridEu.py b/module/plugins/accounts/MegaDebridEu.py index 9a7508617..53c67833c 100644 --- a/module/plugins/accounts/MegaDebridEu.py +++ b/module/plugins/accounts/MegaDebridEu.py @@ -14,7 +14,7 @@ class MegaDebridEu(Account): __authors__ = [("D.Ducatel", "dducatel@je-geek.fr")] - # Define the base URL of MegaDebrid api + #: Define the base URL of MegaDebrid api API_URL = "https://www.mega-debrid.eu/api.php" diff --git a/module/plugins/accounts/MyfastfileCom.py b/module/plugins/accounts/MyfastfileCom.py index a854dd826..258c99346 100644 --- a/module/plugins/accounts/MyfastfileCom.py +++ b/module/plugins/accounts/MyfastfileCom.py @@ -25,7 +25,7 @@ class MyfastfileCom(Account): def login(self, user, data, req): - # Password to use is the API-Password written in http://myfastfile.com/myaccount + #: Password to use is the API-Password written in http://myfastfile.com/myaccount html = self.load("https://myfastfile.com/api.php", get={"user": user, "pass": data['password']}, req=req) diff --git a/module/plugins/accounts/NoPremiumPl.py b/module/plugins/accounts/NoPremiumPl.py index 024cdfebe..30822791b 100644 --- a/module/plugins/accounts/NoPremiumPl.py +++ b/module/plugins/accounts/NoPremiumPl.py @@ -36,7 +36,7 @@ class NoPremiumPl(Account): try: result = json_loads(self.runAuthQuery()) except Exception: - # todo: return or let it be thrown? + #@TODO: return or let it be thrown? return premium = False diff --git a/module/plugins/accounts/OverLoadMe.py b/module/plugins/accounts/OverLoadMe.py index e7e1b71e1..898c122cd 100644 --- a/module/plugins/accounts/OverLoadMe.py +++ b/module/plugins/accounts/OverLoadMe.py @@ -23,7 +23,7 @@ class OverLoadMe(Account): data = json_loads(html) self.logDebug(data) - # Check for premium + #: Check for premium if data['membership'] == "Free": return {'premium': False, 'validuntil': None, 'trafficleft': None} else: diff --git a/module/plugins/accounts/PremiumizeMe.py b/module/plugins/accounts/PremiumizeMe.py index 686898ca4..d7f0b7391 100644 --- a/module/plugins/accounts/PremiumizeMe.py +++ b/module/plugins/accounts/PremiumizeMe.py @@ -15,11 +15,11 @@ class PremiumizeMe(Account): def loadAccountInfo(self, user, req): - # Get user data from premiumize.me + #: Get user data from premiumize.me status = self.getAccountStatus(user, req) self.logDebug(status) - # Parse account info + #: Parse account info account_info = {"validuntil": float(status['result']['expires']), "trafficleft": max(0, status['result']['trafficleft_bytes'] / 1024)} #@TODO: Remove `/ 1024` in 0.4.10 @@ -30,17 +30,17 @@ class PremiumizeMe(Account): def login(self, user, data, req): - # Get user data from premiumize.me + #: Get user data from premiumize.me status = self.getAccountStatus(user, req) - # Check if user and password are valid + #: Check if user and password are valid if status['status'] != 200: self.wrongPassword() def getAccountStatus(self, user, req): - # Use premiumize.me API v1 (see https://secure.premiumize.me/?show=api) - # to retrieve account info and return the parsed json answer + #: Use premiumize.me API v1 (see https://secure.premiumize.me/?show=api) + #: to retrieve account info and return the parsed json answer answer = self.load("http://api.premiumize.me/pm-api/v1.php", #@TODO: Revert to `https` in 0.4.10 get={'method' : "accountstatus", 'params[login]': user, diff --git a/module/plugins/accounts/RPNetBiz.py b/module/plugins/accounts/RPNetBiz.py index 509febde6..be456f2d7 100644 --- a/module/plugins/accounts/RPNetBiz.py +++ b/module/plugins/accounts/RPNetBiz.py @@ -15,11 +15,11 @@ class RPNetBiz(Account): def loadAccountInfo(self, user, req): - # Get account information from rpnet.biz + #: Get account information from rpnet.biz res = self.getAccountStatus(user, req) try: if res['accountInfo']['isPremium']: - # Parse account info. Change the trafficleft later to support per host info. + #: Parse account info. Change the trafficleft later to support per host info. account_info = {"validuntil": float(res['accountInfo']['premiumExpiry']), "trafficleft": -1, "premium": True} else: @@ -33,16 +33,16 @@ class RPNetBiz(Account): def login(self, user, data, req): - # Get account information from rpnet.biz + #: Get account information from rpnet.biz res = self.getAccountStatus(user, req) - # If we have an error in the res, we have wrong login information + #: If we have an error in the res, we have wrong login information if 'error' in res: self.wrongPassword() def getAccountStatus(self, user, req): - # Using the rpnet API, check if valid premium account + #: Using the rpnet API, check if valid premium account res = self.load("https://premium.rpnet.biz/client_api.php", get={"username": user, "password": self.getAccountData(user)['password'], "action": "showAccountInformation"}) diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 8b868ee07..0fc934255 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -36,7 +36,7 @@ class RapideoPl(Account): try: result = json_loads(self.runAuthQuery()) except Exception: - # todo: return or let it be thrown? + #@TODO: return or let it be thrown? return premium = False diff --git a/module/plugins/accounts/SmoozedCom.py b/module/plugins/accounts/SmoozedCom.py index da81a6b80..148818957 100644 --- a/module/plugins/accounts/SmoozedCom.py +++ b/module/plugins/accounts/SmoozedCom.py @@ -43,7 +43,7 @@ class SmoozedCom(Account): 'trafficleft': None, 'premium' : False} else: - # Parse account info + #: Parse account info info = {'validuntil' : float(status["data"]["user"]["user_premium"]), 'trafficleft': max(0, status["data"]["traffic"][1] - status["data"]["traffic"][0]), 'session' : status["data"]["session_key"], @@ -61,10 +61,10 @@ class SmoozedCom(Account): def login(self, user, data, req): - # Get user data from premiumize.me + #: Get user data from premiumize.me status = self.getAccountStatus(user, req) - # Check if user and password are valid + #: Check if user and password are valid if status['state'] != 'ok': self.wrongPassword() diff --git a/module/plugins/accounts/UploadedTo.py b/module/plugins/accounts/UploadedTo.py index 8cdfab0c6..55bddabae 100644 --- a/module/plugins/accounts/UploadedTo.py +++ b/module/plugins/accounts/UploadedTo.py @@ -61,7 +61,7 @@ class UploadedTo(Account): def login(self, user, data, req): - # req.cj.setCookie("uploaded.net", "lang", "en") + #: req.cj.setCookie("uploaded.net", "lang", "en") html = self.load("https://uploaded.net/io/login", post={'id': user, 'pw': data['password'], '_': ""}, req=req) diff --git a/module/plugins/captcha/CircleCaptcha.py b/module/plugins/captcha/CircleCaptcha.py index 8b59c6703..6c758d3de 100644 --- a/module/plugins/captcha/CircleCaptcha.py +++ b/module/plugins/captcha/CircleCaptcha.py @@ -59,25 +59,25 @@ class CircleCaptcha(OCR): if curpix > self.BACKGROUND: if howmany <= cleandeep and howmany > 0: - # clean pixel + #: clean pixel for ic in range(1,cleandeep+1): if x -ic > 0: pix[x-ic,y] = self.BACKGROUND jump = False howmany = 0 curcolor = curpix - # print (x, y), jump,2 + #: print (x, y), jump,2 else: if howmany == 0: - # found pixel + #: found pixel jump = True howmany = howmany + 1 curcolor = curpix - # print (x, y), jump,2 + #: print (x, y), jump,2 else: howmany = howmany + 1 if howmany == 1: - # clean pixel + #: clean pixel pix[x-1,y] = self.BACKGROUND curcolor = self.BACKGROUND @@ -86,32 +86,32 @@ class CircleCaptcha(OCR): howmany = 0 for y in imageheight: curpix = pix[x,y] - # if jump == True: + #: if jump == True: if curpix > self.BACKGROUND: if howmany <= cleandeep and howmany > 0: - # clean pixel + #: clean pixel for ic in range(1,cleandeep+1): - # raw_input('2'+str(ic)) + #: raw_input('2'+str(ic)) if y-ic > 0: pix[x,y-ic] = self.BACKGROUND jump = False howmany = 0 curcolor = curpix - # print (x, y), jump + #: print (x, y), jump else: if howmany == 0: - # found pixel + #: found pixel jump = True howmany = howmany + 1 curcolor = curpix - # print (x, y), jump + #: print (x, y), jump else: howmany = howmany + 1 if howmany == 1: - # clean pixel + #: clean pixel pix[x-1,y] = self.BACKGROUND - # return -1 + #: return -1 def findFirstPixelX(self, im, pix, curx, cury, color = -1, ExitWithBlack = False): @@ -126,21 +126,21 @@ class CircleCaptcha(OCR): if curpix < self.BLACKCOLOR: blackfound = blackfound + 1 if ExitWithBlack == True and blackfound >= 3: - break; #exit if found black + break #: exit if found black else: - continue; + continue if curpix >= self.BACKGROUND: - # found first pixel white + #: found first pixel white jump = False - continue; + continue if (curpix < self.BACKGROUND and color == -1) or (curpix == color and color > -1): if jump == False: - # found pixel + #: found pixel curcolor = curpix newx = x, curcolor - break; + break return newx @@ -156,17 +156,17 @@ class CircleCaptcha(OCR): if curpix < self.BLACKCOLOR: blackfound = blackfound + 1 if ExitWithBlack == True and blackfound >= 3: - break; #exit if found black + break #: exit if found black else: - continue; + continue if curpix >= self.BACKGROUND: if newx != (-1,-1): - # found last pixel and the first white - break; + #: found last pixel and the first white + break if (curpix < self.BACKGROUND and color == -1) or (curpix == color and color > -1): - # found pixel + #: found pixel curcolor = curpix newx = x, curcolor @@ -187,17 +187,17 @@ class CircleCaptcha(OCR): if curpix < self.BLACKCOLOR: blackfound = blackfound + 1 if ExitWithBlack == True and blackfound >= 3: - break; #exit if found black + break #: exit if found black else: - continue; + continue if curpix >= self.BACKGROUND: if newy != (-1,-1): - # found last pixel and the first white - break; + #: found last pixel and the first white + break if (curpix < self.BACKGROUND and color == -1) or (curpix == color and color > -1): - # found pixel + #: found pixel curcolor = curpix newy = y, color @@ -205,24 +205,24 @@ class CircleCaptcha(OCR): def findCircle(self, pix, x1, y1, x2, y2, x3, y3): - # trasposizione coordinate - # A(0,0) B(x2-x1,y2-y1) C(x3-x1,y3-y1) - # x**2+y**2+ax+bx+c=0 + #: trasposizione coordinate + #: A(0,0) B(x2-x1,y2-y1) C(x3-x1,y3-y1) + #: x**2+y**2+ax+bx+c=0 p1 = (0,0) p2 = (x2-x1,y2-y1) p3 = (x3-x1,y3-y1) - # 1 + #: 1 c=0 - # 2 - # p2[0]**2+a*p2[0]+c=0 - # a*p2[0]=-1*(p2[0]**2-c) - # a=(-1*(p2[0]**2-c))/p2[0] + #: 2 + #: p2[0]**2+a*p2[0]+c=0 + #: a*p2[0]=-1*(p2[0]**2-c) + #: a=(-1*(p2[0]**2-c))/p2[0] a=(-1*(p2[0]**2-c))/p2[0] - # 3 - # p3[0]**2+p3[1]**2+a*p3[0]+b*p3[1]+c=0 - # b*p3[1]=-(p3[0]**2+p3[1]**2+a*p3[0]+c) - # b=(-1 * (p3[0]**2+p3[1]**2+a*p3[0]+c)) / p3[1] + #: 3 + #: p3[0]**2+p3[1]**2+a*p3[0]+b*p3[1]+c=0 + #: b*p3[1]=-(p3[0]**2+p3[1]**2+a*p3[0]+c) + #: b=(-1 * (p3[0]**2+p3[1]**2+a*p3[0]+c)) / p3[1] b=(-1 * (p3[0]**2+p3[1]**2+a*p3[0]+c)) / p3[1] r=math.floor(math.sqrt((-1*(a/2))**2+(-1*(b/2))**2)) @@ -252,44 +252,44 @@ class CircleCaptcha(OCR): missing = 0 missingconsecutive = 0 missinglist = [] - minX = 0; maxX = 0; minY = 0; maxY = 0 + minX = 0 maxX = 0 minY = 0 maxY = 0 pointsofcircle = [] if (c[2] < min_ray) or (c[2] > max_ray): return -1 - # check cardinal points (at least 3) (if found i have to leave this position) + #: check cardinal points (at least 3) (if found i have to leave this position) if pix[c[0] + c[2],c[1]] < self.BLACKCOLOR: - return -2; + return -2 if pix[c[0] - c[2],c[1]] < self.BLACKCOLOR: - return -2; + return -2 if pix[c[0],c[1] + c[2]] < self.BLACKCOLOR: - return -2; + return -2 if pix[c[0],c[1] - c[2]] < self.BLACKCOLOR: - return -2; + return -2 cardinalpoints = 0 if self.verifyPoint(im, pix,c[0] + c[2],c[1],True) == 1: cardinalpoints = cardinalpoints + 1 if self.verifyPoint(im, pix,c[0] + c[2],c[1],False) == -1: - return -2; + return -2 if self.verifyPoint(im, pix,c[0] - c[2],c[1],True) == 1: cardinalpoints = cardinalpoints + 1 if self.verifyPoint(im, pix,c[0] - c[2],c[1],False) == -1: - return -2; + return -2 if self.verifyPoint(im, pix,c[0],c[1] + c[2],True) == 1: cardinalpoints = cardinalpoints + 1 if self.verifyPoint(im, pix,c[0],c[1] + c[2],False) == -1: - return -2; + return -2 if self.verifyPoint(im, pix,c[0],c[1] - c[2],True) == 1: cardinalpoints = cardinalpoints + 1 if self.verifyPoint(im, pix,c[0],c[1] - c[2],False) == -1: - return -2; + return -2 if cardinalpoints < 3: - return -1; + return -1 for x in imagewidth: - # Pitagora + #: Pitagora y = int(round(c[1]- math.sqrt(c[2]**2-(c[0]-x)**2))) y2= int(round(c[1]+ math.sqrt(c[2]**2-(c[0]-x)**2))) @@ -301,7 +301,7 @@ class CircleCaptcha(OCR): pointsofcircle.append((x,y)) if self.verifyPoint(im, pix, x,y,False) == -1: - return -2; + return -2 if self.verifyPoint(im, pix, x,y2,exactfind) == 0: missing = missing + 1 @@ -310,7 +310,7 @@ class CircleCaptcha(OCR): pointsofcircle.append((x,y2)) if self.verifyPoint(im, pix, x,y2,False) == -1: - return -2; + return -2 def verifyCircle(self, im, pix, c): @@ -333,44 +333,44 @@ class CircleCaptcha(OCR): missing = 0 missingconsecutive = 0 missinglist = [] - minX = 0; maxX = 0; minY = 0; maxY = 0 + minX = 0 maxX = 0 minY = 0 maxY = 0 pointsofcircle = [] if (c[2] < min_ray) or (c[2] > max_ray): return -1 - # check cardinal points (at least 3) (if found i have to leave this position) + #: check cardinal points (at least 3) (if found i have to leave this position) if pix[c[0] + c[2],c[1]] < self.BLACKCOLOR: - return -2; + return -2 if pix[c[0] - c[2],c[1]] < self.BLACKCOLOR: - return -2; + return -2 if pix[c[0],c[1] + c[2]] < self.BLACKCOLOR: - return -2; + return -2 if pix[c[0],c[1] - c[2]] < self.BLACKCOLOR: - return -2; + return -2 cardinalpoints = 0 if self.verifyPoint(im, pix,c[0] + c[2],c[1],True) == 1: cardinalpoints = cardinalpoints + 1 if self.verifyPoint(im, pix,c[0] + c[2],c[1],False) == -1: - return -2; + return -2 if self.verifyPoint(im, pix,c[0] - c[2],c[1],True) == 1: cardinalpoints = cardinalpoints + 1 if self.verifyPoint(im, pix,c[0] - c[2],c[1],False) == -1: - return -2; + return -2 if self.verifyPoint(im, pix,c[0],c[1] + c[2],True) == 1: cardinalpoints = cardinalpoints + 1 if self.verifyPoint(im, pix,c[0],c[1] + c[2],False) == -1: - return -2; + return -2 if self.verifyPoint(im, pix,c[0],c[1] - c[2],True) == 1: cardinalpoints = cardinalpoints + 1 if self.verifyPoint(im, pix,c[0],c[1] - c[2],False) == -1: - return -2; + return -2 if cardinalpoints < 3: - return -1; + return -1 for x in imagewidth: - # Pitagora + #: Pitagora y = int(round(c[1]- math.sqrt(c[2]**2-(c[0]-x)**2))) y2= int(round(c[1]+ math.sqrt(c[2]**2-(c[0]-x)**2))) @@ -382,7 +382,7 @@ class CircleCaptcha(OCR): pointsofcircle.append((x,y)) if self.verifyPoint(im, pix, x,y,False) == -1: - return -2; + return -2 if self.verifyPoint(im, pix, x,y2,exactfind) == 0: missing = missing + 1 @@ -391,10 +391,10 @@ class CircleCaptcha(OCR): pointsofcircle.append((x,y2)) if self.verifyPoint(im, pix, x,y2,False) == -1: - return -2; + return -2 for y in imageheight: - # Pitagora + #: Pitagora x = int(round(c[0]- math.sqrt(c[2]**2-(c[1]-y)**2))) x2= int(round(c[0]+ math.sqrt(c[2]**2-(c[1]-y)**2))) @@ -406,7 +406,7 @@ class CircleCaptcha(OCR): pointsofcircle.append((x,y)) if self.verifyPoint(im, pix, x,y,False) == -1: - return -2; + return -2 if self.verifyPoint(im, pix, x2,y,exactfind) == 0: missing = missing + 1 @@ -415,21 +415,21 @@ class CircleCaptcha(OCR): pointsofcircle.append((x2,y)) if self.verifyPoint(im, pix, x2,y,exactfind) == -1: - return -2; + return -2 for p in missinglist: - # left and bottom + #: left and bottom if (self.verifyPoint(im, pix, p[0]-1, p[1],exactfind) == 1 and \ self.verifyPoint(im, pix, p[0], p[1]+1,exactfind) == 1): missing = missing - 1 elif (self.verifyPoint(im, pix, p[0]-1, p[1],exactfind) == 1 and \ self.verifyPoint(im, pix, p[0], p[1]-1,exactfind) == 1): missing = missing - 1 - # right and bottom + #: right and bottom elif (self.verifyPoint(im, pix, p[0]+1, p[1],exactfind) == 1 and \ self.verifyPoint(im, pix, p[0], p[1]+1,exactfind) == 1): missing = missing - 1 - # right and up + #: right and up elif (self.verifyPoint(im, pix, p[0]+1, p[1],exactfind) == 1 and \ self.verifyPoint(im, pix, p[0], p[1]-1,exactfind) == 1): missing = missing - 1 @@ -445,7 +445,7 @@ class CircleCaptcha(OCR): self.verifyPoint(im, pix, p[0], p[1],False) == 1: missingconsecutive = missingconsecutive + 1 # else: - # pix[p[0], p[1]] = 0 + # pix[p[0], p[1]] = 0 if missing / howmany > 0: indice = c[2] * (missing / howmany) @@ -459,7 +459,7 @@ class CircleCaptcha(OCR): minY = min(missinglist, key=operator.itemgetter(1))[1] maxY = max(missinglist, key=operator.itemgetter(1))[1] - # Assial Simmetric + #: Assial Simmetric if self._DEBUG == True: print "Center: " + str(c) print "Missing: " + str(missing) @@ -471,41 +471,41 @@ class CircleCaptcha(OCR): print "Ratio without consecutives: " + str((missing - missingconsecutive) / howmany) print "List missing: " + str(missinglist) - # Lenght of missing cannot be over 75% of diameter + #: Lenght of missing cannot be over 75% of diameter if maxX - minX >= c[2] * 2 * 0.75: - return -1; + return -1 if maxY - minY >= c[2] * 2 * 0.75: - # raw_input('tro') - return -1; + #: raw_input('tro') + return -1 """ - # Lenght of missing cannot be less 10% of diameter + #: Lenght of missing cannot be less 10% of diameter if maxX - minX < c[2] * 2 * 0.10 and maxY - minY < c[2] * 2 * 0.10: - return -1; + return -1 """ if missing / howmany > 0.25 or \ missingconsecutive >= (howmany / 4) * 2 or \ howmany < 80: - return -1; - # elif missing / howmany < 0.10: + return -1 + #: elif missing / howmany < 0.10: elif missing == 0: self.pointsofcirclefound.extend(pointsofcircle) - return 1; + return 1 elif (missing - missingconsecutive) / howmany < 0.20: - return 0; + return 0 else: self.pointsofcirclefound.extend(pointsofcircle) - return 1; + return 1 def verifyPoint(self, im, pix, x,y,exact,color = -1): - # Verify point + #: Verify point result = 0 if x < 0 or x >= im.size[0]: - return result; + return result if y < 0 or y >= im.size[1]: - return result; + return result curpix = pix[x,y] if (curpix == color and color > -1) or (curpix < self.BACKGROUND and color == -1): @@ -514,7 +514,7 @@ class CircleCaptcha(OCR): else: result = -1 - # Verify around + #: Verify around if (exact == False): if x + 1 < im.size[0]: curpix = pix[x+1,y] @@ -531,7 +531,7 @@ class CircleCaptcha(OCR): result = 1 if curpix <= self.BLACKCOLOR: result = -1 - # print str((x,y)) + " = " + str(result); + #: print str((x,y)) + " = " + str(result) return result @@ -547,14 +547,14 @@ class CircleCaptcha(OCR): if self._DEBUG == True: iDebugSaveFile = iDebugSaveFile + 1 - # if iDebugSaveFile < 7: continue; + #: if iDebugSaveFile < 7: continue im.save("output" + str(iDebugSaveFile) + ".png", "png") raw_input('frame: '+ str(im)) pix = im.load() stepheight = range(1,im.size[1],2) - # stepheight = range(45,47) + #: stepheight = range(45,47) imagewidth = range(1,im.size[0]) lstPoints = [] # Declares an empty list for the points lstX = [] # CoordinateX @@ -568,14 +568,14 @@ class CircleCaptcha(OCR): draw = ImageDraw.Draw(imdebug) pixcopy = imdebug.load() - # Clean image for powerfull search + #: Clean image for powerfull search self.cleanImage(im, pix) im.save("cleaned" + str(iDebugSaveFile) + ".png", "png") found = set() findnewcircle = True - # finding all the circles + #: finding all the circles for y1 in stepheight: x1 = 1 curcolor = -1 @@ -585,17 +585,17 @@ class CircleCaptcha(OCR): x1 = retval[0] curcolor = retval[1] if x1 == -2: - break; + break if x1 == -1: - break; + break if self._DEBUG == True: print "x1, y1 -> " + str((x1,y1)) + ": " + str(pix[x1,y1]) if (x1,y1) in self.pointsofcirclefound: if self._DEBUG == True: print 'found ' + str((x1,y1)) - continue; + continue if self._DEBUG == True: pixcopy[x1,y1] = 45 #(255,0,0,255) - # found 1 pixel, seeking x2,y2 + #: found 1 pixel, seeking x2,y2 x2 = x1 y2 = y1 for i in range(1,100): @@ -603,52 +603,52 @@ class CircleCaptcha(OCR): x2 = retval[0] if x1 == -2: findnewcircle = True - break; + break if x2 == -1: - break; + break if self._DEBUG == True: print "x2, y2 -> " + str((x2,y1)) + ": " + str(pix[x2,y1]) if abs(x2 - x1) < min_distance: - continue; + continue if abs(x2 - x1) > (im.size[1] * 2 / 3): - break; + break if abs(x2 - x1) > max_diameter: - break; + break if self._DEBUG == True: pixcopy[x2,y2] = 65 #(0,255,0,255) - # found 2 pixel, seeking x3,y3 - # verify cord + #: found 2 pixel, seeking x3,y3 + #: verify cord for invert in range(0,2): x3 = math.floor(x2 - ((x2 - x1) / 2)) y3 = y1 for j in range(1,50): retval = self.findLastPixelY(im, pix, x3, y3, True if invert == 1 else False, -1, True) - # print (x3, y3,retval[0],invert) + #: print (x3, y3,retval[0],invert) y3 = retval[0] if y3 == -2: findnewcircle = True - break; + break if y3 == -1: - break; + break if self._DEBUG == True: print "x3, y3 -> " + str((x3,y3)) + ": " + str(pix[x3,y3]) - # verify cord + #: verify cord if abs(y3 - y2) < min_distance: - continue; + continue if abs(y3 - y2) > (im.size[1] * 2 / 3): - break; + break if abs(y3 - y2) > max_diameter: - break; + break if self._DEBUG == True: pixcopy[x3,y3] = 85 - # found 3 pixel. try circle + #: found 3 pixel. try circle c = self.findCircle(pix, x1,y1,x2,y2,x3,y3) if c[0] + c[2] >= im.size[0] or c[1] + c[2] >= im.size[1] or c[0] - c[2] <= 0 or c[1] - c[2] <= 0: - continue; + continue if self._DEBUG == True: pixcopy[c[0],c[1]] = 0 - # (x-r, y-r, x+r, y+r) + #: (x-r, y-r, x+r, y+r) verified = self.verifyCircle(im, pix, c) if verified == -1: @@ -662,10 +662,10 @@ class CircleCaptcha(OCR): if self._DEBUG == True: _pause = "" - # if verified == -1: - # draw.ellipse((c[0]-c[2],c[1]-c[2],c[0]+c[2],c[1]+c[2]),outline=0) - # _pause = "NOTDOUND" - # imdebug.save("debug.png", "png") + #: if verified == -1: + #: draw.ellipse((c[0]-c[2],c[1]-c[2],c[0]+c[2],c[1]+c[2]),outline=0) + #: _pause = "NOTDOUND" + #: imdebug.save("debug.png", "png") if verified == 0: draw.ellipse((c[0]-c[2],c[1]-c[2],c[0]+c[2],c[1]+c[2]),outline=120) _pause = "OPENED" @@ -679,19 +679,19 @@ class CircleCaptcha(OCR): if _pause != "": valore = raw_input('Found ' + _pause + ' CIRCLE circle press [Enter] = continue / [q] for Quit: ' + str(verified)) if valore == 'q': - sys.exit(); + sys.exit() if findnewcircle == True: - break; + break if findnewcircle == True: - break; + break if findnewcircle == True: - break; + break if self._DEBUG == True: print 'Howmany opened circle? ' + str(len(found)) + ' ' + str(found) - # clean results + #: clean results for c in found: verify = c[1] if verify == 0: @@ -707,7 +707,7 @@ class CircleCaptcha(OCR): ((p[0]-1, p[1]-1,p[2]),1) in found \ ): - # delete nearly circle + #: delete nearly circle verify = -1 if ( ((p[0], p[1]+1,p[2]+1),1) in found or \ @@ -720,7 +720,7 @@ class CircleCaptcha(OCR): ((p[0]-1, p[1]-1,p[2]+1),1) in found \ ): - # delete nearly circle + #: delete nearly circle verify = -1 if ( ((p[0], p[1]+1,p[2]-1),1) in found or \ @@ -733,38 +733,38 @@ class CircleCaptcha(OCR): ((p[0]-1, p[1]-1,p[2]-1),1) in found \ ): - # delete nearly circle + #: delete nearly circle verify = -1 - # if verify == 0: - # if self._DEBUG == True: - # pix[c[0][0],c[0][1]] = 90 #(255,255,0) - # im.save("output.png", "png") - # return c[0][0],c[0][1] - # elif verify == 1: - # if self._DEBUG == True: - # pix[c[0][0],c[0][1]] = 40 #(255,0,0) - # im.save("output.png", "png") - # else: - # if self._DEBUG == True: - # pix[c[0][0],c[0][1]] = 180 #(0,0,255) - # im.save("output.png", "png") + #: if verify == 0: + #: if self._DEBUG == True: + #: pix[c[0][0],c[0][1]] = 90 #(255,255,0) + #: im.save("output.png", "png") + #: return c[0][0],c[0][1] + #: elif verify == 1: + #: if self._DEBUG == True: + #: pix[c[0][0],c[0][1]] = 40 #(255,0,0) + #: im.save("output.png", "png") + #: else: + #: if self._DEBUG == True: + #: pix[c[0][0],c[0][1]] = 180 #(0,0,255) + #: im.save("output.png", "png") if self._DEBUG == True: im.save("output.png", "png") - # Return coordinates of opened circle (eg (x,y)) + #: Return coordinates of opened circle (eg (x,y)) def decrypt_from_web(self, url): file = cStringIO.StringIO(urllib.urlopen(url).read()) img = Image.open(file) - coords = self.decrypt(img); + coords = self.decrypt(img) print "Coords: " + str(coords) - # Return coordinates of opened circle (eg (x,y)) + #: Return coordinates of opened circle (eg (x,y)) def decrypt_from_file(self, filename): - coords = self.decrypt(Image.open(filename)); #Can be many different formats. + coords = self.decrypt(Image.open(filename)) #: Can be many different formats. print "Coords: " + str(coords) diff --git a/module/plugins/container/TXT.py b/module/plugins/container/TXT.py index 66abb9ae8..76cf41f60 100644 --- a/module/plugins/container/TXT.py +++ b/module/plugins/container/TXT.py @@ -43,7 +43,7 @@ class TXT(Container): continue if link.startswith("[") and link.endswith("]"): - # new package + #: new package curPack = link[1:-1] packages[curPack] = [] continue @@ -52,7 +52,7 @@ class TXT(Container): txt.close() - # empty packages fix + #: empty packages fix for key, value in packages.iteritems(): if not value: packages.pop(key, None) diff --git a/module/plugins/crypter/DataHuFolder.py b/module/plugins/crypter/DataHuFolder.py index fcbc5b2af..0b241bf66 100644 --- a/module/plugins/crypter/DataHuFolder.py +++ b/module/plugins/crypter/DataHuFolder.py @@ -28,7 +28,7 @@ class DataHuFolder(SimpleCrypter): def prepare(self): super(DataHuFolder, self).prepare() - if u'K\xe9rlek add meg a jelsz\xf3t' in self.html: # Password protected + if u'K\xe9rlek add meg a jelsz\xf3t' in self.html: #: Password protected password = self.getPassword() if not password: self.fail(_("Password required")) @@ -37,7 +37,7 @@ class DataHuFolder(SimpleCrypter): self.html = self.load(self.pyfile.url, post={'mappa_pass': password}) - if u'Hib\xe1s jelsz\xf3' in self.html: # Wrong password + if u'Hib\xe1s jelsz\xf3' in self.html: #: Wrong password self.fail(_("Wrong password")) diff --git a/module/plugins/crypter/DlProtectCom.py b/module/plugins/crypter/DlProtectCom.py index fde43ff43..6ced6a706 100644 --- a/module/plugins/crypter/DlProtectCom.py +++ b/module/plugins/crypter/DlProtectCom.py @@ -29,7 +29,7 @@ class DlProtectCom(SimpleCrypter): def getLinks(self): - # Direct link with redirect + #: Direct link with redirect if not re.match(r"https?://(?:www\.)?dl-protect\.com/.+", self.req.http.lastEffectiveURL): return [self.req.http.lastEffectiveURL] diff --git a/module/plugins/crypter/FilecryptCc.py b/module/plugins/crypter/FilecryptCc.py index 7ca5659fb..769877802 100644 --- a/module/plugins/crypter/FilecryptCc.py +++ b/module/plugins/crypter/FilecryptCc.py @@ -160,16 +160,16 @@ class FilecryptCc(Crypter): def _getLinks(self, crypted, jk): - # Get key + #: Get key key = binascii.unhexlify(str(jk)) - # Decrypt + #: Decrypt Key = key IV = key obj = AES.new(Key, AES.MODE_CBC, IV) text = obj.decrypt(crypted.decode('base64')) - # Extract links + #: Extract links text = text.replace("\x00", "").replace("\r", "") links = filter(bool, text.split('\n')) diff --git a/module/plugins/crypter/LinkCryptWs.py b/module/plugins/crypter/LinkCryptWs.py index 28c431e80..b9abb08d2 100644 --- a/module/plugins/crypter/LinkCryptWs.py +++ b/module/plugins/crypter/LinkCryptWs.py @@ -36,12 +36,12 @@ class LinkCryptWs(Crypter): def prepare(self): - # Init + #: Init self.fileid = re.match(self.__pattern__, self.pyfile.url).group('ID') self.req.cj.setCookie("linkcrypt.ws", "language", "en") - # Request package + #: Request package self.req.http.c.setopt(pycurl.USERAGENT, "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko") #: better chance to not get those key-captchas self.html = self.load(self.pyfile.url) @@ -63,21 +63,21 @@ class LinkCryptWs(Crypter): self.unlockCaptchaProtection() self.handleCaptchaErrors() - # Check for protection + #: Check for protection if self.isPasswordProtected(): self.unlockPasswordProtection() self.handleErrors() - # get unrar password + #: get unrar password self.getunrarpw() - # Get package name and folder + #: Get package name and folder package_name, folder_name = self.getPackageInfo() #get the container definitions from script section self.get_container_html() - # Extract package links + #: Extract package links for type in self.sources: links = self.handleLinkSource(type) @@ -234,7 +234,7 @@ class LinkCryptWs(Crypter): self.logDebug('Search for %s Container links' % type.upper()) - if not type.isalnum(): # check to prevent broken re-pattern (cnl2,rsdf,ccf,dlc,web are all alpha-numeric) + if not type.isalnum(): #: check to prevent broken re-pattern (cnl2,rsdf,ccf,dlc,web are all alpha-numeric) self.fail(_("Unknown container type: %s") % type) #@TODO: Replace with self.error in 0.4.10 for line in self.container_html: @@ -282,37 +282,37 @@ class LinkCryptWs(Crypter): def _getCipherParams(self, cnl_section): - # Get jk + #: Get jk jk_re = r'<INPUT.*?NAME="%s".*?VALUE="(.*?)"' % LinkCryptWs.JK_KEY vjk = re.findall(jk_re, cnl_section) - # Get crypted + #: Get crypted crypted_re = r'<INPUT.*?NAME="%s".*?VALUE="(.*?)"' % LinkCryptWs.CRYPTED_KEY vcrypted = re.findall(crypted_re, cnl_section) - # Log and return + #: Log and return self.logDebug("Detected %d crypted blocks" % len(vcrypted)) return vcrypted, vjk def _getLinks(self, crypted, jk): - # Get key + #: Get key jreturn = self.js.eval("%s f()" % jk) key = binascii.unhexlify(jreturn) self.logDebug("JsEngine returns value [%s]" % jreturn) - # Decrypt + #: Decrypt Key = key IV = key obj = AES.new(Key, AES.MODE_CBC, IV) text = obj.decrypt(crypted.decode('base64')) - # Extract links + #: Extract links text = text.replace("\x00", "").replace("\r", "") links = filter(bool, text.split('\n')) - # Log and return + #: Log and return self.logDebug("Package has %d links" % len(links)) return links diff --git a/module/plugins/crypter/MediafireComFolder.py b/module/plugins/crypter/MediafireComFolder.py index c3b1c7e9f..dd23df7ca 100644 --- a/module/plugins/crypter/MediafireComFolder.py +++ b/module/plugins/crypter/MediafireComFolder.py @@ -29,14 +29,14 @@ class MediafireComFolder(Crypter): self.logDebug("Location (%d): %s" % (result, url)) if result == 0: - # load and parse html + #: load and parse html html = self.load(pyfile.url) m = re.search(self.LINK_PATTERN, html) if m: - # file page + #: file page self.urls.append("http://www.mediafire.com/file/%s" % m.group(1)) else: - # folder page + #: folder page m = re.search(self.FOLDER_KEY_PATTERN, html) if m: folder_key = m.group(1) diff --git a/module/plugins/crypter/NCryptIn.py b/module/plugins/crypter/NCryptIn.py index f92f47e99..ec43d7fa9 100644 --- a/module/plugins/crypter/NCryptIn.py +++ b/module/plugins/crypter/NCryptIn.py @@ -38,42 +38,42 @@ class NCryptIn(Crypter): def decrypt(self, pyfile): - # Init + #: Init self.package = pyfile.package() package_links = [] package_name = self.package.name folder_name = self.package.folder - # Deal with single links + #: Deal with single links if self.isSingleLink(): package_links.extend(self.handleSingleLink()) - # Deal with folders + #: Deal with folders else: - # Request folder home + #: Request folder home self.html = self.requestFolderHome() self.cleanedHtml = self.removeHtmlCrap(self.html) if not self.isOnline(): self.offline() - # Check for folder protection + #: Check for folder protection if self.isProtected(): self.html = self.unlockProtection() self.cleanedHtml = self.removeHtmlCrap(self.html) self.handleErrors() - # Prepare package name and folder + #: Prepare package name and folder (package_name, folder_name) = self.getPackageInfo() - # Extract package links + #: Extract package links for link_source_type in self.links_source_order: package_links.extend(self.handleLinkSource(link_source_type)) - if package_links: # use only first source which provides links + if package_links: #: use only first source which provides links break package_links = set(package_links) - # Pack and return links + #: Pack and return links if package_links: self.packages = [(package_name, package_links, folder_name)] @@ -135,13 +135,13 @@ class NCryptIn(Crypter): form = re.search(r'<form name="protected"(.*?)</form>', self.cleanedHtml, re.S).group(1) - # Submit package password + #: Submit package password if "password" in form: password = self.getPassword() self.logDebug("Submitting password [%s] for protected links" % password) postData['password'] = password - # Resolve anicaptcha + #: Resolve anicaptcha if "anicaptcha" in form: self.logDebug("Captcha protected") captchaUri = re.search(r'src="(/temp/anicaptcha/.+?)"', form).group(1) @@ -149,7 +149,7 @@ class NCryptIn(Crypter): self.logDebug("Captcha resolved [%s]" % captcha) postData['captcha'] = captcha - # Resolve recaptcha + #: Resolve recaptcha if "recaptcha" in form: self.logDebug("ReCaptcha protected") captcha_key = re.search(r'\?k=(.*?)"', form).group(1) @@ -159,7 +159,7 @@ class NCryptIn(Crypter): postData['recaptcha_challenge_field'] = challenge postData['recaptcha_response_field'] = response - # Resolve circlecaptcha + #: Resolve circlecaptcha if "circlecaptcha" in form: self.logDebug("CircleCaptcha protected") captcha_img_url = "http://ncrypt.in/classes/captcha/circlecaptcha.php" @@ -168,7 +168,7 @@ class NCryptIn(Crypter): postData['circle.x'] = coords[0] postData['circle.y'] = coords[1] - # Unlock protection + #: Unlock protection postData['submit_protected'] = 'Continue to folder' return self.load(self.pyfile.url, post=postData) @@ -188,13 +188,13 @@ class NCryptIn(Crypter): def handleLinkSource(self, link_source_type): - # Check for JS engine + #: Check for JS engine require_js_engine = link_source_type in ("cnl2", "rsdf", "ccf", "dlc") if require_js_engine and not self.js: self.logDebug("No JS engine available, skip %s links" % link_source_type) return [] - # Select suitable handler + #: Select suitable handler if link_source_type == 'single': return self.handleSingleLink() if link_source_type == 'cnl2': @@ -211,7 +211,7 @@ class NCryptIn(Crypter): self.logDebug("Handling Single link") package_links = [] - # Decrypt single link + #: Decrypt single link decrypted_link = self.decryptLink(self.pyfile.url) if decrypted_link: package_links.append(decrypted_link) @@ -276,35 +276,35 @@ class NCryptIn(Crypter): def _getCipherParams(self): pattern = r'<input.*?name="%s".*?value="(.*?)"' - # Get jk + #: Get jk jk_re = pattern % NCryptIn.JK_KEY vjk = re.findall(jk_re, self.html) - # Get crypted + #: Get crypted crypted_re = pattern % NCryptIn.CRYPTED_KEY vcrypted = re.findall(crypted_re, self.html) - # Log and return + #: Log and return self.logDebug("Detected %d crypted blocks" % len(vcrypted)) return vcrypted, vjk def _getLinks(self, crypted, jk): - # Get key + #: Get key jreturn = self.js.eval("%s f()" % jk) self.logDebug("JsEngine returns value [%s]" % jreturn) key = binascii.unhexlify(jreturn) - # Decrypt + #: Decrypt Key = key IV = key obj = AES.new(Key, AES.MODE_CBC, IV) text = obj.decrypt(crypted.decode('base64')) - # Extract links + #: Extract links text = text.replace("\x00", "").replace("\r", "") links = filter(bool, text.split('\n')) - # Log and return + #: Log and return self.logDebug("Block has %d links" % len(links)) return links diff --git a/module/plugins/crypter/RelinkUs.py b/module/plugins/crypter/RelinkUs.py index 25bd98190..cda70816d 100644 --- a/module/plugins/crypter/RelinkUs.py +++ b/module/plugins/crypter/RelinkUs.py @@ -62,17 +62,17 @@ class RelinkUs(Crypter): def decrypt(self, pyfile): - # Init + #: Init self.initPackage(pyfile) - # Request package + #: Request package self.requestPackage() - # Check for online + #: Check for online if not self.isOnline(): self.offline() - # Check for protection + #: Check for protection if self.isPasswordProtected(): self.unlockPasswordProtection() self.handleErrors() @@ -82,18 +82,18 @@ class RelinkUs(Crypter): self.unlockCaptchaProtection() self.handleErrors() - # Get package name and folder + #: Get package name and folder (package_name, folder_name) = self.getPackageInfo() - # Extract package links + #: Extract package links package_links = [] for sources in self.PREFERRED_LINK_SOURCES: package_links.extend(self.handleLinkSource(sources)) - if package_links: # use only first source which provides links + if package_links: #: use only first source which provides links break package_links = set(package_links) - # Pack + #: Pack if package_links: self.packages = [(package_name, package_links, folder_name)] @@ -151,7 +151,7 @@ class RelinkUs(Crypter): def getPackageInfo(self): name = folder = None - # Try to get info from web + #: Try to get info from web m = re.search(self.FILE_TITLE_REGEX, self.html) if m: title = m.group(1).strip() @@ -159,13 +159,13 @@ class RelinkUs(Crypter): name = folder = title self.logDebug("Found name [%s] and folder [%s] in package info" % (name, folder)) - # Fallback to defaults + #: Fallback to defaults if not name or not folder: name = self.package.name folder = self.package.folder self.logDebug("Package info not found, defaulting to pyfile name [%s] and folder [%s]" % (name, folder)) - # Return package info + #: Return package info return name, folder @@ -259,35 +259,35 @@ class RelinkUs(Crypter): def _getCipherParams(self, cnl2_form): - # Get jk + #: Get jk jk_re = self.CNL2_FORMINPUT_REGEX % self.CNL2_JK_KEY vjk = re.findall(jk_re, cnl2_form, re.I) - # Get crypted + #: Get crypted crypted_re = self.CNL2_FORMINPUT_REGEX % RelinkUs.CNL2_CRYPTED_KEY vcrypted = re.findall(crypted_re, cnl2_form, re.I) - # Log and return + #: Log and return self.logDebug("Detected %d crypted blocks" % len(vcrypted)) return vcrypted, vjk def _getLinks(self, crypted, jk): - # Get key + #: Get key jreturn = self.js.eval("%s f()" % jk) self.logDebug("JsEngine returns value [%s]" % jreturn) key = binascii.unhexlify(jreturn) - # Decrypt + #: Decrypt Key = key IV = key obj = AES.new(Key, AES.MODE_CBC, IV) text = obj.decrypt(crypted.decode('base64')) - # Extract links + #: Extract links text = text.replace("\x00", "").replace("\r", "") links = filter(bool, text.split('\n')) - # Log and return + #: Log and return self.logDebug("Package has %d links" % len(links)) return links diff --git a/module/plugins/crypter/SexuriaCom.py b/module/plugins/crypter/SexuriaCom.py index 4ee4eb0b3..cce2177f4 100644 --- a/module/plugins/crypter/SexuriaCom.py +++ b/module/plugins/crypter/SexuriaCom.py @@ -29,11 +29,11 @@ class SexuriaCom(Crypter): def decrypt(self, pyfile): - # Init + #: Init self.pyfile = pyfile self.package = pyfile.package() - # Get package links + #: Get package links package_name, self.links, folder_name, package_pwd = self.decryptLinks(self.pyfile.url) self.packages = [(package_name, self.links, folder_name)] @@ -45,20 +45,20 @@ class SexuriaCom(Crypter): password = None if re.match(self.PATTERN_SUPPORTED_MAIN, url, re.I): - # Processing main page + #: Processing main page html = self.load(url) links = re.findall(self.PATTERN_DL_LINK_PAGE, html, re.I) for link in links: linklist.append("http://sexuria.com/v1/" + link) elif re.match(self.PATTERN_SUPPORTED_REDIRECT, url, re.I): - # Processing direct redirect link (out.php), redirecting to main page + #: Processing direct redirect link (out.php), redirecting to main page id = re.search(self.PATTERN_SUPPORTED_REDIRECT, url, re.I).group('ID') if id: linklist.append("http://sexuria.com/v1/Pornos_Kostenlos_liebe_%s.html" % id) elif re.match(self.PATTERN_SUPPORTED_CRYPT, url, re.I): - # Extract info from main file + #: Extract info from main file id = re.search(self.PATTERN_SUPPORTED_CRYPT, url, re.I).group('ID') html = self.load("http://sexuria.com/v1/Pornos_Kostenlos_info_%s.html" % id) @@ -72,7 +72,7 @@ class SexuriaCom(Crypter): password = pwd.strip() self.logDebug("Password info [%s] found" % password) - # Process link (dl_link) + #: Process link (dl_link) html = self.load(url) links = re.findall(self.PATTERN_REDIRECT_LINKS, html, re.I) if len(links) == 0: @@ -86,7 +86,7 @@ class SexuriaCom(Crypter): else: linklist.append(finallink) - # Debug log + #: Debug log self.logDebug("%d supported links" % len(linklist)) for i, link in enumerate(linklist): self.logDebug("Supported link %d, %s" % (i + 1, link)) diff --git a/module/plugins/crypter/ShareLinksBiz.py b/module/plugins/crypter/ShareLinksBiz.py index 2d72b513e..250cc0c81 100644 --- a/module/plugins/crypter/ShareLinksBiz.py +++ b/module/plugins/crypter/ShareLinksBiz.py @@ -29,17 +29,17 @@ class ShareLinksBiz(Crypter): def decrypt(self, pyfile): - # Init + #: Init self.initFile(pyfile) - # Request package + #: Request package url = self.baseUrl + '/' + self.fileId self.html = self.load(url) - # Unblock server (load all images) + #: Unblock server (load all images) self.unblockServer() - # Check for protection + #: Check for protection if self.isPasswordProtected(): self.unlockPasswordProtection() self.handleErrors() @@ -49,17 +49,17 @@ class ShareLinksBiz(Crypter): self.unlockCaptchaProtection() self.handleErrors() - # Extract package links + #: Extract package links package_links = [] package_links.extend(self.handleWebLinks()) package_links.extend(self.handleContainers()) package_links.extend(self.handleCNL2()) package_links = set(package_links) - # Get package info + #: Get package info package_name, package_folder = self.getPackageInfo() - # Pack + #: Pack self.packages = [(package_name, package_links, package_folder)] @@ -108,18 +108,18 @@ class ShareLinksBiz(Crypter): def unlockCaptchaProtection(self): - # Get captcha map + #: Get captcha map captchaMap = self._getCaptchaMap() self.logDebug("Captcha map with [%d] positions" % len(captchaMap.keys())) - # Request user for captcha coords + #: Request user for captcha coords m = re.search(r'<img src="/captcha.gif\?d=(.*?)&PHPSESSID=(.*?)&legend=1"', self.html) captchaUrl = self.baseUrl + '/captcha.gif?d=%s&PHPSESSID=%s' % (m.group(1), m.group(2)) self.logDebug("Waiting user for correct position") coords = self.decryptCaptcha(captchaUrl, forceUser=True, imgtype="gif", result_type='positional') self.logDebug("Captcha resolved, coords [%s]" % str(coords)) - # Resolve captcha + #: Resolve captcha href = self._resolveCoords(coords, captchaMap) if href is None: self.invalidCaptcha() @@ -161,7 +161,7 @@ class ShareLinksBiz(Crypter): def getPackageInfo(self): name = folder = None - # Extract from web package header + #: Extract from web package header title_re = r'<h2><img.*?/>(.*)</h2>' m = re.search(title_re, self.html, re.S) if m: @@ -170,13 +170,13 @@ class ShareLinksBiz(Crypter): name = folder = title self.logDebug("Found name [%s] and folder [%s] in package info" % (name, folder)) - # Fallback to defaults + #: Fallback to defaults if not name or not folder: name = self.package.name folder = self.package.folder self.logDebug("Package info not found, defaulting to pyfile name [%s] and folder [%s]" % (name, folder)) - # Return package info + #: Return package info return name, folder @@ -240,40 +240,40 @@ class ShareLinksBiz(Crypter): def _getCipherParams(self): - # Request CNL2 + #: Request CNL2 code = re.search(r'ClicknLoad.swf\?code=(.*?)"', self.html).group(1) url = "%s/get/cnl2/%s" % (self.baseUrl, code) res = self.load(url) params = res.split(";;") - # Get jk + #: Get jk strlist = list(params[1].decode('base64')) jk = ''.join(strlist[::-1]) - # Get crypted + #: Get crypted strlist = list(params[2].decode('base64')) crypted = ''.join(strlist[::-1]) - # Log and return + #: Log and return return crypted, jk def _getLinks(self, crypted, jk): - # Get key + #: Get key jreturn = self.js.eval("%s f()" % jk) self.logDebug("JsEngine returns value [%s]" % jreturn) key = binascii.unhexlify(jreturn) - # Decrypt + #: Decrypt Key = key IV = key obj = AES.new(Key, AES.MODE_CBC, IV) text = obj.decrypt(crypted.decode('base64')) - # Extract links + #: Extract links text = text.replace("\x00", "").replace("\r", "") links = filter(bool, text.split('\n')) - # Log and return + #: Log and return self.logDebug("Block has %d links" % len(links)) return links diff --git a/module/plugins/crypter/YoutubeComFolder.py b/module/plugins/crypter/YoutubeComFolder.py index c6f86113d..fed832b7d 100644 --- a/module/plugins/crypter/YoutubeComFolder.py +++ b/module/plugins/crypter/YoutubeComFolder.py @@ -42,7 +42,7 @@ class YoutubeComFolder(Crypter): return {"id": channel['id'], "title": channel['snippet']['title'], "relatedPlaylists": channel['contentDetails']['relatedPlaylists'], - "user": user} # One lone channel for user? + "user": user} #: One lone channel for user? def getPlaylist(self, p_id): diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 1faa6ebe3..02b1df67b 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -113,7 +113,6 @@ class AntiVirus(Hook): def download_failed(self, pyfile): - #: Check if pyfile is still "failed", - # maybe might has been restarted in meantime + #: Check if pyfile is still "failed", maybe might has been restarted in meantime if pyfile.status == 8 and self.getConfig('scanfailed'): return self.scan(pyfile) diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 912a1ba1f..df81be384 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -110,7 +110,7 @@ class Checksum(Hook): if not os.path.isfile(local_file): self.checkFailed(pyfile, None, "File does not exist") - # validate file size + #: validate file size if "size" in data: api_size = int(data['size']) file_size = os.path.getsize(local_file) @@ -121,7 +121,7 @@ class Checksum(Hook): data.pop('size', None) - # validate checksum + #: validate checksum if data and self.getConfig('check_checksum'): if not 'md5' in data: diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index f7431ebac..b1009420a 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -22,7 +22,7 @@ def forward(source, destination): bufdata = source.recv(bufsize) finally: destination.shutdown(socket.SHUT_WR) - # destination.close() + #: destination.close() #@TODO: IPv6 support diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index 86532cdad..a3e171a43 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -23,7 +23,7 @@ class DeleteFinished(Hook): ## overwritten methods ## def setup(self): self.info = {} #@TODO: Remove in 0.4.10 - # self.event_list = ["pluginConfigChanged"] + #: self.event_list = ["pluginConfigChanged"] self.interval = self.MIN_CHECK_INTERVAL @@ -38,10 +38,10 @@ class DeleteFinished(Hook): self.addEvent('package_finished', self.wakeup) - # def pluginConfigChanged(self, plugin, name, value): - # if name == "interval" and value != self.interval: - # self.interval = value * 3600 - # self.init_periodical() + #: def pluginConfigChanged(self, plugin, name, value): + #: if name == "interval" and value != self.interval: + #: self.interval = value * 3600 + #: self.init_periodical() def deactivate(self): @@ -50,8 +50,8 @@ class DeleteFinished(Hook): def activate(self): self.info['sleep'] = True - # interval = self.getConfig('interval') - # self.pluginConfigChanged(self.__name__, 'interval', interval) + #: interval = self.getConfig('interval') + #: self.pluginConfigChanged(self.__name__, 'interval', interval) self.interval = max(self.MIN_CHECK_INTERVAL, self.getConfig('interval') * 60 * 60) self.addEvent('package_finished', self.wakeup) diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 773de7c4b..0ccc8a0ec 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -26,7 +26,7 @@ class DownloadScheduler(Hook): def setup(self): self.info = {} #@TODO: Remove in 0.4.10 - self.cb = None # callback to scheduler job; will be by removed hookmanager when hook unloaded + self.cb = None #: callback to scheduler job; will be by removed hookmanager when hook unloaded def activate(self): diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index ee41068eb..925976bc6 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -23,7 +23,7 @@ if sys.version_info < (2, 7) and os.name != "nt": raise - # unsued timeout option for older python version + #: unsued timeout option for older python version def wait(self, timeout=0): """ Wait for child process to terminate. Returns returncode @@ -36,9 +36,9 @@ if sys.version_info < (2, 7) and os.name != "nt": except OSError, e: if e.errno != errno.ECHILD: raise - # This happens if SIGCLD is set to be ignored or waiting - # for child processes has otherwise been disabled for our - # process. This child is dead, we can't get the status. + #: This happens if SIGCLD is set to be ignored or waiting + #: for child processes has otherwise been disabled for our + #: process. This child is dead, we can't get the status. sts = 0 self._handle_exitstatus(sts) return self.returncode @@ -262,12 +262,12 @@ class ExtractArchive(Hook): if extensions: self.logDebug("Use for extensions: %s" % "|.".join(extensions)) - # reload from txt file + #: reload from txt file self.reloadPasswords() download_folder = self.core.config.get("general", "download_folder") - # iterate packages -> extractors -> targets + #: iterate packages -> extractors -> targets for pid in ids: pypack = self.core.files.getPackage(pid) @@ -277,7 +277,7 @@ class ExtractArchive(Hook): self.logInfo(_("Check package: %s") % pypack.name) - # determine output folder + #: determine output folder out = fs_join(download_folder, pypack.folder, destination, "") #: force trailing slash if subfolder: @@ -291,7 +291,7 @@ class ExtractArchive(Hook): files_ids = dict((pylink['name'],((fs_join(download_folder, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() #: remove duplicates - # check as long there are unseen files + #: check as long there are unseen files while files_ids: new_files_ids = [] @@ -341,7 +341,7 @@ class ExtractArchive(Hook): success = False continue - # remove processed file and related multiparts from list + #: remove processed file and related multiparts from list files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \ if fname not in archive.getDeleteFiles()] self.logDebug("Extracted files: %s" % new_files) diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index d50fd6107..61922f657 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -84,7 +84,7 @@ class IRCInterface(Thread, Hook): def run(self): - # connect to IRC etc. + #: connect to IRC etc. self.sock = socket.socket() host = self.getConfig('host') self.sock.connect((host, self.getConfig('port'))) @@ -158,7 +158,7 @@ class IRCInterface(Thread, Hook): if msg['action'] != "PRIVMSG": return - # HANDLE CTCP ANTI FLOOD/BOT PROTECTION + #: HANDLE CTCP ANTI FLOOD/BOT PROTECTION if msg['text'] == "\x01VERSION\x01": self.logDebug("Sending CTCP VERSION") self.sock.send("NOTICE %s :%s\r\n" % (msg['origin'], "pyLoad! IRC Interface")) @@ -344,7 +344,7 @@ class IRCInterface(Thread, Hook): return ["INFO: Added %d links to Package %s [#%d]" % (len(links), pack['name'], id)] except Exception: - # create new package + #: create new package id = self.core.api.addPackage(pack, links, 1) return ["INFO: Created new Package %s [#%d] with %d links." % (pack, id, len(links))] diff --git a/module/plugins/hooks/PremiumizeMeHook.py b/module/plugins/hooks/PremiumizeMeHook.py index bc803b1f5..615c6c2d8 100644 --- a/module/plugins/hooks/PremiumizeMeHook.py +++ b/module/plugins/hooks/PremiumizeMeHook.py @@ -21,18 +21,18 @@ class PremiumizeMeHook(MultiHook): def getHosters(self): - # Get account data + #: Get account data user, data = self.account.selectAccount() - # Get supported hosters list from premiumize.me using the - # json API v1 (see https://secure.premiumize.me/?show=api) + #: Get supported hosters list from premiumize.me using the + #: json API v1 (see https://secure.premiumize.me/?show=api) answer = self.load("http://api.premiumize.me/pm-api/v1.php", #@TODO: Revert to `https` in 0.4.10 get={'method': "hosterlist", 'params[login]': user, 'params[pass]': data['password']}) data = json_loads(answer) - # If account is not valid thera are no hosters available + #: If account is not valid thera are no hosters available if data['status'] != 200: return [] - # Extract hosters from json file + #: Extract hosters from json file return data['result']['hosterlist'] diff --git a/module/plugins/hooks/RPNetBizHook.py b/module/plugins/hooks/RPNetBizHook.py index 872eb7e08..8b3dd6ea1 100644 --- a/module/plugins/hooks/RPNetBizHook.py +++ b/module/plugins/hooks/RPNetBizHook.py @@ -21,16 +21,16 @@ class RPNetBizHook(MultiHook): def getHosters(self): - # Get account data + #: Get account data user, data = self.account.selectAccount() res = self.load("https://premium.rpnet.biz/client_api.php", get={'username': user, 'password': data['password'], 'action': "showHosterList"}) hoster_list = json_loads(res) - # If account is not valid thera are no hosters available + #: If account is not valid thera are no hosters available if 'error' in hoster_list: return [] - # Extract hosters from json file + #: Extract hosters from json file return hoster_list['hosters'] diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 153b4716c..0c74a544a 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -18,15 +18,15 @@ class RestartFailed(Hook): MIN_CHECK_INTERVAL = 15 * 60 #: 15 minutes - # def pluginConfigChanged(self, plugin, name, value): - # if name == "interval": - # interval = value * 60 - # if self.MIN_CHECK_INTERVAL <= interval != self.interval: - # self.core.scheduler.removeJob(self.cb) - # self.interval = interval - # self.init_periodical() - # else: - # self.logDebug("Invalid interval value, kept current") + #: def pluginConfigChanged(self, plugin, name, value): + #: if name == "interval": + #: interval = value * 60 + #: if self.MIN_CHECK_INTERVAL <= interval != self.interval: + #: self.core.scheduler.removeJob(self.cb) + #: self.interval = interval + #: self.init_periodical() + #: else: + #: self.logDebug("Invalid interval value, kept current") def periodical(self): @@ -36,10 +36,10 @@ class RestartFailed(Hook): def setup(self): self.info = {} #@TODO: Remove in 0.4.10 - # self.event_list = ["pluginConfigChanged"] + #: self.event_list = ["pluginConfigChanged"] self.interval = self.MIN_CHECK_INTERVAL def activate(self): - # self.pluginConfigChanged(self.__name__, "interval", self.getConfig('interval')) + #: self.pluginConfigChanged(self.__name__, "interval", self.getConfig('interval')) self.interval = max(self.MIN_CHECK_INTERVAL, self.getConfig('interval') * 60) diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 32454d255..503833d53 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -79,14 +79,13 @@ class SkipRev(Hook): pyfile.setCustomStatus("SkipRev", "skipped") if not hasattr(pyfile.plugin, "_setup"): - # Work-around: inject status checker inside the preprocessing routine of the plugin + #: Work-around: inject status checker inside the preprocessing routine of the plugin pyfile.plugin._setup = pyfile.plugin.setup pyfile.plugin.setup = MethodType(self._setup, pyfile.plugin) def download_failed(self, pyfile): - #: Check if pyfile is still "failed", - # maybe might has been restarted in meantime + #: Check if pyfile is still "failed", maybe might has been restarted in meantime if pyfile.status != 8 or pyfile.name.rsplit('.', 1)[-1].strip() not in ("rar", "rev"): return diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 9ba53a698..cbfbff1b6 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -24,8 +24,7 @@ class UnSkipOnFail(Hook): def download_failed(self, pyfile): - #: Check if pyfile is still "failed", - # maybe might has been restarted in meantime + #: Check if pyfile is still "failed", maybe might has been restarted in meantime if pyfile.status != 8: return @@ -36,13 +35,13 @@ class UnSkipOnFail(Hook): if link: self.logInfo(_("Queue found duplicate: %s (pid:%s)") % (link.name, link.packageID)) - #: Change status of "link" to "new_status". - # "link" has to be a valid FileData object, - # "new_status" has to be a valid status name - # (i.e. "queued" for this Plugin) - # It creates a temporary PyFile object using - # "link" data, changes its status, and tells - # the core.files-manager to save its data. + # Change status of "link" to "new_status". + # "link" has to be a valid FileData object, + # "new_status" has to be a valid status name + # (i.e. "queued" for this Plugin) + # It creates a temporary PyFile object using + # "link" data, changes its status, and tells + # the core.files-manager to save its data. pylink = self._pyfile(link) pylink.setCustomStatus(_("unskipped"), "queued") diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 0a89405e7..a06ed97e9 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -174,10 +174,10 @@ class UpdateManager(Hook): exitcode = 3 # Exit codes: - # -1 = No plugin updated, new pyLoad version available - # 0 = No plugin updated - # 1 = Plugins updated - # 2 = Plugins updated, but restart required + # -1 = No plugin updated, new pyLoad version available + # 0 = No plugin updated + # 1 = Plugins updated + # 2 = Plugins updated, but restart required return exitcode @@ -206,7 +206,7 @@ class UpdateManager(Hook): if blacklist: type_plugins = [(plugin['type'], plugin['name'].rsplit('.', 1)[0]) for plugin in blacklist] - # Protect UpdateManager from self-removing + #: Protect UpdateManager from self-removing try: type_plugins.remove(("hook", "UpdateManager")) except ValueError: @@ -286,9 +286,9 @@ class UpdateManager(Hook): self.logInfo(_("No plugin updates available")) # Exit codes: - # 0 = No plugin updated - # 1 = Plugins updated - # 2 = Plugins updated, but restart required + # 0 = No plugin updated + # 1 = Plugins updated + # 2 = Plugins updated, but restart required return exitcode diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 8ef5941d1..0c103b56a 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -44,13 +44,13 @@ class XFileSharingPro(Hook): CRYPTER_BUILTIN = ["junocloud.me", "rapidfileshare.net"] - # def pluginConfigChanged(self, plugin, name, value): - # self.loadPattern() + #: def pluginConfigChanged(self, plugin, name, value): + #: self.loadPattern() def setup(self): self.info = {} #@TODO: Remove in 0.4.10 - # self.event_list = ["pluginConfigChanged"] + #: self.event_list = ["pluginConfigChanged"] def activate(self): @@ -105,7 +105,7 @@ class XFileSharingPro(Hook): def deactivate(self): - # self.unloadHoster("BasePlugin") + #: self.unloadHoster("BasePlugin") for type, plugin in (("hoster", "XFileSharingPro"), ("crypter", "XFileSharingProFolder")): self._unload(type, plugin) @@ -126,10 +126,10 @@ class XFileSharingPro(Hook): return False - # def download_failed(self, pyfile): - # if pyfile.pluginname == "BasePlugin" \ - # and pyfile.hasStatus("failed") \ - # and not self.getConfig('use_hoster_list') \ - # and self.unloadHoster("BasePlugin"): - # self.logDebug("Unloaded XFileSharingPro from BasePlugin") - # pyfile.setStatus("queued") + #: def download_failed(self, pyfile): + #: if pyfile.pluginname == "BasePlugin" \ + #: and pyfile.hasStatus("failed") \ + #: and not self.getConfig('use_hoster_list') \ + #: and self.unloadHoster("BasePlugin"): + #: self.logDebug("Unloaded XFileSharingPro from BasePlugin") + #: pyfile.setStatus("queued") diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index 847fb26c3..10a03603e 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -36,7 +36,7 @@ class XMPPInterface(IRCInterface, JabberClient): self.jid = JID(self.getConfig('jid')) password = self.getConfig('pw') - # if bare JID is provided add a resource -- it is required + #: if bare JID is provided add a resource -- it is required if not self.jid.resource: self.jid = JID(self.jid.node, self.jid.domain, "pyLoad") @@ -47,8 +47,8 @@ class XMPPInterface(IRCInterface, JabberClient): tls_settings = None auth = ("sasl:DIGEST-MD5", "digest") - # setup client with provided connection information - # and identity data + #: setup client with provided connection information + #: and identity data JabberClient.__init__(self, self.jid, password, disco_name="pyLoad XMPP Client", disco_type="bot", tls_settings=tls_settings, auth_methods=auth) @@ -83,7 +83,7 @@ class XMPPInterface(IRCInterface, JabberClient): def run(self): - # connect to IRC etc. + #: connect to IRC etc. self.connect() try: self.loop() @@ -133,7 +133,7 @@ class XMPPInterface(IRCInterface, JabberClient): self.logDebug("Body: %s Subject: %s Type: %s" % (body, subject, t)) if t == "headline": - # 'headline' messages should never be replied to + #: 'headline' messages should never be replied to return True if subject: subject = u"Re: " + subject diff --git a/module/plugins/hoster/BitshareCom.py b/module/plugins/hoster/BitshareCom.py index f3d513adf..2736d98a8 100644 --- a/module/plugins/hoster/BitshareCom.py +++ b/module/plugins/hoster/BitshareCom.py @@ -40,25 +40,25 @@ class BitshareCom(SimpleHoster): if self.premium: self.account.relogin(self.user) - # File id + #: File id m = re.match(self.__pattern__, pyfile.url) self.file_id = max(m.group('ID1'), m.group('ID2')) self.logDebug("File id is [%s]" % self.file_id) - # Load main page + #: Load main page self.html = self.load(pyfile.url, ref=False) - # Check offline + #: Check offline if re.search(self.OFFLINE_PATTERN, self.html): self.offline() - # Check Traffic used up + #: Check Traffic used up if re.search(self.TRAFFIC_USED_UP, self.html): self.logInfo(_("Your Traffic is used up for today")) self.wait(30 * 60, True) self.retry() - # File name + #: File name m = re.match(self.__pattern__, pyfile.url) name1 = m.group('NAME') if m else None @@ -67,11 +67,11 @@ class BitshareCom(SimpleHoster): pyfile.name = max(name1, name2) - # Ajax file id + #: Ajax file id self.ajaxid = re.search(self.AJAXID_PATTERN, self.html).group(1) self.logDebug("File ajax id is [%s]" % self.ajaxid) - # This may either download our file or forward us to an error page + #: This may either download our file or forward us to an error page self.link = self.getDownloadUrl() if self.checkDownload({"error": ">Error occured<"}): @@ -79,13 +79,13 @@ class BitshareCom(SimpleHoster): def getDownloadUrl(self): - # Return location if direct download is active + #: Return location if direct download is active if self.premium: header = self.load(self.pyfile.url, just_header=True) if 'location' in header: return header['location'] - # Get download info + #: Get download info self.logDebug("Getting download info") res = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", post={"request": "generateID", "ajaxid": self.ajaxid}) @@ -99,7 +99,7 @@ class BitshareCom(SimpleHoster): self.logDebug("Download info [type: '%s', waiting: %d, captcha: %d]" % (filetype, wait, captcha)) - # Waiting + #: Waiting if wait > 0: self.logDebug("Waiting %d seconds." % wait) if wait < 120: @@ -108,12 +108,12 @@ class BitshareCom(SimpleHoster): self.wait(wait - 55, True) self.retry() - # Resolve captcha + #: Resolve captcha if captcha == 1: self.logDebug("File is captcha protected") recaptcha = ReCaptcha(self) - # Try up to 3 times + #: Try up to 3 times for i in xrange(3): response, challenge = recaptcha.challenge() res = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", @@ -124,7 +124,7 @@ class BitshareCom(SimpleHoster): if self.handleCaptchaErrors(res): break - # Get download URL + #: Get download URL self.logDebug("Getting download url") res = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", post={"request": "getDownloadURL", "ajaxid": self.ajaxid}) diff --git a/module/plugins/hoster/CzshareCom.py b/module/plugins/hoster/CzshareCom.py index e3d89a2a5..01e120e5e 100644 --- a/module/plugins/hoster/CzshareCom.py +++ b/module/plugins/hoster/CzshareCom.py @@ -40,7 +40,7 @@ class CzshareCom(SimpleHoster): def checkTrafficLeft(self): - # check if user logged in + #: check if user logged in m = re.search(self.USER_CREDIT_PATTERN, self.html) if m is None: self.account.relogin(self.user) @@ -49,7 +49,7 @@ class CzshareCom(SimpleHoster): if m is None: return False - # check user credit + #: check user credit try: credit = parseFileSize(m.group(1).replace(' ', ''), m.group(2)) self.logInfo(_("Premium download for %i KiB of Credit") % (self.pyfile.size / 1024)) @@ -58,14 +58,14 @@ class CzshareCom(SimpleHoster): self.logInfo(_("Not enough credit to download file: %s") % self.pyfile.name) return False except Exception, e: - # let's continue and see what happens... + #: let's continue and see what happens... self.logError(e) return True def handlePremium(self, pyfile): - # parse download link + #: parse download link try: form = re.search(self.PREMIUM_FORM_PATTERN, self.html, re.S).group(1) inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) @@ -73,12 +73,12 @@ class CzshareCom(SimpleHoster): self.logError(e) self.resetAccount() - # download the file, destination is determined by pyLoad + #: download the file, destination is determined by pyLoad self.download("http://sdilej.cz/profi_down.php", post=inputs, disposition=True) def handleFree(self, pyfile): - # get free url + #: get free url m = re.search(self.FREE_URL_PATTERN, self.html) if m is None: self.error(_("FREE_URL_PATTERN not found")) @@ -87,7 +87,7 @@ class CzshareCom(SimpleHoster): self.logDebug("PARSED_URL:" + parsed_url) - # get download ticket and parse html + #: get download ticket and parse html self.html = self.load(parsed_url) if re.search(self.MULTIDL_PATTERN, self.html): self.wait(5 * 60, 12, _("Download limit reached")) @@ -101,7 +101,7 @@ class CzshareCom(SimpleHoster): self.logError(e) self.error(_("Form")) - # get and decrypt captcha + #: get and decrypt captcha captcha_url = 'http://sdilej.cz/captcha.php' for _i in xrange(5): inputs['captchastring2'] = self.decryptCaptcha(captcha_url) @@ -122,7 +122,7 @@ class CzshareCom(SimpleHoster): m = re.search("countdown_number = (\d+);", self.html) self.setWait(int(m.group(1)) if m else 50) - # download the file, destination is determined by pyLoad + #: download the file, destination is determined by pyLoad self.logDebug("WAIT URL", self.req.lastEffectiveURL) m = re.search("free_wait.php\?server=(.*?)&(.*)", self.req.lastEffectiveURL) @@ -135,7 +135,7 @@ class CzshareCom(SimpleHoster): def checkFile(self): - # check download + #: check download check = self.checkDownload({ "temp offline" : re.compile(r"^Soubor je do.*asn.* nedostupn.*$"), "credit" : re.compile(r"^Nem.*te dostate.*n.* kredit.$"), diff --git a/module/plugins/hoster/DlFreeFr.py b/module/plugins/hoster/DlFreeFr.py index ff5ee7b92..e3be19782 100644 --- a/module/plugins/hoster/DlFreeFr.py +++ b/module/plugins/hoster/DlFreeFr.py @@ -76,11 +76,11 @@ class DlFreeFr(SimpleHoster): if headers.get('code') == 200: content_type = headers.get('content-type') if content_type and content_type.startswith("text/html"): - # Undirect acces to requested file, with a web page providing it (captcha) + #: Undirect acces to requested file, with a web page providing it (captcha) self.html = self.load(valid_url) self.handleFree(pyfile) else: - # Direct access to requested file for users using free.fr as Internet Service Provider. + #: Direct access to requested file for users using free.fr as Internet Service Provider. self.link = valid_url self.download(self.link, disposition=True) diff --git a/module/plugins/hoster/FileSharkPl.py b/module/plugins/hoster/FileSharkPl.py index 5be339896..d01a34bad 100644 --- a/module/plugins/hoster/FileSharkPl.py +++ b/module/plugins/hoster/FileSharkPl.py @@ -47,7 +47,7 @@ class FileSharkPl(SimpleHoster): def checkErrors(self): - # check if file is now available for download (-> file name can be found in html body) + #: check if file is now available for download (-> file name can be found in html body) m = re.search(self.WAIT_PATTERN, self.html) if m: errmsg = self.info['error'] = _("Another download already run") diff --git a/module/plugins/hoster/FilepostCom.py b/module/plugins/hoster/FilepostCom.py index 1f3de6717..b2891a9e8 100644 --- a/module/plugins/hoster/FilepostCom.py +++ b/module/plugins/hoster/FilepostCom.py @@ -40,7 +40,7 @@ class FilepostCom(SimpleHoster): self.error(_("Captcha key")) captcha_key = m.group(1) - # Get wait time + #: Get wait time get_dict = {'SID': self.req.cj.getCookie('SID'), 'JsHttpRequest': str(int(time.time() * 10000)) + '-xml'} post_dict = {'action': 'set_download', 'token': flp_token, 'code': self.info['pattern']['ID']} wait_time = int(self.getJsonResponse(get_dict, post_dict, 'wait_time')) @@ -51,7 +51,7 @@ class FilepostCom(SimpleHoster): post_dict = {"token": flp_token, "code": self.info['pattern']['ID'], "file_pass": ''} if 'var is_pass_exists = true;' in self.html: - # Solve password + #: Solve password password = self.getPassword() if password: @@ -68,7 +68,7 @@ class FilepostCom(SimpleHoster): self.fail(_("No password found")) else: - # Solve recaptcha + #: Solve recaptcha recaptcha = ReCaptcha(self) for i in xrange(5): @@ -93,15 +93,15 @@ class FilepostCom(SimpleHoster): if not 'js' in res: self.error(_("JSON %s 1") % field) - # i changed js_answer to res['js'] since js_answer is nowhere set. - # i don't know the JSON-HTTP specs in detail, but the previous author - # accessed res['js']['error'] as well as js_answer['error']. - # see the two lines commented out with "# ~?". + #: i changed js_answer to res['js'] since js_answer is nowhere set. + #: i don't know the JSON-HTTP specs in detail, but the previous author + #: accessed res['js']['error'] as well as js_answer['error']. + #: see the two lines commented out with "# ~?". if 'error' in res['js']: if res['js']['error'] == 'download_delay': self.retry(wait_time=res['js']['params']['next_download']) - # ~? self.retry(wait_time=js_answer['params']['next_download']) + #: ~? self.retry(wait_time=js_answer['params']['next_download']) elif 'Wrong file password' in res['js']['error'] \ or 'You entered a wrong CAPTCHA code' in res['js']['error'] \ diff --git a/module/plugins/hoster/FilesMailRu.py b/module/plugins/hoster/FilesMailRu.py index 66f715962..f93281702 100644 --- a/module/plugins/hoster/FilesMailRu.py +++ b/module/plugins/hoster/FilesMailRu.py @@ -24,8 +24,8 @@ def getInfo(urls): except Exception: pass - # status 1=OFFLINE, 2=OK, 3=UNKNOWN - # result.append((#name,#size,#status,#url)) + #: status 1=OFFLINE, 2=OK, 3=UNKNOWN + #: result.append((#name,#size,#status,#url)) yield result @@ -93,16 +93,16 @@ class FilesMailRu(Hoster): def myPostProcess(self): - # searches the file for HTMl-Code. Sometimes the Redirect - # doesn't work (maybe a curl Problem) and you get only a small - # HTML file and the Download is marked as "finished" - # then the download will be restarted. It's only bad for these - # who want download a HTML-File (it's one in a million ;-) ) + #: searches the file for HTMl-Code. Sometimes the Redirect + #: doesn't work (maybe a curl Problem) and you get only a small + #: HTML file and the Download is marked as "finished" + #: then the download will be restarted. It's only bad for these + #: who want download a HTML-File (it's one in a million ;-) ) # - # The maximum UploadSize allowed on files.mail.ru at the moment is 100MB - # so i set it to check every download because sometimes there are downloads - # that contain the HTML-Text and 60MB ZEROs after that in a xyzfile.part1.rar file - # (Loading 100MB in to ram is not an option) + #: The maximum UploadSize allowed on files.mail.ru at the moment is 100MB + #: so i set it to check every download because sometimes there are downloads + #: that contain the HTML-Text and 60MB ZEROs after that in a xyzfile.part1.rar file + #: (Loading 100MB in to ram is not an option) check = self.checkDownload({"html": "<meta name="}, read_size=50000) if check == "html": self.logInfo(_( diff --git a/module/plugins/hoster/FileserveCom.py b/module/plugins/hoster/FileserveCom.py index 3f4c7d6ed..71cdb1fae 100644 --- a/module/plugins/hoster/FileserveCom.py +++ b/module/plugins/hoster/FileserveCom.py @@ -108,13 +108,13 @@ class FileserveCom(Hoster): else: self.error(_("Unknown server response")) - # show download link + #: show download link res = self.load(self.url, post={"downloadLink": "show"}) self.logDebug("Show downloadLink response: %s" % res) if "fail" in res: self.error(_("Couldn't retrieve download url")) - # this may either download our file or forward us to an error page + #: this may either download our file or forward us to an error page self.download(self.url, post={"download": "normal"}) self.logDebug(self.req.http.lastEffectiveURL) @@ -135,7 +135,7 @@ class FileserveCom(Hoster): self.wait() self.retry() - self.thread.m.reconnecting.wait(3) # Ease issue with later downloads appearing to be in parallel + self.thread.m.reconnecting.wait(3) #: Ease issue with later downloads appearing to be in parallel def doTimmer(self): diff --git a/module/plugins/hoster/FlyFilesNet.py b/module/plugins/hoster/FlyFilesNet.py index 689eb3c66..fb57baffd 100644 --- a/module/plugins/hoster/FlyFilesNet.py +++ b/module/plugins/hoster/FlyFilesNet.py @@ -31,7 +31,7 @@ class FlyFilesNet(SimpleHoster): url = "http://flyfiles.net" - # get download URL + #: get download URL parsed_url = getURL(url, post={"getDownLink": session}) self.logDebug("Parsed URL: %s" % parsed_url) diff --git a/module/plugins/hoster/FreakshareCom.py b/module/plugins/hoster/FreakshareCom.py index 5abded2ac..f8e72e62f 100644 --- a/module/plugins/hoster/FreakshareCom.py +++ b/module/plugins/hoster/FreakshareCom.py @@ -87,7 +87,7 @@ class FreakshareCom(Hoster): def download_html(self): - self.load("http://freakshare.com/index.php", {"language": "EN"}) # Set english language in server session + self.load("http://freakshare.com/index.php", {"language": "EN"}) #: Set english language in server session self.html = self.load(self.pyfile.url) @@ -98,7 +98,7 @@ class FreakshareCom(Hoster): if not self.html: self.download_html() if not self.wantReconnect: - self.req_opts = self.get_download_options() # get the Post options for the Request + self.req_opts = self.get_download_options() #: get the Post options for the Request #file_url = self.pyfile.url #return file_url else: @@ -165,11 +165,11 @@ class FreakshareCom(Hoster): def get_download_options(self): re_envelope = re.search(r".*?value=\"Free\sDownload\".*?\n*?(.*?<.*?>\n*)*?\n*\s*?</form>", - self.html).group(0) # get the whole request + self.html).group(0) #: get the whole request to_sort = re.findall(r"<input\stype=\"hidden\"\svalue=\"(.*?)\"\sname=\"(.*?)\"\s\/>", re_envelope) request_options = dict((n, v) for (v, n) in to_sort) - herewego = self.load(self.pyfile.url, None, request_options) # the actual download-Page + herewego = self.load(self.pyfile.url, None, request_options) #: the actual download-Page to_sort = re.findall(r"<input\stype=\".*?\"\svalue=\"(\S*?)\".*?name=\"(\S*?)\"\s.*?\/>", herewego) request_options = dict((n, v) for (v, n) in to_sort) diff --git a/module/plugins/hoster/FreeWayMe.py b/module/plugins/hoster/FreeWayMe.py index bb6d9f29d..215dd8f5a 100644 --- a/module/plugins/hoster/FreeWayMe.py +++ b/module/plugins/hoster/FreeWayMe.py @@ -26,7 +26,7 @@ class FreeWayMe(MultiHoster): user, data = self.account.selectAccount() for _i in xrange(5): - # try it five times + #: try it five times header = self.load("http://www.free-way.bz/load.php", #@TODO: Revert to `https` in 0.4.10 get={'multiget': 7, 'url' : pyfile.url, @@ -38,14 +38,14 @@ class FreeWayMe(MultiHoster): if 'location' in header: headers = self.load(header['location'], just_header=True) if headers['code'] == 500: - # error on 2nd stage + #: error on 2nd stage self.logError(_("Error [stage2]")) else: - # seems to work.. + #: seems to work.. self.download(header['location']) break else: - # error page first stage + #: error page first stage self.logError(_("Error [stage1]")) #@TODO: handle errors diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index 2e10de971..f4d6380ee 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -68,7 +68,7 @@ class Ftp(Hoster): pyfile.url = pyfile.url.rstrip('/') pkgname = "/".join([pyfile.package().name, urlparse.urlparse(pyfile.url).path.rpartition('/')[2]]) pyfile.url += '/' - self.req.http.c.setopt(48, 1) # CURLOPT_DIRLISTONLY + self.req.http.c.setopt(48, 1) #: CURLOPT_DIRLISTONLY res = self.load(pyfile.url, decode=False) links = [pyfile.url + x for x in res.splitlines()] self.logDebug("LINKS", links) diff --git a/module/plugins/hoster/Keep2ShareCc.py b/module/plugins/hoster/Keep2ShareCc.py index 19a8f2ba6..d90466904 100644 --- a/module/plugins/hoster/Keep2ShareCc.py +++ b/module/plugins/hoster/Keep2ShareCc.py @@ -55,7 +55,7 @@ class Keep2ShareCc(SimpleHoster): if m: self.logDebug("Hoster told us to wait for %s" % m.group(1)) - # string to time convert courtesy of https://stackoverflow.com/questions/10663720 + #: string to time convert courtesy of https://stackoverflow.com/questions/10663720 ftr = [3600, 60, 1] wait_time = sum(a * b for a, b in zip(ftr, map(int, m.group(1).split(':')))) @@ -69,8 +69,8 @@ class Keep2ShareCc(SimpleHoster): self.fid = re.search(r'<input type="hidden" name="slow_id" value="(.+?)">', self.html).group(1) self.html = self.load(pyfile.url, post={'yt0': '', 'slow_id': self.fid}) - # self.logDebug(self.fid) - # self.logDebug(pyfile.url) + #: self.logDebug(self.fid) + #: self.logDebug(pyfile.url) self.checkErrors() diff --git a/module/plugins/hoster/KingfilesNet.py b/module/plugins/hoster/KingfilesNet.py index a25c39b21..f14cbd8b4 100644 --- a/module/plugins/hoster/KingfilesNet.py +++ b/module/plugins/hoster/KingfilesNet.py @@ -36,7 +36,7 @@ class KingfilesNet(SimpleHoster): def handleFree(self, pyfile): - # Click the free user button + #: Click the free user button post_data = {'op' : "download1", 'usr_login' : "", 'id' : self.info['pattern']['ID'], @@ -49,7 +49,7 @@ class KingfilesNet(SimpleHoster): solvemedia = SolveMedia(self) response, challenge = solvemedia.challenge() - # Make the downloadlink appear and load the file + #: Make the downloadlink appear and load the file m = re.search(self.RAND_ID_PATTERN, self.html) if m is None: self.error(_("Random key not found")) diff --git a/module/plugins/hoster/LoadTo.py b/module/plugins/hoster/LoadTo.py index 7a9be86e1..e974b9f3d 100644 --- a/module/plugins/hoster/LoadTo.py +++ b/module/plugins/hoster/LoadTo.py @@ -40,19 +40,19 @@ class LoadTo(SimpleHoster): def handleFree(self, pyfile): - # Search for Download URL + #: Search for Download URL m = re.search(self.LINK_FREE_PATTERN, self.html) if m is None: self.error(_("LINK_FREE_PATTERN not found")) self.link = m.group(1) - # Set Timer - may be obsolete + #: Set Timer - may be obsolete m = re.search(self.WAIT_PATTERN, self.html) if m: self.wait(m.group(1)) - # Load.to is using solvemedia captchas since ~july 2014: + #: Load.to is using solvemedia captchas since ~july 2014: solvemedia = SolveMedia(self) captcha_key = solvemedia.detect_key() diff --git a/module/plugins/hoster/LuckyShareNet.py b/module/plugins/hoster/LuckyShareNet.py index 293dab8f9..c08203346 100644 --- a/module/plugins/hoster/LuckyShareNet.py +++ b/module/plugins/hoster/LuckyShareNet.py @@ -40,8 +40,8 @@ class LuckyShareNet(SimpleHoster): return json_loads(rep) - # TODO: There should be a filesize limit for free downloads - # TODO: Some files could not be downloaded in free mode + #@TODO: There should be a filesize limit for free downloads + # Some files could not be downloaded in free mode def handleFree(self, pyfile): rep = self.load(r"http://luckyshare.net/download/request/type/time/file/" + self.info['pattern']['ID']) diff --git a/module/plugins/hoster/MegaCoNz.py b/module/plugins/hoster/MegaCoNz.py index 20b879aba..2e6dcfda6 100644 --- a/module/plugins/hoster/MegaCoNz.py +++ b/module/plugins/hoster/MegaCoNz.py @@ -84,7 +84,7 @@ class MegaCoNz(Hoster): """ Dispatch a call to the api, see https://mega.co.nz/#developers """ - # generate a session id, no idea where to obtain elsewhere + #: generate a session id, no idea where to obtain elsewhere uid = random.randint(10 << 9, 10 ** 10) res = self.load(self.API_URL, get={'id': uid}, post=json_dumps([kwargs])) @@ -101,7 +101,7 @@ class MegaCoNz(Hoster): if not attr.startswith("MEGA"): self.fail(_("Decryption failed")) - # Data is padded, 0-bytes must be stripped + #: Data is padded, 0-bytes must be stripped return json_loads(re.search(r'{.+?}', attr).group(0)) @@ -109,10 +109,10 @@ class MegaCoNz(Hoster): """ Decrypts the file at lastDownload` """ - # upper 64 bit of counter start + #: upper 64 bit of counter start n = self.b64_decode(key)[16:24] - # convert counter to long and shift bytes + #: convert counter to long and shift bytes k, iv, meta_mac = self.getCipherKey(key) ctr = Counter.new(128, initial_value=long(n.encode("hex"), 16) << 64) cipher = AES.new(k, AES.MODE_CTR, counter=ctr) @@ -130,8 +130,8 @@ class MegaCoNz(Hoster): except IOError, e: self.fail(e) - chunk_size = 2 ** 15 # buffer size, 32k - # file_mac = [0, 0, 0, 0] # calculate CBC-MAC for checksum + chunk_size = 2 ** 15 #: buffer size, 32k + #: file_mac = [0, 0, 0, 0] # calculate CBC-MAC for checksum chunks = os.path.getsize(file_crypted) / chunk_size + 1 for i in xrange(chunks): @@ -144,27 +144,27 @@ class MegaCoNz(Hoster): self.pyfile.setProgress(int((100.0 / chunks) * i)) - # chunk_mac = [iv[0], iv[1], iv[0], iv[1]] - # for i in xrange(0, chunk_size, 16): - # block = chunk[i:i+16] - # if len(block) % 16: - # block += '=' * (16 - (len(block) % 16)) - # block = array.array("I", block) + #: chunk_mac = [iv[0], iv[1], iv[0], iv[1]] + #: for i in xrange(0, chunk_size, 16): + #: block = chunk[i:i+16] + #: if len(block) % 16: + #: block += '=' * (16 - (len(block) % 16)) + #: block = array.array("I", block) - # chunk_mac = [chunk_mac[0] ^ a_[0], chunk_mac[1] ^ block[1], chunk_mac[2] ^ block[2], chunk_mac[3] ^ block[3]] - # chunk_mac = aes_cbc_encrypt_a32(chunk_mac, k) + #: chunk_mac = [chunk_mac[0] ^ a_[0], chunk_mac[1] ^ block[1], chunk_mac[2] ^ block[2], chunk_mac[3] ^ block[3]] + #: chunk_mac = aes_cbc_encrypt_a32(chunk_mac, k) - # file_mac = [file_mac[0] ^ chunk_mac[0], file_mac[1] ^ chunk_mac[1], file_mac[2] ^ chunk_mac[2], file_mac[3] ^ chunk_mac[3]] - # file_mac = aes_cbc_encrypt_a32(file_mac, k) + #: file_mac = [file_mac[0] ^ chunk_mac[0], file_mac[1] ^ chunk_mac[1], file_mac[2] ^ chunk_mac[2], file_mac[3] ^ chunk_mac[3]] + #: file_mac = aes_cbc_encrypt_a32(file_mac, k) self.pyfile.setProgress(100) f.close() df.close() - # if file_mac[0] ^ file_mac[1], file_mac[2] ^ file_mac[3] != meta_mac: - # os.remove(file_decrypted) - # self.fail(_("Checksum mismatch")) + #: if file_mac[0] ^ file_mac[1], file_mac[2] ^ file_mac[3] != meta_mac: + #: os.remove(file_decrypted) + #: self.fail(_("Checksum mismatch")) os.remove(file_crypted) self.lastDownload = fs_decode(file_decrypted) @@ -194,8 +194,8 @@ class MegaCoNz(Hoster): self.logDebug("ID: %s" % id, "Key: %s" % key, "Type: %s" % ("public" if public else "node")) - # g is for requesting a download url - # this is similar to the calls in the mega js app, documentation is very bad + #: g is for requesting a download url + #: this is similar to the calls in the mega js app, documentation is very bad if public: mega = self.api_response(a="g", g=1, p=id, ssl=1)[0] else: @@ -211,11 +211,11 @@ class MegaCoNz(Hoster): pyfile.name = attr['n'] + self.FILE_SUFFIX pyfile.size = mega['s'] - # self.req.http.c.setopt(pycurl.SSL_CIPHER_LIST, "RC4-MD5:DEFAULT") + #: self.req.http.c.setopt(pycurl.SSL_CIPHER_LIST, "RC4-MD5:DEFAULT") self.download(mega['g']) self.decryptFile(key) - # Everything is finished and final name can be set + #: Everything is finished and final name can be set pyfile.name = attr['n'] diff --git a/module/plugins/hoster/MegacrypterCom.py b/module/plugins/hoster/MegacrypterCom.py index aea564ded..27c3c7253 100644 --- a/module/plugins/hoster/MegacrypterCom.py +++ b/module/plugins/hoster/MegacrypterCom.py @@ -34,18 +34,18 @@ class MegacrypterCom(MegaCoNz): def process(self, pyfile): - # match is guaranteed because plugin was chosen to handle url + #: match is guaranteed because plugin was chosen to handle url node = re.match(self.__pattern__, pyfile.url).group(0) - # get Mega.co.nz link info + #: get Mega.co.nz link info info = self.api_response(link=node, m="info") - # get crypted file URL + #: get crypted file URL dl = self.api_response(link=node, m="dl") - # TODO: map error codes, implement password protection - # if info['pass'] is True: - # crypted_file_key, md5_file_key = info['key'].split("#") + #@TODO: map error codes, implement password protection + # if info['pass'] is True: + # crypted_file_key, md5_file_key = info['key'].split("#") key = self.b64_decode(info['key']) @@ -55,5 +55,5 @@ class MegacrypterCom(MegaCoNz): self.decryptFile(key) - # Everything is finished and final name can be set + #: Everything is finished and final name can be set pyfile.name = info['name'] diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index ed2363fe3..0c74e380d 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -83,7 +83,7 @@ class MegasharesCom(SimpleHoster): self.logDebug("Waiting %d seconds for a new passport" % renew) self.retry(wait_time=renew, reason=_("Passport renewal")) - # Check traffic left on passport + #: Check traffic left on passport m = re.search(self.PASSPORT_LEFT_PATTERN, self.html, re.M | re.S) if m is None: self.fail(_("Passport not found")) @@ -99,7 +99,7 @@ class MegasharesCom(SimpleHoster): def handleDownload(self, premium=False): - # Find download link; + #: Find download link m = re.search(self.LINK_PATTERN % (1 if premium else 2), self.html) msg = _('%s download URL' % ('Premium' if premium else 'Free')) if m is None: diff --git a/module/plugins/hoster/NitroflareCom.py b/module/plugins/hoster/NitroflareCom.py index a0734d9b1..efd54dd62 100644 --- a/module/plugins/hoster/NitroflareCom.py +++ b/module/plugins/hoster/NitroflareCom.py @@ -32,7 +32,7 @@ class NitroflareCom(SimpleHoster): def handleFree(self, pyfile): - # used here to load the cookies which will be required later + #: used here to load the cookies which will be required later self.load(pyfile.url, post={'goToFreePage': ""}) self.load("http://nitroflare.com/ajax/setCookie.php", post={'fileId': self.info['pattern']['ID']}) diff --git a/module/plugins/hoster/NoPremiumPl.py b/module/plugins/hoster/NoPremiumPl.py index 23343cd3f..ec3699a08 100644 --- a/module/plugins/hoster/NoPremiumPl.py +++ b/module/plugins/hoster/NoPremiumPl.py @@ -78,10 +78,10 @@ class NoPremiumPl(MultiHoster): if "errno" in parsed.keys(): if parsed["errno"] in self.ERROR_CODES: - # error code in known + #: error code in known self.fail(self.ERROR_CODES[parsed["errno"]] % self.__name__) else: - # error code isn't yet added to plugin + #: error code isn't yet added to plugin self.fail( parsed["errstring"] or _("Unknown error (code: %s)") % parsed["errno"] diff --git a/module/plugins/hoster/NosuploadCom.py b/module/plugins/hoster/NosuploadCom.py index 0b4af511c..4f3f34ddb 100644 --- a/module/plugins/hoster/NosuploadCom.py +++ b/module/plugins/hoster/NosuploadCom.py @@ -24,18 +24,18 @@ class NosuploadCom(XFSHoster): def getDownloadLink(self): - # stage1: press the "Free Download" button + #: stage1: press the "Free Download" button data = self.getPostParameters() self.html = self.load(self.pyfile.url, post=data) - # stage2: wait some time and press the "Download File" button + #: stage2: wait some time and press the "Download File" button data = self.getPostParameters() wait_time = re.search(self.WAIT_PATTERN, self.html, re.M | re.S).group(1) self.logDebug("Hoster told us to wait %s seconds" % wait_time) self.wait(wait_time) self.html = self.load(self.pyfile.url, post=data) - # stage3: get the download link + #: stage3: get the download link return re.search(self.LINK_PATTERN, self.html, re.S).group(1) diff --git a/module/plugins/hoster/OboomCom.py b/module/plugins/hoster/OboomCom.py index e2a9c114a..4f845394a 100644 --- a/module/plugins/hoster/OboomCom.py +++ b/module/plugins/hoster/OboomCom.py @@ -100,7 +100,7 @@ class OboomCom(Hoster): self.retry(5, 15 * 60, _("Service unavailable")) elif result[0] == 403: - if result[1] == -1: # another download is running + if result[1] == -1: #: another download is running self.setWait(15 * 60) else: self.setWait(result[1], True) diff --git a/module/plugins/hoster/PornhostCom.py b/module/plugins/hoster/PornhostCom.py index 55e04e5f6..708abf40a 100644 --- a/module/plugins/hoster/PornhostCom.py +++ b/module/plugins/hoster/PornhostCom.py @@ -26,7 +26,7 @@ class PornhostCom(Hoster): self.download(self.get_file_url()) - # Old interface + #: Old interface def download_html(self): url = self.pyfile.url self.html = self.load(url) @@ -46,7 +46,7 @@ class PornhostCom(Hoster): url = re.search(r'width: 894px; height: 675px">.*?<img src="(.*?)"', self.html) if url is None: url = re.search(r'"http://file\d+\.pornhost\.com/\d+/.*?"', - self.html) # TODO: fix this one since it doesn't match + self.html) #@TODO: fix this one since it doesn't match return url.group(1).strip() diff --git a/module/plugins/hoster/PornhubCom.py b/module/plugins/hoster/PornhubCom.py index 857bb404c..92119df56 100644 --- a/module/plugins/hoster/PornhubCom.py +++ b/module/plugins/hoster/PornhubCom.py @@ -40,7 +40,7 @@ class PornhubCom(Hoster): url = "http://www.pornhub.com//gateway.php" video_id = self.pyfile.url.split('=')[-1] - # thanks to jD team for this one v + #: thanks to jD team for this one v post_data = "\x00\x03\x00\x00\x00\x01\x00\x0c\x70\x6c\x61\x79\x65\x72\x43\x6f\x6e\x66\x69\x67\x00\x02\x2f\x31\x00\x00\x00\x44\x0a\x00\x00\x00\x03\x02\x00" post_data += chr(len(video_id)) post_data += video_id diff --git a/module/plugins/hoster/PremiumTo.py b/module/plugins/hoster/PremiumTo.py index 2007eefa7..c810a1f5a 100644 --- a/module/plugins/hoster/PremiumTo.py +++ b/module/plugins/hoster/PremiumTo.py @@ -41,7 +41,7 @@ class PremiumTo(MultiHoster): err = '' if self.req.http.code == '420': - # Custom error code send - fail + #: Custom error code send - fail file = fs_encode(self.lastDownload) with open(file, "rb") as f: err = f.read(256).strip() diff --git a/module/plugins/hoster/PremiumizeMe.py b/module/plugins/hoster/PremiumizeMe.py index e1f982d78..8e7d74012 100644 --- a/module/plugins/hoster/PremiumizeMe.py +++ b/module/plugins/hoster/PremiumizeMe.py @@ -18,27 +18,27 @@ class PremiumizeMe(MultiHoster): def handlePremium(self, pyfile): - # In some cases hostsers do not supply us with a filename at download, so we - # are going to set a fall back filename (e.g. for freakshare or xfileshare) - pyfile.name = pyfile.name.split('/').pop() # Remove everthing before last slash + #: In some cases hostsers do not supply us with a filename at download, so we + #: are going to set a fall back filename (e.g. for freakshare or xfileshare) + pyfile.name = pyfile.name.split('/').pop() #: Remove everthing before last slash - # Correction for automatic assigned filename: Removing html at end if needed + #: Correction for automatic assigned filename: Removing html at end if needed suffix_to_remove = ["html", "htm", "php", "php3", "asp", "shtm", "shtml", "cfml", "cfm"] temp = pyfile.name.split('.') if temp.pop() in suffix_to_remove: pyfile.name = ".".join(temp) - # Get account data + #: Get account data user, data = self.account.selectAccount() - # Get rewritten link using the premiumize.me api v1 (see https://secure.premiumize.me/?show=api) + #: Get rewritten link using the premiumize.me api v1 (see https://secure.premiumize.me/?show=api) data = json_loads(self.load("http://api.premiumize.me/pm-api/v1.php", #@TODO: Revert to `https` in 0.4.10 get={'method' : "directdownloadlink", 'params[login]': user, 'params[pass]' : data['password'], 'params[link]' : pyfile.url})) - # Check status and decide what to do + #: Check status and decide what to do status = data['status'] if status == 200: diff --git a/module/plugins/hoster/PromptfileCom.py b/module/plugins/hoster/PromptfileCom.py index 4a1b07f05..c6878cbb0 100644 --- a/module/plugins/hoster/PromptfileCom.py +++ b/module/plugins/hoster/PromptfileCom.py @@ -34,7 +34,7 @@ class PromptfileCom(SimpleHoster): chash = m.group(1) self.logDebug("Read chash %s" % chash) - # continue to stage2 + #: continue to stage2 self.html = self.load(pyfile.url, post={'chash': chash}) # STAGE 2: get the direct link diff --git a/module/plugins/hoster/QuickshareCz.py b/module/plugins/hoster/QuickshareCz.py index 8cfb72c9a..26bb1e2df 100644 --- a/module/plugins/hoster/QuickshareCz.py +++ b/module/plugins/hoster/QuickshareCz.py @@ -28,12 +28,12 @@ class QuickshareCz(SimpleHoster): self.html = self.load(pyfile.url) self.getFileInfo() - # parse js variables + #: parse js variables self.jsvars = dict((x, y.strip("'")) for x, y in re.findall(r"var (\w+) = ([\d.]+|'.+?')", self.html)) self.logDebug(self.jsvars) pyfile.name = self.jsvars['ID3'] - # determine download type - free or premium + #: determine download type - free or premium if self.premium: if 'UU_prihlasen' in self.jsvars: if self.jsvars['UU_prihlasen'] == '0': @@ -54,7 +54,7 @@ class QuickshareCz(SimpleHoster): def handleFree(self, pyfile): - # get download url + #: get download url download_url = '%s/download.php' % self.jsvars['server'] data = dict((x, self.jsvars[x]) for x in self.jsvars if x in ("ID1", "ID2", "ID3", "ID4")) self.logDebug("FREE URL1:" + download_url, data) @@ -71,7 +71,7 @@ class QuickshareCz(SimpleHoster): self.link = m.group(1).rstrip() #@TODO: Remove .rstrip() in 0.4.10 self.logDebug("FREE URL2:" + self.link) - # check errors + #: check errors m = re.search(r'/chyba/(\d+)', self.link) if m: if m.group(1) == '1': diff --git a/module/plugins/hoster/RPNetBiz.py b/module/plugins/hoster/RPNetBiz.py index d783e1b8f..47f18afff 100644 --- a/module/plugins/hoster/RPNetBiz.py +++ b/module/plugins/hoster/RPNetBiz.py @@ -26,7 +26,7 @@ class RPNetBiz(MultiHoster): def handlePremium(self, pyfile): user, data = self.account.selectAccount() - # Get the download link + #: Get the download link res = self.load("https://premium.rpnet.biz/client_api.php", get={"username": user, "password": data['password'], @@ -34,15 +34,15 @@ class RPNetBiz(MultiHoster): "links" : pyfile.url}) self.logDebug("JSON data: %s" % res) - link_status = json_loads(res)['links'][0] # get the first link... since we only queried one + link_status = json_loads(res)['links'][0] #: get the first link... since we only queried one - # Check if we only have an id as a HDD link + #: Check if we only have an id as a HDD link if 'id' in link_status: self.logDebug("Need to wait at least 30 seconds before requery") - self.setWait(30) # wait for 30 seconds + self.setWait(30) #: wait for 30 seconds self.wait() - # Lets query the server again asking for the status on the link, - # we need to keep doing this until we reach 100 + #: Lets query the server again asking for the status on the link, + #: we need to keep doing this until we reach 100 max_tries = 30 my_try = 0 while (my_try <= max_tries): @@ -66,7 +66,7 @@ class RPNetBiz(MultiHoster): self.wait() my_try += 1 - if my_try > max_tries: # We went over the limit! + if my_try > max_tries: #: We went over the limit! self.fail(_("Waited for about 15 minutes for download to finish but failed")) if 'generated' in link_status: diff --git a/module/plugins/hoster/RapideoPl.py b/module/plugins/hoster/RapideoPl.py index daefcd5a8..6304bd38a 100644 --- a/module/plugins/hoster/RapideoPl.py +++ b/module/plugins/hoster/RapideoPl.py @@ -78,10 +78,10 @@ class RapideoPl(MultiHoster): if "errno" in parsed.keys(): if parsed["errno"] in self.ERROR_CODES: - # error code in known + #: error code in known self.fail(self.ERROR_CODES[parsed["errno"]] % self.__name__) else: - # error code isn't yet added to plugin + #: error code isn't yet added to plugin self.fail( parsed["errstring"] or _("Unknown error (code: %s)") % parsed["errno"] diff --git a/module/plugins/hoster/ShareplaceCom.py b/module/plugins/hoster/ShareplaceCom.py index 47ad05a8c..815f54c79 100644 --- a/module/plugins/hoster/ShareplaceCom.py +++ b/module/plugins/hoster/ShareplaceCom.py @@ -39,7 +39,7 @@ class ShareplaceCom(Hoster): if not self.html: self.download_html() - #var zzipitime = 15; + # var zzipitime = 15 m = re.search(r'var zzipitime = (\d+);', self.html) if m: sec = int(m.group(1)) diff --git a/module/plugins/hoster/SmoozedCom.py b/module/plugins/hoster/SmoozedCom.py index bf9f387b4..af6c8b68e 100644 --- a/module/plugins/hoster/SmoozedCom.py +++ b/module/plugins/hoster/SmoozedCom.py @@ -22,18 +22,18 @@ class SmoozedCom(MultiHoster): def handleFree(self, pyfile): - # In some cases hostsers do not supply us with a filename at download, so we - # are going to set a fall back filename (e.g. for freakshare or xfileshare) - pyfile.name = pyfile.name.split('/').pop() # Remove everthing before last slash + #: In some cases hostsers do not supply us with a filename at download, so we + #: are going to set a fall back filename (e.g. for freakshare or xfileshare) + pyfile.name = pyfile.name.split('/').pop() #: Remove everthing before last slash - # Correction for automatic assigned filename: Removing html at end if needed + #: Correction for automatic assigned filename: Removing html at end if needed suffix_to_remove = ["html", "htm", "php", "php3", "asp", "shtm", "shtml", "cfml", "cfm"] temp = pyfile.name.split('.') if temp.pop() in suffix_to_remove: pyfile.name = ".".join(temp) - # Check the link + #: Check the link get_data = {'session_key': self.account.getAccountInfo(self.user)['session'], 'url' : pyfile.url} @@ -51,7 +51,7 @@ class SmoozedCom(MultiHoster): pyfile.name = data["data"]["name"] pyfile.size = int(data["data"]["size"]) - # Start the download + #: Start the download header = self.load("http://www2.smoozed.com/api/download", get=get_data, just_header=True) if not "location" in header: diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index 8dff4f42a..2b041bb94 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -37,7 +37,7 @@ class SoundcloudCom(SimpleHoster): except Exception: client_id = "b45b1aa10f1ac2941910a7f0d10f8e28" - # url to retrieve the actual song url + #: url to retrieve the actual song url streams = json_loads(self.load("https://api.soundcloud.com/tracks/%s/streams" % song_id, get={'client_id': client_id})) diff --git a/module/plugins/hoster/StreamCz.py b/module/plugins/hoster/StreamCz.py index a2fe32c5c..24b725722 100644 --- a/module/plugins/hoster/StreamCz.py +++ b/module/plugins/hoster/StreamCz.py @@ -13,7 +13,7 @@ def getInfo(urls): html = getURL(url) if re.search(StreamCz.OFFLINE_PATTERN, html): - # File offline + #: File offline result.append((url, 0, 1, url)) else: result.append((url, 0, 2, url)) diff --git a/module/plugins/hoster/TurbobitNet.py b/module/plugins/hoster/TurbobitNet.py index b70f9e72b..efff6521a 100644 --- a/module/plugins/hoster/TurbobitNet.py +++ b/module/plugins/hoster/TurbobitNet.py @@ -100,10 +100,10 @@ class TurbobitNet(SimpleHoster): if not rtUpdate: if self.getStorage("version") != self.__version__ \ or int(self.getStorage("timestamp", 0)) + 86400000 < timestamp(): - # that's right, we are even using jdownloader updates + #: that's right, we are even using jdownloader updates rtUpdate = getURL("http://update0.jdownloader.org/pluginstuff/tbupdate.js") rtUpdate = self.decrypt(rtUpdate.splitlines()[1]) - # but we still need to fix the syntax to work with other engines than rhino + #: but we still need to fix the syntax to work with other engines than rhino rtUpdate = re.sub(r'for each\(var (\w+) in(\[[^\]]+\])\)\{', r'zza=\2;for(var zzi=0;zzi<zza.length;zzi++){\1=zza[zzi];', rtUpdate) rtUpdate = re.sub(r"for\((\w+)=", r"for(var \1=", rtUpdate) @@ -145,7 +145,7 @@ class TurbobitNet(SimpleHoster): self.logError(e) else: if self.retries >= 2: - # retry with updated js + #: retry with updated js self.delStorage("rtUpdate") else: self.retry() diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py index 2edc929ea..6a2836b50 100644 --- a/module/plugins/hoster/UlozTo.py +++ b/module/plugins/hoster/UlozTo.py @@ -8,7 +8,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo def convertDecimalPrefix(m): - # decimal prefixes used in filesize and traffic + #: decimal prefixes used in filesize and traffic return ("%%.%df" % {'k': 3, 'M': 6, 'G': 9}[m.group(2)] % float(m.group(1))).replace('.', '') @@ -54,9 +54,9 @@ class UlozTo(SimpleHoster): self.error(_("Free download form not found")) self.logDebug("inputs.keys = " + str(inputs.keys())) - # get and decrypt captcha + #: get and decrypt captcha if all(key in inputs for key in ("captcha_value", "captcha_id", "captcha_key")): - # Old version - last seen 9.12.2013 + #: Old version - last seen 9.12.2013 self.logDebug('Using "old" version') captcha_value = self.decryptCaptcha("http://img.uloz.to/captcha/%s.png" % inputs['captcha_id']) @@ -65,7 +65,7 @@ class UlozTo(SimpleHoster): inputs.update({'captcha_id': inputs['captcha_id'], 'captcha_key': inputs['captcha_key'], 'captcha_value': captcha_value}) elif all(key in inputs for key in ("captcha_value", "timestamp", "salt", "hash")): - # New version - better to get new parameters (like captcha reload) because of image url - since 6.12.2013 + #: New version - better to get new parameters (like captcha reload) because of image url - since 6.12.2013 self.logDebug('Using "new" version') xapca = self.load("http://www.ulozto.net/reloadXapca.php", get={'rnd': str(int(time.time()))}) @@ -124,7 +124,7 @@ class UlozTo(SimpleHoster): "wrong_captcha": re.compile(r'<ul class="error">\s*<li>Error rewriting the text.</li>'), "offline" : re.compile(self.OFFLINE_PATTERN), "passwd" : self.PASSWD_PATTERN, - "server_error" : 'src="http://img.ulozto.cz/error403/vykricnik.jpg"', # paralell dl, server overload etc. + "server_error" : 'src="http://img.ulozto.cz/error403/vykricnik.jpg"', #: paralell dl, server overload etc. "not_found" : "<title>Ulož.to</title>" }) diff --git a/module/plugins/hoster/UploadableCh.py b/module/plugins/hoster/UploadableCh.py index b33c81ae7..b2323644f 100644 --- a/module/plugins/hoster/UploadableCh.py +++ b/module/plugins/hoster/UploadableCh.py @@ -33,13 +33,13 @@ class UploadableCh(SimpleHoster): def handleFree(self, pyfile): - # Click the "free user" button and wait + #: Click the "free user" button and wait a = self.load(pyfile.url, post={'downloadLink': "wait"}) self.logDebug(a) self.wait(30) - # Make the recaptcha appear and show it the pyload interface + #: Make the recaptcha appear and show it the pyload interface b = self.load(pyfile.url, post={'checkDownload': "check"}) self.logDebug(b) #: Expected output: {"success":"showCaptcha"} @@ -47,7 +47,7 @@ class UploadableCh(SimpleHoster): response, challenge = recaptcha.challenge(self.RECAPTCHA_KEY) - # Submit the captcha solution + #: Submit the captcha solution self.load("http://www.uploadable.ch/checkReCaptcha.php", post={'recaptcha_challenge_field' : challenge, 'recaptcha_response_field' : response, @@ -55,12 +55,12 @@ class UploadableCh(SimpleHoster): self.wait(3) - # Get ready for downloading + #: Get ready for downloading self.load(pyfile.url, post={'downloadLink': "show"}) self.wait(3) - # Download the file + #: Download the file self.download(pyfile.url, post={'download': "normal"}, disposition=True) diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index 46ed863d9..b88ac5f0b 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -62,7 +62,7 @@ class UploadedTo(SimpleHoster): def setup(self): self.multiDL = self.resumeDownload = self.premium - self.chunkLimit = 1 # critical problems with more chunks + self.chunkLimit = 1 #: critical problems with more chunks def handleFree(self, pyfile): diff --git a/module/plugins/hoster/UpstoreNet.py b/module/plugins/hoster/UpstoreNet.py index e7b6d044f..342009c98 100644 --- a/module/plugins/hoster/UpstoreNet.py +++ b/module/plugins/hoster/UpstoreNet.py @@ -34,7 +34,7 @@ class UpstoreNet(SimpleHoster): self.error(_("CHASH_PATTERN not found")) chash = m.group(1) self.logDebug("Read hash " + chash) - # continue to stage2 + #: continue to stage2 post_data = {'hash': chash, 'free': 'Slow download'} self.html = self.load(pyfile.url, post=post_data) @@ -42,17 +42,17 @@ class UpstoreNet(SimpleHoster): # first get the infos we need: recaptcha key and wait time recaptcha = ReCaptcha(self) - # try the captcha 5 times + #: try the captcha 5 times for i in xrange(5): m = re.search(self.WAIT_PATTERN, self.html) if m is None: self.error(_("Wait pattern not found")) wait_time = int(m.group(1)) - # then, do the waiting + #: then, do the waiting self.wait(wait_time) - # then, handle the captcha + #: then, handle the captcha response, challenge = recaptcha.challenge() post_data.update({'recaptcha_challenge_field': challenge, 'recaptcha_response_field' : response}) diff --git a/module/plugins/hoster/VeehdCom.py b/module/plugins/hoster/VeehdCom.py index 11c70ebff..9f8e77d94 100644 --- a/module/plugins/hoster/VeehdCom.py +++ b/module/plugins/hoster/VeehdCom.py @@ -58,7 +58,7 @@ class VeehdCom(Hoster): name = m.group(1) - # replace unwanted characters in filename + #: replace unwanted characters in filename if self.getConfig('filename_spaces'): pattern = '[^\w ]+' else: diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index 20f800967..f1508f0e4 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -27,13 +27,13 @@ class Xdcc(Hoster): def setup(self): - self.debug = 0 # 0,1,2 + self.debug = 0 #: 0,1,2 self.timeout = 30 self.multiDL = False def process(self, pyfile): - # change request type + #: change request type self.req = self.core.requestFactory.getRequest(self.__name__, type="XDCC") self.pyfile = pyfile @@ -60,7 +60,7 @@ class Xdcc(Hoster): def doDownload(self, url): - self.pyfile.setStatus("waiting") # real link + self.pyfile.setStatus("waiting") #: real link m = re.match(r'xdcc://(.*?)/#?(.*?)/(.*?)/#?(\d+)/?', url) server = m.group(1) @@ -81,13 +81,13 @@ class Xdcc(Hoster): self.fail(_("Invalid hostname for IRC Server: %s") % server) ####################### - # CONNECT TO IRC AND IDLE FOR REAL LINK + #: CONNECT TO IRC AND IDLE FOR REAL LINK dl_time = time.time() sock = socket.socket() sock.connect((host, int(port))) if nick == "pyload": - nick = "pyload-%d" % (time.time() % 1000) # last 3 digits + nick = "pyload-%d" % (time.time() % 1000) #: last 3 digits sock.send("NICK %s\r\n" % nick) sock.send("USER %s %s bla :%s\r\n" % (ident, host, real)) @@ -97,14 +97,14 @@ class Xdcc(Hoster): sock.send("JOIN #%s\r\n" % chan) sock.send("PRIVMSG %s :xdcc send #%s\r\n" % (bot, pack)) - # IRC recv loop + #: IRC recv loop readbuffer = "" done = False retry = None m = None while True: - # done is set if we got our real link + #: done is set if we got our real link if done: break @@ -115,7 +115,7 @@ class Xdcc(Hoster): sock.send("PRIVMSG %s :xdcc send #%s\r\n" % (bot, pack)) else: - if (dl_time + self.timeout) < time.time(): # todo: add in config + if (dl_time + self.timeout) < time.time(): #@TODO: add in config sock.send("QUIT :byebye\r\n") sock.close() self.fail(_("XDCC Bot did not answer")) @@ -159,7 +159,7 @@ class Xdcc(Hoster): self.logDebug("Sending CTCP TIME") sock.send("NOTICE %s :%d\r\n" % (msg['origin'], time.time())) elif msg['text'] == "\x01LAG\x01": - pass # don't know how to answer + pass #: don't know how to answer if not (bot == msg['origin'][0:len(bot)] and nick == msg['target'][0:len(nick)] @@ -179,7 +179,7 @@ class Xdcc(Hoster): if m: done = True - # get connection data + #: get connection data ip = socket.inet_ntoa(struct.pack('L', socket.ntohl(int(m.group(2))))) port = int(m.group(3)) packname = m.group(1) @@ -200,8 +200,8 @@ class Xdcc(Hoster): self.logInfo(_("%(name)s saved as %(newname)s") % {"name": self.pyfile.name, "newname": newname}) filename = newname - # kill IRC socket - # sock.send("QUIT :byebye\r\n") + #: kill IRC socket + #: sock.send("QUIT :byebye\r\n") sock.close() self.lastDownload = filename diff --git a/module/plugins/hoster/YourfilesTo.py b/module/plugins/hoster/YourfilesTo.py index f64ac1a43..7db6129e2 100644 --- a/module/plugins/hoster/YourfilesTo.py +++ b/module/plugins/hoster/YourfilesTo.py @@ -40,7 +40,7 @@ class YourfilesTo(Hoster): if not self.html: self.download_html() - #var zzipitime = 15; + # var zzipitime = 15 m = re.search(r'var zzipitime = (\d+);', self.html) if m: sec = int(m.group(1)) diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index b2696ddfb..c4e1ebf28 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -52,10 +52,10 @@ class YoutubeCom(Hoster): URL_REPLACEMENTS = [(r'youtu\.be/', 'youtube.com/')] - # Invalid characters that must be removed from the file name + #: Invalid characters that must be removed from the file name invalidChars = u'\u2605:?><"|\\' - # name, width, height, quality ranking, 3D + #: name, width, height, quality ranking, 3D formats = {5 : (".flv" , 400 , 240 , 1 , False), 6 : (".flv" , 640 , 400 , 4 , False), 17 : (".3gp" , 176 , 144 , 0 , False), @@ -119,7 +119,7 @@ class YoutubeCom(Hoster): streams = [dict((y.split('=', 1)) for y in x) for x in streams] streams = [(int(x['itag']), urllib.unquote(x['url'])) for x in streams] - # self.logDebug("Found links: %s" % streams) + #: self.logDebug("Found links: %s" % streams) self.logDebug("AVAILABLE STREAMS: %s" % [x[0] for x in streams]) @@ -140,7 +140,7 @@ class YoutubeCom(Hoster): if desired_fmt in fmt_dict and allowed(desired_fmt): fmt = desired_fmt else: - sel = lambda x: self.formats[x][3] # select quality index + sel = lambda x: self.formats[x][3] #: select quality index comp = lambda x, y: abs(sel(x) - sel(y)) self.logDebug("Choosing nearest fmt: %s" % [(x, allowed(x), comp(x, desired_fmt)) for x in fmt_dict.keys()]) @@ -159,7 +159,7 @@ class YoutubeCom(Hoster): file_name_pattern = '<meta name="title" content="(.+?)">' name = re.search(file_name_pattern, html).group(1).replace("/", "") - # Cleaning invalid characters from the file name + #: Cleaning invalid characters from the file name name = name.encode('ascii', 'replace') for c in self.invalidChars: name = name.replace(c, '_') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index d776e5928..7bae8cc19 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -58,35 +58,35 @@ class ZippyshareCom(SimpleHoster): def get_link(self): - # get all the scripts inside the html body + #: get all the scripts inside the html body soup = BeautifulSoup(self.html) scripts = (s.getText().strip() for s in soup.body.findAll('script', type='text/javascript')) - # meant to be populated with the initialization of all the DOM elements found in the scripts + #: meant to be populated with the initialization of all the DOM elements found in the scripts initScripts = set() def replElementById(element): - id = element.group(1) # id might be either 'x' (a real id) or x (a variable) - attr = element.group(4) # attr might be None + id = element.group(1) #: id might be either 'x' (a real id) or x (a variable) + attr = element.group(4) #: attr might be None varName = re.sub(r'-', '', 'GVAR[%s+"_%s"]' %(id, attr)) realid = id.strip('"\'') - if id != realid: #id is not a variable, so look for realid.attr in the html + if id != realid: #: id is not a variable, so look for realid.attr in the html initValues = filter(None, [elt.get(attr, None) for elt in soup.findAll(id=realid)]) initValue = '"%s"' % initValues[-1] if initValues else 'null' initScripts.add('%s = %s;' % (varName, initValue)) return varName - # handle all getElementById + #: handle all getElementById reVar = r'document.getElementById\(([\'"\w-]+)\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' scripts = [re.sub(reVar, replElementById, script) for script in scripts if script] - # add try/catch in JS to handle deliberate errors + #: add try/catch in JS to handle deliberate errors scripts = ['\n'.join(('try{', script, '} catch(err){}')) for script in scripts] - # get the file's url by evaluating all the scripts + #: get the file's url by evaluating all the scripts scripts = ['var GVAR = {}'] + list(initScripts) + scripts + ['GVAR["dlbutton_href"]'] return self.js.eval('\n'.join(scripts)) diff --git a/module/plugins/internal/Account.py b/module/plugins/internal/Account.py index 0595da20b..d2efe7996 100644 --- a/module/plugins/internal/Account.py +++ b/module/plugins/internal/Account.py @@ -57,7 +57,7 @@ class Account(Plugin): @lock def _login(self, user, data): - # set timestamp for login + #: set timestamp for login self.timestamps[user] = time.time() req = self.getAccountRequest(user) @@ -192,7 +192,7 @@ class Account(Plugin): """ return {"validuntil" : None, #: -1 for unlimited "login" : name, - # "password" : self.accounts[name]['password'], #: commented due security reason + #: "password" : self.accounts[name]['password'], #: commented due security reason "options" : self.accounts[name]['options'], "valid" : self.accounts[name]['valid'], "trafficleft": None, #: in bytes, -1 for unlimited diff --git a/module/plugins/internal/AdYouLike.py b/module/plugins/internal/AdYouLike.py index b7324ef8e..f623ed268 100644 --- a/module/plugins/internal/AdYouLike.py +++ b/module/plugins/internal/AdYouLike.py @@ -37,8 +37,8 @@ class AdYouLike(Captcha): def challenge(self, key=None, html=None): ayl, callback = key or self.retrieve_key(html) - # {"adyoulike":{"key":"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, - # "all":{"element_id":"ayl_private_cap_92300","lang":"fr","env":"prod"}} + #: {"adyoulike":{"key":"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, + #: "all":{"element_id":"ayl_private_cap_92300","lang":"fr","env":"prod"}} ayl = json_loads(ayl) html = self.plugin.load("http://api-ayl.appspot.com/challenge", @@ -57,15 +57,15 @@ class AdYouLike(Captcha): def result(self, server, challenge): - # Adyoulike.g._jsonp_5579316662423138 - # ({"translations":{"fr":{"instructions_visual":"Recopiez « Soonnight » ci-dessous :"}}, - # "site_under":true,"clickable":true,"pixels":{"VIDEO_050":[],"DISPLAY":[],"VIDEO_000":[],"VIDEO_100":[], - # "VIDEO_025":[],"VIDEO_075":[]},"medium_type":"image/adyoulike", - # "iframes":{"big":"<iframe src=\"http://www.soonnight.com/campagn.html\" scrolling=\"no\" - # height=\"250\" width=\"300\" frameborder=\"0\"></iframe>"},"shares":{},"id":256, - # "token":"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1","formats":{"small":{"y":300,"x":0,"w":300,"h":60}, - # "big":{"y":0,"x":0,"w":300,"h":250},"hover":{"y":440,"x":0,"w":300,"h":60}}, - # "tid":"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"}) + #: Adyoulike.g._jsonp_5579316662423138 + #: ({"translations":{"fr":{"instructions_visual":"Recopiez « Soonnight » ci-dessous :"}}, + #: "site_under":true,"clickable":true,"pixels":{"VIDEO_050":[],"DISPLAY":[],"VIDEO_000":[],"VIDEO_100":[], + #: "VIDEO_025":[],"VIDEO_075":[]},"medium_type":"image/adyoulike", + #: "iframes":{"big":"<iframe src=\"http://www.soonnight.com/campagn.html\" scrolling=\"no\" + #: height=\"250\" width=\"300\" frameborder=\"0\"></iframe>"},"shares":{},"id":256, + #: "token":"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1","formats":{"small":{"y":300,"x":0,"w":300,"h":60}, + #: "big":{"y":0,"x":0,"w":300,"h":250},"hover":{"y":440,"x":0,"w":300,"h":60}}, + #: "tid":"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"}) if isinstance(server, basestring): server = json_loads(server) diff --git a/module/plugins/internal/Crypter.py b/module/plugins/internal/Crypter.py index e97f22316..d8cda17d4 100644 --- a/module/plugins/internal/Crypter.py +++ b/module/plugins/internal/Crypter.py @@ -82,7 +82,7 @@ class Crypter(Hoster): if package_password: self.core.api.setPackageData(pid, {"password": package_password}) - # Workaround to do not break API addPackage method + #: Workaround to do not break API addPackage method setFolder = lambda x: self.core.api.setPackageData(pid, {"folder": x or ""}) if use_subfolder: diff --git a/module/plugins/internal/Hook.py b/module/plugins/internal/Hook.py index 3a0431feb..5959089b5 100644 --- a/module/plugins/internal/Hook.py +++ b/module/plugins/internal/Hook.py @@ -46,7 +46,7 @@ class Hook(Plugin): #: automatically register event listeners for functions, attribute will be deleted dont use it yourself self.event_map = {} - # Deprecated alternative to event_map + #: Deprecated alternative to event_map #: List of events the plugin can handle, name the functions exactly like eventname. self.event_list = [] #@NOTE: dont make duplicate entries in event_map @@ -68,7 +68,7 @@ class Hook(Plugin): else: self.manager.addEvent(event, getattr(self, funcs)) - # delete for various reasons + #: delete for various reasons self.event_map = None if self.event_list: diff --git a/module/plugins/internal/Hoster.py b/module/plugins/internal/Hoster.py index 32c3312d0..e1a13af01 100644 --- a/module/plugins/internal/Hoster.py +++ b/module/plugins/internal/Hoster.py @@ -435,7 +435,7 @@ class Hoster(Plugin): except Exception, e: self.fail(e) - # convert back to unicode + #: convert back to unicode location = fs_decode(location) name = safe_filename(self.pyfile.name) @@ -519,8 +519,8 @@ class Hoster(Plugin): with open(lastDownload, "rb") as f: content = f.read(read_size) - # produces encoding errors, better log to other file in the future? - # self.logDebug("Content: %s" % content) + #: produces encoding errors, better log to other file in the future? + #: self.logDebug("Content: %s" % content) for name, rule in rules.iteritems(): if isinstance(rule, basestring): if rule in content: diff --git a/module/plugins/internal/MultiHook.py b/module/plugins/internal/MultiHook.py index 739b225b4..22b0fd7c6 100644 --- a/module/plugins/internal/MultiHook.py +++ b/module/plugins/internal/MultiHook.py @@ -207,7 +207,7 @@ class MultiHook(Hook): self.logError(_("No %s loaded") % self.plugintype) return - # inject plugin plugin + #: inject plugin plugin self.logDebug("Overwritten %ss: %s" % (self.plugintype, ", ".join(sorted(self.supported)))) for plugin in self.supported: @@ -223,7 +223,7 @@ class MultiHook(Hook): self.logDebug("New %ss: %s" % (self.plugintype, ", ".join(plugins))) - # create new regexp + #: create new regexp regexp = r'.*(?P<DOMAIN>%s).*' % "|".join(x.replace('.', '\.') for x in plugins) if hasattr(self.pluginclass, "__pattern__") and isinstance(self.pluginclass.__pattern__, basestring) and "://" in self.pluginclass.__pattern__: regexp = r'%s|%s' % (self.pluginclass.__pattern__, regexp) @@ -252,7 +252,7 @@ class MultiHook(Hook): for plugin in self.supported: self.unloadPlugin(plugin) - # reset pattern + #: reset pattern hdict = self.core.pluginManager.plugins[self.plugintype][self.pluginname] hdict['pattern'] = getattr(self.pluginclass, "__pattern__", r'^unmatchable$') diff --git a/module/plugins/internal/OCR.py b/module/plugins/internal/OCR.py index 5fe6f2532..0191a4938 100644 --- a/module/plugins/internal/OCR.py +++ b/module/plugins/internal/OCR.py @@ -61,12 +61,12 @@ class OCR(Plugin): def run_tesser(self, subset=False, digits=True, lowercase=True, uppercase=True, pagesegmode=None): - # tmpTif = tempfile.NamedTemporaryFile(suffix=".tif") + #: tmpTif = tempfile.NamedTemporaryFile(suffix=".tif") try: tmpTif = open(fs_join("tmp", "tmpTif_%s.tif" % self.__name__), "wb") tmpTif.close() - # tmpTxt = tempfile.NamedTemporaryFile(suffix=".txt") + #: tmpTxt = tempfile.NamedTemporaryFile(suffix=".txt") tmpTxt = open(fs_join("tmp", "tmpTxt_%s.txt" % self.__name__), "wb") tmpTxt.close() @@ -88,7 +88,7 @@ class OCR(Plugin): tessparams.extend(["-psm", str(pagesegmode)]) if subset and (digits or lowercase or uppercase): - # tmpSub = tempfile.NamedTemporaryFile(suffix=".subset") + #: tmpSub = tempfile.NamedTemporaryFile(suffix=".subset") with open(fs_join("tmp", "tmpSub_%s.subset" % self.__name__), "wb") as tmpSub: tmpSub.write("tessedit_char_whitelist ") @@ -154,7 +154,7 @@ class OCR(Plugin): for y in xrange(h): if pixels[x, y] == 255: continue - # No point in processing white pixels since we only want to remove black pixel + #: No point in processing white pixels since we only want to remove black pixel count = 0 try: @@ -177,12 +177,12 @@ class OCR(Plugin): except Exception: pass - # not enough neighbors are dark pixels so mark this pixel - # to be changed to white + #: not enough neighbors are dark pixels so mark this pixel + #: to be changed to white if count < allowed: pixels[x, y] = 1 - # second pass: this time set all 1's to 255 (white) + #: second pass: this time set all 1's to 255 (white) for x in xrange(w): for y in xrange(h): if pixels[x, y] == 1: diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py index 68169e077..1f86214c4 100644 --- a/module/plugins/internal/Plugin.py +++ b/module/plugins/internal/Plugin.py @@ -45,7 +45,7 @@ def parseHtmlForm(attr_str, html, input_names={}): inputs[name] = value if input_names: - # check input attributes + #: check input attributes for key, val in input_names.iteritems(): if key in inputs: if isinstance(val, basestring) and inputs[key] == val: @@ -60,7 +60,7 @@ def parseHtmlForm(attr_str, html, input_names={}): else: return action, inputs #: passed attribute check else: - # no attribute check + #: no attribute check return action, inputs return {}, None #: no matching form found @@ -281,7 +281,7 @@ class Plugin(object): self.logError(e) if just_header: - # parse header + #: parse header header = {"code": req.code} for line in res.splitlines(): line = line.strip() diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index cad4cfa1c..7a79c278c 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -53,7 +53,7 @@ class SevenZip(UnRar): def verify(self, password): - # 7z can't distinguish crc and pw error in test + #: 7z can't distinguish crc and pw error in test p = self.call_cmd("l", "-slt", fs_encode(self.filename)) out, err = p.communicate() @@ -72,7 +72,7 @@ class SevenZip(UnRar): p = self.call_cmd("l", "-slt", fs_encode(self.filename)) out, err = p.communicate() - # check if output or error macthes the 'wrong password'-Regexp + #: check if output or error macthes the 'wrong password'-Regexp if self.re_wrongpwd.search(out): raise PasswordError @@ -91,7 +91,7 @@ class SevenZip(UnRar): renice(p.pid, self.renice) - # communicate and retrieve stderr + #: communicate and retrieve stderr self._progress(p) err = p.stderr.read().strip() diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 85e939b6a..25a8a52de 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -105,7 +105,7 @@ class UnRar(Extractor): if self.re_wrongcrc.search(err): raise CRCError(err) - # output only used to check if passworded files are present + #: output only used to check if passworded files are present for attr in self.re_filelist.findall(out): if attr[0].startswith("*"): raise PasswordError @@ -114,7 +114,7 @@ class UnRar(Extractor): def repair(self): p = self.call_cmd("rc", fs_encode(self.filename)) - # communicate and retrieve stderr + #: communicate and retrieve stderr self._progress(p) err = p.stderr.read().strip() if err or p.returncode: @@ -126,17 +126,17 @@ class UnRar(Extractor): s = "" while True: c = process.stdout.read(1) - # quit loop on eof + #: quit loop on eof if not c: break - # reading a percentage sign -> set progress and restart + #: reading a percentage sign -> set progress and restart if c == '%': self.notifyProgress(int(s)) s = "" - # not reading a digit -> therefore restart + #: not reading a digit -> therefore restart elif c not in digits: s = "" - # add digit to progressstring + #: add digit to progressstring else: s += c @@ -148,7 +148,7 @@ class UnRar(Extractor): renice(p.pid, self.renice) - # communicate and retrieve stderr + #: communicate and retrieve stderr self._progress(p) err = p.stderr.read().strip() @@ -171,10 +171,10 @@ class UnRar(Extractor): def getDeleteFiles(self): dir, name = os.path.split(self.filename) - # actually extracted file + #: actually extracted file files = [self.filename] - # eventually Multipart Files + #: eventually Multipart Files files.extend(fs_join(dir, os.path.basename(file)) for file in filter(self.isMultipart, os.listdir(dir)) if re.sub(self.re_multipart,".rar",name) == re.sub(self.re_multipart,".rar",file)) @@ -195,7 +195,7 @@ class UnRar(Extractor): result = set() if not self.fullpath and self.VERSION.startswith('5'): - # NOTE: Unrar 5 always list full path + #@NOTE: Unrar 5 always list full path for f in fs_decode(out).splitlines(): f = fs_join(self.out, os.path.basename(f.strip())) if os.path.isfile(f): @@ -211,7 +211,7 @@ class UnRar(Extractor): def call_cmd(self, command, *xargs, **kwargs): args = [] - # overwrite flag + #: overwrite flag if self.overwrite: args.append("-o+") else: @@ -222,10 +222,10 @@ class UnRar(Extractor): for word in self.excludefiles: args.append("-x'%s'" % word.strip()) - # assume yes on all queries + #: assume yes on all queries args.append("-y") - # set a password + #: set a password if "password" in kwargs and kwargs['password']: args.append("-p%s" % kwargs['password']) else: @@ -234,7 +234,7 @@ class UnRar(Extractor): if self.keepbroken: args.append("-kb") - # NOTE: return codes are not reliable, some kind of threading, cleanup whatever issue + #@NOTE: return codes are not reliable, some kind of threading, cleanup whatever issue call = [self.CMD, command] + args + list(xargs) self.manager.logDebug(" ".join(call)) |