Refactor/code cleanup (#37)
* fix imports remove unused imports use full import path sort import (1. Standard Library, 2. Third-Party, 3. Local) in alphabetic. * - remove: Method 3 from src.core.ytsage_downlader:cleanup_subtitle_file - it could delete the subtitle file of other movies if it present in same directory as it scane recursively. - refactor: migrate from os.path to pathlib.Path for path handling - Replaced os.path methods with pathlib.Path to improve readability, - avoid repeatation. - cross-platform compatibility, and maintain cleaner code. - improve: enhance code readability - Standardized string literals to use double quotes for consistency - Removed unnecessary spaces to maintain cleaner formatting - Applied code formatting for better readability and maintainability * - add: ytsage_constants.py file for one place to store all constants. - imporve: return type hint for function. - remove: src/gui/ytsage_gui_dialogs.py file to avoid repetation - src/gui/dialogs is renamed to src/gui/ytsage_gui_dialogs for same naming convection. (future import will remains same) - use of src/gui/ytsage_gui_dialogs/__init__.py to import the dilogs modules. - change: variable self.parent to self._parent so it does not overwrite the parent() - add type hint checking. * - refactor: QMetaObject.invokeMethod to Signal - I encounter error with incokeMethod. Could not solve it. - So, Changed it to Signal to match app code language. - implement: the ytsage_constants.py to code - remove: unnecessary logic - remove: repetitive code logic. - update: yt-dlp logic for src\gui\ytsage_gui_dialogs\ytsage_dialogs_update:_update_binary - yt-dlp update logic will use `yt-dlp -U` * refactor: remove unused imports and streamline code formatting across multiple files
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
import sys
|
||||
|
||||
from PySide6.QtWidgets import QApplication, QMessageBox
|
||||
from src.gui.ytsage_gui_main import YTSageApp # Import the main application class from ytsage_gui_main
|
||||
from src.core.ytsage_yt_dlp import check_ytdlp_binary, setup_ytdlp, get_ytdlp_executable_path # Import the new yt-dlp setup functions
|
||||
|
||||
from src.core.ytsage_logging import logger
|
||||
from src.core.ytsage_yt_dlp import ( # Import the new yt-dlp setup functions
|
||||
check_ytdlp_binary,
|
||||
setup_ytdlp,
|
||||
)
|
||||
from src.gui.ytsage_gui_main import YTSageApp # Import the main application class from ytsage_gui_main
|
||||
|
||||
|
||||
def show_error_dialog(message):
|
||||
error_dialog = QMessageBox()
|
||||
@@ -12,28 +18,29 @@ def show_error_dialog(message):
|
||||
error_dialog.setWindowTitle("Error")
|
||||
error_dialog.exec()
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
logger.info("Starting YTSage application")
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
|
||||
# Get the expected binary path and check if it exists
|
||||
expected_path = get_ytdlp_executable_path()
|
||||
if not check_ytdlp_binary():
|
||||
# No app-specific binary found, show setup dialog regardless of Python package
|
||||
logger.warning("No yt-dlp binary found, starting setup process")
|
||||
yt_dlp_path = setup_ytdlp()
|
||||
if yt_dlp_path == "yt-dlp": # If user canceled or something went wrong
|
||||
logger.warning("yt-dlp not configured properly")
|
||||
|
||||
window = YTSageApp() # Instantiate the main application class
|
||||
|
||||
window = YTSageApp() # Instantiate the main application class
|
||||
window.show()
|
||||
logger.info("Application window shown, entering main loop")
|
||||
sys.exit(app.exec())
|
||||
except Exception as e:
|
||||
logger.critical(f"Critical application error: {str(e)}", exc_info=True)
|
||||
show_error_dialog(f"Critical error: {str(e)}")
|
||||
logger.critical(f"Critical application error: {e}", exc_info=True)
|
||||
show_error_dialog(f"Critical error: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user