aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-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));
+ }
}
}
}