Remove unused code and style module
Deleted the ytsage_style.py file and removed related imports, as well as unused compatibility exception classes and the sanitize_filename function. The downloader now always uses the direct CLI command, removing the Python API fallback.
This commit is contained in:
@@ -88,7 +88,6 @@ class DownloadThread(QThread):
|
||||
self.paused = False
|
||||
self.cancelled = False
|
||||
self.process = None
|
||||
self.use_direct_command = True # Flag to use direct CLI command instead of Python API
|
||||
self.last_output_time = time.time()
|
||||
self.timeout_timer = None
|
||||
self.current_filename = None # Initialize filename storage
|
||||
@@ -317,12 +316,8 @@ class DownloadThread(QThread):
|
||||
except Exception as e:
|
||||
logger.exception(f"Error scanning for initial subtitle files: {e}")
|
||||
|
||||
if self.use_direct_command:
|
||||
# Use direct CLI command instead of Python API
|
||||
self._run_direct_command()
|
||||
else:
|
||||
# Original method using Python API - code left for reference
|
||||
self._run_python_api()
|
||||
# Use direct CLI command
|
||||
self._run_direct_command()
|
||||
|
||||
except Exception as e:
|
||||
# Catch errors during setup
|
||||
@@ -664,11 +659,6 @@ class DownloadThread(QThread):
|
||||
|
||||
self.update_details.emit("") # Clear details label on completion
|
||||
|
||||
def _run_python_api(self) -> None:
|
||||
"""Original download method using Python API - kept for reference."""
|
||||
# The existing run method code using yt_dlp.YoutubeDL starts here
|
||||
# This method is no longer used by default
|
||||
|
||||
def pause(self) -> None:
|
||||
self.paused = True
|
||||
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
MAIN_STYLE = """
|
||||
QMainWindow {
|
||||
background-color: #15181b;
|
||||
}
|
||||
QWidget {
|
||||
background-color: #15181b;
|
||||
color: #ffffff;
|
||||
font-size: 12px;
|
||||
}
|
||||
QLineEdit {
|
||||
padding: 8px;
|
||||
border: 2px solid #1b2021;
|
||||
border-radius: 4px;
|
||||
background-color: #1b2021;
|
||||
color: #ffffff;
|
||||
selection-background-color: #c90000;
|
||||
selection-color: #ffffff;
|
||||
}
|
||||
QPushButton {
|
||||
padding: 8px 15px;
|
||||
background-color: #c90000;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
min-height: 20px;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background-color: #a50000;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-color: #800000;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
background-color: #666666;
|
||||
color: #999999;
|
||||
}
|
||||
QTableWidget {
|
||||
border: 2px solid #1b2021;
|
||||
border-radius: 4px;
|
||||
background-color: #1b2021;
|
||||
gridline-color: #1b2021;
|
||||
selection-background-color: #c90000;
|
||||
selection-color: #ffffff;
|
||||
}
|
||||
QHeaderView::section {
|
||||
background-color: #15181b;
|
||||
padding: 5px;
|
||||
border: 1px solid #1b2021;
|
||||
color: #ffffff;
|
||||
font-weight: bold;
|
||||
}
|
||||
QScrollBar:vertical {
|
||||
border: none;
|
||||
background-color: #15181b;
|
||||
width: 12px;
|
||||
margin: 0px;
|
||||
}
|
||||
QScrollBar::handle:vertical {
|
||||
background-color: #666666;
|
||||
min-height: 20px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
QScrollBar::handle:vertical:hover {
|
||||
background-color: #c90000;
|
||||
}
|
||||
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {
|
||||
height: 0px;
|
||||
}
|
||||
QProgressBar {
|
||||
border: 2px solid #1b2021;
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
color: white;
|
||||
background-color: #1b2021;
|
||||
}
|
||||
QProgressBar::chunk {
|
||||
background-color: #c90000;
|
||||
border-radius: 2px;
|
||||
}
|
||||
QComboBox {
|
||||
padding: 8px;
|
||||
border: 2px solid #1b2021;
|
||||
border-radius: 4px;
|
||||
background-color: #1b2021;
|
||||
color: #ffffff;
|
||||
min-height: 20px;
|
||||
}
|
||||
QComboBox:hover {
|
||||
border: 2px solid #c90000;
|
||||
}
|
||||
QComboBox:focus {
|
||||
border: 2px solid #c90000;
|
||||
}
|
||||
QComboBox::drop-down {
|
||||
border: none;
|
||||
width: 30px;
|
||||
background-color: #1b2021;
|
||||
border-radius: 0 4px 4px 0;
|
||||
}
|
||||
QComboBox::drop-down:hover {
|
||||
background-color: #c90000;
|
||||
}
|
||||
QComboBox::down-arrow {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-left: 5px solid transparent;
|
||||
border-right: 5px solid transparent;
|
||||
border-top: 8px solid #ffffff;
|
||||
margin: auto;
|
||||
}
|
||||
QComboBox QAbstractItemView {
|
||||
border: 2px solid #1b2021;
|
||||
border-radius: 4px;
|
||||
background-color: #1b2021;
|
||||
color: #ffffff;
|
||||
selection-background-color: #c90000;
|
||||
selection-color: #ffffff;
|
||||
outline: none;
|
||||
}
|
||||
QComboBox QAbstractItemView::item {
|
||||
height: 30px;
|
||||
padding: 5px;
|
||||
border: none;
|
||||
background-color: #1b2021;
|
||||
color: #ffffff;
|
||||
}
|
||||
QComboBox QAbstractItemView::item:hover {
|
||||
background-color: #c90000;
|
||||
color: #ffffff;
|
||||
}
|
||||
QComboBox QAbstractItemView::item:selected {
|
||||
background-color: #c90000;
|
||||
color: #ffffff;
|
||||
}
|
||||
QCheckBox {
|
||||
spacing: 5px;
|
||||
color: #ffffff;
|
||||
}
|
||||
QCheckBox::indicator {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 9px;
|
||||
}
|
||||
QCheckBox::indicator:unchecked {
|
||||
border: 2px solid #666666;
|
||||
background: #15181b;
|
||||
}
|
||||
QCheckBox::indicator:checked {
|
||||
border: 2px solid #c90000;
|
||||
background: #c90000;
|
||||
}
|
||||
QRadioButton {
|
||||
spacing: 5px;
|
||||
color: #ffffff;
|
||||
}
|
||||
QRadioButton::indicator {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 9px;
|
||||
}
|
||||
QRadioButton::indicator:unchecked {
|
||||
border: 2px solid #666666;
|
||||
background: #15181b;
|
||||
}
|
||||
QRadioButton::indicator:checked {
|
||||
border: 2px solid #c90000;
|
||||
background: #c90000;
|
||||
}
|
||||
QLabel {
|
||||
color: #ffffff;
|
||||
}
|
||||
QGroupBox {
|
||||
color: #ffffff;
|
||||
border: 2px solid #1b2021;
|
||||
border-radius: 4px;
|
||||
margin-top: 1ex;
|
||||
padding-top: 10px;
|
||||
}
|
||||
QGroupBox::title {
|
||||
subcontrol-origin: margin;
|
||||
left: 10px;
|
||||
padding: 0 5px 0 5px;
|
||||
color: #c90000;
|
||||
font-weight: bold;
|
||||
}
|
||||
QTextEdit, QPlainTextEdit {
|
||||
background-color: #1b2021;
|
||||
color: #ffffff;
|
||||
border: 2px solid #1b2021;
|
||||
border-radius: 4px;
|
||||
selection-background-color: #c90000;
|
||||
selection-color: #ffffff;
|
||||
}
|
||||
QMessageBox {
|
||||
background-color: #15181b;
|
||||
}
|
||||
QMessageBox QLabel {
|
||||
color: #ffffff;
|
||||
}
|
||||
QMessageBox QPushButton {
|
||||
min-width: 80px;
|
||||
}
|
||||
"""
|
||||
@@ -825,33 +825,3 @@ def validate_video_url(url: str) -> tuple[bool, str]:
|
||||
logger.info(f"YouTube URL doesn't match known patterns but allowing: {url}")
|
||||
return True, ""
|
||||
|
||||
|
||||
def sanitize_filename(filename: str) -> str:
|
||||
"""
|
||||
Sanitize a filename by removing or replacing dangerous characters.
|
||||
|
||||
Args:
|
||||
filename: The filename to sanitize
|
||||
|
||||
Returns:
|
||||
str: Sanitized filename safe for filesystem use
|
||||
|
||||
Example:
|
||||
>>> sanitize_filename('video<>file?.mp4')
|
||||
'video__file_.mp4'
|
||||
"""
|
||||
import re
|
||||
|
||||
# Replace dangerous characters with underscore
|
||||
# Characters not allowed in Windows filenames: < > : " / \ | ? *
|
||||
# Also remove control characters
|
||||
sanitized = re.sub(r'[<>:"/\\|?*\x00-\x1f]', '_', filename)
|
||||
|
||||
# Remove leading/trailing dots and spaces (Windows compatibility)
|
||||
sanitized = sanitized.strip('. ')
|
||||
|
||||
# Ensure filename is not empty after sanitization
|
||||
if not sanitized:
|
||||
sanitized = "video"
|
||||
|
||||
return sanitized
|
||||
|
||||
Reference in New Issue
Block a user