def check_file_dest_cloud(path_file_cloud): """check if file exist in destination""" lib_cm.message_write_to_console(ac, "check_files_cloud") file_is_online = False if os.path.isfile(path_file_cloud): filename = lib_cm.extract_filename(ac, path_file_cloud) lib_cm.message_write_to_console(ac, "vorhanden: " + path_file_cloud) db.write_log_to_db_a( ac, "Vorproduktion fuer extern in Cloud bereits vorhanden: " + filename, "k", "write_also_to_console") file_is_online = True return file_is_online
def check_file_source_cloud(path_file_source): """check if file exist in dropbox""" lib_cm.message_write_to_console(ac, "check_files_cloud") file_is_online = False if os.path.isfile(path_file_source): filename = lib_cm.extract_filename(ac, path_file_source) lib_cm.message_write_to_console(ac, "vorhanden: " + path_file_source) db.write_log_to_db_a( ac, "Vorproduktion von extern in Cloud vorhanden: " + filename, "k", "write_also_to_console" ) file_is_online = True return file_is_online
def check_file_dest_play_out(path_file_dest, sendung): """check if file exist in play-out""" lib_cm.message_write_to_console(ac, "check if file exist in play-out") success_file = None if os.path.isfile(path_file_dest): filename = lib_cm.extract_filename(ac, path_file_dest) lib_cm.message_write_to_console(ac, "vorhanden: " + filename) db.write_log_to_db_a( ac, "Vorproduktion von extern bereits in Play_Out vorhanden: " + sendung[12], "f", "write_also_to_console" ) success_file = True return success_file
def check_file_dest_play_out(path_file_dest, sendung): """check if file exist in play-out""" lib_cm.message_write_to_console(ac, "check if file exist in play-out") success_file = None if os.path.isfile(path_file_dest): filename = lib_cm.extract_filename(ac, path_file_dest) lib_cm.message_write_to_console(ac, "vorhanden: " + filename) db.write_log_to_db_a(ac, "Vorproduktion von extern bereits in Play_Out vorhanden: " + sendung[12], "f", "write_also_to_console") success_file = True return success_file
def check_file_source(path_f_source, sendung): """check if file exist in source""" lib_cm.message_write_to_console(ac, "check if file exist in source") success_file = True if not os.path.isfile(path_f_source): filename = lib_cm.extract_filename(ac, path_f_source) lib_cm.message_write_to_console(ac, u"nicht vorhanden: " + filename) db.write_log_to_db_a(ac, u"Vorproduktion fuer extern noch nicht in Play_Out vorhanden: " + sendung[12], "f", "write_also_to_console") success_file = False return success_file
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, log_message, "x", "write_also_to_console") return lib_cm.message_write_to_console(ac, u"returncode 0") lib_cm.message_write_to_console(ac, p[0]) lib_cm.message_write_to_console(ac, u"returncode 1") lib_cm.message_write_to_console(ac, p[1]) # search for success-msg, if not found: -1 cmd_output_1 = string.find(p[1], "100%") lib_cm.message_write_to_console(ac, cmd_output_1) # if found, position, otherwise -1 if cmd_output_1 != -1: log_message = "Externe VP heruntergeladen... " db.write_log_to_db_a(ac, log_message, "k", "write_also_to_console") file_orig = lib_cm.extract_filename(ac, db.ac_config_1[7]) lib_cm.message_write_to_console(ac, file_orig) lib_cm.message_write_to_console(ac, dest_file) #os.rename(file_orig, dest_file) return True else: # no 100% message, trying to find another error, here in german! cmd_output_1 = string.find(p[1], "gibt es nicht") if cmd_output_1 != -1: db.write_log_to_db_a(ac, "Datei auf ftp-Server nicht vorhanden: " + url_source_file, "t", "write_also_to_console") else: db.write_log_to_db_a(ac, ac.app_errorslist[1] + u"100% beim Download nicht erreicht...", "x", "write_also_to_console") filename_ftp_temp = lib_cm.extract_filename(ac,
db.write_log_to_db_a(ac, log_message, "x", "write_also_to_console") return lib_cm.message_write_to_console(ac, u"returncode 0") lib_cm.message_write_to_console(ac, p[0]) lib_cm.message_write_to_console(ac, u"returncode 1") lib_cm.message_write_to_console(ac, p[1]) # search for success-msg, if not found: -1 cmd_output_1 = string.find(p[1], "100%") lib_cm.message_write_to_console(ac, cmd_output_1) # if found, position, otherwise -1 if cmd_output_1 != -1: log_message = "Externe News heruntergeladen... " db.write_log_to_db_a(ac, log_message, "k", "write_also_to_console") file_orig = lib_cm.extract_filename(ac, db.ac_config_1[7]) lib_cm.message_write_to_console(ac, file_orig) lib_cm.message_write_to_console(ac, dest_file) os.rename(file_orig, dest_file) return True else: db.write_log_to_db_a(ac, ac.app_errorslist[1] + u"100% beim Download nicht erreicht...", "x", "write_also_to_console") return None def copy_media_db(path_file_source, dest_file): """copy audiofile""" success_copy = None try:
db.write_log_to_db_a(ac, log_message, "x", "write_also_to_console") return lib_cm.message_write_to_console(ac, u"returncode 0") lib_cm.message_write_to_console(ac, p[0]) lib_cm.message_write_to_console(ac, u"returncode 1") lib_cm.message_write_to_console(ac, p[1]) # search for success-msg, if not found: -1 cmd_output_1 = string.find(p[1], "100%") lib_cm.message_write_to_console(ac, cmd_output_1) # if found, position, otherwise -1 if cmd_output_1 != -1: log_message = "Externe News heruntergeladen... " db.write_log_to_db_a(ac, log_message, "k", "write_also_to_console") file_orig = lib_cm.extract_filename(ac, db.ac_config_1[7]) lib_cm.message_write_to_console(ac, file_orig) lib_cm.message_write_to_console(ac, dest_file) os.rename(file_orig, dest_file) return True else: db.write_log_to_db_a( ac, ac.app_errorslist[1] + u"100% beim Download nicht erreicht...", "x", "write_also_to_console") return None def copy_media_db(path_file_source, dest_file): """copy audiofile""" success_copy = None try:
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, log_message, "x", "write_also_to_console") return lib_cm.message_write_to_console(ac, u"returncode 0") lib_cm.message_write_to_console(ac, p[0]) lib_cm.message_write_to_console(ac, u"returncode 1") lib_cm.message_write_to_console(ac, p[1]) # search for success-msg, if not found: -1 cmd_output_1 = string.find(p[1], "100%") lib_cm.message_write_to_console(ac, cmd_output_1) # if found, position, otherwise -1 if cmd_output_1 != -1: log_message = "Externe VP heruntergeladen... " db.write_log_to_db_a(ac, log_message, "k", "write_also_to_console") file_orig = lib_cm.extract_filename(ac, db.ac_config_1[7]) lib_cm.message_write_to_console(ac, file_orig) lib_cm.message_write_to_console(ac, dest_file) # os.rename(file_orig, dest_file) return True else: # no 100% message, trying to find another error, here in german! cmd_output_1 = string.find(p[1], "gibt es nicht") if cmd_output_1 != -1: db.write_log_to_db_a( ac, "Datei auf ftp-Server nicht vorhanden: " + url_source_file, "t", "write_also_to_console" ) else: db.write_log_to_db_a( ac, ac.app_errorslist[1] + u"100% beim Download nicht erreicht...", "x", "write_also_to_console" )