def filepaths(d_pattern, l_path_title, item, sendung): """concatenate paths and filenames""" success_file = True try: # Verschiebung von Datum Erstsendung new_date = sendung[2] + datetime.timedelta(days=-item[5]) lib_cm.message_write_to_console(ac, new_date.strftime(d_pattern)) if item[1].strip() == "T": # from dropbox path_source = lib_cm.check_slashes(ac, db.ac_config_servpath_b[5]) path_file_source = ( path_source + l_path_title[0] # + sendung[0][2].strftime('%Y_%m_%d') + l_path_title[1].rstrip()) + new_date.strftime(d_pattern) + l_path_title[1].rstrip() ) if item[3].strip() == "T": # from ftp # url_base = db.ac_config_1[3].encode(ac.app_encode_out_strings) # url_source_file = db.ac_config_1[7].encode(ac.app_encode_out_strings) path_source = lib_cm.check_slashes(ac, db.ac_config_1[3]) path_file_source = ( path_source + l_path_title[0] # + sendung[0][2].strftime('%Y_%m_%d') + l_path_title[1].rstrip()) + new_date.strftime(d_pattern) + l_path_title[1].rstrip() ) # it or mag else sendung if sendung[4].strip() == "T" or sendung[5].strip() == "T": path_dest = lib_cm.check_slashes(ac, db.ac_config_servpath_a[1]) else: path_dest = lib_cm.check_slashes(ac, db.ac_config_servpath_a[2]) # replace special char # replace_uchar_sonderzeichen_with_latein path_file_dest = ( path_dest + str(sendung[8]) + "_" + lib_cm.replace_sonderzeichen_with_latein(sendung[16]) + "_" + lib_cm.replace_sonderzeichen_with_latein(sendung[13]) # + lib_cm.replace_uchar_sonderzeichen_with_latein(sendung[0][13]) + ".mp3" ) except Exception, e: log_message = ac.app_errorslist[5] + "fuer: " + sendung[11].encode("ascii", "ignore") + " " + str(e) db.write_log_to_db_a(ac, log_message, "x", "write_also_to_console") success_file = None
def filepaths(d_pattern, l_path_title, item, sendung): """concatenate paths and filenames""" success_file = True try: # Verschiebung von Datum Erstsendung new_date = sendung[2] + datetime.timedelta(days=-item[5]) lib_cm.message_write_to_console(ac, new_date.strftime(d_pattern)) if item[1].strip() == "T": # from dropbox path_source = lib_cm.check_slashes(ac, db.ac_config_servpath_b[5]) path_file_source = (path_source + l_path_title[0] #+ sendung[0][2].strftime('%Y_%m_%d') + l_path_title[1].rstrip()) + new_date.strftime(d_pattern) + l_path_title[1].rstrip()) if item[3].strip() == "T": # from ftp #url_base = db.ac_config_1[3].encode(ac.app_encode_out_strings) #url_source_file = db.ac_config_1[7].encode(ac.app_encode_out_strings) path_source = lib_cm.check_slashes(ac, db.ac_config_1[3]) path_file_source = (path_source + l_path_title[0] #+ sendung[0][2].strftime('%Y_%m_%d') + l_path_title[1].rstrip()) + new_date.strftime(d_pattern) + l_path_title[1].rstrip()) # it or mag else sendung if sendung[4].strip() == "T" or sendung[5].strip() == "T": path_dest = lib_cm.check_slashes(ac, db.ac_config_servpath_a[1]) else: path_dest = lib_cm.check_slashes(ac, db.ac_config_servpath_a[2]) # replace special char # replace_uchar_sonderzeichen_with_latein path_file_dest = (path_dest + str(sendung[8]) + "_" + lib_cm.replace_sonderzeichen_with_latein(sendung[16]) + "_" + lib_cm.replace_sonderzeichen_with_latein(sendung[13]) #+ lib_cm.replace_uchar_sonderzeichen_with_latein(sendung[0][13]) + ".mp3") except Exception, e: log_message = (ac.app_errorslist[5] + "fuer: " + sendung[11].encode('ascii', 'ignore') + " " + str(e)) db.write_log_to_db_a(ac, log_message, "x", "write_also_to_console") success_file = None
def encode_file(podcast_sendung): """recode mp3-files with lower rate""" lib_cm.message_write_to_console(ac, u"encode_file") # all cmds must be in the right charset c_lame_encoder = db.ac_config_etools[6].encode(ac.app_encode_out_strings) #lib_cm.message_write_to_console(ac, u"type c_lame_encoder") #lib_cm.message_write_to_console(ac, type(c_lame_encoder)) #lib_cm.message_write_to_console(ac, u"type podcast_sendung[1]") #lib_cm.message_write_to_console(ac, type(podcast_sendung[1])) c_id3_title = u"--tt".encode(ac.app_encode_out_strings) #lib_cm.message_write_to_console(ac, u"type( c_id3_title )") #lib_cm.message_write_to_console(ac, type(c_id3_title)) #c_id3_title_value = podcast_sendung[1].encode( ac.app_encode_out_strings ) c_id3_title_value_uni = (lib_cm.replace_sonderzeichen_with_latein( podcast_sendung[1])) c_id3_title_value = c_id3_title_value_uni.encode(ac.app_encode_out_strings) #lib_cm.message_write_to_console(ac, u"type( c_id3_title_value )") #lib_cm.message_write_to_console(ac, type(c_id3_title_value)) c_id3_author = u"--ta".encode(ac.app_encode_out_strings) #lib_cm.message_write_to_console(ac, u"type( c_id3_author )") #lib_cm.message_write_to_console(ac, type(c_id3_author)) id3_author_value_uni = (lib_cm.replace_sonderzeichen_with_latein( podcast_sendung[2]) + " " + lib_cm.replace_sonderzeichen_with_latein(podcast_sendung[3])) c_id3_author_value = id3_author_value_uni.encode(ac.app_encode_out_strings) #lib_cm.message_write_to_console(ac, u"type(c_id3_author_value )") #lib_cm.message_write_to_console(ac, type(c_id3_author_value)) # source sendung path_sendung_source = lib_cm.check_slashes(ac, db.ac_config_servpath_a[6]) c_source_file = (path_sendung_source.encode(ac.app_encode_out_strings) + podcast_sendung[0].encode(ac.app_encode_out_strings)) #lib_cm.message_write_to_console(ac, c_source_file) # source infotime und mag path_it_mg_source = lib_cm.check_slashes(ac, db.ac_config_servpath_a[5]) # infotime if podcast_sendung[4] == "T": #c_source_file = path_it_mg_source + podcast_sendung[0] c_source_file = (path_it_mg_source.encode(ac.app_encode_out_strings) + podcast_sendung[0].encode(ac.app_encode_out_strings)) # magazine if podcast_sendung[5] == "T": #c_source_file = path_it_mg_source + podcast_sendung[0] c_source_file = (path_it_mg_source.encode(ac.app_encode_out_strings) + podcast_sendung[0].encode(ac.app_encode_out_strings)) #lib_cm.message_write_to_console(ac, c_source_file) #lib_cm.message_write_to_console(ac, u"type(c_source_file)") #lib_cm.message_write_to_console(ac, type(c_source_file)) if not os.path.isfile(c_source_file): db.write_log_to_db_a(ac, ac.app_errorslist[5] + " " + podcast_sendung[0].encode(ac.app_encode_out_strings), "x", "write_also_to_console") return None # dest recoded file path_dest = lib_cm.check_slashes(ac, db.ac_config_1[10]) c_dest_file = (path_dest.encode(ac.app_encode_out_strings) + podcast_sendung[0].encode(ac.app_encode_out_strings)) #lib_cm.message_write_to_console(ac, c_dest_file) #lib_cm.message_write_to_console(ac, u"type(c_dest_file)") #lib_cm.message_write_to_console(ac, type(c_dest_file)) # das geht auch #p = subprocess.Popen([c_lame_encoder, "--add-id3v2", c_id3_title, #c_id3_title_value, #c_id3_author, c_id3_author_value, #c_source_file, c_dest_file ]).communicate() # ausgaben abfangen #p = subprocess.Popen([c_lame_encoder, "--add-id3v2", c_id3_title, #c_id3_title_value, c_id3_author, c_id3_author_value, #c_source_file, c_dest_file ], #stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() p = subprocess.Popen([c_lame_encoder, u"--add-id3v2".encode( ac.app_encode_out_strings), c_id3_title, c_id3_title_value, c_id3_author, c_id3_author_value, c_source_file, c_dest_file], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() 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-mesg, if not found: -1 n_encode_percent = string.find(p[1], "(100%)") n_encode_percent_1 = string.find(p[1], "(99%)") lib_cm.message_write_to_console(ac, n_encode_percent) c_complete = "no" # by short files 100% will not be reached, # therefor also let's take 99% if n_encode_percent == -1: # 100% not reached if n_encode_percent_1 != -1: # but 99 c_complete = "yes" else: c_complete = "yes" if c_complete == "yes": log_message = u"recoded_file: " + c_source_file db.write_log_to_db(ac, log_message, "k") #lib_cm.message_write_to_console(ac, "ok") return c_dest_file else: db.write_log_to_db_a(ac, ac.app_errorslist[2] + c_source_file, "x", "write_also_to_console") return None