Skip to content

Commit 8766739

Browse files
committed
cleanup
1 parent b0dd023 commit 8766739

8 files changed

Lines changed: 48 additions & 72 deletions

File tree

module/Api.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
from remote.thriftbackend.thriftgen.pyload.ttypes import *
2525
from remote.thriftbackend.thriftgen.pyload.Pyload import Iface
2626

27-
from module.PyFile import PyFile
28-
from module.database.UserDatabase import ROLE
29-
from module.utils import freeSpace, compare_time
30-
from module.common.packagetools import parseNames
27+
from PyFile import PyFile
28+
from database.UserDatabase import ROLE
29+
from utils import freeSpace, compare_time
30+
from common.packagetools import parseNames
31+
from network.RequestFactory import getURL
3132

3233

3334
class Api(Iface):
@@ -265,8 +266,13 @@ def addPackage(self, name, links, dest):
265266
return pid
266267

267268
def parseURLs(self, html):
268-
#TODO implement
269-
pass
269+
html = getURL(html)
270+
271+
# TODO parse
272+
urls = []
273+
274+
return self.checkURLs(urls)
275+
270276

271277
def checkURLs(self, urls):
272278
data = self.core.pluginManager.parseUrls(urls)
@@ -318,7 +324,6 @@ def pollResults(self, rid):
318324
return OnlineCheck(rid, result)
319325

320326

321-
322327
def generatePackages(self, links):
323328
""" Parses links, generates packages names only from urls
324329

module/common/packagetools.py

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import re
66
from urlparse import urlparse
77

8-
from ..remote.thriftbackend.thriftgen.pyload.ttypes import OnlineStatus
9-
108
def matchFirst(string, *args):
119
""" matches against list of regexp and returns first match"""
1210
for patternlist in args:
@@ -95,49 +93,29 @@ def parseNames(files):
9593
name = name.replace(r.group(0), "")
9694
patternMatch = True
9795

98-
# remove extension
99-
index = name.rfind(".")
100-
if index <= 0:
101-
index = name.rfind("_")
102-
if index > 0:
103-
length = len(name) - index
104-
if length <= 4:
105-
name = name[:-length]
106-
107-
# remove endings like . _ -
108-
r = pat3.search(name)
109-
if r is not None:
110-
name = r.group(1)
111-
112-
# replace . and _ with space
113-
name = name.replace(".", " ")
114-
name = name.replace("_", " ")
115-
116-
name = name.strip()
117-
118-
# special checks if no extension pattern matched
119-
if patternMatch is False:
120-
# checks if name could be a hash
121-
if file.find("file/" + name) >= 0:
122-
name = ""
123-
124-
if file.find("files/" + name) >= 0:
125-
name = ""
126-
127-
r = re.search("^[0-9]+$", name, re.I)
96+
# additional checks if extension pattern matched
97+
if patternMatch:
98+
# remove extension
99+
index = name.rfind(".")
100+
if index <= 0:
101+
index = name.rfind("_")
102+
if index > 0:
103+
length = len(name) - index
104+
if length <= 4:
105+
name = name[:-length]
106+
107+
# remove endings like . _ -
108+
r = pat3.search(name)
128109
if r is not None:
129-
name = ""
110+
name = r.group(1)
130111

131-
r = re.search("^[0-9a-z]+$", name, re.I)
132-
if r is not None:
133-
r1 = re.search("[0-9]+.+[0-9]", name)
134-
r2 = re.search("[a-z]+.+[a-z]+", name, re.I)
135-
if r1 is not None and r2 is not None:
136-
name = ""
137-
138-
path = urlparse(file).path
139-
if path == "/" + name or path == "/" + name + ".htm":
140-
name = ""
112+
# replace . and _ with space
113+
name = name.replace(".", " ")
114+
name = name.replace("_", " ")
115+
116+
name = name.strip()
117+
else:
118+
name = ""
141119

142120
# fallback: package by hoster
143121
if not name:

module/network/HTTPRequest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from logging import getLogger
2525
from cStringIO import StringIO
2626

27-
from module.utils import html_unescape
2827
from module.plugins.Plugin import Abort
2928

3029
def myquote(url):

module/plugins/Container.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ class Container(Crypter):
3232
__author_name__ = ("mkaay")
3333
__author_mail__ = ("mkaay@mkaay.de")
3434

35-
36-
37-
#----------------------------------------------------------------------
35+
3836
def preprocessing(self, thread):
3937
"""prepare"""
4038

@@ -48,13 +46,12 @@ def preprocessing(self, thread):
4846

4947
self.createPackages()
5048

51-
52-
#----------------------------------------------------------------------
49+
5350
def loadToDisk(self):
5451
"""loads container to disk if its stored remotely and overwrite url,
5552
or check existent on several places at disk"""
5653

57-
if self.pyfile.url.startswith("http://"):
54+
if self.pyfile.url.startswith("http"):
5855
self.pyfile.name = re.findall("([^\/=]+)", self.pyfile.url)[-1]
5956
content = self.load(self.pyfile.url)
6057
self.pyfile.url = join(self.config["general"]["download_folder"], self.pyfile.name)
@@ -71,8 +68,6 @@ def loadToDisk(self):
7168
self.fail(_("File not exists."))
7269

7370

74-
75-
#----------------------------------------------------------------------
7671
def deleteTmp(self):
7772
if self.pyfile.name.startswith("tmp_"):
7873
remove(self.pyfile.url)

module/plugins/Crypter.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
from module.plugins.Plugin import Plugin
2121

22-
from os.path import join, exists, basename
23-
2422
class Crypter(Plugin):
2523
__name__ = "Crypter"
2624
__version__ = "0.1"
@@ -33,15 +31,16 @@ class Crypter(Plugin):
3331
def __init__(self, pyfile):
3432
Plugin.__init__(self, pyfile)
3533

36-
""" Put all packages here. It's a list of tuples like:
37-
( name, [list of links], folder ) """
34+
#: Put all packages here. It's a list of tuples like: ( name, [list of links], folder )
3835
self.packages = []
36+
37+
#: List of urls, pyLoad will generate packagenames
38+
self.urls = []
3939

4040
self.multiDL = True
4141
self.limitDL = 0
42-
self.setup()
4342

44-
#----------------------------------------------------------------------
43+
4544
def preprocessing(self, thread):
4645
"""prepare"""
4746
self.setup()
@@ -54,8 +53,7 @@ def preprocessing(self, thread):
5453

5554
def decrypt(self, pyfile):
5655
raise NotImplementedError
57-
58-
#----------------------------------------------------------------------
56+
5957
def createPackages(self):
6058
""" create new packages from self.packages """
6159
for pack in self.packages:
@@ -68,4 +66,7 @@ def createPackages(self):
6866

6967
if self.pyfile.package().password:
7068
self.core.api.setPackageData(pid, {"password": self.pyfile.package().password})
69+
70+
if self.urls:
71+
self.core.api.generateAndAddPackages(self.urls)
7172

module/plugins/hoster/RealdebridCom.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
import re
55
from urllib import quote, unquote
66
from random import randrange
7-
from time import sleep
87

98
from module.plugins.Hoster import Hoster
109

1110
class RealdebridCom(Hoster):
1211
__name__ = "RealdebridCom"
13-
__version__ = "0.4"
12+
__version__ = "0.41"
1413
__type__ = "hoster"
1514

1615
__pattern__ = r"https?://.*real-debrid\..*"
@@ -80,5 +79,5 @@ def process(self, pyfile):
8079

8180
if check == "error":
8281
#usual this download can safely be retried
83-
self.retry(reason="An error occured while generating link.")
82+
self.retry(reason="An error occured while generating link.", wait_time=60)
8483

module/web/filters.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# -*- coding: utf-8 -*-
33
import os
44
from os.path import abspath, commonprefix, join
5-
from time import strftime, mktime, gmtime
65

76
quotechar = "::/"
87

module/web/pyload_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
from filters import relpath, unquotepath
3838

39-
from module.utils import formatSize, decode, fs_decode, freeSpace
39+
from module.utils import formatSize, decode, fs_decode
4040

4141
# Helper
4242

0 commit comments

Comments
 (0)