diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-14 16:59:27 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-14 16:59:27 +0200 |
commit | e1c8cd4430015a307dbcb32894a030d5a13aee67 (patch) | |
tree | e467cf115657f1cbf58f81aef96b5a6b67f11538 /src/plugins | |
parent | a2a49eee1985ec13e52e477060a50da2fcbdb894 (diff) |
Remove async image loader threads and instead check if the curl download process has finished
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Youtube.cpp | 32 |
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'; |