Example #1
0
def improve_and_upload_buttons(message):
    """
    :return: a button to improve video(send top 4 tracks for the video) or upload a new video
    or change parameters buttons
    """
    try:
        language_phrase = phrase_on_language(message, "improve_and_upload_buttons")
    except:
        create_users_data_dir(message)
        language_phrase = phrase_on_language(message, "improve_and_upload_buttons")

    keyboard = telebot.types.InlineKeyboardMarkup()

    keyboard.row(
        telebot.types.InlineKeyboardButton('πŸ“š ' + language_phrase[0], callback_data='improve')
    )
    keyboard.row(
        telebot.types.InlineKeyboardButton('πŸ“‹ ' + language_phrase[3], callback_data='change_music_params')
    )
    keyboard.row(
        telebot.types.InlineKeyboardButton('πŸ”„ ' + language_phrase[2], callback_data='upload_new_video')
    )

    bot.send_message(message.chat.id, language_phrase[1],
                     reply_markup=keyboard, disable_notification=True)
Example #2
0
def opt_answers_in_dict_from_buttons(answer, n_question):
    """

    :return: save user answer from buttons on a special question in DB
    """
    full_phrases_path = os.path.join(os.getcwd(), 'templates', 'phrases')
    language_answers = phrase_on_language(answer, 'answers')

    with open(full_phrases_path + ".json", "r", encoding="utf-8") as f:
        phrases = json.load(f)
        ru_answers = phrases['answers']['ru']
        ru_questions = phrases['questions']['ru']

    ru_question = ru_questions[n_question]

    answer_text = ''
    try:
        answer_text = answer.data
    except:
        pass

    answer_text = answer_text[:len(answer_text) - 1]

    full_survey_answer_path = os.path.join(os.getcwd(), 'templates',
                                           'answers_on_survey')

    try:
        user_chat_id = str(answer.from_user.id)
        if user_chat_id not in os.listdir("users_data") or user_chat_id + "_data.json" \
                not in os.listdir(os.path.join('users_data', user_chat_id)):
            create_users_data_dir(answer)
            print("opt_answers_in_dict_from_buttons ERROR")

        with open(full_survey_answer_path + ".json", "r",
                  encoding='utf-8') as f:
            survey_dict = json.load(f)
            # username = create_username_for_db(answer)
            print("answer", answer)
            try:
                update_answer(answer_text, language_answers, ru_answers,
                              survey_dict, ru_question, answer,
                              full_survey_answer_path, n_question,
                              user_chat_id)

            except:
                with open(full_phrases_path + ".json", "r",
                          encoding='utf-8') as f:
                    phrases = json.load(f)
                    language_answers = phrases['answers']['uk']

                update_answer(answer_text, language_answers, ru_answers,
                              survey_dict, ru_question, answer,
                              full_survey_answer_path, n_question,
                              user_chat_id)

    except:
        print(
            'answers_in_dict_from_buttons error - if answer_text in language_answers: or'
            ' json.dump(survey_dict, f, ensure_ascii=False, indent=4)')
Example #3
0
def upload_less_20(message):
    try:
        language_phrases = phrase_on_language(message, "take_input")

    except:
        create_users_data_dir(message)
        language_phrases = phrase_on_language(message, "take_input")

    bot.send_message(message.chat.id, language_phrases[1], disable_notification=True)
def clean_audio_change_upload(message, user_chat_id):
    """

    :return: clean audios downloaded from user dir which are top 4 special for the video
    and update last_upload a video to understand active users in general
    """
    try:
        # delete musics_for_video dir if it exists to start work with a new video
        audios_path = os.path.join(os.getcwd(), 'users_data', user_chat_id, 'musics_for_video')

        try:
            language_phrases = phrase_on_language(message, 'get_video_less_20')
            error_phrases = phrase_on_language(message, 'send_video_to_user')

        except:
            create_users_data_dir(message)
            language_phrases = phrase_on_language(message, 'get_video_less_20')
            error_phrases = phrase_on_language(message, 'send_video_to_user')

        chat_id = create_chat_id_for_db(message)

        if user_chat_id not in os.listdir("users_data") or user_chat_id + "_data.json" \
                not in os.listdir(os.path.join('users_data', user_chat_id)):
            create_users_data_dir(message)
            print("clean_audio_change_upload ERROR")

        # last upload refresh
        full_file_path = os.path.join(os.getcwd(), 'users_data', user_chat_id, user_chat_id)
        with open(full_file_path + "_data" + ".json", "r", encoding='utf-8') as f:
            file_user_data = json.load(f)
            file_user_data['last_upload'] = datetime.today().strftime('%Y-%m-%d-%H:%M:%S')

        with open(full_file_path + "_data" + ".json", "w") as f:
            json.dump(file_user_data, f, ensure_ascii=False, indent=4)

        try:
            if os.listdir(audios_path):
                for the_file in os.listdir(audios_path):
                    file_path = os.path.join(audios_path, the_file)
                    try:
                        if os.path.isfile(file_path):
                            os.unlink(file_path)
                    except Exception as e:
                        print(e)

        except:
            print('musics_for_video dir is empty')

    except:
        print('get_video error - general')
        try:
            bot.send_message(message.chat.id, error_phrases[4])
        except:
            bot.send_message(message.chat.id, "Something went wrong ! Please. upload your video once more")

    return chat_id, language_phrases, error_phrases
Example #5
0
def update_n_videos_last_upload(message, user_chat_id):
    try:
        print(
            "\n update_n_videos_last_upload function ------------------------------------"
        )

        # create user_dir if it is not in the users_data dir
        if user_chat_id not in os.listdir("users_data") or user_chat_id + "_data.json" \
                not in os.listdir(os.path.join('users_data', user_chat_id)):
            create_users_data_dir(message)
            print("update_n_videos_last_upload ERROR")

        full_file_path = os.path.join(os.getcwd(), 'users_data', user_chat_id,
                                      user_chat_id)
        with open(full_file_path + "_data" + ".json", "r",
                  encoding='utf-8') as f:
            file_user_data = json.load(f)
            file_user_data["n_videos"] = file_user_data.get("n_videos", 0) + 1
            file_user_data["n_surveys"] = file_user_data.get("n_surveys", 0)

            # data in users_data table
            update_sql('users_data', 'n_videos', user_chat_id,
                       file_user_data["n_videos"])
            update_sql('users_data', 'last_upload', user_chat_id,
                       file_user_data["last_upload"])
            try:
                print("n_surveys n_videos", file_user_data["n_surveys"],
                      file_user_data["n_videos"])
                # after 3 and 23 video each user should give a feedback.
                # if not - send the survey each 10th video untill he will not give a feedback
                if file_user_data["n_videos"] == 3:
                    get_survey_button(message)

                elif file_user_data["n_videos"] == 23:
                    get_survey_button(message)

                elif file_user_data["n_surveys"] == 0 and \
                        file_user_data["n_videos"] % 10 == 0:
                    get_survey_button(message)

                elif file_user_data["n_surveys"] == 1 and file_user_data["n_videos"] >= 8 and \
                        file_user_data["n_videos"] % 10 == 0:
                    get_survey_button(message)

            except:
                print("get_survey_button(message) ERROR")

        with open(full_file_path + "_data" + ".json", "w") as f:
            json.dump(file_user_data, f, ensure_ascii=False, indent=4)
    except:
        print("update_n_videos_last_upload ERROR - no such file")
Example #6
0
def informate_all(message, language):
    try:
        user_chat_id = str(message.chat.id)
    except:
        user_chat_id = str(message.message.chat.id)

    full_file_path = os.path.join(os.getcwd(), 'users_data', user_chat_id,
                                  user_chat_id + '_data')

    try:
        with open(full_file_path + ".json", "r", encoding='utf-8') as f:
            user_data = json.load(f)
    except:
        create_users_data_dir(message)
        user_data = {}
    languages = list(set(['ua', 'uk', 'ru']) - set([language]))
    if is_informate_all(message, languages[0]):
        bot.send_message(user_chat_id,
                         'already informate_all_' + languages[0].upper())
    elif is_informate_all(message, languages[1]):
        bot.send_message(user_chat_id,
                         'already informate_all_' + languages[1].upper())
    else:
        try:
            user_data['informate_all'][language] = True
        except:
            user_data['informate_all'] = {language: True}

        try:
            files_path = [
                value['photo']
                for value in user_data['input_informate_all_values'][language]
                if list(value.keys())[0] == 'photo'
            ]
            for file_path in files_path:
                os.remove(file_path)
        except:
            print("already deleted informating messages")
        try:
            user_data['input_informate_all_values'][language] = []
        except:
            user_data['input_informate_all_values'] = {}

        bot.send_message(user_chat_id, 'message recording started')

        try:
            with open(full_file_path + ".json", "w") as f:
                json.dump(user_data, f)
        except:
            print("informate_all ERROR - no such file")
def write_in_user_file(message, data, key_name, user_chat_id="", function=""):
    if user_chat_id == "":
        try:
            user_chat_id = str(message.chat.id)
        except:
            user_chat_id = str(message.from_user.id)

    print("write_in_user_file")
    try:
        write_in_file(data, key_name, user_chat_id, function)

    except:
        create_users_data_dir(message)
        write_in_file(data, key_name, user_chat_id, function)
Example #8
0
def get_survey_button(message):
    try:
        language_phrase = phrase_on_language(message, "survey_buttons")
    except:
        create_users_data_dir(message)
        language_phrase = phrase_on_language(message, "survey_buttons")

    keyboard = telebot.types.InlineKeyboardMarkup()

    keyboard.row(
        telebot.types.InlineKeyboardButton(language_phrase[0],
                                           callback_data='survey'))

    bot.send_message(message.chat.id,
                     'Γ°ΕΈβ€œΒ¨Γ°ΕΈβ€œΛ†Γ°ΕΈβ€œΕ  ' + language_phrase[1],
                     reply_markup=keyboard)
Example #9
0
def opt_answers_in_dict(answer, n_question):
    """

    :return: save user answer on a special question in DB
    """
    full_phrases_path = os.path.join(os.getcwd(), 'templates', 'phrases')

    try:
        user_chat_id = str(answer.chat.id)
        if user_chat_id not in os.listdir("users_data") or user_chat_id + "_data.json" \
                not in os.listdir(os.path.join('users_data', user_chat_id)):
            create_users_data_dir(answer)
            print("opt_answers_in_dict_from_buttons ERROR")

        with open(full_phrases_path + ".json", "r", encoding="utf-8") as f:
            phrases = json.load(f)
            ru_questions = phrases['questions']['ru']

        ru_question = ru_questions[n_question]

        full_phrases_path = os.path.join(os.getcwd(), 'templates',
                                         'answers_on_survey')
        with open(full_phrases_path + ".json", "r", encoding='utf-8') as f:
            survey_dict = json.load(f)

            # update data in answers_on_survey table SQL
            # username = create_username_for_db(answer)
            username = Survey.query.filter_by(
                chat_id=user_chat_id).first().username
            print("username", username)
            print(" answer", answer)

            user_answer = username + ':   ' + answer.text
            survey_dict[ru_question].append(user_answer)
            # create_user_answers(answer, answer.text)
            update_question_answer_db(user_chat_id, answer.from_user,
                                      n_question, answer.text)
            # update_sql('answers_on_survey', 'question' + str(n_question + 1), user_chat_id, answer.text)

        with open(full_phrases_path + ".json", "w", encoding='utf-8') as f:
            json.dump(survey_dict, f, ensure_ascii=False, indent=4)

    except:
        print(
            'answers_in_dict error - ru_questions = phrases[\'questions\'][\'ru\']'
            ' or update_sql(\'answers_on_survey\',')
Example #10
0
def save_photo(message, language):
    try:
        user_chat_id = str(message.chat.id)
    except:
        user_chat_id = str(message.message.chat.id)

    full_file_path = os.path.join(os.getcwd(), 'users_data', user_chat_id,
                                  user_chat_id + '_data')

    try:
        with open(full_file_path + ".json", "r", encoding='utf-8') as f:
            user_data = json.load(f)
    except:
        create_users_data_dir(message)
        user_data = {}

    image_id = message.photo[-1].file_id
    image_info = bot.get_file(image_id)

    downloaded_file = bot.download_file(image_info.file_path)

    image_path = os.path.join(os.getcwd(), 'users_data', user_chat_id,
                              image_id + '.jpg')
    try:
        with open(image_path, 'wb') as f:
            f.write(downloaded_file)
    except:
        print('file exist')

    try:
        user_data['input_informate_all_values'][language].append(
            {'photo': image_path})
    except:
        user_data['input_informate_all_values'][language] = [{
            'photo':
            image_path
        }]

    bot.send_message(user_chat_id, "image was saved")
    try:
        with open(full_file_path + ".json", "w") as f:
            json.dump(user_data, f)
    except:
        print("save_photo ERROR")
def phrase_on_language(message, function, user_chat_id=""):
    """

    :param message: a message to translate
    :param function: a function from which we translate phrases
    to find the special phrase in phrases.json
    :return: translated phrase on the user language
    """
    if user_chat_id == "":
        if isinstance(message, dict):
            user_chat_id = message["chat"]["id"]
        else:
            try:
                user_chat_id = str(message.chat.id)
            except:
                user_chat_id = str(message.message.chat.id)

    full_file_path = os.path.join(os.getcwd(), 'users_data', user_chat_id,
                                  user_chat_id)
    full_phrases_path = os.path.join(os.getcwd(), 'templates', 'phrases')

    try:
        with open(full_file_path + '_data' + ".json", "r",
                  encoding='utf-8') as f:
            user_data = json.load(f)
            language = user_data["language"]

    except:
        create_users_data_dir(message)
        print(
            'phrase_on_language error - user_data = json.load(f) or language_phrase = phrases[function][language]'
        )
        if db.session.query(Users.id).filter_by(chat_id=user_chat_id).scalar():
            user_db = Users.query.filter_by(chat_id=user_chat_id).first()
            language = user_db.language

        else:
            language = "uk"

    with open(full_phrases_path + ".json", "r", encoding='utf-8') as f:
        phrases = json.load(f)
        language_phrase = phrases[function][language]

    return language_phrase
Example #12
0
def survey_buttons(message):
    """
    :return: a button starting a survey
    """
    try:
        language_phrase = phrase_on_language(message, "survey_buttons")
    except:
        create_users_data_dir(message)
        language_phrase = phrase_on_language(message, "survey_buttons")

    keyboard = telebot.types.InlineKeyboardMarkup()

    keyboard.row(
        telebot.types.InlineKeyboardButton(language_phrase[0],
                                           callback_data='survey'))

    bot.send_message(message.chat.id,
                     language_phrase[1],
                     reply_markup=keyboard)
Example #13
0
def keyboard_buttons_survey(message, question):
    try:
        language_answers_button = phrase_on_language(message, "answers")
        questions = phrase_on_language(message, 'questions')
    except:
        create_users_data_dir(message)
        language_answers_button = phrase_on_language(message, "answers")
        questions = phrase_on_language(message, 'questions')

    n_question = questions.index(question)
    keyboard = telebot.types.InlineKeyboardMarkup()

    for i in range(len(language_answers_button)):
        keyboard.row(
            telebot.types.InlineKeyboardButton(
                language_answers_button[i],
                callback_data=language_answers_button[i] + str(n_question)))

    bot.send_message(message.chat.id, question, reply_markup=keyboard)
Example #14
0
def update_question_answer_db(user_chat_id, message, n_question, ru_answer):
    full_file_path = os.path.join(os.getcwd(), 'users_data', user_chat_id,
                                  user_chat_id)
    print(":update_question_answer_db")
    if user_chat_id not in os.listdir("users_data") or user_chat_id + "_data.json" \
            not in os.listdir(os.path.join('users_data', user_chat_id)):
        create_users_data_dir(message)
        print("get file_user_data['n_surveys'] ERROR")

    with open(full_file_path + "_data" + ".json", "r", encoding='utf-8') as f:
        file_user_data = json.load(f)
        if file_user_data['n_surveys'] >= 1:
            update_sql(
                'answers_on_survey', 'question' + str(n_question + 1),
                user_chat_id + "_survey_" +
                str(file_user_data['n_surveys'] + 1), ru_answer)
        else:
            update_sql('answers_on_survey', 'question' + str(n_question + 1),
                       user_chat_id, ru_answer)
Example #15
0
def start_upload_video_buttons(message):
    """
    :return: buttons with Upload more or less 20 mb video
    """
    try:
        language_phrase = phrase_on_language(message, "start_upload_video_buttons")
    except:
        create_users_data_dir(message)
        language_phrase = phrase_on_language(message, "start_upload_video_buttons")

    keyboard = telebot.types.InlineKeyboardMarkup()

    keyboard.row(
        telebot.types.InlineKeyboardButton(language_phrase[0], callback_data='upload_video2')
    )

    keyboard.row(
        telebot.types.InlineKeyboardButton(language_phrase[1], callback_data='video_more_20')
    )

    bot.send_message(message.chat.id, language_phrase[2],
                     reply_markup=keyboard, disable_notification=True)
Example #16
0
def make_continue_editing_button(message, user_chat_id, keyboard, function=""):
    delete_previous_video(user_chat_id)

    try:
        language_phrase = phrase_on_language(message, "improve_and_upload_buttons")
    except:
        create_users_data_dir(message)
        language_phrase = phrase_on_language(message, "improve_and_upload_buttons")

    if function == "single_button":
        keyboard = telebot.types.InlineKeyboardMarkup()

    # keyboard.row(
    #     telebot.types.InlineKeyboardButton(language_phrase[4],
    #                                        callback_data='continue_edit')
    # )
    keyboard.row(
        telebot.types.InlineKeyboardButton('πŸ”„ ' + language_phrase[2], callback_data='upload_new_video')
    )
    if function == "single_button":
        bot.send_message(user_chat_id, "⛔️‼️ " + language_phrase[5],
                                 reply_markup=keyboard, disable_notification=True)
Example #17
0
def more_20_mb_videos_buttons(message, user_data=""):
    if isinstance(message, dict):
        user_chat_id = message["chat"]["id"]
        message_chat_id = int(user_chat_id)

    else:
        user_chat_id = str(message.chat.id)
        message_chat_id = message.chat.id

    try:
        language_phrases = phrase_on_language(message, 'get_video_less_20')

    except:
        create_users_data_dir(message)
        language_phrases = phrase_on_language(message, 'get_video_less_20')

    if user_data == "":
        user_data = Users.query.filter_by(chat_id=user_chat_id).first()

    user_id_code_web = user_data.user_id_code_web
    print("\n more_20_mb_videos_buttons function ------------------------------------")
    print("user_id_code_web0", user_id_code_web)
    if user_id_code_web is None:
        user_id_code_web = renovate_id_code_db(user_chat_id)

    print("user_id_code_web1", user_id_code_web)
    delete_previous_video(user_chat_id)

    keyboard = telebot.types.InlineKeyboardMarkup()
    flask_url = "{}upload?user_id_code_web={}".format(HEROKU_WEB_URL, user_id_code_web)
    keyboard.row(
        telebot.types.InlineKeyboardButton('🎬️ ' + language_phrases[3], url=flask_url)
    )
    make_continue_editing_button(message, user_chat_id, keyboard, "")
    # bot.send_message(message_chat_id, "😒 " + language_phrases[10] + " 😎", disable_notification=True)
    bot.send_message(message_chat_id, language_phrases[7],
                     reply_markup=keyboard, disable_notification=True)
Example #18
0
def payment_buttons(message, query_data=""):
    try:
        language_phrases = phrase_on_language(message, 'get_video_less_20')

    except:
        create_users_data_dir(message)
        language_phrases = phrase_on_language(message, 'get_video_less_20')

    if isinstance(message, dict):
        user_chat_id = message["chat"]["id"]
    else:
        user_chat_id = str(message.chat.id)

    print("\n payment_buttons function ------------------------------------")
    print("message before update", message)
    if query_data != "":
        # save last function before payment to start this function when user get a subscription on site
        update_sql("users_data", "last_function_before_pay",
                   str(message.chat.id), PREMIUM_FUNCTIONS[query_data])

        file_name = """{"file_name": ""}"""
        try:
            if message.document.file_name is not None and message.document.file_name != False and \
                    message.document.file_name != True:
                file_name = """{"file_name": \"""" + str(message.document.file_name) + "\"}"
                print("file_name", file_name)
        except:
            print("message.document.file_name ERRor")

        message_chat_id = """{"id": \"""" + str(message.chat.id) + "\"" + "}"

        update_sql("users_data", "last_message_before_pay",
                   str(message.chat.id), '{' + """"chat": {}, "document": {}""".format(message_chat_id,
                                                                                       str(file_name)).replace("\'",
                                                                                                               "\"") + '}')

    keyboard = telebot.types.InlineKeyboardMarkup()
    user_data = Users.query.filter_by(chat_id=user_chat_id).first()

    buy_user_id_web = user_data.buy_user_id_web
    if buy_user_id_web is None:
        buy_user_id_web = renovate_buy_user_id_web(user_chat_id)

    flask_url = "{}buy_subscription?buy_user_id_web={}".format(HEROKU_WEB_URL, buy_user_id_web)

    keyboard.row(
        telebot.types.InlineKeyboardButton(language_phrases[6][0], callback_data='pay_in_telegram')
    )

    keyboard.row(
        telebot.types.InlineKeyboardButton(language_phrases[6][1], url=flask_url)
    )

    keyboard.row(
        telebot.types.InlineKeyboardButton("βœ– " + language_phrases[8], callback_data="upload_new_video")
    )

    bot.send_message(message.chat.id, language_phrases[5])

    bot.send_message(message.chat.id, language_phrases[9].format(
        UPLOAD_TERM, TERM_OF_USE, PRIVACY_POLICY),
                     parse_mode=telegram.ParseMode.HTML,
                     reply_markup=keyboard,
                     disable_web_page_preview=True)
Example #19
0
def informate_all_end(message, language):
    try:
        user_chat_id = str(message.chat.id)
    except:
        user_chat_id = str(message.message.chat.id)

    full_file_path = os.path.join(os.getcwd(), 'users_data', user_chat_id,
                                  user_chat_id + '_data')
    try:
        with open(full_file_path + ".json", "r", encoding='utf-8') as f:
            user_data = json.load(f)
    except:
        create_users_data_dir(message)
        user_data = {}

    try:
        if user_data['informate_all'][language]:
            user_data['informate_all'][language] = False

            try:
                input_values = user_data['input_informate_all_values'][
                    language]

                for user in Users.query.filter_by(language=language).all():
                    print(user.username, user.chat_id)
                    time.sleep(1)
                    try:
                        for input_value in input_values:
                            # if list(input_value.keys())[0] == 'text':
                            try:
                                bot.send_message(user.chat_id,
                                                 input_value['text'])
                                # else:
                            except:
                                try:
                                    print("send photo to users")
                                    image = open(input_value['photo'], 'rb')
                                    bot.send_photo(user.chat_id, image)
                                    image.close()
                                except:
                                    print(
                                        "image = open(input_value['photo'], 'rb') ERROR"
                                    )

                    except Exception as error:
                        print("informate_all_end ERROR - no such chat", error)

                try:
                    files_path = [
                        value['photo'] for value in
                        user_data['input_informate_all_values'][language]
                        if list(value.keys())[0] == 'photo'
                    ]

                    for file_path in files_path:
                        os.remove(file_path)
                except:
                    print(
                        "already deleted informating messages in informate_all_end"
                    )

                user_data['input_informate_all_values'][language] = []

            except:
                print("Keyerror in informate_all_end")
                user_data['input_informate_all_values'][language] = []

    except:
        print("general ERROR in informate_all_end")
        user_data['informate_all'] = {}
        user_data['informate_all'][language] = False

    try:
        with open(full_file_path + ".json", "w") as f:
            json.dump(user_data, f)
    except:
        print("informate_all_end ERROR - no such file")
def send_other_musics(message):
    """
    :return: 4 songs with 60 sec duration - other top 4 special for this video
    """
    try:
        language_phrases = phrase_on_language(message, "send_video_to_user")

    except:
        create_users_data_dir(message)
        language_phrases = phrase_on_language(message, "send_video_to_user")

    user_chat_id = str(message.chat.id)
    error_phrases = phrase_on_language(message, 'send_video_to_user')

    full_file_path = os.path.join(os.getcwd(), 'users_data', user_chat_id,
                                  user_chat_id)
    try:
        with open(full_file_path + 'musics5_for_video' + ".json",
                  'r') as musics5_file:
            musics5 = json.load(musics5_file)

    except:
        bot.send_message(message.chat.id, language_phrases[3])

    audios_path = os.path.join(os.getcwd(), 'users_data', user_chat_id,
                               'musics_for_video')
    try:
        os.mkdir(audios_path)
    except OSError:
        print("Creation of the directory %s failed or this directory exists" %
              audios_path)
    else:
        print("Successfully created the directory %s " % audios_path)

    audio_names = []
    # if dir is empty - save
    urls = []
    titles = []
    n_selected_music = ''

    bot.send_message(message.chat.id, language_phrases[5])
    bot.send_chat_action(message.chat.id, 'upload_audio')

    try:
        for i in range(len(musics5["extra_music"])):
            url = musics5["extra_music"][i]["download-link"]
            title = musics5["extra_music"][i]["title"]
            title = re.sub(r"[#%!@*']", "", title)
            title = re.findall(r"[\w']+", title)
            title = '_'.join(title)
            titles.append(title)
            audio_name = os.path.join(audios_path, title + '.mp3')
            audio_names.append(audio_name)

            # add | to url to get audio_name from download_url func
            # and do not download soundtracks which are in the dir
            if not title + '.mp3' in os.listdir(audios_path) \
                    and not title + '_trim.mp3' in os.listdir(audios_path):
                print("added title", title)
                url += '|' + audio_name
                urls.append(url)
    except:
        print('send_other_musics error -  range(len(musics5["extra_music"]))')
        bot.send_message(message.chat.id, error_phrases[4])

    try:
        # checking if this audio_names not in dir for get similar music -> change genre ->
        # -> get similar music and do not download musics that are in the dir
        if urls:
            # Run several multiple threads. Each call will take the next element in urls list
            # download urls
            pool = ThreadPool(len(urls))
            results = pool.map(download_url, urls)
            pool.close()

            proc = []

            # cut soundtracks which are longer 60 sec
            for url in urls:
                print("audio_name0", url)

                p = Process(target=cut_music, args=(url, ))
                p.start()
                proc.append(p)

                n_selected_music = musics5["selected_music"]

            for p in proc:
                p.join()

            gc.collect()

        try:
            with open(full_file_path + ".json", "r") as f:
                data = json.loads(f.read())

            n_selected_music = data["selected_music"]

        except:
            print('send_other_musics error - data = json.loads(f.read())')
            bot.send_message(message.chat.id, error_phrases[4])

    except:
        print('send_other_musics error -  range(len(musics5["extra_music"])) '
              'or  pool = '
              'ThreadPool(len(musics5["extra_music"]))')
        bot.send_message(message.chat.id, error_phrases[4])

    if n_selected_music != '':
        try:
            with open(full_file_path + "_data" + ".json",
                      "r",
                      encoding='utf-8') as f:
                file_user_data = json.load(f)
                file_user_data["n_selected_music"] = n_selected_music

            with open(full_file_path + "_data" + ".json", "w") as f:
                json.dump(file_user_data, f)
        except:
            print(
                'send_other_musics error - file_user_data["n_selected_music"] = n_selected_music'
            )
            bot.send_message(message.chat.id, error_phrases[4])

        try:
            language_phrases = phrase_on_language(message, "send_other_musics")

        except:
            create_users_data_dir(message)
            language_phrases = phrase_on_language(message, "send_other_musics")

        audios = []
        # add mark to name to trimmed audios which now are less than 60 sec
        # it is special to delete a full audio from dir and save time
        for audio_name in audio_names:
            try:
                try:
                    audio = open(audio_name, 'rb')
                except:
                    pos = audio_name.rfind('.')
                    audio_name = audio_name[:pos] + "_trim" + audio_name[pos:]
                    audio = open(audio_name, 'rb')
                audios.append(audio)

            except:
                print('send_other_musics error - audio = open(audio_name')
                bot.send_message(message.chat.id, error_phrases[4])

        n_on_button_audios = [0 for i in range(5)]
        n_audio = 1
        for i in range(len(n_on_button_audios)):
            if i == n_selected_music:
                n_on_button_audios[i] = 0

            else:
                n_on_button_audios[i] = n_audio
                n_audio += 1

        try:
            for i in range(len(musics5["extra_music"])):
                if n_on_button_audios[i] != 0:
                    if i == 0:
                        bot.send_audio(message.chat.id, audios[i])

                    else:
                        bot.send_audio(message.chat.id,
                                       audios[i],
                                       disable_notification=True)

        except:
            pass
        length_cycle = len(audios)

        keyboard = telebot.types.InlineKeyboardMarkup()

        n_audio_buttons = []
        for i in range(length_cycle):
            if n_on_button_audios[i] != 0:
                callback_button = telebot.types.InlineKeyboardButton(
                    text=str(n_on_button_audios[i]),
                    callback_data='audio_' + str(i))
                n_audio_buttons.append(callback_button)

        keyboard.add(*n_audio_buttons)
        bot.send_message(message.chat.id,
                         language_phrases[1],
                         reply_markup=keyboard)

        for audio in audios:
            audio.close()

    else:
        print("send_other_musics ERROR")
        bot.send_message(message.chat.id, error_phrases[4])