Fix bug when game has no cover in IGDB

This commit is contained in:
Simon Grimme
2022-07-25 11:34:22 +02:00
parent b86544b22a
commit 206272b50b
5 changed files with 29 additions and 11 deletions
@@ -8,6 +8,7 @@ import de.grimsi.gameyfin.util.ProtobufUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.nio.file.FileSystem;
@@ -38,7 +39,7 @@ public class GameMapper {
.onlineCoop(hasOnlineCoop(multiplayerModes))
.lanSupport(hasLanSupport(multiplayerModes))
.maxPlayers(getMaxPlayers(multiplayerModes))
.coverId(g.getCover().getImageId())
.coverId(getCoverId(g))
.screenshotIds(screenshotIds)
.videoIds(videoIds)
.companies(CompanyMapper.toCompanies(g.getInvolvedCompaniesList()))
@@ -59,6 +60,14 @@ public class GameMapper {
.build();
}
private static String getCoverId(Igdb.Game g) {
String coverId = g.getCover().getImageId();
if(StringUtils.hasText(coverId)) return coverId;
return "nocover";
}
private static boolean hasOfflineCoop(List<Igdb.MultiplayerMode> modes) {
return modes.stream().anyMatch(Igdb.MultiplayerMode::getOfflinecoop);
}
@@ -1,9 +1,9 @@
gameyfin:
#root: C:\Projects\privat\gameyfin-library
root: \\NAS-Simon\Öffentlich\Spiele
root: C:\Projects\privat\gameyfin-library
#root: \\NAS-Simon\Öffentlich\Spiele
cache: ${gameyfin.root}\.gameyfin\cache
#db: ${gameyfin.root}\.gameyfin\db
db: ./data
db: ${gameyfin.root}\.gameyfin\db
#db: ./data
igdb:
api:
client-id: 23l3l5qshx4dwjuao6yb8jyf1qrd08
@@ -1,4 +1,5 @@
<a routerLink="/game/{{game.slug}}">
<div class="game-cover-container shine" [style.background-image]="'url(v1/images/' + game.coverId + ')'">
<div class="game-cover-container shine" [style.background-image]="'url(v1/images/' + game.coverId + ')'" fxLayoutAlign="center end">
<h2 *ngIf="game.coverId === 'nocover'" class="no-link-stlying">{{game.title}}</h2>
</div>
</a>
@@ -49,3 +49,8 @@
}
}
}
.no-link-styling a:hover, a:visited, a:link, a:active {
text-decoration: none;
color: black;
}
@@ -1,8 +1,8 @@
<div fxLayout="row" fxLayoutAlign="center" style="margin-top: 16px;">
<div fxLayout="column" fxFlex="0 1 70" fxLayoutGap="16px" fxFlex.lt-xl="95">
<div fxLayout="row" fxLayoutGap="16px">
<div fxLayout="row" fxLayout.lt-lg="column" fxLayoutGap="16px">
<img src="v1/images/{{game.coverId}}" alt="Game cover">
<img style="max-width: 352px;" src="v1/images/{{game.coverId}}" alt="Game cover">
<div fxFlex="40" fxLayout="column" id="game-details">
<h1>{{game.title}}</h1>
@@ -13,9 +13,12 @@
<div fxLayout="column" fxFlex="40" fxLayoutGap="16px">
<button mat-raised-button color="primary" (click)="downloadGame()">
Download ({{bytesAsHumanReadableString(game.diskSize)}})
</button>
<div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="16px">
<button mat-raised-button color="primary" (click)="downloadGame()">
<mat-icon>download</mat-icon>
</button>
<b style="font-size: 24px">Download ({{bytesAsHumanReadableString(game.diskSize)}})</b>
</div>
<div fxLayout="column" fxLayoutGap="24px">
<div *ngIf="game.genres !== undefined && game.genres.length > 0">