MDResolveHandle::MDResolveHandle(const ScraperSearchResult& result, const ScraperSearchParams& search) : mResult(result) { if(!result.imageUrl.empty()) { std::string ext; // If we have a file extension returned by the scraper, then use it. // Otherwise, try to guess it by the name of the URL, which point to an image. if (!result.imageType.empty()) { ext = result.imageType; }else{ size_t dot = result.imageUrl.find_last_of('.'); if (dot != std::string::npos) ext = result.imageUrl.substr(dot, std::string::npos); } std::string imgPath = getSaveAsPath(search, "image", ext); mFuncs.push_back(ResolvePair(downloadImageAsync(result.imageUrl, imgPath), [this, imgPath] { mResult.mdl.set("image", imgPath); mResult.imageUrl = ""; })); } }
MDResolveHandle::MDResolveHandle(const ScraperSearchResult& result, const ScraperSearchParams& search) : mResult(result) { if(!result.imageUrl.empty()) { std::string imgPath = getSaveAsPath(search, "image", result.imageUrl); mFuncs.push_back(ResolvePair(downloadImageAsync(result.imageUrl, imgPath), [this, imgPath] { mResult.metadata.set("image", imgPath); mResult.imageUrl = ""; })); } }