✨ Can explicitly set ffmpeg path.
This commit is contained in:
+21
-28
@@ -9,7 +9,6 @@ from tidalapi import Quality as QualityAudio
|
|||||||
from tidal_dl_ng import __version__
|
from tidal_dl_ng import __version__
|
||||||
from tidal_dl_ng.config import Settings
|
from tidal_dl_ng.config import Settings
|
||||||
from tidal_dl_ng.constants import CoverDimensions, QualityVideo, SkipExisting
|
from tidal_dl_ng.constants import CoverDimensions, QualityVideo, SkipExisting
|
||||||
from tidal_dl_ng.helper.path import is_installed_ffmpeg
|
|
||||||
from tidal_dl_ng.model.cfg import HelpSettings
|
from tidal_dl_ng.model.cfg import HelpSettings
|
||||||
from tidal_dl_ng.model.cfg import Settings as ModelSettings
|
from tidal_dl_ng.model.cfg import Settings as ModelSettings
|
||||||
from tidal_dl_ng.model.meta import ReleaseLatest
|
from tidal_dl_ng.model.meta import ReleaseLatest
|
||||||
@@ -132,26 +131,9 @@ class DialogPreferences(QtWidgets.QDialog):
|
|||||||
self.ui.setupUi(self)
|
self.ui.setupUi(self)
|
||||||
# Set data.
|
# Set data.
|
||||||
self.gui_populate()
|
self.gui_populate()
|
||||||
self._init_signals()
|
|
||||||
|
|
||||||
self.exec()
|
self.exec()
|
||||||
|
|
||||||
def _init_signals(self):
|
|
||||||
self.ui.cb_video_convert_mp4.stateChanged.connect(self.on_cb_video_convert_mp4)
|
|
||||||
|
|
||||||
def on_cb_video_convert_mp4(self, change_status: int):
|
|
||||||
# Check if ffmpeg is in PATH otherwise show error message.
|
|
||||||
if self.ui.cb_video_convert_mp4.isChecked() and not is_installed_ffmpeg():
|
|
||||||
self.ui.cb_video_convert_mp4.setChecked(False)
|
|
||||||
self.ui.cb_video_convert_mp4.setCheckState(QtCore.Qt.CheckState.Unchecked)
|
|
||||||
QtWidgets.QMessageBox.critical(
|
|
||||||
self,
|
|
||||||
"FFmpeg not found!",
|
|
||||||
"Either FFmpeg is not installed on your computer or not set within "
|
|
||||||
"your PATH variable. You cannot activate this option until FFmpeg "
|
|
||||||
"is correctly installed and set to your environmental PATH variable.",
|
|
||||||
)
|
|
||||||
|
|
||||||
def _init_line_edit(self):
|
def _init_line_edit(self):
|
||||||
self.parameters_line_edit = [
|
self.parameters_line_edit = [
|
||||||
"download_base_path",
|
"download_base_path",
|
||||||
@@ -160,6 +142,7 @@ class DialogPreferences(QtWidgets.QDialog):
|
|||||||
"format_mix",
|
"format_mix",
|
||||||
"format_track",
|
"format_track",
|
||||||
"format_video",
|
"format_video",
|
||||||
|
"path_binary_ffmpeg",
|
||||||
]
|
]
|
||||||
|
|
||||||
def _init_comboboxes(self):
|
def _init_comboboxes(self):
|
||||||
@@ -184,30 +167,36 @@ class DialogPreferences(QtWidgets.QDialog):
|
|||||||
self.populate_combo()
|
self.populate_combo()
|
||||||
self.populate_line_edit()
|
self.populate_line_edit()
|
||||||
|
|
||||||
def dialog_dir_open(self, obj_line_edit):
|
def dialog_chose_file(
|
||||||
|
self,
|
||||||
|
obj_line_edit: QtWidgets.QLineEdit,
|
||||||
|
file_mode: QtWidgets.QFileDialog | QtWidgets.QFileDialog.FileMode = QtWidgets.QFileDialog.Directory,
|
||||||
|
):
|
||||||
# If a path is set, use it otherwise the users home directory.
|
# If a path is set, use it otherwise the users home directory.
|
||||||
settings_path: str = os.path.expanduser(obj_line_edit.text()) if obj_line_edit.text() else ""
|
settings_path: str = os.path.expanduser(obj_line_edit.text()) if obj_line_edit.text() else ""
|
||||||
dir_current = settings_path if settings_path and os.path.exists(settings_path) else str(Path.home())
|
dir_current: str = settings_path if settings_path and os.path.exists(settings_path) else str(Path.home())
|
||||||
dialog = QtWidgets.QFileDialog()
|
dialog: QtWidgets.QFileDialog = QtWidgets.QFileDialog()
|
||||||
|
|
||||||
# Set to directory mode only but show files.
|
# Set to directory mode only but show files.
|
||||||
dialog.setFileMode(QtWidgets.QFileDialog.Directory)
|
dialog.setFileMode(file_mode)
|
||||||
dialog.setViewMode(QtWidgets.QFileDialog.Detail)
|
dialog.setViewMode(QtWidgets.QFileDialog.Detail)
|
||||||
dialog.setOption(QtWidgets.QFileDialog.ShowDirsOnly, False)
|
dialog.setOption(QtWidgets.QFileDialog.ShowDirsOnly, False)
|
||||||
|
dialog.setOption(QtWidgets.QFileDialog.DontResolveSymlinks, True)
|
||||||
|
|
||||||
# There is a bug in the PyQt implementation, which hides files in Directory mode.
|
# There is a bug in the PyQt implementation, which hides files in Directory mode.
|
||||||
# Thus, we need to use the PyQt dialog instead of the native dialog.
|
# Thus, we need to use the PyQt dialog instead of the native dialog.
|
||||||
if os.name == "nt":
|
if os.name == "nt" and file_mode == QtWidgets.QFileDialog.Directory:
|
||||||
dialog.setOption(QtWidgets.QFileDialog.DontUseNativeDialog, True)
|
dialog.setOption(QtWidgets.QFileDialog.DontUseNativeDialog, True)
|
||||||
|
|
||||||
dialog.setDirectory(dir_current)
|
dialog.setDirectory(dir_current)
|
||||||
|
|
||||||
# Execute dialog and set path is something is choosen.
|
# Execute dialog and set path is something is choosen.
|
||||||
if dialog.exec():
|
if dialog.exec():
|
||||||
dir_name = dialog.selectedFiles()[0]
|
dir_name: str = dialog.selectedFiles()[0]
|
||||||
path = Path(dir_name)
|
path: Path = Path(dir_name)
|
||||||
obj_line_edit.setText(str(path))
|
obj_line_edit.setText(str(path))
|
||||||
|
|
||||||
def populate_line_edit(self):
|
def populate_line_edit(self):
|
||||||
|
|
||||||
for pn in self.parameters_line_edit:
|
for pn in self.parameters_line_edit:
|
||||||
label_icon: QtWidgets.QLabel = getattr(self.ui, self.prefix_label + self.prefix_icon + pn)
|
label_icon: QtWidgets.QLabel = getattr(self.ui, self.prefix_label + self.prefix_icon + pn)
|
||||||
label: QtWidgets.QLabel = getattr(self.ui, self.prefix_label + pn)
|
label: QtWidgets.QLabel = getattr(self.ui, self.prefix_label + pn)
|
||||||
@@ -219,10 +208,14 @@ class DialogPreferences(QtWidgets.QDialog):
|
|||||||
line_edit.setText(getattr(self.data, pn))
|
line_edit.setText(getattr(self.data, pn))
|
||||||
|
|
||||||
# Base Path File Dialog
|
# Base Path File Dialog
|
||||||
self.ui.pb_download_base_path.clicked.connect(lambda x: self.dialog_dir_open(self.ui.le_download_base_path))
|
self.ui.pb_download_base_path.clicked.connect(lambda x: self.dialog_chose_file(self.ui.le_download_base_path))
|
||||||
|
self.ui.pb_path_binary_ffmpeg.clicked.connect(
|
||||||
|
lambda x: self.dialog_chose_file(
|
||||||
|
self.ui.le_path_binary_ffmpeg, file_mode=QtWidgets.QFileDialog.FileMode.ExistingFiles
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def populate_combo(self):
|
def populate_combo(self):
|
||||||
|
|
||||||
for p in self.parameters_combo:
|
for p in self.parameters_combo:
|
||||||
pn: str = p[0]
|
pn: str = p[0]
|
||||||
values: Enum = p[1]
|
values: Enum = p[1]
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class Settings:
|
|||||||
format_track: str = "Tracks/{artist_name} - {track_title}"
|
format_track: str = "Tracks/{artist_name} - {track_title}"
|
||||||
format_video: str = "Videos/{artist_name} - {track_title}"
|
format_video: str = "Videos/{artist_name} - {track_title}"
|
||||||
video_convert_mp4: bool = True
|
video_convert_mp4: bool = True
|
||||||
|
path_binary_ffmpeg: str = ""
|
||||||
metadata_cover_dimension: CoverDimensions = CoverDimensions.Px320
|
metadata_cover_dimension: CoverDimensions = CoverDimensions.Px320
|
||||||
|
|
||||||
|
|
||||||
@@ -65,8 +66,9 @@ class HelpSettings:
|
|||||||
format_video: str = "Where to download videos and how to name the items."
|
format_video: str = "Where to download videos and how to name the items."
|
||||||
video_convert_mp4: str = (
|
video_convert_mp4: str = (
|
||||||
"Videos are downloaded as MPEG Transport Stream (TS) files. With this option each video "
|
"Videos are downloaded as MPEG Transport Stream (TS) files. With this option each video "
|
||||||
"will be converted to MP4. FFMPEG must be installed and added to your 'PATH' variable."
|
"will be converted to MP4. FFmpeg must be installed and the binary path must be configured."
|
||||||
)
|
)
|
||||||
|
path_binary_ffmpeg: str = "If you like to convert videos, this must point to your installed ffmpeg binary."
|
||||||
metadata_cover_dimension: str = (
|
metadata_cover_dimension: str = (
|
||||||
"The dimensions of the cover image embedded into the track. Possible values: 320x320, 640x640x 1280x1280."
|
"The dimensions of the cover image embedded into the track. Possible values: 320x320, 640x640x 1280x1280."
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -364,6 +364,24 @@ class Ui_DialogSettings:
|
|||||||
|
|
||||||
self.verticalLayout_2.addLayout(self.lh_path_fmt_mix)
|
self.verticalLayout_2.addLayout(self.lh_path_fmt_mix)
|
||||||
|
|
||||||
|
self.lh_path_binary_ffmpeg = QHBoxLayout()
|
||||||
|
self.lh_path_binary_ffmpeg.setObjectName("lh_path_binary_ffmpeg")
|
||||||
|
self.l_icon_path_binary_ffmpeg = QLabel(self.gb_path)
|
||||||
|
self.l_icon_path_binary_ffmpeg.setObjectName("l_icon_path_binary_ffmpeg")
|
||||||
|
sizePolicy4.setHeightForWidth(self.l_icon_path_binary_ffmpeg.sizePolicy().hasHeightForWidth())
|
||||||
|
self.l_icon_path_binary_ffmpeg.setSizePolicy(sizePolicy4)
|
||||||
|
|
||||||
|
self.lh_path_binary_ffmpeg.addWidget(self.l_icon_path_binary_ffmpeg)
|
||||||
|
|
||||||
|
self.l_path_binary_ffmpeg = QLabel(self.gb_path)
|
||||||
|
self.l_path_binary_ffmpeg.setObjectName("l_path_binary_ffmpeg")
|
||||||
|
sizePolicy3.setHeightForWidth(self.l_path_binary_ffmpeg.sizePolicy().hasHeightForWidth())
|
||||||
|
self.l_path_binary_ffmpeg.setSizePolicy(sizePolicy3)
|
||||||
|
|
||||||
|
self.lh_path_binary_ffmpeg.addWidget(self.l_path_binary_ffmpeg)
|
||||||
|
|
||||||
|
self.verticalLayout_2.addLayout(self.lh_path_binary_ffmpeg)
|
||||||
|
|
||||||
self.horizontalLayout_2.addLayout(self.verticalLayout_2)
|
self.horizontalLayout_2.addLayout(self.verticalLayout_2)
|
||||||
|
|
||||||
self.verticalLayout = QVBoxLayout()
|
self.verticalLayout = QVBoxLayout()
|
||||||
@@ -432,6 +450,23 @@ class Ui_DialogSettings:
|
|||||||
|
|
||||||
self.verticalLayout.addLayout(self.horizontalLayout_8)
|
self.verticalLayout.addLayout(self.horizontalLayout_8)
|
||||||
|
|
||||||
|
self.horizontalLayout_31 = QHBoxLayout()
|
||||||
|
self.horizontalLayout_31.setObjectName("horizontalLayout_31")
|
||||||
|
self.le_path_binary_ffmpeg = QLineEdit(self.gb_path)
|
||||||
|
self.le_path_binary_ffmpeg.setObjectName("le_path_binary_ffmpeg")
|
||||||
|
sizePolicy2.setHeightForWidth(self.le_path_binary_ffmpeg.sizePolicy().hasHeightForWidth())
|
||||||
|
self.le_path_binary_ffmpeg.setSizePolicy(sizePolicy2)
|
||||||
|
self.le_path_binary_ffmpeg.setDragEnabled(True)
|
||||||
|
|
||||||
|
self.horizontalLayout_31.addWidget(self.le_path_binary_ffmpeg)
|
||||||
|
|
||||||
|
self.pb_path_binary_ffmpeg = QPushButton(self.gb_path)
|
||||||
|
self.pb_path_binary_ffmpeg.setObjectName("pb_path_binary_ffmpeg")
|
||||||
|
|
||||||
|
self.horizontalLayout_31.addWidget(self.pb_path_binary_ffmpeg)
|
||||||
|
|
||||||
|
self.verticalLayout.addLayout(self.horizontalLayout_31)
|
||||||
|
|
||||||
self.horizontalLayout_2.addLayout(self.verticalLayout)
|
self.horizontalLayout_2.addLayout(self.verticalLayout)
|
||||||
|
|
||||||
self.horizontalLayout_2.setStretch(1, 50)
|
self.horizontalLayout_2.setStretch(1, 50)
|
||||||
@@ -488,6 +523,9 @@ class Ui_DialogSettings:
|
|||||||
self.l_format_playlist.setText(QCoreApplication.translate("DialogSettings", "TextLabel", None))
|
self.l_format_playlist.setText(QCoreApplication.translate("DialogSettings", "TextLabel", None))
|
||||||
self.l_icon_format_mix.setText(QCoreApplication.translate("DialogSettings", "TextLabel", None))
|
self.l_icon_format_mix.setText(QCoreApplication.translate("DialogSettings", "TextLabel", None))
|
||||||
self.l_format_mix.setText(QCoreApplication.translate("DialogSettings", "TextLabel", None))
|
self.l_format_mix.setText(QCoreApplication.translate("DialogSettings", "TextLabel", None))
|
||||||
|
self.l_icon_path_binary_ffmpeg.setText(QCoreApplication.translate("DialogSettings", "TextLabel", None))
|
||||||
|
self.l_path_binary_ffmpeg.setText(QCoreApplication.translate("DialogSettings", "TextLabel", None))
|
||||||
self.pb_download_base_path.setText(QCoreApplication.translate("DialogSettings", "...", None))
|
self.pb_download_base_path.setText(QCoreApplication.translate("DialogSettings", "...", None))
|
||||||
|
self.pb_path_binary_ffmpeg.setText(QCoreApplication.translate("DialogSettings", "...", None))
|
||||||
|
|
||||||
# retranslateUi
|
# retranslateUi
|
||||||
|
|||||||
@@ -518,6 +518,36 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="lh_path_binary_ffmpeg">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="l_icon_path_binary_ffmpeg">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="l_path_binary_ffmpeg">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -588,6 +618,30 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="le_path_binary_ffmpeg">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="dragEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pb_path_binary_ffmpeg">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|||||||
Reference in New Issue
Block a user