summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Core.py78
-rw-r--r--Plugins/Plugin.py33
-rw-r--r--Plugins/RSDF.py38
-rw-r--r--Plugins/RapidshareCom.py42
-rw-r--r--Plugins/UploadedTo.py21
-rw-r--r--Plugins/YoutubeCom.py22
-rw-r--r--config3
-rw-r--r--module/Py_Load_File.py3
-rw-r--r--module/download_thread.py4
-rw-r--r--module/thread_list.py27
10 files changed, 151 insertions, 120 deletions
diff --git a/Core.py b/Core.py
index 6b316abb5..31b38013c 100644
--- a/Core.py
+++ b/Core.py
@@ -21,19 +21,22 @@ CURRENT_VERSION = '0.1'
#python imports
import ConfigParser
-from glob import glob
-from os import sep, mkdir
-from os.path import exists, basename
-from sys import path, exit, stdout
-import urllib2
-import re
-from time import sleep, time
import logging
import logging.handlers
+import time
+import urllib2
+from glob import glob
+from os import mkdir
+from os import sep
+from os.path import basename
+from os.path import exists
+from sys import exit
+from sys import path
+from sys import stdout
+from time import sleep
-#my imports
-from module.thread_list import Thread_List
from module.Py_Load_File import PyLoadFile
+from module.thread_list import Thread_List
class Core(object):
""" pyLoad main
@@ -42,14 +45,15 @@ class Core(object):
self.check_update()
self.config = {}
-
- self.plugins_folder = "Plugins"
+
+ self.config['plugin_folder'] = "Plugins"
self.config['link_file'] = "links.txt"
self.plugins_avaible = {}
self.search_updates = False
self.read_config()
-
+ print self.is_dltime # debug only
+
self.thread_list = Thread_List(self)
self.check_create(self.config['download_folder'], "Ordner für Downloads")
@@ -58,26 +62,34 @@ class Core(object):
self.init_logger(logging.DEBUG) # logging level
- path.append(self.plugins_folder)
+ path.append(self.config['plugin_folder'])
self.create_plugin_index()
def read_config(self):
""" read config and sets preferences
"""
- config = ConfigParser.ConfigParser()
+
+ config = ConfigParser.SafeConfigParser()
config.read('config')
+
+ for section in config.sections():
+ for option in config.options(section):
+ self.config[option] = config.get(section, option)
+
self.config['download_folder'] = config.get('general', 'downloadFolder')
self.config['link_file'] = config.get('general', 'linkFile')
- self.config['search_updates'] = config.get('updates', 'searchUpdates')
+ self.config['search_updates'] = config.getboolean('updates', 'searchUpdates')
self.config['log_folder'] = config.get('log', 'logFolder')
+ self.config['reconnectMethod'] = config.get('general', 'reconnectMethod')
+
def create_plugin_index(self):
- for file_handler in glob(self.plugins_folder + sep + '*.py'):
- if file_handler != self.plugins_folder + sep + "Plugin.py":
+ for file_handler in glob(self.config['plugin_folder'] + sep + '*.py'):
+ if file_handler != self.config['plugin_folder'] + sep + "Plugin.py":
plugin_pattern = ""
plugin_file = basename(file_handler).replace('.py', '')
for line in open(file_handler, "r").readlines():
- if "plugin_config['pattern']" in line:
+ if "props['pattern']" in line:
plugin_pattern = line.split("r\"")[1].split("\"")[0]
if plugin_pattern != "":
self.plugins_avaible[plugin_file] = plugin_pattern
@@ -134,7 +146,7 @@ class Core(object):
else:
print "Beta Version " + CURRENT_VERSION + " in benutzung" #using beta version
- def check_create(self, check_name, legend, folder = True):
+ def check_create(self, check_name, legend, folder=True):
if not exists(check_name):
try:
if folder:
@@ -166,7 +178,7 @@ class Core(object):
return True
def init_logger(self, level):
- handler = logging.handlers.RotatingFileHandler(self.config['log_folder'] + sep + 'log.txt', maxBytes = 12800 , backupCount = 10) #100 kb
+ handler = logging.handlers.RotatingFileHandler(self.config['log_folder'] + sep + 'log.txt', maxBytes=12800, backupCount=10) #100 kb
console = logging.StreamHandler(stdout)
#handler = logging.FileHandler('Logs/log.txt')
frm = logging.Formatter("%(asctime)s: %(levelname)-8s %(message)s", "%d.%m.%Y %H:%M:%S")
@@ -178,15 +190,35 @@ class Core(object):
self.logger.addHandler(console) #if console logging
self.logger.setLevel(level)
+
+ def is_dltime(self):
+ start_h, start_m = self.config['start'].split(":")
+ end_h, end_m = self.config['end'].split(":")
+
+ #@todo: doesnt work at the moment
+ hour, minute = time.localtime()[3:5]
+
+ print start_h, start_m, end_h, end_m
+ print hour, minute
+
+ if hour > start_h and hour < end_h:
+ return True
+ elif hour == start_h and minute >= start_m:
+ return True
+ elif hour == end_h and minute <= end_m:
+ return True
+ else:
+ return False
+
def _test_print_status(self):
if self.thread_list.py_downloading:
for pyfile in self.thread_list.py_downloading:
if pyfile.status.type == 'downloading':
- print pyfile.status.filename + ": speed is" ,int(pyfile.status.get_speed()) ,"kb/s"
- print pyfile.status.filename + ": arraives in" ,int(pyfile.status.get_ETA()) ,"seconds"
+ print pyfile.status.filename + ": speed is", int(pyfile.status.get_speed()), "kb/s"
+ print pyfile.status.filename + ": arraives in", int(pyfile.status.get_ETA()), "seconds"
elif pyfile.status.type == 'waiting':
- print pyfile.status.filename + ": wait", int(pyfile.status.waituntil -time()) , "seconds"
+ print pyfile.status.filename + ": wait", int(pyfile.status.waituntil -time.time()), "seconds"
def start(self):
""" starts the machine
diff --git a/Plugins/Plugin.py b/Plugins/Plugin.py
index 0eefd8d9b..0345d7b1d 100644
--- a/Plugins/Plugin.py
+++ b/Plugins/Plugin.py
@@ -1,24 +1,26 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
+import ConfigParser
import re
-from time import time
+
from module.network.Request import Request
class Plugin():
def __init__(self, parent):
- self.plugin_name = None
+ self.plugin_name = "Base"
self.plugin_pattern = None
self.plugin_type = "hoster"
- plugin_config = {}
- plugin_config['name'] = "Base Plugin"
- plugin_config['version'] = "0.1"
- plugin_config['format'] = "*.py"
- plugin_config['description'] = """bla"""
- plugin_config['author'] = "Spoob"
- plugin_config['author_email'] = "nn@nn.de"
- self.plugin_config = plugin_config
+ self.parser = ConfigParser.SafeConfigParser()
+ props = {}
+ props['name'] = "Base Plugin"
+ props['version'] = "0.1"
+ props['format'] = "*.py"
+ props['description'] = """bla"""
+ props['author'] = "Spoob"
+ props['author_email'] = "nn@nn.de"
+ self.props = props
self.parent = parent
self.req = Request()
self.html = None
@@ -49,7 +51,7 @@ class Plugin():
def get_file_name(self):
- return re.findall("([^\/=]+)",self.parent.url)[-1]
+ return re.findall("([^\/=]+)", self.parent.url)[-1]
def wait_until(self):
if self.html != None:
@@ -58,6 +60,13 @@ class Plugin():
def proceed(self, url, location):
self.req.download(url, location)
-
+
+ def set_config(self):
+ pass
+
+ def get_config(self, value):
+ self.parser.read("pluginconfig")
+ return self.parser.get(self.props['name'], value)
+
def __call__(self):
return self.plugin_name
diff --git a/Plugins/RSDF.py b/Plugins/RSDF.py
index 27938bb17..bbbf3d960 100644
--- a/Plugins/RSDF.py
+++ b/Plugins/RSDF.py
@@ -1,30 +1,24 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-import urllib2
-import urllib
-import re
-import time
-import binascii
import base64
-import sys
+import binascii
from Plugin import Plugin
-from time import time
class RSDF(Plugin):
def __init__(self, parent):
Plugin.__init__(self, parent)
- plugin_config = {}
- plugin_config['name'] = "RSDF"
- plugin_config['type'] = "container"
- plugin_config['pattern'] = r".*\.rsdf"
- plugin_config['version'] = "0.2"
- plugin_config['description'] = """RSDF Container Decode Plugin"""
- plugin_config['author_name'] = ("RaNaN", "spoob")
- plugin_config['author_mail'] = ("RaNaN@pyload.org", "spoob@pyload.org")
- self.plugin_config = plugin_config
+ props = {}
+ props['name'] = "RSDF"
+ props['type'] = "container"
+ props['pattern'] = r".*\.rsdf"
+ props['version'] = "0.2"
+ props['description'] = """RSDF Container Decode Plugin"""
+ props['author_name'] = ("RaNaN", "spoob")
+ props['author_mail'] = ("RaNaN@pyload.org", "spoob@pyload.org")
+ self.props = props
self.parent = parent
self.multi_dl = True
self.links = []
@@ -35,22 +29,22 @@ class RSDF(Plugin):
return True
def __call__(self):
- return self.plugin_config['name']
+ return self.props['name']
def proceed(self, url, location):
try:
from Crypto.Cipher import AES
- infile = url.replace("\n","")
+ infile = url.replace("\n", "")
Key = binascii.unhexlify('8C35192D964DC3182C6F84F3252239EB4A320D2500000000')
IV = binascii.unhexlify('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')
- IV_Cipher = AES.new(Key,AES.MODE_ECB)
+ IV_Cipher = AES.new(Key, AES.MODE_ECB)
IV = IV_Cipher.encrypt(IV)
- obj = AES.new(Key,AES.MODE_CFB,IV)
+ obj = AES.new(Key, AES.MODE_CFB, IV)
- rsdf = open(infile,'r')
+ rsdf = open(infile, 'r')
data = rsdf.read()
data = binascii.unhexlify(''.join(data.split()))
@@ -59,7 +53,7 @@ class RSDF(Plugin):
for link in data:
link = base64.b64decode(link)
link = obj.decrypt(link)
- decryptedUrl = link.replace('CCF: ','')
+ decryptedUrl = link.replace('CCF: ', '')
self.links.append(decryptedUrl)
rsdf.close()
diff --git a/Plugins/RapidshareCom.py b/Plugins/RapidshareCom.py
index 694fa29c9..8f774937b 100644
--- a/Plugins/RapidshareCom.py
+++ b/Plugins/RapidshareCom.py
@@ -1,27 +1,25 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-import urllib2
-import urllib
import re
import time
+from time import time
from Plugin import Plugin
-from time import time
class RapidshareCom(Plugin):
def __init__(self, parent):
Plugin.__init__(self, parent)
- plugin_config = {}
- plugin_config['name'] = "RapidshareCom"
- plugin_config['type'] = "hoster"
- plugin_config['pattern'] = r"http://(?:www.)?rapidshare.com/files/"
- plugin_config['version'] = "0.1"
- plugin_config['description'] = """Rapidshare.com Download Plugin"""
- plugin_config['author_name'] = ("spoob")
- plugin_config['author_mail'] = ("spoob@pyload.org")
- self.plugin_config = plugin_config
+ props = {}
+ props['name'] = "RapidshareCom"
+ props['type'] = "hoster"
+ props['pattern'] = r"http://(?:www.)?rapidshare.com/files/"
+ props['version'] = "0.1"
+ props['description'] = """Rapidshare.com Download Plugin"""
+ props['author_name'] = ("spoob")
+ props['author_mail'] = ("spoob@pyload.org")
+ self.props = props
self.parent = parent
self.html = [None, None]
self.html_old = None #time() where loaded the HTML
@@ -57,7 +55,7 @@ class RapidshareCom(Plugin):
file_server_url = re.search(r"<form action=\"(.*?)\"", self.html[0]).group(1)
#free user
#free_user_encode = urllib.urlencode({"dl.start" : "Free"})
- self.html[1] = self.req.load(file_server_url, None,{"dl.start" : "Free"})
+ self.html[1] = self.req.load(file_server_url, None, {"dl.start": "Free"})
self.html_old = time()
self.get_wait_time()
@@ -65,17 +63,17 @@ class RapidshareCom(Plugin):
def get_wait_time(self):
if self.html[1] == None:
- download_serverhtml(self)
+ self.download_serverhtml(self)
if re.search(r".*is already downloading.*", self.html[1]) != None:
- self.time_plus_wait = time() + 10*60
+ self.time_plus_wait = time() + 10 * 60
try:
wait_minutes = re.search(r"Or try again in about (\d+) minute", self.html[1]).group(1)
self.time_plus_wait = time() + 60 * int(wait_minutes)
self.want_reconnect = True
except:
if re.search(r".*Currently a lot of users.*", self.html[1]) != None:
- self.time_plus_wait = time() + 2*60
+ self.time_plus_wait = time() + 2 * 60
wait_seconds = re.search(r"var c=(.*);.*", self.html[1]).group(1)
self.time_plus_wait = time() + int(wait_seconds) + 5
@@ -85,10 +83,10 @@ class RapidshareCom(Plugin):
if self.html[0] == None:
self.download_html()
if re.search(r".*The File could not be found.*", self.html[0]) != None or \
- re.search(r"(<p>This limit is reached.</p>)", self.html[0]) or \
- re.search(r"(.*is momentarily not available.*)", self.html[0]) or \
- re.search(r"(.*The uploader has removed this file from the server.*)", self.html[0]) or \
- re.search(r"(.*This file is suspected to contain illegal content.*)", self.html[0]):
+ re.search(r"(<p>This limit is reached.</p>)", self.html[0]) or \
+ re.search(r"(.*is momentarily not available.*)", self.html[0]) or \
+ re.search(r"(.*The uploader has removed this file from the server.*)", self.html[0]) or \
+ re.search(r"(.*This file is suspected to contain illegal content.*)", self.html[0]):
return False
else:
return True
@@ -98,7 +96,7 @@ class RapidshareCom(Plugin):
"""
if self.html[1] == None:
self.download_serverhtml()
- if (self.html_old + 5*60) < time(): # nach einiger zeit ist die file_url nicht mehr aktuell
+ if (self.html_old + 5 * 60) < time(): # nach einiger zeit ist die file_url nicht mehr aktuell
self.download_serverhtml()
if not self.want_reconnect:
@@ -122,4 +120,4 @@ class RapidshareCom(Plugin):
return self.time_plus_wait
def __call__(self):
- return self.plugin_config['name']
+ return self.props['name']
diff --git a/Plugins/UploadedTo.py b/Plugins/UploadedTo.py
index 7c579ea15..29817e992 100644
--- a/Plugins/UploadedTo.py
+++ b/Plugins/UploadedTo.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python
-import urllib2
import re
from time import time
from Plugin import Plugin
@@ -9,15 +8,15 @@ class UploadedTo(Plugin):
def __init__(self, parent):
Plugin.__init__(self, parent)
- plugin_config = {}
- plugin_config['name'] = "UploadedTo"
- plugin_config['type'] = "hoster"
- plugin_config['pattern'] = r"http://(www\.)?uploaded.to/"
- plugin_config['version'] = "0.1"
- plugin_config['description'] = """Uploaded.to Download Plugin"""
- plugin_config['author_name'] = ("spoob")
- plugin_config['author_mail'] = ("spoob@pyload.org")
- self.plugin_config = plugin_config
+ props = {}
+ props['name'] = "UploadedTo"
+ props['type'] = "hoster"
+ props['pattern'] = r"http://(www\.)?uploaded.to/"
+ props['version'] = "0.1"
+ props['description'] = """Uploaded.to Download Plugin"""
+ props['author_name'] = ("spoob")
+ props['author_mail'] = ("spoob@pyload.org")
+ self.plugin_config = props
self.parent = parent
self.html = None
self.html_old = None #time() where loaded the HTML
@@ -83,4 +82,4 @@ class UploadedTo(Plugin):
return self.time_plus_wait
def __call__(self):
- return self.plugin_config['name']
+ return self.props['name']
diff --git a/Plugins/YoutubeCom.py b/Plugins/YoutubeCom.py
index d6b0473d3..c1ad22102 100644
--- a/Plugins/YoutubeCom.py
+++ b/Plugins/YoutubeCom.py
@@ -1,23 +1,21 @@
#!/usr/bin/env python
-import urllib2
import re
-from time import time
from Plugin import Plugin
class YoutubeCom(Plugin):
def __init__(self, parent):
Plugin.__init__(self, parent)
- plugin_config = {}
- plugin_config['name'] = "YoutubeCom"
- plugin_config['type'] = "hoster"
- plugin_config['pattern'] = r"http://(www\.)?(de\.)?\youtube\.com/watch\?v=.*"
- plugin_config['version'] = "0.1"
- plugin_config['description'] = """Youtube.com Video Download Plugin"""
- plugin_config['author_name'] = ("spoob")
- plugin_config['author_mail'] = ("spoob@pyload.org")
- self.plugin_config = plugin_config
+ props = {}
+ props['name'] = "YoutubeCom"
+ props['type'] = "hoster"
+ props['pattern'] = r"http://(www\.)?(de\.)?\youtube\.com/watch\?v=.*"
+ props['version'] = "0.1"
+ props['description'] = """Youtube.com Video Download Plugin"""
+ props['author_name'] = ("spoob")
+ props['author_mail'] = ("spoob@pyload.org")
+ self.props = props
self.parent = parent
self.html = None
self.html_old = None #time() where loaded the HTML
@@ -71,4 +69,4 @@ class YoutubeCom(Plugin):
return self.time_plus_wait
def __call__(self):
- return self.plugin_config['name']
+ return self.props['name']
diff --git a/config b/config
index 71378e630..4c9b1fdf4 100644
--- a/config
+++ b/config
@@ -8,3 +8,6 @@ searchUpdates: True
[log]
logFolder: Logs
fullLog: True
+[time]
+start: 10:00
+end: 13:00 \ No newline at end of file
diff --git a/module/Py_Load_File.py b/module/Py_Load_File.py
index ecfded6fd..97479384c 100644
--- a/module/Py_Load_File.py
+++ b/module/Py_Load_File.py
@@ -1,6 +1,7 @@
-from download_thread import Status
import re
+from download_thread import Status
+
class PyLoadFile:
""" represents the url or file
"""
diff --git a/module/download_thread.py b/module/download_thread.py
index 9147af923..f8786c810 100644
--- a/module/download_thread.py
+++ b/module/download_thread.py
@@ -20,7 +20,6 @@
import threading
from time import time, sleep
-from copy import copy
class Status(object):
""" Saves all status information
@@ -92,8 +91,7 @@ class Download_Thread(threading.Thread):
sleep(1)
self.parent.remove_thread(self)
- def download(self, py_load_file):
- pyfile = py_load_file
+ def download(self, pyfile):
status = pyfile.status
pyfile.prepareDownload()
diff --git a/module/thread_list.py b/module/thread_list.py
index 4cd1f1978..a206c19c4 100644
--- a/module/thread_list.py
+++ b/module/thread_list.py
@@ -18,13 +18,12 @@
#
###
#python
-import time
-import urllib2
import re
import subprocess
-from Queue import Queue
+import time
+import urllib2
from threading import Lock
-#my
+
from download_thread import Download_Thread
class Thread_List(object):
@@ -33,12 +32,11 @@ class Thread_List(object):
self.threads = []
self.max_threads = 3
self.py_load_files = [] # files in queque
- self.download_queue = Queue()
- #self.status_queue = Queue()
- self.f_relation = [0,0]
+ self.f_relation = [0, 0]
self.lock = Lock()
self.py_downloading = [] # files downloading
- self.occ_plugins = [] #occupied plugins
+ self.occ_plugins = [] #occupied plugins
+ self.pause = False
def create_thread(self):
""" creates thread for Py_Load_File and append thread to self.threads
@@ -66,7 +64,10 @@ class Thread_List(object):
def get_job(self):
# return job if suitable, otherwise send thread idle
self.lock.acquire()
-
+
+ if self.pause:
+ return None
+
pyfile = None
for i in range(len(self.py_load_files)):
if not self.py_load_files[i].modul.__name__ in self.occ_plugins:
@@ -77,7 +78,7 @@ class Thread_List(object):
self.py_downloading.append(pyfile)
if not pyfile.plugin.multi_dl:
self.occ_plugins.append(pyfile.modul.__name__)
- self.parent.logger.info('start downloading ' + pyfile.url )
+ self.parent.logger.info('start downloading ' + pyfile.url)
self.lock.release()
return pyfile
@@ -90,12 +91,11 @@ class Thread_List(object):
self.occ_plugins.remove(pyfile.modul.__name__)
self.py_downloading.remove(pyfile)
- self.parent.logger.info('finished downloading ' + pyfile.url + ' @'+str(pyfile.status.get_speed())+'kb/s')
+ self.parent.logger.info('finished downloading ' + pyfile.url + ' @' + str(pyfile.status.get_speed()) + 'kb/s')
- if pyfile.plugin.plugin_config['type'] == "container":
+ if pyfile.plugin.props['type'] == "container":
self.parent.extend_links(pyfile.plugin.links)
- #remove from list, logging etc
self.lock.release()
return True
@@ -111,7 +111,6 @@ class Thread_List(object):
def append_py_load_file(self, py_load_file):
py_load_file.id = len(self.py_load_files)
self.py_load_files.append(py_load_file)
- self.download_queue.put(py_load_file)
self.f_relation[1] += 1
self.select_thread()