Added /streamlink command (#2443)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Paweł
2021-02-12 14:16:44 +01:00
committed by GitHub
parent 3658b8130d
commit 185980f8a2
3 changed files with 31 additions and 2 deletions
@@ -17,6 +17,7 @@
#include "singletons/WindowManager.hpp"
#include "util/CombinePath.hpp"
#include "util/FormatTime.hpp"
#include "util/StreamLink.hpp"
#include "util/Twitch.hpp"
#include "widgets/Window.hpp"
#include "widgets/dialogs/UserInfoPopup.hpp"
@@ -538,6 +539,34 @@ void CommandController::initialize(Settings &, Paths &paths)
return "";
});
this->registerCommand(
"/streamlink", [](const QStringList &words, ChannelPtr channel) {
if (words.size() < 2)
{
if (!channel->isTwitchChannel() || channel->isEmpty())
{
channel->addMessage(makeSystemMessage(
"Usage: /streamlink <channel>. You can also use the "
"command without arguments in any twitch channel to "
"open it in streamlink."));
}
else
{
channel->addMessage(
makeSystemMessage(QString("Opening %1 in streamlink...")
.arg(channel->getName())));
openStreamlinkForChannel(channel->getName());
}
return "";
}
channel->addMessage(makeSystemMessage(
QString("Opening %1 in streamlink...").arg(words[1])));
openStreamlinkForChannel(words[1]);
return "";
});
}
void CommandController::save()
+1 -2
View File
@@ -187,8 +187,7 @@ void openStreamlink(const QString &channelURL, const QString &quality,
arguments << quality;
}
bool res = QProcess::startDetached(getStreamlinkProgram() + " " +
QString(arguments.join(' ')));
bool res = QProcess::startDetached(getStreamlinkProgram(), arguments);
if (!res)
{