1.0.1 • Published 2 years ago

@media-fetch-project/animecharactersdatabase-source v1.0.1

Weekly downloads
-
License
CC-BY-4.0
Repository
github
Last release
2 years ago

MediaFetchProject AnimeCharactersDatabase-Source

NPM version NPM downloads

AnimeCharactersDatabase-Source is an anime character picture fetcher based on the MediaFetchProject.

The objective is to use the unique structure of the DevLib to ensure an easy implementation with other fetchers (ex: to make an app that looks on many different websites for your result).

Usage Example

import AnimeCharactersDatabase from '@media-fetch-project/animecharactersdatabase-source';
import { createWriteStream, existsSync, mkdirSync } from 'fs';
import path from 'path';
import { Readable } from 'stream';

const folderPath = path.normalize('./dl/AnimeCharactersDatabase/');
const characterToSearch = 'Kurisu Makise';

if (!existsSync(folderPath)) mkdirSync(folderPath, { recursive: true });

new AnimeCharactersDatabase()
  .search({ text: characterToSearch })
  .then((animeCharacters) =>
    animeCharacters.forEach(async (animeCharacter) => {
      const characterTitle = await animeCharacter.getTitle();
      const characterPicture = (await animeCharacter.getMedia())[0];

      console.log(characterTitle, 'found.');

      const writableStream = createWriteStream(
        path.normalize(
          path.join(
            folderPath,
            `${characterTitle}.${await characterPicture.getType()}`
          )
        ),
        { autoClose: true, flags: 'w' }
      );
      Readable.from(await characterPicture.fetch())
        .pipe(writableStream)
        .once('close', async () => console.log(characterTitle, 'downloaded.'));
    })
  )
  .catch(console.error);

Want to add your repository to the list of official media fetchers? Create an issue with the following label on the DevLib repository.

Licence

This project is under the CC-CY-4.0 licence.

Please respect it when using, modifing or distributing this project.

For more information, please go on the official Creative Commons website