use of lee.study.down.model.UpdateInfo in project proxyee-down by monkeyWie.
the class GithubUpdateService method main.
public static void main(String[] args) throws Exception {
GithubUpdateService githubUpdateService = new GithubUpdateService();
UpdateInfo updateInfo = githubUpdateService.check(1.0F);
githubUpdateService.update(updateInfo, null);
}
use of lee.study.down.model.UpdateInfo in project proxyee-down by monkeyWie.
the class GithubUpdateService method check.
@Override
public UpdateInfo check(float currVersion) throws Exception {
UpdateInfo updateInfo = new UpdateInfo();
Document document = Jsoup.connect("https://github.com/monkeyWie/proxyee-down/releases").get();
Elements versions = document.select("h1.release-title.text-normal");
Collections.sort(versions, (v1, v2) -> {
float version1 = Float.parseFloat(v1.text());
float version2 = Float.parseFloat(v2.text());
return version1 < version2 ? 1 : -1;
});
float maxVersion = Float.parseFloat(versions.get(0).text());
if (maxVersion > currVersion) {
updateInfo.setVersion(maxVersion);
updateInfo.setVersionStr(versions.get(0).text());
Element releaseDiv = versions.get(0).parent().parent();
for (Element element : releaseDiv.select(".d-block.py-2")) {
if (element.select("strong").text().indexOf("-jar.zip") != -1) {
updateInfo.setUrl("https://github.com" + element.select("a").attr("href"));
break;
}
}
if (updateInfo.getUrl() == null) {
return null;
}
updateInfo.setDesc(releaseDiv.select(".markdown-body").html());
return updateInfo;
}
return null;
}
Aggregations