diff options
Diffstat (limited to 'src/YtdlpWrapper.cpp')
-rw-r--r-- | src/YtdlpWrapper.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/YtdlpWrapper.cpp b/src/YtdlpWrapper.cpp index a1e417f..424c6a4 100644 --- a/src/YtdlpWrapper.cpp +++ b/src/YtdlpWrapper.cpp @@ -41,7 +41,7 @@ void Video::to_json(json& j, const video& v) { j = json{{"id", v.id}, {"title", v.title}, - {"url", v.url}, + {"webpage_url", v.url}, {"channel_id", v.channelId}, {"channel_url", v.channelUrl}}; @@ -75,10 +75,10 @@ void Video::from_json(const json& j, format& f) { j.at("acodec").get_to(f.acodec); j.at("ext").get_to(f.ext); - if (j.contains("quality")) { f.quality = j.at("quality"); } - if (j.contains("resolution")) { f.resolution = j.at("resolution"); } - if (j.contains("width")) { f.width = j.at("width"); } - if (j.contains("height")) { f.height = j.at("height"); } + if (j.contains("quality") && j.at("quality").is_string()) { f.quality = j.at("quality"); } + if (j.contains("resolution") && j.at("resolution").is_string()) { f.resolution = j.at("resolution"); } + if (j.contains("width") && j.at("width").is_number()) { f.width = j.at("width"); } + if (j.contains("height") && j.at("height").is_number()) { f.height = j.at("height"); } } void Video::from_json(const json& j, thumbnail& t) { @@ -87,18 +87,18 @@ void Video::from_json(const json& j, thumbnail& t) { j.at("preference").get_to(t.preference); j.at("id").get_to(t.id); - if (j.contains("resolution")) { t.resolution = j.at("resolution"); } - if (j.contains("width")) { t.width = j.at("width"); } - if (j.contains("height")) { t.height = j.at("height"); } + if (j.contains("resolution") && j.at("resolution").is_string()) { t.resolution = j.at("resolution"); } + if (j.contains("width") && j.at("width").is_number()) { t.width = j.at("width"); } + if (j.contains("height") && j.at("height").is_number()) { t.height = j.at("height"); } } void Video::from_json(const json& j, video& v) { j.at("id").get_to(v.id); j.at("title").get_to(v.title); - j.at("url").get_to(v.url); - j.at("channelId").get_to(v.channelId); - j.at("channelUrl").get_to(v.channelUrl); + j.at("webpage_url").get_to(v.url); + j.at("channel_id").get_to(v.channelId); + j.at("channel_url").get_to(v.channelUrl); if (j.contains("uploader")) { v.uploader = j.at("uploader"); } if (j.contains("uploader_id")) { v.uploaderId = j.at("uploader_id"); } @@ -110,14 +110,14 @@ void Video::from_json(const json& j, video& v) { for (json f: j.at("formats")) { format form; - from_json(j, form); + from_json(f, form); v.formats.push_back(form); } for (json t: j.at("thumbnails")) { thumbnail thumb; - from_json(j, thumb); + from_json(t, thumb); v.thumbnails.push_back(thumb); } } |