#!/usr/bin/env python3

# Copyright © 2025 Noah Vogt <noah@noahvogt.com>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import colorama

from PyQt5.QtWidgets import (  # pylint: disable=no-name-in-module
    QApplication,
)

from utils import (
    log,
    DatePickerDialog,
    get_mp3_file_via_picker_dialog,
)
from recording import upload_sermon_audiofile
from input import validate_manual_filedrop_sermon_upload_config


if __name__ == "__main__":
    colorama.init()
    validate_manual_filedrop_sermon_upload_config()

    app = QApplication([])
    dialog = DatePickerDialog()
    if dialog.exec_():
        date = dialog.selected_date()
        yyyy_mm_dd = date.toString("yyyy-MM-dd")
        log("Selected date: {}".format(yyyy_mm_dd))
        file_path = get_mp3_file_via_picker_dialog()
        if file_path:
            del app
            upload_sermon_audiofile(file_path, yyyy_mm_dd)
        else:
            log("No file selected.")
