kodilist
Version:
CLI tool for generating Kodi playlists based on filename-embedded tags.
56 lines (55 loc) • 2.4 kB
TypeScript
export interface SearchTerms {
[index: string]: string[];
sources: string[];
tags: string[];
people: string[];
}
export interface ConfigFile {
kodi: string;
configPath: string;
save: () => void;
directories: string[];
ignoreList: string[];
searchTerms: SearchTerms;
}
/**
* Turns a full file path like "~/foo/bar/Rainbow.Lorikeet.2017.mp4"
* and returns a simplified name like "rainbow lorikeet 2017 mp4" by
* lowercasing it, swapping dots for spaces, and removing path information.
*/
export declare function simplifyName(name: string): string;
/**
* Returns the path to Kodi's video playlists folder if it exists; aborts the
* entire program if it doesn't. The path is discovered by checking for the
* default path on various platforms, so if the user has installed Kodi in a
* non-standard location, this can fail.
*
* TODO: Allow the user to manually specify where they installed Kodi without
* having to edit `kodilist.json`.
*/
export declare function getKodiFolder(): string;
/**
* Creates a folder at the supplied path if it doesn't already exist.
*/
export declare function guaranteeFolder(root: string, name: string): void;
/**
* Writes M3U playlists for each of the user's tracked people, tags, and
* sources in folders named 'people', 'tags', and 'sources' respectively.
*/
export declare function writePlaylistsSearchTerms(config: ConfigFile, files: any[]): void;
/**
* Writes a playlist `new.m3u` with files created within the last week,
* measured using `fs.Stats.birthTimeMs`. For large libraries this is the
* slowest part of the program after generating the initial file list. This
* could be improved performance-wise by caching data from the last run, at the
* potential cost of reliability -- what if a file is replaced by a new but
* identically-named file -- and we'd still need to check that the files still
* exist so it'd still involve touching the disk again.
*/
export declare function writePlaylistsNew(config: ConfigFile, files: any[]): void;
/**
* Writes a playlist `a.m3u` with all files beginning with A or a, `b.m3u`
* with all files beginning with B or b, and so on. If the filename begins with
* any non-alphabetical character it falls under `!.m3u`.
*/
export declare function writePlaylistsAlphabet(config: ConfigFile, files: any[]): void;