def move_finished_to_destination(): print "moving finished tasks to destination folder" security_id = General.login(session_name()) tasks = DownloadStation.get_tasks(security_id) # for each task in download station for task in tasks["data"]["tasks"]: # where task has ended seeding if task["status"] == "finished": title = unicode_functions.welcome_string(task["title"]) id = task["id"] for include in includes: # if the task was included automatically if include["cadena"].lower() in title.lower(): # we check if destination folder exists info = FileStation.get_info(include["destino"], security_id) if info["success"]: destino = info["data"]["files"][0] if "code" in destino and destino["code"] == 408: print "the directory does not exist, we create it" norm = os.path.normpath(destino["path"]) nombre = os.path.basename(norm) path = os.path.dirname(norm) FileStation.create_folder(path, nombre, security_id) fichero_a_mover = download_dir() + "/" + title if FileStation.move(fichero_a_mover, destino["path"], security_id): print "moved ", fichero_a_mover, " to ", destino["path"], ", eliminando tarea" if DownloadStation.delete_task(id, security_id): print "deleted task ", id # say.say("ya esta disponible el fichero " + title + " en el NAS") else: print "hubo un problema moviendo fichero ", title else: print "error obtaining info about ", include["destino"] General.logout(session_name())
def download_previously_not_included(): print "searching includes that were previously skipped" connection = get_mongo_client() security_id = General.login(session_name()) torrents = connection.descargas.torrents """ we go through includes checking if something that was not included neither excluded can be now marked as included """ for include in includes: # print "checking include ", include['cadena'], " to see if we left something..." documento = {"titulo": re.compile(include["cadena"], re.IGNORECASE), "incluido": False, "excluido": False} for doc in torrents.find(documento): # we check if it has been downloaded by exact title titulo = doc["titulo"] url = doc["url"] if excluded(titulo): print "se encontro ", titulo, " que esta incluido por ", include[ "cadena" ], " pero no se descarga por estar tambien excluido" else: encontrado = torrents.find_one({"titulo": titulo}) if "descargado" not in encontrado or encontrado["descargado"] is False: print "downloading ", titulo, " at url ", url html = download_file.download_url_html(url) magnets = download_file.download_magnet_in_html_regex(html) for magnet in magnets: DownloadStation.add_task(magnet, security_id) encontrado["descargado"] = True encontrado["incluido"] = True torrents.save(encontrado) print "updated document to remember that it was already downloaded, waiting 10 seg..." time.sleep(10) # wait 10 seconds trying not to trigger server DDOS counter measures General.logout(session_name()) connection.close()
def test(): try: id = General.login('test') ds_shares = list_shares(id) for share in ds_shares['data']['shares']: print share ds_files = list('/public/downloaded', id) for file in ds_files['data']['files']: if not file['isdir']: print file General.logout('test') except: print "error..."
def read_elitetorrent(): print "reading data from elitetorrent" d = feedparser.parse('http://www.elitetorrent.net/rss.php') if d['status'] == 200: print('status ok, interpreting data') connection = get_mongo_client() torrents = connection.descargas.torrents # respuestas_rss = connection.descargas.respuestas_rss security_id = General.login(session_name()) for theEntry in d['entries']: treat_entry(theEntry, security_id, torrents) connection.close() General.logout(session_name()) else: print("status received from server is not 200, giving up...")
def read_elitetorrent(): print "reading data from elitetorrent" d = feedparser.parse("http://www.elitetorrent.net/rss.php") if d["status"] == 200: print ("status ok, interpreting data") connection = get_mongo_client() torrents = connection.descargas.torrents # respuestas_rss = connection.descargas.respuestas_rss security_id = General.login(session_name()) for theEntry in d["entries"]: treat_entry(theEntry, security_id, torrents) connection.close() General.logout(session_name()) else: print ("status received from server is not 200, giving up...")
def download_previously_not_included(): print "searching includes that were previously skipped" connection = get_mongo_client() security_id = General.login(session_name()) torrents = connection.descargas.torrents """ we go through includes checking if something that was not included neither excluded can be now marked as included """ for include in includes: # print "checking include ", include['cadena'], " to see if we left something..." documento = { "titulo": re.compile(include['cadena'], re.IGNORECASE), "incluido": False, "excluido": False } for doc in torrents.find(documento): # we check if it has been downloaded by exact title titulo = doc['titulo'] url = doc['url'] if excluded(titulo): print "se encontro ", titulo, " que esta incluido por ", include['cadena'], \ " pero no se descarga por estar tambien excluido" else: encontrado = torrents.find_one({'titulo': titulo}) if "descargado" not in encontrado or encontrado[ 'descargado'] is False: print "downloading ", titulo, " at url ", url html = download_file.download_url_html(url) magnets = download_file.download_magnet_in_html_regex(html) for magnet in magnets: DownloadStation.add_task(magnet, security_id) encontrado['descargado'] = True encontrado['incluido'] = True torrents.save(encontrado) print "updated document to remember that it was already downloaded, waiting 10 seg..." time.sleep( 10 ) # wait 10 seconds trying not to trigger server DDOS counter measures General.logout(session_name()) connection.close()
def move_finished_to_destination(): print "moving finished tasks to destination folder" security_id = General.login(session_name()) tasks = DownloadStation.get_tasks(security_id) # for each task in download station for task in tasks['data']['tasks']: # where task has ended seeding if task['status'] == 'finished': title = unicode_functions.welcome_string(task['title']) id = task['id'] for include in includes: # if the task was included automatically if include['cadena'].lower() in title.lower(): # we check if destination folder exists info = FileStation.get_info(include['destino'], security_id) if info['success']: destino = info['data']['files'][0] if 'code' in destino and destino['code'] == 408: print "the directory does not exist, we create it" norm = os.path.normpath(destino['path']) nombre = os.path.basename(norm) path = os.path.dirname(norm) FileStation.create_folder(path, nombre, security_id) fichero_a_mover = download_dir() + '/' + title if FileStation.move(fichero_a_mover, destino['path'], security_id): print "moved ", fichero_a_mover, " to ", destino[ 'path'], ", eliminando tarea" if DownloadStation.delete_task(id, security_id): print "deleted task ", id #say.say("ya esta disponible el fichero " + title + " en el NAS") else: print "hubo un problema moviendo fichero ", title else: print "error obtaining info about ", include['destino'] General.logout(session_name())