diff options
| -rw-r--r-- | Core.py | 6 | ||||
| -rw-r--r-- | Plugins/Plugin.py | 4 | ||||
| -rw-r--r-- | Plugins/RapidshareCom.py | 13 | ||||
| -rw-r--r-- | Plugins/UploadedTo.py | 2 | ||||
| -rw-r--r-- | Py_Load_File.py | 8 | ||||
| -rw-r--r-- | download_thread.py | 12 | 
6 files changed, 28 insertions, 17 deletions
| @@ -217,7 +217,7 @@ class Core(object):      def __new_py_load_file(self, url, plugin):          plugin_name = plugin.__name__ -        new_file = PyLoadFile(plugin, plugin_name, url) +        new_file = PyLoadFile(self, plugin, url)          new_file.download_folder = self.download_folder          self.thread_list.append_py_load_file(new_file)          return True @@ -239,8 +239,8 @@ class Core(object):          while True:              self._get_links(self.link_file)              self.thread_list.status() -            self._test_print_status() -            sleep(0.1) +           # self._test_print_status() +            sleep(1)              if len(self.thread_list.threads) == 0:                  break diff --git a/Plugins/Plugin.py b/Plugins/Plugin.py index 591d32594..933c72004 100644 --- a/Plugins/Plugin.py +++ b/Plugins/Plugin.py @@ -19,7 +19,7 @@ class Plugin():          pluginProp ['author_email'] = "nn@nn.de"          self.pluginProp = pluginProp           self.parent = parent -        self.html = "" +        self.html = None          self.time_plus_wait = None #time() + wait in seconds      def set_parent_status(self): @@ -46,7 +46,7 @@ class Plugin():              self.download_html()      def get_file_name(self): -        pass +        raise NotImplementedError      def wait_until(self):          if self.html != None: diff --git a/Plugins/RapidshareCom.py b/Plugins/RapidshareCom.py index 69a8cf933..427b43518 100644 --- a/Plugins/RapidshareCom.py +++ b/Plugins/RapidshareCom.py @@ -25,7 +25,7 @@ class RapidshareCom(Plugin):          pluginProp ['author_email'] = "nn@nn.de"          self.pluginProp = pluginProp           self.parent = parent -        self.html = "" +        self.html = None          self.html_old = None         #time() where loaded the HTML          self.time_plus_wait = None   #time() + wait in seconds @@ -47,7 +47,7 @@ class RapidshareCom(Plugin):          self.html_old = time()          file_server_url = re.search(r"<form action=\"(.*?)\"", self.html).group(1)          free_user_encode = urllib.urlencode({"dl.start" : "Free"}) -        self.free_user_html = urllib2.urlopen(file_server_url, free_user_encode).read() +        self.html = urllib2.urlopen(file_server_url, free_user_encode).read()          if re.search(r".*is already downloading.*", self.html) != None:              self.time_plus_wait = time() + 10*60          try: @@ -57,7 +57,8 @@ class RapidshareCom(Plugin):              if re.search(r".*Currently a lot of users.*", self.html) != None:                  return ('wait', 2*60)                wait_seconds = re.search(r"var c=(.*);.*", self.html).group(1) -            self.time_plus_wait = time() + wait_seconds +	    print "wait" ,wait_seconds +            self.time_plus_wait = time() + int(wait_seconds)      def file_exists(self):          """ returns True or False  @@ -78,8 +79,11 @@ class RapidshareCom(Plugin):              self.download_html()          if (self.html_old + 5*60) > time(): # nach einiger zeit ist die file_url nicht mehr aktuell              self.download_html() +	if(time() < self.time_plus_wait): +		return ('wait', self.time_plus_wait - time()) +          file_url_pattern = r".*name=\"dlf\" action=\"(.*)\" method=.*" -        return re.search(file_url_pattern, self.html).group(1) +        return ('download', (re.search(file_url_pattern, self.html).group(1), self.get_file_name()))      def get_file_name(self):          if self.html == None: @@ -91,7 +95,6 @@ class RapidshareCom(Plugin):          if self.html == None:              self.download_html()          return self.time_plus_wait -              def __call__(self):          return self.plugin_name diff --git a/Plugins/UploadedTo.py b/Plugins/UploadedTo.py index 0a3b7ef71..dad5db3a9 100644 --- a/Plugins/UploadedTo.py +++ b/Plugins/UploadedTo.py @@ -20,7 +20,7 @@ class UploadedTo(Plugin):          pluginProp ['author_email'] = "spoob@gmx.de"          self.pluginProp = pluginProp           self.parent = parent -        self.html = "" +        self.html = None          self.html_old = None         #time() where loaded the HTML          self.time_plus_wait = None   #time() + wait in seconds diff --git a/Py_Load_File.py b/Py_Load_File.py index 0abb6c8b9..6463379a1 100644 --- a/Py_Load_File.py +++ b/Py_Load_File.py @@ -3,13 +3,15 @@ from download_thread import Status  class PyLoadFile:      """ represents the url or file      """ -    def __init__(self, parent, url): +    def __init__(self, parent, plugin, url):          self.parent = parent          self.id = None -        self.plugin = None +	pluginClass = getattr(plugin, plugin.__name__) +        self.plugin = pluginClass(self)          self.url = url +	self.filename = "filename"          self.download_folder = "" -        self.status = Status() +        self.status = Status(self.id)      def _get_my_plugin():          plugins = parent.get_avail_plugins() diff --git a/download_thread.py b/download_thread.py index 7808d22f1..5fe132245 100644 --- a/download_thread.py +++ b/download_thread.py @@ -59,7 +59,6 @@ class Status(object):  class Download_Thread(threading.Thread):      def __init__(self, parent):          threading.Thread.__init__(self) -        self.setDaemon(1)          self.shutdown = False          self.parent = parent          self.start() @@ -75,8 +74,8 @@ class Download_Thread(threading.Thread):      def download(self, py_load_file):          url = py_load_file.url -        type, params = py_load_file.plugin.get_file_url(url) -        status = Status(py_load_file.id, self.parent.status_queue) +        type, params = py_load_file.plugin.get_file_url() +        status = py_load_file.status          #missing wenn datei nicht auf server vorhanden          #if type=="check":              #return params @@ -85,9 +84,16 @@ class Download_Thread(threading.Thread):              #print "Datei auf Server nicht vorhanden: " + params              ##im logger eintragen das datei auf server nicht vorhanden ist              #warning("Datei auf Server nicht voblocks_readrhanden: " + url) +	#if type in 'wait': +	 #   status.type = "waiting" +	  #  print params +	   # sleep(params+1) +          if type in 'download': +	    print "download"              status.type = "downloading"              #startet downloader              status.url, status.filename = params +	    print status.url, status.filename              urllib.urlretrieve(status.url, py_load_file.download_folder + "/" + status.filename, status)              self.shutdown = True | 
