diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/Lbry.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/plugins/Lbry.cpp b/src/plugins/Lbry.cpp index 6be0148..a5806ab 100644 --- a/src/plugins/Lbry.cpp +++ b/src/plugins/Lbry.cpp @@ -25,6 +25,20 @@ namespace QuickMedia { return true; } + static bool extract_youtube_video_id(const std::string &url, std::string &video_id) { + size_t start_index = url.find("ytimg.com/vi/"); + if(start_index == std::string::npos) + return false; + + start_index += 13; + size_t end_index = url.find('/', start_index); + if(end_index == std::string::npos) + end_index = url.size(); + + video_id = url.substr(start_index, end_index - start_index); + return true; + } + static std::shared_ptr<BodyItem> resolve_claim(const Json::Value &result_json, time_t time_now) { if(!result_json.isObject()) return nullptr; @@ -67,16 +81,18 @@ namespace QuickMedia { if(!stream_type_json.isString() || strcmp(stream_type_json.asCString(), "video") != 0) return nullptr; } - body_item->thumbnail_size = { 177, 100 }; + body_item->thumbnail_size = { 220, 130 }; const Json::Value &thumbnail_json = value_json["thumbnail"]; if(thumbnail_json.isObject()) { const Json::Value &url_json = thumbnail_json["url"]; if(url_json.isString()) { - if(strstr(url_json.asCString(), "ytimg.com")) - body_item->thumbnail_url = url_json.asString(); + std::string url = url_json.asString(); + std::string youtube_video_id; + if(extract_youtube_video_id(url, youtube_video_id)) + body_item->thumbnail_url = "https://thumbnails.odycdn.com/optimize/s:220:130/quality:85/plain/https://thumbnails.lbry.com/" + youtube_video_id; else - body_item->thumbnail_url = url_json.asString() + "?quality=85&width=177&height=100"; + body_item->thumbnail_url = "https://thumbnails.odycdn.com/optimize/s:220:130/quality:85/plain/" + url; } } |