File ytdl-gui-add-ytdlp-use-option.patch of Package ytdl-gui
From 8b56f1a742c691ee2377155ca45da422488493f4 Mon Sep 17 00:00:00 2001
From: Ricky Thomson <flytheflag@gmx.co.uk>
Date: Wed, 16 Feb 2022 03:07:42 +0000
Subject: [PATCH] add option to use "yt-dlp" for faster downloads
---
src/mainactions.cpp | 13 +++++++++++--
src/readconfig.cpp | 2 +-
src/ytdl.cpp | 3 +++
src/ytdl.ui | 16 ++++++++++++++++
4 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/src/mainactions.cpp b/src/mainactions.cpp
index 8067888..baf1770 100644
--- a/src/mainactions.cpp
+++ b/src/mainactions.cpp
@@ -38,6 +38,7 @@ mainActions::mainActions(QObject *parent) : QObject(parent) {
//apply checkbox settings
bool_to_checkbox(user_settings->values[0], ui->defaultsCheck);
bool_to_checkbox(user_settings->values[1], ui->playlistCheck);
+ bool_to_checkbox(user_settings->values[8], ui->dlpCheck);
//apply dir setting
std::string stored_value = user_settings->values[2];
@@ -233,12 +234,20 @@ void ytdl::printResult(int result_num) {
}
void ytdl::downloadAction() {
- std::string ytdl_prog = "youtube-dl 2> /tmp/ytdl_stderr --no-warnings --all-subs";
std::string url_str = quote + QString_to_str(ui->lineURL->text()) + quote;
std::string directory_str = quote + QString_to_str(ui->lineBrowse->text()) + "/%(title)s.%(ext)s" + quote;
std::string parse_output = R"(stdbuf -o0 grep -oP '^\[download\].*?\K([0-9]+)')";
std::string thumbnail;
+ //
+ std::string ytdl_prog;
+ if (ui->dlpCheck->isChecked()) {
+ ytdl_prog = "yt-dlp";
+ }
+ else {
+ ytdl_prog = "youtube-dl";
+ }
+
//Youtube playlist support
std::string playlist;
if (ui->playlistCheck->isChecked()) {
@@ -253,7 +262,7 @@ void ytdl::downloadAction() {
//Audio selected
if (ui->Tabs->currentIndex() == 0) {
- std::string command = ytdl_prog + " -x " + url_str + " -o " + directory_str \
+ std::string command = ytdl_prog + "2> /tmp/ytdl_stderr --no-warnings --all-subs -x " + url_str + " -o " + directory_str \
+ " --ignore-config " + playlist + "--newline | " \
+ parse_output;
diff --git a/src/readconfig.cpp b/src/readconfig.cpp
index 5a8a262..0d6e10d 100644
--- a/src/readconfig.cpp
+++ b/src/readconfig.cpp
@@ -29,7 +29,7 @@ void readConfig::get_values() {
if (curr_file.is_open()) {
int counter = 0;
- while (getline(curr_file, curr_line) && counter < 8) {
+ while (getline(curr_file, curr_line) && counter < 9) {
std::string reduced = remove_whitespace(curr_line);
int last_space = reduced.find_last_of(' ');
values[counter++] = reduced.substr(last_space + 1, reduced.size() - last_space);
diff --git a/src/ytdl.cpp b/src/ytdl.cpp
index b9d8793..454203e 100644
--- a/src/ytdl.cpp
+++ b/src/ytdl.cpp
@@ -140,6 +140,9 @@ void ytdl::closeEvent(QCloseEvent *event) {
//video format
config_file << "Video Format: " << ui->VFormatGroup->checkedId() << std::endl;
+ //download command
+ config_file << "DLP: " << check_to_bool(ui->dlpCheck) << std::endl;
+
}
config_file.close();
diff --git a/src/ytdl.ui b/src/ytdl.ui
index fe81bfd..b909b92 100644
--- a/src/ytdl.ui
+++ b/src/ytdl.ui
@@ -506,6 +506,22 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="dlpCheck">
+ <property name="minimumSize">
+ <size>
+ <width>77</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="text">
+ <string>Use yt-dlp</string>
+ </property>
+ </widget>
+ </item>
<item>
<widget class="QPushButton" name="buttonDownload">
<property name="minimumSize">