aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-15 01:56:41 +0200
committerdec05eba <dec05eba@protonmail.com>2020-10-15 01:56:41 +0200
commit0603980988beda54847edf8924f91be820f0532f (patch)
treeae9c6f2a101918cf1daf7080f5f97169e9b7b6d8 /src
parent170a2c042c79bfa069e7e3fb4cfb18a5a3cb9072 (diff)
Youtube: make video order match youtube more...
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Youtube.cpp49
1 files changed, 26 insertions, 23 deletions
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index b34a873..9e84903 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -102,35 +102,38 @@ namespace QuickMedia {
return;
for(const Json::Value &content_item_json : item_contents_json) {
- std::shared_ptr<BodyItem> body_item = parse_content_video_renderer(content_item_json, added_videos);
- if(body_item)
- result_items.push_back(std::move(body_item));
- }
-
- for(const Json::Value &content_item_json : item_contents_json) {
if(!content_item_json.isObject())
continue;
- const Json::Value &shelf_renderer_json = content_item_json["shelfRenderer"];
- if(!shelf_renderer_json.isObject())
- continue;
+ for(Json::Value::const_iterator it = content_item_json.begin(); it != content_item_json.end(); ++it) {
+ Json::Value key = it.key();
+ if(key.isString() && strcmp(key.asCString(), "shelfRenderer") == 0) {
+ const Json::Value &shelf_renderer_json = *it;
+ if(!shelf_renderer_json.isObject())
+ continue;
- const Json::Value &item_content_json = shelf_renderer_json["content"];
- if(!item_content_json.isObject())
- continue;
+ const Json::Value &item_content_json = shelf_renderer_json["content"];
+ if(!item_content_json.isObject())
+ continue;
- const Json::Value &vertical_list_renderer_json = item_content_json["verticalListRenderer"];
- if(!vertical_list_renderer_json.isObject())
- continue;
+ const Json::Value &vertical_list_renderer_json = item_content_json["verticalListRenderer"];
+ if(!vertical_list_renderer_json.isObject())
+ continue;
- const Json::Value &items_json = vertical_list_renderer_json["items"];
- if(!items_json.isArray())
- continue;
-
- for(const Json::Value &item_json : items_json) {
- std::shared_ptr<BodyItem> body_item = parse_content_video_renderer(item_json, added_videos);
- if(body_item)
- result_items.push_back(std::move(body_item));
+ const Json::Value &items_json = vertical_list_renderer_json["items"];
+ if(!items_json.isArray())
+ continue;
+
+ for(const Json::Value &item_json : items_json) {
+ std::shared_ptr<BodyItem> body_item = parse_content_video_renderer(item_json, added_videos);
+ if(body_item)
+ result_items.push_back(std::move(body_item));
+ }
+ } else {
+ std::shared_ptr<BodyItem> body_item = parse_content_video_renderer(content_item_json, added_videos);
+ if(body_item)
+ result_items.push_back(std::move(body_item));
+ }
}
}
}