summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar spoob <spoob@gmx.de> 2010-04-08 21:45:05 +0200
committerGravatar spoob <spoob@gmx.de> 2010-04-08 21:45:05 +0200
commit8ea7bd3241016b2084eb923c37bf7e7a75a296eb (patch)
treef1f18eeebe6bfc315de9729642c5adda87e147ab
parentCleaned Megaupload (diff)
downloadpyload-8ea7bd3241016b2084eb923c37bf7e7a75a296eb.tar.xz
_.-:Package Folders:-._
-rw-r--r--module/Plugin.py36
-rw-r--r--module/download_thread.py9
-rwxr-xr-xmodule/network/Request.py8
-rw-r--r--module/plugins/hoster/UploadedTo.py14
-rw-r--r--module/thread_list.py2
5 files changed, 43 insertions, 26 deletions
diff --git a/module/Plugin.py b/module/Plugin.py
index ff4c66c01..4f6b1b39a 100644
--- a/module/Plugin.py
+++ b/module/Plugin.py
@@ -20,10 +20,12 @@
import logging
import re
from os.path import exists
+from os.path import join
from time import sleep
from module.network.Request import Request
+from os import makedirs
from module.download_thread import CaptchaError
@@ -52,17 +54,17 @@ class Plugin():
self.decryptNow = True
def prepare(self, thread):
- pyfile = self.parent
+ self.pyfile = self.parent
self.want_reconnect = False
- pyfile.status.exists = self.file_exists()
+ self.pyfile.status.exists = self.file_exists()
- if not pyfile.status.exists:
+ if not self.pyfile.status.exists:
return False
- pyfile.status.filename = self.get_file_name()
- pyfile.status.waituntil = self.time_plus_wait
- pyfile.status.url = self.get_file_url()
- pyfile.status.want_reconnect = self.want_reconnect
+ self.pyfile.status.filename = self.get_file_name()
+ self.pyfile.status.waituntil = self.time_plus_wait
+ self.pyfile.status.url = self.get_file_url()
+ self.pyfile.status.want_reconnect = self.want_reconnect
thread.wait(self.parent)
return True
@@ -82,7 +84,7 @@ class Plugin():
"""
if re.search(r"(?!http://).*\.(dlc|ccf|rsdf|txt)", self.parent.url):
return exists(self.parent.url)
- header = self.req.load(self.parent.url, just_header=True)
+ header = self.load(self.parent.url, just_header=True)
try:
if re.search(r"HTTP/1.1 404 Not Found", header):
return False
@@ -107,7 +109,7 @@ class Plugin():
return self.time_plus_wait
def proceed(self, url, location):
- self.req.download(url, location)
+ self.download(url, location)
def set_config(self):
for k, v in self.config.items():
@@ -148,7 +150,7 @@ class Plugin():
10 - not implemented
20 - unknown error
"""
- return (True, 10)
+ return (True, 10)
def waitForCaptcha(self, captchaData, imgType):
captchaManager = self.parent.core.captchaManager
@@ -163,3 +165,17 @@ class Plugin():
result = task.getResult()
task.removeTask()
return result
+
+ def load(self, url, get={}, post={}, ref=True, cookies=True, just_header=False):
+ return self.req.load(url, get, post, ref, cookies, just_header)
+
+ def download(self, url, file_name, get={}, post={}, ref=True, cookies=True):
+ if self.pyfile.package.data["package_name"] != "links.txt":
+ self.pyfile.folder = self.pyfile.package.data["package_name"]
+ location = join("Downloads", self.pyfile.folder)
+ makedirs(location)
+ file_path = join(location, self.pyfile.status.filename)
+ else:
+ file_path = join("Downloads", self.pyfile.status.filename)
+
+ self.pyfile.status.filename = self.req.download(url, file_path, get, post, ref, cookies)
diff --git a/module/download_thread.py b/module/download_thread.py
index b56fc1b4c..6dd9c3f2c 100644
--- a/module/download_thread.py
+++ b/module/download_thread.py
@@ -29,6 +29,9 @@ from time import sleep, time
from module.network.Request import AbortDownload
from module.PullEvents import UpdateEvent
+from module.network.Request import Request as Browser
+
+
class Status(object):
""" Saves all status information
"""
@@ -149,12 +152,12 @@ class Download_Thread(threading.Thread):
#~ free_file_name = self.get_free_name(status.filename)
- location = join(pyfile.folder, status.filename)
- pyfile.plugin.proceed(status.url, location)
+ #~ location = join(pyfile.folder, status.filename)
+ pyfile.plugin.proceed(status.url, status.filename)
if self.parent.parent.xmlconfig.get("general", "checksum", True):
status.type = "checking"
- check, code = pyfile.plugin.check_file(location)
+ check, code = pyfile.plugin.check_file(status.filename)
"""
return codes:
0 - checksum ok
diff --git a/module/network/Request.py b/module/network/Request.py
index a074df7c4..76f94ae41 100755
--- a/module/network/Request.py
+++ b/module/network/Request.py
@@ -250,7 +250,6 @@ class Request:
self.chunkRead += chunkSize
self.dl_arrived += chunkSize
-
self.pycurl.setopt(pycurl.WRITEFUNCTION, writefunc)
try:
@@ -264,13 +263,14 @@ class Request:
if self.abort:
raise AbortDownload
-
- rename(file_temp, self.get_free_name(file_name))
+
+ free_name = self.get_free_name(file_name)
+ rename(file_temp, free_name)
self.dl = False
self.dl_finished = time.time()
- return True
+ return free_name
def updateCurrentSpeed(self, speed):
self.dl_speed = speed
diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py
index 05ac65f3a..ae9ed0b14 100644
--- a/module/plugins/hoster/UploadedTo.py
+++ b/module/plugins/hoster/UploadedTo.py
@@ -74,7 +74,7 @@ class UploadedTo(Plugin):
url = self.parent.url
match = re.compile(self.props['pattern']).search(url)
if match:
- src = self.req.load("http://uploaded.to/api/file", cookies=False, get={"id": match.group(1).split("/")[0]})
+ src = self.load("http://uploaded.to/api/file", cookies=False, get={"id": match.group(1).split("/")[0]})
if not src.find("404 Not Found"):
return
self.api_data = {}
@@ -85,7 +85,7 @@ class UploadedTo(Plugin):
def download_html(self):
url = self.parent.url
- self.html = self.req.load(url, cookies=False)
+ self.html = self.load(url, cookies=False)
def get_waiting_time(self):
try:
@@ -119,7 +119,7 @@ class UploadedTo(Plugin):
return self.parent.url
def file_exists(self):
- if re.search(r"(File doesn't exist .*)", self.html) != None:
+ if re.search(r"(File doesn't exist)", self.html) != None:
return False
else:
return True
@@ -133,14 +133,14 @@ class UploadedTo(Plugin):
def proceed(self, url, location):
if self.config['premium']:
- self.req.load("http://uploaded.to/login", None, { "email" : self.config['username'], "password" : self.config['password']}, cookies=True)
- self.req.load(url, cookies=True, just_header=True)
+ self.load("http://uploaded.to/login", None, { "email" : self.config['username'], "password" : self.config['password']}, cookies=True)
+ self.load(url, cookies=True, just_header=True)
if self.cleanUrl(self.req.lastEffectiveURL) == self.cleanUrl(url):
self.logger.info(_("UploadedTo indirect download"))
url = self.cleanUrl(url)+"?redirect"
- self.req.download(url, location, cookies=True)
+ self.download(url, location, cookies=True)
else:
- self.req.download(url, location, cookies=False, post={"download_submit": "Free Download"})
+ self.download(url, location, cookies=False, post={"download_submit": "Free Download"})
def check_file(self, local_file):
if self.api_data and self.api_data["checksum"]:
diff --git a/module/thread_list.py b/module/thread_list.py
index 3698e4e0b..8f02536de 100644
--- a/module/thread_list.py
+++ b/module/thread_list.py
@@ -29,7 +29,6 @@ import subprocess
from threading import RLock, Thread
import time
import urllib2
-
from download_thread import Download_Thread
class Thread_List(object):
@@ -96,7 +95,6 @@ class Thread_List(object):
self.lock.release()
return pyfile
-
def job_finished(self, pyfile):
"""manage completing download"""
self.lock.acquire()