mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-15 16:20:03 +00:00
@@ -96,44 +96,43 @@ public class ImageService {
|
|||||||
private int saveImagesIntoCache(MultiValueMap<String, String> entityToImageIds, String imageSize, String imageType, String entityType) {
|
private int saveImagesIntoCache(MultiValueMap<String, String> entityToImageIds, String imageSize, String imageType, String entityType) {
|
||||||
AtomicInteger downloadCounter = new AtomicInteger();
|
AtomicInteger downloadCounter = new AtomicInteger();
|
||||||
|
|
||||||
entityToImageIds.entrySet().parallelStream().forEach(entry ->
|
entityToImageIds.forEach((key, value) -> value.forEach(imageId -> {
|
||||||
entry.getValue().forEach(imageId -> {
|
|
||||||
|
|
||||||
if (!StringUtils.hasText(imageId)) return;
|
if (!StringUtils.hasText(imageId)) return;
|
||||||
|
|
||||||
String imgFileName = "%s.png".formatted(imageId);
|
String imgFileName = "%s.png".formatted(imageId);
|
||||||
String imgUrl = "t_%s/%s".formatted(imageSize, imgFileName);
|
String imgUrl = "t_%s/%s".formatted(imageSize, imgFileName);
|
||||||
|
|
||||||
if (filesystemService.doesCachedFileExist(imgFileName)) {
|
if (filesystemService.doesCachedFileExist(imgFileName)) {
|
||||||
if (filesystemService.isCachedFileCorrupt(imgFileName)) {
|
if (filesystemService.isCachedFileCorrupt(imgFileName)) {
|
||||||
log.info("File '{}' is corrupt, retrying download...", imgFileName);
|
log.info("File '{}' is corrupt, retrying download...", imgFileName);
|
||||||
filesystemService.deleteFileFromCache(imgFileName);
|
filesystemService.deleteFileFromCache(imgFileName);
|
||||||
} else {
|
} else {
|
||||||
log.debug("{} for {} '{}' already downloaded ({}), skipping.",
|
log.debug("{} for {} '{}' already downloaded ({}), skipping.",
|
||||||
imageType.substring(0, 1).toUpperCase() + imageType.substring(1).toLowerCase(),
|
imageType.substring(0, 1).toUpperCase() + imageType.substring(1).toLowerCase(),
|
||||||
entityType,
|
entityType,
|
||||||
entry.getKey(),
|
key,
|
||||||
imgFileName);
|
imgFileName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Flux<DataBuffer> dataBuffer = igdbImageClient.get()
|
Flux<DataBuffer> dataBuffer = igdbImageClient.get()
|
||||||
.uri(imgUrl)
|
.uri(imgUrl)
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.bodyToFlux(DataBuffer.class);
|
.bodyToFlux(DataBuffer.class);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
filesystemService.saveFileToCache(dataBuffer, imgFileName);
|
filesystemService.saveFileToCache(dataBuffer, imgFileName);
|
||||||
} catch (WebClientResponseException e) {
|
} catch (WebClientResponseException e) {
|
||||||
if (e.getStatusCode().is4xxClientError()) {
|
if (e.getStatusCode().is4xxClientError()) {
|
||||||
log.error("Could not download {} for {} '{}' from {}: {}", imageType, entityType, entry.getKey(), IgdbApiProperties.IMAGES_BASE_URL + imgUrl, e.getStatusCode());
|
log.error("Could not download {} for {} '{}' from {}: {}", imageType, entityType, key, IgdbApiProperties.IMAGES_BASE_URL + imgUrl, e.getStatusCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadCounter.getAndIncrement();
|
downloadCounter.getAndIncrement();
|
||||||
log.info("Downloaded {} for {} '{}' from {}", imageType, entityType, entry.getKey(), IgdbApiProperties.IMAGES_BASE_URL + imgUrl);
|
log.info("Downloaded {} for {} '{}' from {}", imageType, entityType, key, IgdbApiProperties.IMAGES_BASE_URL + imgUrl);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return downloadCounter.get();
|
return downloadCounter.get();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ public class LibraryService {
|
|||||||
// For each new game, load the info from IGDB
|
// For each new game, load the info from IGDB
|
||||||
// If a game is not found on IGDB, add it to the list of unmapped files, so we won't query the API later on for the same path
|
// If a game is not found on IGDB, add it to the list of unmapped files, so we won't query the API later on for the same path
|
||||||
// If a game is not found on IGDB, blacklist the path, so we won't query the API later for the same path
|
// If a game is not found on IGDB, blacklist the path, so we won't query the API later for the same path
|
||||||
List<DetectedGame> newDetectedGames = gameFiles.parallelStream()
|
List<DetectedGame> newDetectedGames = gameFiles.stream()
|
||||||
.map(p -> {
|
.map(p -> {
|
||||||
Optional<Igdb.Game> optionalGame = igdbWrapper.searchForGameByTitle(getFilenameWithoutAdditions(p), platformsFilter);
|
Optional<Igdb.Game> optionalGame = igdbWrapper.searchForGameByTitle(getFilenameWithoutAdditions(p), platformsFilter);
|
||||||
|
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "frontend",
|
"name": "frontend",
|
||||||
"version": "1.4.2-SNAPSHOT",
|
"version": "1.4.4-SNAPSHOT",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "frontend",
|
"name": "frontend",
|
||||||
"version": "1.4.2-SNAPSHOT",
|
"version": "1.4.4-SNAPSHOT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^16.2.8",
|
"@angular/animations": "^16.2.8",
|
||||||
"@angular/cdk": "^16.2.7",
|
"@angular/cdk": "^16.2.7",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "frontend",
|
"name": "frontend",
|
||||||
"version": "1.4.2-SNAPSHOT",
|
"version": "1.4.4-SNAPSHOT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
|
|||||||
Reference in New Issue
Block a user