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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 2 deletions

View file

@ -50,6 +50,7 @@
- Minor: Update the listing of top-level domains. (#2345)
- Minor: Properly respect RECONNECT messages from Twitch (#2347)
- Minor: Added human-readable formatting to remaining timeout duration. (#2398)
- Minor: Added `/streamlink` command. Usage: `/streamlink <channel>`. You can also use the command without arguments in any twitch channel to open it in streamlink. (#2443)
- Bugfix: Fix crash occurring when pressing Escape in the Color Picker Dialog (#1843)
- Bugfix: Fix bug where the "check user follow state" event could trigger a network request requesting the user to follow or unfollow a user. By itself its quite harmless as it just repeats to Twitch the same follow state we had, so no follows should have been lost by this but it meant there was a rogue network request that was fired that could cause a crash (#1906)
- Bugfix: /usercard command will now respect the "Automatically close user popup" setting (#1918)

View file

@ -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()

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)
{