From 990ac651ae79bba88ffb0a5efc008a3eba76b539 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sun, 8 Apr 2018 15:14:14 +0200 Subject: [PATCH] Differentiate live streams and vodcasts Fixes #320 --- src/providers/twitch/twitchchannel.cpp | 13 +++++++++++++ src/providers/twitch/twitchchannel.hpp | 1 + src/widgets/helper/splitheader.cpp | 11 +++++++---- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/providers/twitch/twitchchannel.cpp b/src/providers/twitch/twitchchannel.cpp index d47b7f667..8daa92d75 100644 --- a/src/providers/twitch/twitchchannel.cpp +++ b/src/providers/twitch/twitchchannel.cpp @@ -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); diff --git a/src/providers/twitch/twitchchannel.hpp b/src/providers/twitch/twitchchannel.hpp index 9ba0ae0f0..948c8650b 100644 --- a/src/providers/twitch/twitchchannel.hpp +++ b/src/providers/twitch/twitchchannel.hpp @@ -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; diff --git a/src/widgets/helper/splitheader.cpp b/src/widgets/helper/splitheader.cpp index 77ccd8d70..e4f9dc0e2 100644 --- a/src/widgets/helper/splitheader.cpp +++ b/src/widgets/helper/splitheader.cpp @@ -172,14 +172,17 @@ void SplitHeader::updateChannelText() this->isLive = true; this->tooltip = "" "

" + - streamStatus.title + "

" + streamStatus.game + - "
" - "Live for " + + streamStatus.title + "

" + streamStatus.game + "
" + + (streamStatus.rerun ? "Vod-casting" : "Live") + " for " + streamStatus.uptime + " with " + QString::number(streamStatus.viewerCount) + " viewers" "

"; - this->titleLabel->setText(channelName + " (live)"); + if (streamStatus.rerun) { + this->titleLabel->setText(channelName + " (rerun)"); + } else { + this->titleLabel->setText(channelName + " (live)"); + } return; }