Skip to content

Commit

Permalink
Add the ability to override comic titles
Browse files Browse the repository at this point in the history
  • Loading branch information
floogulinc committed May 31, 2024
1 parent 0eef245 commit ae2e57e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ Here are the app config items (they are all optional):
| `comicTagServices` | `["all known tags"]` | An array of tag service names that will be used for comic title, volume, chapter, and page tags. They will be used in the order given. |
| `comicFullThumbs` | `false` | A boolean indicating whether to show full thumbnails in the comic gallery view. If set to `false` thumbnails will be cropped in to fill the thumb container. If true the container will be a square unless `comicThumbAspectRatio` is set. |
| `comicThumbAspectRatio` | | The aspect ratio for comic thumbnails. If this is unset the aspect ratio of the files will be used. Accepts any valid [CSS aspect-ratio value](https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio). If you have "thumbnail scaling" set to "scale to fill" in your Hydrus settings you should set this to the aspect ratio of your set thumbnail dimensions. This can also be used to restrict normal thumbnail to a specific aspect like `1/1.5`. |
| `comicTitleOverrides` | | A JSON object of comic paths to title strings. The comic titles here override any tags on the files. |

## Running as a service

Expand Down
8 changes: 5 additions & 3 deletions src/comic/comic.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ export class ComicService {
this.logger.debug(`Comic cache MISS (${id})`);
const pages = await firstValueFrom(this.getComicPagesFromApi(id));
const title =
this.appConfig.comicTitleFromNamespace && pages[0]
? this.getTitle(pages[0]) ?? id
: id;
this.appConfig.comicTitleOverrides && this.appConfig.comicTitleOverrides.hasOwnProperty(id)
? this.appConfig.comicTitleOverrides[id]
: this.appConfig.comicTitleFromNamespace && pages[0]
? this.getTitle(pages[0]) ?? id
: id;
const comicFromApi = {
title,
pages,
Expand Down
4 changes: 4 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,8 @@ export class AppConfig {
@IsString()
@IsOptional()
public readonly comicThumbAspectRatio?: string;

@IsObject()
@IsOptional()
public readonly comicTitleOverrides?: Record<string, string>;
}

0 comments on commit ae2e57e

Please sign in to comment.