Ejemplo n.º 1
0
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())
Ejemplo n.º 2
0
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()
Ejemplo n.º 3
0
def treat_entry(entry, security_id, torrents):
    """ treats each of the rss entries """
    esperar = False
    titulo = entry["title_detail"]["value"]
    url = entry["link"]
    fecha = entry["published_parsed"]
    documento = {"titulo": titulo, "url": url, "fecha": from_datetime_struct_to_timestamp(fecha)}
    document = torrents.find_one(documento)
    if document:
        print "'", unicode_functions.printable_string(titulo), "' already processed, skipping"
    else:
        is_included = included(titulo)
        is_excluded = excluded(titulo)
        documento["incluido"] = is_included
        documento["excluido"] = is_excluded
        if is_excluded:
            print "filter discards '", unicode_functions.printable_string(titulo), "'"
        else:
            if is_included:
                print "downloading ", unicode_functions.printable_string(titulo), " at url ", url
                html = download_file.download_url_html(url)
                esperar = True
                magnets = download_file.download_magnet_in_html_regex(html)
                for magnet in magnets:
                    DownloadStation.add_task(magnet, security_id)
                documento["descargado"] = True
            else:
                print "filter does not include '", unicode_functions.printable_string(titulo), "'"
                # notify_mobile_phone(titulo + " not included", url)  # lets you download it manually
                notify_mobile_phone(titulo + " not included", "")
                documento["notificado"] = True
        torrents.insert(documento)
    if esperar:
        print "waiting 10 seg..."
        time.sleep(10)  # wait 10 seconds trying not to trigger server DOS counter measures
Ejemplo n.º 4
0
def treat_entry(entry, security_id, torrents):
    """ treats each of the rss entries """
    esperar = False
    titulo = entry['title_detail']['value']
    url = entry['link']
    fecha = entry['published_parsed']
    documento = {
        "titulo": titulo,
        "url": url,
        "fecha": from_datetime_struct_to_timestamp(fecha)
    }
    document = torrents.find_one(documento)
    if document:
        print "'", unicode_functions.printable_string(
            titulo), "' already processed, skipping"
    else:
        is_included = included(titulo)
        is_excluded = excluded(titulo)
        documento['incluido'] = is_included
        documento['excluido'] = is_excluded
        if is_excluded:
            print "filter discards '", unicode_functions.printable_string(
                titulo), "'"
        else:
            if is_included:
                print "downloading ", unicode_functions.printable_string(
                    titulo), " at url ", url
                html = download_file.download_url_html(url)
                esperar = True
                magnets = download_file.download_magnet_in_html_regex(html)
                for magnet in magnets:
                    DownloadStation.add_task(magnet, security_id)
                documento['descargado'] = True
            else:
                print "filter does not include '", unicode_functions.printable_string(
                    titulo), "'"
                #notify_mobile_phone(titulo + " not included", url)  # lets you download it manually
                notify_mobile_phone(titulo + " not included", "")
                documento['notificado'] = True
        torrents.insert(documento)
    if esperar:
        print "waiting 10 seg..."
        time.sleep(
            10
        )  # wait 10 seconds trying not to trigger server DOS counter measures
Ejemplo n.º 5
0
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()
Ejemplo n.º 6
0
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())