Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live streams that are marked as reruns now mark a tab as yellow instead of red #5176

Merged
merged 7 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- Minor: Added support for the `{input.text}` placeholder in the **Split** -> **Run a command** hotkey. (#5130)
- Minor: Add a new Channel API for experimental plugins feature. (#5141)
- Minor: Added the ability to change the top-most status of a window regardless of the _Always on top_ setting (right click the notebook). (#5135)
- Minor: Reintroduced recognising reruns after Twitch broke it. (#5176)
- Bugfix: Fixed an issue where certain emojis did not send to Twitch chat correctly. (#4840)
- Bugfix: Fixed capitalized channel names in log inclusion list not being logged. (#4848)
- Bugfix: Trimmed custom streamlink paths on all platforms making sure you don't accidentally add spaces at the beginning or end of its path. (#4834)
Expand Down
5 changes: 5 additions & 0 deletions src/common/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ bool Channel::isLive() const
return false;
}

bool Channel::isRerun() const
{
return false;
}

bool Channel::shouldIgnoreHighlights() const
{
return this->type_ == Type::TwitchAutomod ||
Expand Down
1 change: 1 addition & 0 deletions src/common/Channel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class Channel : public std::enable_shared_from_this<Channel>
virtual bool hasModRights() const;
virtual bool hasHighRateLimit() const;
virtual bool isLive() const;
virtual bool isRerun() const;
virtual bool shouldIgnoreHighlights() const;
virtual bool canReconnect() const;
virtual void reconnect();
Expand Down
14 changes: 14 additions & 0 deletions src/providers/twitch/TwitchChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,15 @@ void TwitchChannel::updateStreamStatus(

status->rerun = false;
status->streamType = stream.type;
for (const auto &tag : stream.tags)
{
if (QString::compare(tag, "Rerun", Qt::CaseInsensitive) == 0)
{
status->rerun = true;
status->streamType = "rerun";
break;
}
}
}
if (this->setLive(true))
{
Expand Down Expand Up @@ -797,6 +806,11 @@ bool TwitchChannel::isLive() const
return this->streamStatus_.accessConst()->live;
}

bool TwitchChannel::isRerun() const
{
return this->streamStatus_.accessConst()->rerun;
}

SharedAccessGuard<const TwitchChannel::StreamStatus>
TwitchChannel::accessStreamStatus() const
{
Expand Down
1 change: 1 addition & 0 deletions src/providers/twitch/TwitchChannel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class TwitchChannel final : public Channel, public ChannelChatters
const QString &popoutPlayerUrl();
int chatterCount() const;
bool isLive() const override;
bool isRerun() const override;
QString roomId() const;
SharedAccessGuard<const RoomModes> accessRoomModes() const;
SharedAccessGuard<const StreamStatus> accessStreamStatus() const;
Expand Down
8 changes: 8 additions & 0 deletions src/providers/twitch/api/Helix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ struct HelixStream {
QString language;
QString thumbnailUrl;

// This is the names, the IDs are now always empty
std::vector<QString> tags;

HelixStream()
: id("")
, userId("")
Expand Down Expand Up @@ -99,6 +102,11 @@ struct HelixStream {
, language(jsonObject.value("language").toString())
, thumbnailUrl(jsonObject.value("thumbnail_url").toString())
{
const auto jsonTags = jsonObject.value("tags").toArray();
for (const auto &tag : jsonTags)
{
this->tags.push_back(tag.toString());
}
}
};

Expand Down
30 changes: 26 additions & 4 deletions src/widgets/helper/NotebookTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,18 @@ void NotebookTab::setTabLocation(NotebookTabLocation location)
}
}

bool NotebookTab::setRerun(bool isRerun)
{
if (this->isRerun_ != isRerun)
{
this->isRerun_ = isRerun;
this->update();
return true;
}

return false;
}

bool NotebookTab::setLive(bool isLive)
{
if (this->isLive_ != isLive)
Expand Down Expand Up @@ -514,12 +526,22 @@ void NotebookTab::paintEvent(QPaintEvent *)
painter.fillRect(lineRect, lineColor);

// draw live indicator
if (this->isLive_ && getSettings()->showTabLive)
if ((this->isLive_ || this->isRerun_) && getSettings()->showTabLive)
{
painter.setPen(QColor(Qt::GlobalColor::red));
painter.setRenderHint(QPainter::Antialiasing);
// Live overrides rerun
QBrush b;
b.setColor(QColor(Qt::GlobalColor::red));
if (this->isLive_)
{
painter.setPen(QColor(Qt::GlobalColor::red));
b.setColor(QColor(Qt::GlobalColor::red));
}
else
{
painter.setPen(QColor(Qt::GlobalColor::yellow));
b.setColor(QColor(Qt::GlobalColor::yellow));
}

painter.setRenderHint(QPainter::Antialiasing);
b.setStyle(Qt::SolidPattern);
painter.setBrush(b);

Expand Down
8 changes: 8 additions & 0 deletions src/widgets/helper/NotebookTab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ class NotebookTab : public Button
**/
bool setLive(bool isLive);

/**
* @brief Sets the rerun status of this tab
*
* Returns true if the rerun status was changed, false if nothing changed.
**/
bool setRerun(bool isRerun);

/**
* @brief Returns true if any split in this tab is live
**/
Expand Down Expand Up @@ -121,6 +128,7 @@ class NotebookTab : public Button
QAction *highlightNewMessagesAction_;

bool isLive_{};
bool isRerun_{};

int growWidth_ = 0;

Expand Down
8 changes: 7 additions & 1 deletion src/widgets/splits/SplitContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,17 +926,23 @@ void SplitContainer::refreshTabLiveStatus()
}

bool liveStatus = false;
bool rerunStatus = false;
for (const auto &s : this->splits_)
{
auto c = s->getChannel();
if (c->isRerun())
{
rerunStatus = true;
continue; // reruns are also marked as live, SKIP
}
if (c->isLive())
{
liveStatus = true;
break;
}
}

if (this->tab_->setLive(liveStatus))
if (this->tab_->setLive(liveStatus) || this->tab_->setRerun(rerunStatus))
{
auto *notebook = dynamic_cast<Notebook *>(this->parentWidget());
if (notebook)
Expand Down
Loading