mirror of
https://github.com/tiennm99/store-scraper-bot-java.git
synced 2026-05-19 09:26:50 +00:00
Add app ratings retrieval for Apple apps
Introduces a new method getAppRatings in AppStoreScraper to fetch app ratings. Updates CheckAppScoreCommand to display ratings instead of reviews, and refactors AppleAppRequest for improved parameter handling.
This commit is contained in:
@@ -84,4 +84,13 @@ public class AppStoreScraper {
|
||||
}
|
||||
return response.reviews();
|
||||
}
|
||||
|
||||
public static long getAppRatings(String appId) {
|
||||
var response = getResponse(appId);
|
||||
if (response == null) {
|
||||
log.error("response is null");
|
||||
return 0L;
|
||||
}
|
||||
return response.ratings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,23 @@
|
||||
package com.miti99.storescraperbot.api.apple.request;
|
||||
|
||||
public record AppleAppRequest(String appId, Long id, Boolean ratings) {
|
||||
public record AppleAppRequest(
|
||||
Long id,
|
||||
String appId,
|
||||
// String country, // Tạm thời chưa cần phân biệt
|
||||
Boolean ratings) {
|
||||
public AppleAppRequest(String appId) {
|
||||
this(appId, null, true);
|
||||
this(
|
||||
null,
|
||||
appId,
|
||||
// "vn",
|
||||
true);
|
||||
}
|
||||
|
||||
public AppleAppRequest(Long id) {
|
||||
this(null, id, true);
|
||||
this(
|
||||
id,
|
||||
null,
|
||||
// "vn",
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,14 +37,14 @@ public class CheckAppScoreCommand extends BaseStoreScraperBotCommand {
|
||||
var sb = new StringBuilder();
|
||||
sb.append("<b>Apple Apps:</b>\n");
|
||||
sb.append("<code>\n");
|
||||
sb.append("%-20s | %-10s | %-10s\n".formatted("AppId", "Score", "Reviews"));
|
||||
sb.append("%-20s | %-10s | %-10s\n".formatted("AppId", "Score", "Ratings"));
|
||||
sb.append("-".repeat(43));
|
||||
sb.append("\n");
|
||||
for (var app : group.getAppleApps()) {
|
||||
var appId = app.appId();
|
||||
double score = AppStoreScraper.getAppScore(appId);
|
||||
long reviews = AppStoreScraper.getAppReviews(appId);
|
||||
sb.append("%-20s | %-10s | %-10s\n".formatted(appId, score, reviews));
|
||||
long ratings = AppStoreScraper.getAppRatings(appId);
|
||||
sb.append("%-20s | %-10s | %-10s\n".formatted(appId, score, ratings));
|
||||
}
|
||||
sb.append("</code>\n");
|
||||
sb.append("\n");
|
||||
|
||||
Reference in New Issue
Block a user