fix cover url export to audiocove (library part of url)

This commit is contained in:
Stefan Hardegger
2026-07-22 07:22:26 +02:00
parent 2f4ed2efd0
commit 88dded5979
2 changed files with 11 additions and 4 deletions

View File

@@ -29,16 +29,19 @@ public class AudioCoveService {
private final StoryService storyService;
private final CollectionService collectionService;
private final AudioCoveProperties audioCoveProperties;
private final LibraryService libraryService;
private final String publicUrl;
private final RestClient restClient;
public AudioCoveService(StoryService storyService,
CollectionService collectionService,
AudioCoveProperties audioCoveProperties,
LibraryService libraryService,
@Value("${storycove.app.public-url}") String publicUrl) {
this.storyService = storyService;
this.collectionService = collectionService;
this.audioCoveProperties = audioCoveProperties;
this.libraryService = libraryService;
this.publicUrl = publicUrl;
this.restClient = RestClient.create();
}
@@ -121,7 +124,7 @@ public class AudioCoveService {
request.setTags(allTags);
if (collection.getCoverImagePath() != null && !collection.getCoverImagePath().isBlank()) {
request.setCoverImage(publicUrl + "/api/files/images/" + collection.getCoverImagePath());
request.setCoverImage(publicUrl + "/api/files/images/" + libraryService.getCurrentLibraryId() + "/" + collection.getCoverImagePath());
}
logger.info("Sending collection '{}' ({}) to AudioCove with {} stories",
@@ -169,7 +172,7 @@ public class AudioCoveService {
request.setTags(tagNames);
if (story.getCoverPath() != null && !story.getCoverPath().isBlank()) {
request.setCoverImage(publicUrl + "/api/files/images/" + story.getCoverPath());
request.setCoverImage(publicUrl + "/api/files/images/" + libraryService.getCurrentLibraryId() + "/" + story.getCoverPath());
}
return request;

View File

@@ -29,6 +29,9 @@ class AudioCoveServiceTest {
@Mock
private CollectionService collectionService;
@Mock
private LibraryService libraryService;
private AudioCoveProperties audioCoveProperties;
private AudioCoveService audioCoveService;
@@ -37,7 +40,8 @@ class AudioCoveServiceTest {
audioCoveProperties = new AudioCoveProperties();
audioCoveProperties.setUrl("http://audiocove:8000");
audioCoveProperties.setApiKey("test-api-key");
audioCoveService = new AudioCoveService(storyService, collectionService, audioCoveProperties, "http://localhost:6925");
when(libraryService.getCurrentLibraryId()).thenReturn("testlib");
audioCoveService = new AudioCoveService(storyService, collectionService, audioCoveProperties, libraryService, "http://localhost:6925");
}
@Test
@@ -97,7 +101,7 @@ class AudioCoveServiceTest {
assertThat(request.getSeries()).isEqualTo("Nightfall Chronicles");
assertThat(request.getSeriesPart()).isEqualTo("2");
assertThat(request.getTags()).containsExactlyInAnyOrder("fantasy", "short-story");
assertThat(request.getCoverImage()).isEqualTo("http://localhost:6925/api/files/images/cover.jpg");
assertThat(request.getCoverImage()).isEqualTo("http://localhost:6925/api/files/images/testlib/cover.jpg");
assertThat(request.getSchemaVersion()).isEqualTo(1);
}