summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Plugins/LixIn.py1
-rw-r--r--Plugins/RelinkUs.py1
-rw-r--r--Plugins/StealthTo.py1
-rw-r--r--Plugins/ZippyshareCom.py1
-rw-r--r--module/file_list.py39
-rw-r--r--module/thread_list.py15
-rw-r--r--pyLoadCore.py37
7 files changed, 49 insertions, 46 deletions
diff --git a/Plugins/LixIn.py b/Plugins/LixIn.py
index 409c72f6d..ee7d99a62 100644
--- a/Plugins/LixIn.py
+++ b/Plugins/LixIn.py
@@ -3,7 +3,6 @@
import re
-from module.unescape import unescape
from Plugin import Plugin
class LixIn(Plugin):
diff --git a/Plugins/RelinkUs.py b/Plugins/RelinkUs.py
index 51176ec31..31f592759 100644
--- a/Plugins/RelinkUs.py
+++ b/Plugins/RelinkUs.py
@@ -3,7 +3,6 @@
import re
-from module.unescape import unescape
from Plugin import Plugin
class RelinkUs(Plugin):
diff --git a/Plugins/StealthTo.py b/Plugins/StealthTo.py
index 6d59f4b44..c904a07c3 100644
--- a/Plugins/StealthTo.py
+++ b/Plugins/StealthTo.py
@@ -3,7 +3,6 @@
import re
-from module.unescape import unescape
from Plugin import Plugin
class StealthTo(Plugin):
diff --git a/Plugins/ZippyshareCom.py b/Plugins/ZippyshareCom.py
index 8470fdcb1..61408f925 100644
--- a/Plugins/ZippyshareCom.py
+++ b/Plugins/ZippyshareCom.py
@@ -3,7 +3,6 @@
import re
import urllib
-from time import time
from Plugin import Plugin
class ZippyshareCom(Plugin):
diff --git a/module/file_list.py b/module/file_list.py
index c9a96635f..fe4080807 100644
--- a/module/file_list.py
+++ b/module/file_list.py
@@ -22,31 +22,47 @@ LIST_VERSION = 1
import cPickle
from Py_Load_File import PyLoadFile
-
+
class File_List(object):
def __init__(self, core):
self.core = core
self.files = []
self.data = {'version': LIST_VERSION}
- self.id = 0
- #self.load()
+ self.load()
def new_pyfile(self, url):
url = url.replace("\n", "")
pyfile = PyLoadFile(self.core, url)
pyfile.download_folder = self.core.config['download_folder']
- pyfile.id = self.id
- self.id += 1
+ pyfile.id = self.get_id()
return pyfile
def append(self, url):
- self.files.append(self.new_pyfile(url))
+ new_file = self.new_pyfile(url)
+ self.files.append(new_file)
+ self.data[new_file.id] = Data(url)
def extend(self, urls):
for url in urls:
self.append(url)
+ def remove(self, pyfile):
+
+ if pyfile in self.files:
+ self.files.remove(pyfile)
+
+ del self.data[pyfile.id]
+
+ def get_id(self):
+ """return a free id"""
+ id = 1
+ while id in self.data.keys():
+ id += 1
+
+ return id
+
+
def save(self):
output = open('links.pkl', 'wb')
cPickle.dump(self.data, output, -1)
@@ -61,6 +77,13 @@ class File_List(object):
if obj['version'] < LIST_VERSION:
obj = {'version': LIST_VERSION}
- self.data = obj
+ for key, value in obj.iteritems():
+ if key != 'version':
+ self.append(value.url)
-
+ self.core.logger.info("Links loaded: "+ str(int(len(obj) - 1)))
+
+
+class Data():
+ def __init__(self, url):
+ self.url = url \ No newline at end of file
diff --git a/module/thread_list.py b/module/thread_list.py
index 62131b20e..54a17e318 100644
--- a/module/thread_list.py
+++ b/module/thread_list.py
@@ -17,13 +17,11 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
###
-#python
from __future__ import with_statement
import re
import subprocess
import time
import urllib2
-
from threading import RLock
from download_thread import Download_Thread
@@ -31,11 +29,9 @@ from download_thread import Download_Thread
class Thread_List(object):
def __init__(self, parent):
self.parent = parent
- self.list = parent.file_list
+ self.list = parent.file_list #file list
self.threads = []
self.max_threads = int(self.parent.config['max_downloads'])
- # self.py_load_files = [] # files in queque
- # self.f_relation = [0, 0]
self.lock = RLock()
self.py_downloading = [] # files downloading
self.occ_plugins = [] #occupied plugins
@@ -55,7 +51,7 @@ class Thread_List(object):
self.threads.remove(thread)
def select_thread(self):
- """ select a thread
+ """ create all threads
"""
while len(self.threads) < self.max_threads:
self.create_thread()
@@ -89,6 +85,7 @@ class Thread_List(object):
def job_finished(self, pyfile):
+ """manage completing download"""
self.lock.acquire()
if not pyfile.plugin.multi_dl:
@@ -99,6 +96,8 @@ class Thread_List(object):
if pyfile.status.type == "finished":
self.parent.logger.info('Download finished: ' + pyfile.url + ' @' + str(pyfile.status.get_speed()) + 'kb/s')
+ self.list.remove(pyfile)
+
if pyfile.plugin.props['type'] == "container":
self.list.extend(pyfile.plugin.links)
@@ -112,6 +111,10 @@ class Thread_List(object):
with open(self.parent.config['failed_file'], 'a') as f:
f.write(pyfile.url + "\n")
+ self.list.remove(pyfile)
+
+ self.list.save()
+
self.lock.release()
return True
diff --git a/pyLoadCore.py b/pyLoadCore.py
index a4178768e..667cc3473 100644
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -35,11 +35,10 @@ from sys import path
from sys import stdout
from time import sleep
-from module.Py_Load_File import PyLoadFile
+from module.file_list import File_List
from module.remote.RequestObject import RequestObject
from module.remote.SocketServer import ServerThread
from module.thread_list import Thread_List
-from module.file_list import File_List
class Core(object):
""" pyLoad main
@@ -65,13 +64,12 @@ class Core(object):
self.logger.info(_("Downloadtime: %s") % self.is_dltime()) # debug only
+ path.append(self.config['plugin_folder'])
+ self.create_plugin_index()
self.file_list = File_List(self)
self.thread_list = Thread_List(self)
- path.append(self.config['plugin_folder'])
- self.create_plugin_index()
-
self.init_server()
def read_config(self):
@@ -99,12 +97,6 @@ class Core(object):
self.logger.info(_("created index of plugins"))
-# def _get_links(self, link_file):
-# """ funktion nur zum testen ohne gui bzw. tui
-# """
-# links = open(link_file, 'r').readlines()
-# self.extend_links(links)
-
def read_links(self):
"""read links from txt"""
txt = open(self.config['link_file'], 'r')
@@ -113,19 +105,13 @@ class Core(object):
txt.close()
- #self.file_list.save()
-
- #txt = open(self.config['link_file'], 'w')
- #txt.write("")
- #txt.close()
+ self.file_list.save()
+ if links:
+ self.logger.info("Parsed links from " + self.config['link_file'] + ": " + str(len(self.file_list.data)))
-# def append_link(self, link):
-# if link not in self.thread_list.get_loaded_urls():
-# self.__new_py_load_file(link.replace("\n", ""))
-
-# def extend_links(self, links):
-# for link in links:
-# self.append_link(link)
+ txt = open(self.config['link_file'], 'w')
+ txt.write("")
+ txt.close()
#def check_update(self):
#"""checks newst version
@@ -150,11 +136,6 @@ class Core(object):
print _("could not create %s") % legend
exit()
-# def __new_py_load_file(self, url):
-# new_file = PyLoadFile(self, url)
-# new_file.download_folder = self.config['download_folder']
-# self.thread_list.append_py_load_file(new_file)
-# return True
def init_logger(self, level):