aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Youtube.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index 012a20b..40b6970 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -425,6 +425,33 @@ namespace QuickMedia {
return std::nullopt;
}
+ static bool video_is_live(const Json::Value &video_item_json) {
+ if(!video_item_json.isObject())
+ return false;
+
+ const Json::Value &badges_json = video_item_json["badges"];
+ if(!badges_json.isArray())
+ return false;
+
+ for(const Json::Value &badge_json : badges_json) {
+ if(!badge_json.isObject())
+ continue;
+
+ const Json::Value &metadata_badge_renderer_json = badge_json["metadataBadgeRenderer"];
+ if(!metadata_badge_renderer_json.isObject())
+ continue;
+
+ const Json::Value &style_json = metadata_badge_renderer_json["style"];
+ if(!style_json.isString())
+ continue;
+
+ if(strcmp(style_json.asCString(), "BADGE_STYLE_TYPE_LIVE_NOW") == 0)
+ return true;
+ }
+
+ return false;
+ }
+
static std::shared_ptr<BodyItem> parse_common_video_item(const Json::Value &video_item_json, std::unordered_set<std::string> &added_videos) {
const Json::Value &video_id_json = video_item_json["videoId"];
if(!video_id_json.isString())
@@ -491,6 +518,11 @@ namespace QuickMedia {
desc += '\n';
desc += length.value();
}
+ if(video_is_live(video_item_json)) {
+ if(!desc.empty())
+ desc += '\n';
+ desc += "Live now";
+ }
if(owner_text) {
if(!desc.empty())
desc += '\n';