Differentiate live streams and vodcasts

Fixes #320
This commit is contained in:
Rasmus Karlsson 2018-04-08 15:14:14 +02:00
parent 2b3fa06539
commit 990ac651ae
3 changed files with 21 additions and 4 deletions

View file

@ -259,6 +259,19 @@ void TwitchChannel::refreshLiveStatus()
auto diff = since.secsTo(QDateTime::currentDateTime());
channel->streamStatus.uptime =
QString::number(diff / 3600) + "h " + QString::number(diff % 3600 / 60) + "m";
channel->streamStatus.rerun = false;
if (stream.HasMember("broadcast_platform")) {
const auto &broadcastPlatformValue = stream["broadcast_platform"];
if (broadcastPlatformValue.IsString()) {
const char *broadcastPlatform = stream["broadcast_platform"].GetString();
if (strcmp(broadcastPlatform, "rerun") == 0) {
channel->streamStatus.rerun = true;
}
}
}
}
channel->setLive(true);

View file

@ -24,6 +24,7 @@ class TwitchChannel final : public Channel
public:
struct StreamStatus {
bool live = false;
bool rerun = false;
unsigned viewerCount = 0;
QString title;
QString game;

View file

@ -172,14 +172,17 @@ void SplitHeader::updateChannelText()
this->isLive = true;
this->tooltip = "<style>.center { text-align: center; }</style>"
"<p class = \"center\">" +
streamStatus.title + "<br><br>" + streamStatus.game +
"<br>"
"Live for " +
streamStatus.title + "<br><br>" + streamStatus.game + "<br>" +
(streamStatus.rerun ? "Vod-casting" : "Live") + " for " +
streamStatus.uptime + " with " +
QString::number(streamStatus.viewerCount) +
" viewers"
"</p>";
this->titleLabel->setText(channelName + " (live)");
if (streamStatus.rerun) {
this->titleLabel->setText(channelName + " (rerun)");
} else {
this->titleLabel->setText(channelName + " (live)");
}
return;
}