Chore: Stop tracking files based on .gitignore update.

Untracked files matching the following rules:
- Rule "!.vscode/launch.json": 1 file
- Rule "downloaded/*": 1 file
This commit is contained in:
VALLONGOL 2025-09-15 11:17:38 +02:00
parent 6f0ca29327
commit e42fd65115
6 changed files with 38 additions and 22 deletions

2
.gitignore vendored
View File

@ -150,4 +150,4 @@ dmypy.json
*~ *~
_dist/* _dist/*
_build/* _build/*
_downloaded/* downloaded/*

1
.last_download_path Normal file
View File

@ -0,0 +1 @@
C:/src/____GitProjects/DownloaderYouTube/downloaded

View File

@ -6,19 +6,14 @@ import sys
from downloaderyoutube.gui.gui import App from downloaderyoutube.gui.gui import App
from downloaderyoutube.utils.logger import setup_basic_logging, shutdown_logging_system from downloaderyoutube.utils.logger import setup_basic_logging, shutdown_logging_system
# --- Logging Configuration -- # --- Logging Configuration ---
# This dictionary configures the logging system. It can be expanded later.
LOGGING_CONFIG = { LOGGING_CONFIG = {
"default_root_level": logging.DEBUG, "default_root_level": logging.DEBUG,
"specific_levels": { "specific_levels": {},
# You can set different levels for different modules if needed
# "pytube": logging.WARNING,
},
"format": "%(asctime)s [%(levelname)-8s] %(name)-25s : %(message)s", "format": "%(asctime)s [%(levelname)-8s] %(name)-25s : %(message)s",
"date_format": "%Y-%m-%d %H:%M:%S", "date_format": "%Y-%m-%d %H:%M:%S",
"enable_console": True, "enable_console": True,
"enable_file": False, # Set to True to enable file logging "enable_file": False,
# "file_path": "downloader_app.log", # Uncomment if file logging is enabled
} }
def main(): def main():
@ -26,20 +21,13 @@ def main():
Application entry point. Application entry point.
Initializes logging, creates the GUI, and starts the main loop. Initializes logging, creates the GUI, and starts the main loop.
""" """
# --- Diagnostic Prints ---
print("-" * 50)
print(f"--- PYTHON EXECUTABLE: {sys.executable}")
root = tk.Tk() root = tk.Tk()
# --- Setup Logging --- # --- Setup Logging ---
# This is a crucial step to initialize the queue-based logging system.
setup_basic_logging( setup_basic_logging(
root_tk_instance_for_processor=root, logging_config_dict=LOGGING_CONFIG root_tk_instance_for_processor=root, logging_config_dict=LOGGING_CONFIG
) )
# Get a logger for the main entry point
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logger.info("Application starting...") logger.info("Application starting...")
@ -51,7 +39,7 @@ def main():
Handles the window closing event to ensure a clean shutdown. Handles the window closing event to ensure a clean shutdown.
""" """
logger.info("Shutdown sequence initiated.") logger.info("Shutdown sequence initiated.")
# Properly shut down the logging system before closing the app app.save_last_path() # Save the path before closing
shutdown_logging_system() shutdown_logging_system()
root.destroy() root.destroy()

View File

@ -97,7 +97,7 @@ class Downloader:
logger.info(f"Starting download for URL: {url} with format: {format_id}") logger.info(f"Starting download for URL: {url} with format: {format_id}")
ydl_opts = { ydl_opts = {
"format": format_id, "format": format_id,
"outtmpl": f"{download_path}/%(title)s.%(ext)s", "outtmpl": f"{download_path}/%(uploader)s_%(title)s_%(format_note)s.%(ext)s",
"progress_hooks": [self._progress_hook], "progress_hooks": [self._progress_hook],
"logger": logger, "logger": logger,
"noplaylist": True, "noplaylist": True,

View File

@ -1,9 +1,9 @@
import logging import logging
import tkinter as tk import tkinter as tk
from tkinter import ttk, filedialog, messagebox from tkinter import ttk, filedialog, messagebox
from tkinter.scrolledtext import ScrolledText from tkinter.scrolledtext import ScrolledText
from typing import Optional, List, Dict, Any from typing import Optional, List, Dict, Any
import os
from downloaderyoutube.core.core import Downloader, VideoFormat from downloaderyoutube.core.core import Downloader, VideoFormat
from downloaderyoutube.utils.logger import add_tkinter_handler, get_logger from downloaderyoutube.utils.logger import add_tkinter_handler, get_logger
@ -11,6 +11,9 @@ from downloaderyoutube.utils.logger import add_tkinter_handler, get_logger
# Get a logger instance for this module # Get a logger instance for this module
logger = get_logger(__name__) logger = get_logger(__name__)
# --- Constants ---
CONFIG_FILE_NAME = ".last_download_path"
# A basic logging config dictionary for the Tkinter handler # A basic logging config dictionary for the Tkinter handler
LOGGING_CONFIG = { LOGGING_CONFIG = {
"colors": { "colors": {
@ -42,12 +45,13 @@ class App(tk.Frame):
self.duration_var = tk.StringVar(value="Durata: N/A") self.duration_var = tk.StringVar(value="Durata: N/A")
self.master.title("YouTube Downloader") self.master.title("YouTube Downloader")
self.master.geometry("800x650") # Increased height for new info panel self.master.geometry("800x650")
self.pack(fill=tk.BOTH, expand=True, padx=10, pady=10) self.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
self._create_widgets() self._create_widgets()
self._setup_logging_handler() self._setup_logging_handler()
self._load_last_path()
def _create_widgets(self): def _create_widgets(self):
"""Creates and lays out the widgets in the application window.""" """Creates and lays out the widgets in the application window."""
@ -117,6 +121,29 @@ class App(tk.Frame):
) )
logger.info("GUI logging handler configured.") logger.info("GUI logging handler configured.")
def _load_last_path(self):
"""Loads the last used download path from the config file."""
try:
if os.path.exists(CONFIG_FILE_NAME):
with open(CONFIG_FILE_NAME, "r") as f:
path = f.read().strip()
if os.path.isdir(path):
self.download_path = path
self.path_label.config(text=f"Saving to: {self.download_path}")
logger.info(f"Loaded last download path: {path}")
except Exception as e:
logger.warning(f"Could not load last download path: {e}")
def save_last_path(self):
"""Saves the current download path to the config file."""
if self.download_path:
try:
with open(CONFIG_FILE_NAME, "w") as f:
f.write(self.download_path)
logger.info(f"Saved last download path: {self.download_path}")
except Exception as e:
logger.warning(f"Could not save last download path: {e}")
def select_download_path(self): def select_download_path(self):
path = filedialog.askdirectory() path = filedialog.askdirectory()
if path: if path: