aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-07-27 04:40:33 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-27 04:40:33 +0200
commit66e8390dce2d96c2def73f0781c0072a26acd8e4 (patch)
treee57afa85b96163968fc84075d2cea23dd24d8b06 /src/plugins
parentad1077586958cae19acbe925b0be354902a7cb9e (diff)
Add date to youtube search results
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Youtube.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index 6923d04..b50939e 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -35,6 +35,14 @@ namespace QuickMedia {
std::string thumbnail_url = "https://img.youtube.com/vi/" + video_id_str + "/hqdefault.jpg";
+ const char *date = nullptr;
+ const Json::Value &published_time_text_json = video_renderer_json["publishedTimeText"];
+ if(published_time_text_json.isObject()) {
+ const Json::Value &text_json = published_time_text_json["simpleText"];
+ if(text_json.isString())
+ date = text_json.asCString();
+ }
+
const char *title = nullptr;
const Json::Value &title_json = video_renderer_json["title"];
if(title_json.isObject()) {
@@ -53,6 +61,11 @@ namespace QuickMedia {
return nullptr;
auto body_item = std::make_unique<BodyItem>(title);
+ /* TODO: Make date a different color */
+ if(date) {
+ body_item->title += '\n';
+ body_item->title += date;
+ }
body_item->url = "https://www.youtube.com/watch?v=" + video_id_str;
body_item->thumbnail_url = std::move(thumbnail_url);
added_videos.insert(video_id_str);