24 lines
684 B
TypeScript
24 lines
684 B
TypeScript
import { injectable } from 'inversify';
|
|
import { inject } from '../../core/inject';
|
|
import { Work } from '../../entities/library/work';
|
|
import type { SourceGetterInterface } from '../source/source-getter-interface';
|
|
|
|
@injectable()
|
|
export class NhentaiSourceGetter implements SourceGetterInterface {
|
|
private nhentaiApi: NhentaiApiInterface;
|
|
|
|
public constructor(@inject('nhentai-api') nhentaiApi: NhentaiApiInterface) {
|
|
this.nhentaiApi = nhentaiApi;
|
|
}
|
|
|
|
public async find(identifier: string): Promise<Work> {
|
|
const gallery = await this.nhentaiApi.getGallery(identifier);
|
|
|
|
const work = new Work();
|
|
|
|
work.nameCanonical = gallery.title.main;
|
|
|
|
return work;
|
|
}
|
|
}
|