示例#1
0
def check_and_work_on_files(roboting_sgs):
    """
    - search audio files
    - if found, work on it
    """
    lib_cm.message_write_to_console(ac, u"check_and_work_on_files")

    for item in roboting_sgs:
        lib_cm.message_write_to_console(ac, item[0].encode('ascii', 'ignore'))
        titel = item[0]
        # search shows
        sendungen = load_sg(titel)

        if sendungen is None:
            lib_cm.message_write_to_console(ac, "Keine Sendungen gefunden")
            continue

        for sendung in sendungen:
            db.write_log_to_db_a(ac, "Sendung fuer VP-Uebernahme gefunden: "
                    + sendung[11].encode('ascii', 'ignore'), "t",
                    "write_also_to_console")

            # path-file split with date-pattern
            if item[1].strip() == "T":
                d_pattern, l_path_title = date_pattern(item[2])
            if item[3].strip() == "T":
                d_pattern, l_path_title = date_pattern(item[4])
            if d_pattern is None:
                continue

            # concatenate path and filename
            success_file, path_file_source, path_file_dest = filepaths(
                                    d_pattern, l_path_title, item, sendung)
            if success_file is None:
                continue

            # check if file always in play-out
            file_in_play_out = check_file_dest_play_out(path_file_dest, sendung)
            if file_in_play_out is True:
                continue

            if item[1].strip() == "T":
                # check if file in dropbox
                file_in_cloud = check_file_source_cloud(path_file_source)
                if file_in_cloud is False:
                    continue

                # In Play-Out kopieren
                success_copy = audio_copy(path_file_source, path_file_dest)
                if success_copy is None:
                    continue

            if item[3].strip() == "T":
                # fetch file from ftp
                filename_ftp_temp = lib_cm.extract_filename(ac,
                                                        path_file_source)
                file_from_ftp = (fetch_media_ftp(
                                    path_file_dest, path_file_source))
                if file_from_ftp is None:
                    continue

                copy_success = copy_media_to_play_out(
                                    filename_ftp_temp, path_file_dest)
                if copy_success is None:
                    continue

            #audio_validate(path_file_dest)
            success_mp3validate = lib_au.validate_mp3(
                                        ac, db, lib_cm, path_file_dest)

            if success_mp3validate is None:
                db.write_log_to_db_a(ac, ac.app_errorslist[4],
                                        "x", "write_also_to_console")

            success_add_id3 = lib_au.add_id3(
                                ac, db, lib_cm, sendung, path_file_dest)

            if success_add_id3 is None:
                db.write_log_to_db_a(ac, ac.app_errorslist[7],
                                        "x", "write_also_to_console")
                continue

            # mp3gain must proceed after id3-tag is written
            # python-rgain has an error if no id3-tag is present
            #audio_mp3gain(path_file_dest)
            #success_add_rgain = lib_au.add_replaygain(
            #                    ac, db, lib_cm, path_file_dest)

            #if success_add_rgain is None:
            #    db.write_log_to_db_a(ac, ac.app_errorslist[3],
            #                            "x", "write_also_to_console")

            success_add_mp3gain = lib_au.add_mp3gain(
                                        ac, db, lib_cm, path_file_dest)

            if success_add_mp3gain is None:
                db.write_log_to_db_a(ac, ac.app_errorslist[3],
                                        "x", "write_also_to_console")

            reg_lenght(sendung, path_file_dest)

            # filename rechts von slash extrahieren
            if ac.app_windows == "no":
                filename = path_file_dest[string.rfind(path_file_dest,
                                                                    "/") + 1:]
            else:
                filename = path_file_dest[string.rfind(path_file_dest,
                                                                "\\") + 1:]

            #db.write_log_to_db_a(ac, "VP bearbeitet: " + filename, "i",
            #                                        "write_also_to_console")
            db.write_log_to_db_a(ac, "VP bearbeitet: " + filename, "n",
                                                    "write_also_to_console")
        db.write_log_to_db_a(ac,
                             u"Protokoll fuer Wiederholung: " + file_source,
                             "k", "write_also_to_console")
        db.write_log_to_db_a(ac, u"Protokoll kopiert nach: " + file_dest, "c",
                             "write_also_to_console")
    except Exception, e:
        db.write_log_to_db_a(ac, ac.app_errorslist[1], "x",
                             "write_also_to_console")
        log_message = u"copy_files_to_dir_retry Error: %s" % str(e)
        lib_cm.message_write_to_console(ac, log_message)
        db.write_log_to_db(ac, log_message, "x")
        return

    # audio-fx
    #audio_validate(file_dest)
    success_mp3validate = lib_au.validate_mp3(ac, db, lib_cm, file_dest)

    if success_mp3validate is None:
        db.write_log_to_db_a(ac, ac.app_errorslist[2], "x",
                             "write_also_to_console")

    success_add_id3 = lib_au.add_id3(ac, db, lib_cm, repeat_sendung, file_dest)

    if success_add_id3 is None:
        db.write_log_to_db_a(ac, ac.app_errorslist[5], "x",
                             "write_also_to_console")
    #audio_mp3gain(file_dest)
    #audio_id3tag(file_dest,
    #lib_cm.replace_uchar_sonderzeichen_with_latein(repeat_sendung[16]),
    #lib_cm.replace_uchar_sonderzeichen_with_latein(repeat_sendung[13]))
示例#3
0
        shutil.copy(file_source, file_dest)
        db.write_log_to_db_a(ac, u"Protokoll fuer Wiederholung: "
            + file_source, "k", "write_also_to_console")
        db.write_log_to_db_a(ac, u"Protokoll kopiert nach: " + file_dest,
            "c", "write_also_to_console")
    except Exception, e:
        db.write_log_to_db_a(ac, ac.app_errorslist[1], "x",
            "write_also_to_console")
        log_message = u"copy_files_to_dir_retry Error: %s" % str(e)
        lib_cm.message_write_to_console(ac, log_message)
        db.write_log_to_db(ac, log_message, "x")
        return

    # audio-fx
    #audio_validate(file_dest)
    success_mp3validate = lib_au.validate_mp3(
                                        ac, db, lib_cm, file_dest)

    if success_mp3validate is None:
        db.write_log_to_db_a(ac, ac.app_errorslist[2],
                                    "x", "write_also_to_console")

    success_add_id3 = lib_au.add_id3(
                                ac, db, lib_cm, repeat_sendung, file_dest)

    if success_add_id3 is None:
        db.write_log_to_db_a(ac, ac.app_errorslist[5],
                                        "x", "write_also_to_console")
    #audio_mp3gain(file_dest)
    #audio_id3tag(file_dest,
        #lib_cm.replace_uchar_sonderzeichen_with_latein(repeat_sendung[16]),
        #lib_cm.replace_uchar_sonderzeichen_with_latein(repeat_sendung[13]))
示例#4
0
def check_and_work_on_files(roboting_sgs):
    """
    - search audio files
    - if found, work on it
    """
    lib_cm.message_write_to_console(ac, u"check_and_work_on_files")

    for item in roboting_sgs:
        lib_cm.message_write_to_console(ac, item[0].encode("ascii", "ignore"))
        titel = item[0]
        # search shows
        sendungen = load_sg(titel)

        if sendungen is None:
            lib_cm.message_write_to_console(ac, "Keine Sendungen gefunden")
            continue

        for sendung in sendungen:
            db.write_log_to_db_a(
                ac,
                "Sendung fuer VP-Uebernahme gefunden: " + sendung[11].encode("ascii", "ignore"),
                "t",
                "write_also_to_console",
            )

            # path-file split with date-pattern
            if item[1].strip() == "T":
                d_pattern, l_path_title = date_pattern(item[2])
            if item[3].strip() == "T":
                d_pattern, l_path_title = date_pattern(item[4])
            if d_pattern is None:
                continue

            # concatenate path and filename
            success_file, path_file_source, path_file_dest = filepaths(d_pattern, l_path_title, item, sendung)
            if success_file is None:
                continue

            # check if file always in play-out
            file_in_play_out = check_file_dest_play_out(path_file_dest, sendung)
            if file_in_play_out is True:
                continue

            if item[1].strip() == "T":
                # check if file in dropbox
                file_in_cloud = check_file_source_cloud(path_file_source)
                if file_in_cloud is False:
                    continue

                # In Play-Out kopieren
                success_copy = audio_copy(path_file_source, path_file_dest)
                if success_copy is None:
                    continue

            if item[3].strip() == "T":
                # fetch file from ftp
                filename_ftp_temp = lib_cm.extract_filename(ac, path_file_source)
                file_from_ftp = fetch_media_ftp(path_file_dest, path_file_source)
                if file_from_ftp is None:
                    continue

                copy_success = copy_media_to_play_out(filename_ftp_temp, path_file_dest)
                if copy_success is None:
                    continue

            # audio_validate(path_file_dest)
            success_mp3validate = lib_au.validate_mp3(ac, db, lib_cm, path_file_dest)

            if success_mp3validate is None:
                db.write_log_to_db_a(ac, ac.app_errorslist[4], "x", "write_also_to_console")

            success_add_id3 = lib_au.add_id3(ac, db, lib_cm, sendung, path_file_dest)

            if success_add_id3 is None:
                db.write_log_to_db_a(ac, ac.app_errorslist[7], "x", "write_also_to_console")
                continue

            # mp3gain must proceed after id3-tag is written
            # python-rgain has an error if no id3-tag is present
            # audio_mp3gain(path_file_dest)
            # success_add_rgain = lib_au.add_replaygain(
            #                    ac, db, lib_cm, path_file_dest)

            # if success_add_rgain is None:
            #    db.write_log_to_db_a(ac, ac.app_errorslist[3],
            #                            "x", "write_also_to_console")

            success_add_mp3gain = lib_au.add_mp3gain(ac, db, lib_cm, path_file_dest)

            if success_add_mp3gain is None:
                db.write_log_to_db_a(ac, ac.app_errorslist[3], "x", "write_also_to_console")

            reg_lenght(sendung, path_file_dest)

            # filename rechts von slash extrahieren
            if ac.app_windows == "no":
                filename = path_file_dest[string.rfind(path_file_dest, "/") + 1 :]
            else:
                filename = path_file_dest[string.rfind(path_file_dest, "\\") + 1 :]

            # db.write_log_to_db_a(ac, "VP bearbeitet: " + filename, "i",
            #                                        "write_also_to_console")
            db.write_log_to_db_a(ac, "VP bearbeitet: " + filename, "n", "write_also_to_console")