GetImgs(directory, nedb)

Class for getting images from files in the download directory

new GetImgs(directory, nedb)

The constructor for GetImgs

Parameters:
Name Type Description
directory string

a string with path to downloaded files

nedb object

The NeDB instance

Methods

findFiles(directory) → {Promise.<Object>}

Returns object with all files from directory param in an array.

Parameters:
Name Type Description
directory string

Path to files.

Returns:
Promise.<Object>

findRightEp(episodes, tvelem, elempath)

Loops through all episodes found from The TVDB, checking if they match the episode we want. We check the episode number and season. Emits an episode event if it finds an episode, and a notfound event if it doesn't.

Parameters:
Name Type Description
episodes object

Information from The TVDB API about the episodes currently being processed.

tvelem object

Parsed filename usually containing things like show, episode, season etc.

elempath string

Filename without path (includes extension).

getEpisodes(series, tvelem, elempath)

Gets all episodes from a TVDB series ID Emits a notfound event if no episodes are found for the series ID. Probably unlikely, but happens. Calls GetImgs#findRightEp with all episodes.

Parameters:
Name Type Description
series object

Information from The TVDB API about the series currently being processed.

tvelem object

Parsed filename usually containing things like show, episode, season etc.

elempath string

Filename without path (includes extension).

getSeriesByName(tvelem, elempath)

Looks up a series on The TVDB, and gets info about it. Calls GetImgs#getEpisodes if it finds a series. Emits a notfound event if it doesn't find the series.

Parameters:
Name Type Description
tvelem object

Parsed filename usually containing things like show, episode, season etc.

elempath string

Filename without path (includes extension).

async hasShow(tvelem, elempath, elem)

Check if the parsed filename has the needed information in it.

Parameters:
Name Type Description
tvelem object

Parsed filename usually containing things like show, episode, season etc.

elempath string

Filename without path (includes extension).

elem string

Full path to file.

inDB(tvelem) → {Promise.<String>}

Check if there is already an image for an episode in the DB.

Parameters:
Name Type Description
tvelem object

Parsed filename usually containing things like show, episode, season etc.

Returns:
Promise.<String> -
  • 'need image' if needing image, 'got image' if already in DB.

loop(currentFile)

Strips path from filename, parses it, continues to GetImgs#hasShow.

Parameters:
Name Type Description
currentFile string

Path to current file that we are getting images for.

async tvdbInit(directory)

Loop through each file in directory and initiate GetImgs#loop.

Parameters:
Name Type Description
directory string

Path to download directory.