Static Member Summary
Static Public Members | ||
public static get |
constant for movie category |
since 0.0.0 |
public static get |
constant for tv series category |
since 0.0.0 |
Static Method Summary
Static Public Methods | ||
public static |
createFromJSON(json: Object, parser: customParsingFunction): TorrentLibrary Creates an instance of TorrentLibrary |
since 1.2.0 |
public static |
Provides the array of files extensions considered to be media extensions |
since 0.0.0 |
Constructor Summary
Public Constructor | ||
public |
constructor(config: Object, parser: customParsingFunction) Create a TorrentLibrary |
since 1.0.4 |
Member Summary
Public Members | ||
public get |
Getter for the mapping between filepaths and category |
since 0.0.0 |
public get |
Getter for all found movies |
since 0.0.0 |
public get |
Getter for all found tv-series |
since 0.0.0 |
public |
Mapping filepath => category |
since 0.0.0 |
public |
just an easy way to scan the current directory path, if not other paths provided |
since 0.0.0 |
public |
The parsing function to be used with this lib |
since 1.4.0 |
public |
the paths where we are looking the media files |
since 0.0.0 |
public |
The variable where we store all kind of media files found in paths |
since 0.0.0 |
Method Summary
Public Methods | ||
public |
addNewPath(paths: ...string): Promise Add the path(s) to be analyzed by the library if they exist and are readable |
since 0.0.0 |
public |
filterMovies(searchParameters: searchParameters): Set<TPN> Filter the movies based on search parameters |
since 1.3.0 |
public |
filterTvSeries(searchParameters: searchParameters): Map<string, Set<TPN>> Filter the tv-series based on search parameters |
since 1.5.0 |
public |
Tell us if the user has provided us paths |
since 0.0.0 |
public |
removeOldFiles(files: ...string): Promise Removes files stored in this library |
since 1.0.3 |
public |
Scans the paths in search for new files to be added inside this lib |
since 0.0.0 |
public |
Returns an JSON stringified of the current state |
since 1.0.3 |
Static Public Members
Static Public Methods
public static createFromJSON(json: Object, parser: customParsingFunction): TorrentLibrary since 1.2.0 source
Creates an instance of TorrentLibrary
Params:
Name | Type | Attribute | Description |
json | Object |
|
the JSON object of toJSON() string |
json.paths | String[] | the paths where we are looking the media files |
|
json.allFilesWithCategory | Array<Array<String, String>> | Mapping filepath => category |
|
json.movies | TPN_Extended[] | the movies files |
|
json.tv-series | Array<Array<String, TPN_Extended[]>> | the serie files |
|
parser | customParsingFunction |
|
The custom parser you want to use |
Example:
// creates an new instance from another one
const createdInstance = TorrentLibrary.createFromJSON(
JSON.parse(libInstance.toJSON()),
);
// As explained there : https://github.com/clement-escolano/parse-torrent-title#regular-expressions
// If you want an extra field to be populated
const ptt = require("parse-torrent-title");
ptt.addHandler("part", /Part[. ]([0-9])/i, { type: "integer" });
// creates an new instance from another one; with custom parser
const createdInstance = TorrentLibrary.createFromJSON(
JSON.parse(libInstance.toJSON()),
ptt.parse
);
See:
- https://github.com/jy95/torrent-files-library/tree/master/tests/fixtures/example.json for an param example
Public Constructors
public constructor(config: Object, parser: customParsingFunction) since 1.0.4 source
Create a TorrentLibrary
Params:
Name | Type | Attribute | Description |
config | Object |
|
the config object |
config.defaultPath | String |
|
the default path |
config.paths | String[] |
|
the paths where we are looking the media files |
config.allFilesWithCategory | Map<string, string> |
|
Mapping filepath => category |
config.movies | Set<TPN_Extended> |
|
the movies files |
config.series | Map<string, Set<TPN_Extended>> |
|
the serie files |
parser | customParsingFunction |
|
The parsing function to be used with this lib ; default is function parse from parse-torrent-title package |
Public Members
public get allFilesWithCategory: Map<string, string> since 0.0.0 source
Getter for the mapping between filepaths and category
Example:
{ "D:\somePath\Captain Russia The Summer Soldier (2014) 1080p BrRip x264.MKV" => TorrentLibrary.MOVIES_TYPE }
public get allMovies: Set<TPN_Extended> since 0.0.0 source
Getter for all found movies
Example:
// an JSON stringified example of this method
[
{
"year":2012,
"source":"dvdrip",
"codec":"xvid",
"group":"-www.zone-telechargement.ws.avi",
"container":"avi",
"language":"truefrench",
"title":"Bad Ass",
"filePath":"D:\\workspaceNodeJs\\torrent-files-library\\test\\folder1\\Bad.Ass.2012.LiMiTED.TRUEFRENCH.DVDRiP.XviD-www.zone-telechargement.ws.avi"
}
]
Test:
public get allTvSeries: Map<string, Set<TPN_Extended>> since 0.0.0 source
Getter for all found tv-series
Example:
// an JSON stringified example of this method
{
"The Blacklist":[
{
"season":4,
"episode":21,
"source":"webrip",
"codec":"xvid",
"container":"avi",
"language":"french",
"title":"The Blacklist",
"filePath":"D:\\workspaceNodeJs\\torrent-files-library\\test\\folder1\\The.Blacklist.S04E21.FRENCH.WEBRip.XviD.avi"
},
{
"season":4,
"episode":14,
"source":"webrip",
"codec":"xvid",
"container":"avi",
"language":"french",
"title":"The Blacklist",
"filePath":"D:\\workspaceNodeJs\\torrent-files-library\\test\\folder2\\The.Blacklist.S04E14.FRENCH.WEBRip.XviD.avi"
}
]
}
Test:
public categoryForFile: Map<string, string> since 0.0.0 source
Mapping filepath => category
Example:
{ "D:\somePath\Captain Russia The Summer Soldier (2014) 1080p BrRip x264.MKV" => TorrentLibrary.MOVIES_TYPE }
public defaultPath: string since 0.0.0 source
just an easy way to scan the current directory path, if not other paths provided
public parser: customParsingFunction since 1.4.0 source
The parsing function to be used with this lib
Public Methods
public addNewPath(paths: ...string): Promise since 0.0.0 source
Add the path(s) to be analyzed by the library if they exist and are readable
Params:
Name | Type | Attribute | Description |
paths | ...string | A or more path(s) |
Return:
Promise | On success the promise will be resolved with "All paths were added!" |
Emit:
* |
Events#missing_parameter |
* |
Events#error_in_function |
* |
Events#addNewPath |
Example:
// return resolved Promise "All paths were added!"
TorrentLibraryInstance.addNewPath("C:\Users\jy95\Desktop\New folder","C:\Users\jy95\Desktop\New folder2");
public filterMovies(searchParameters: searchParameters): Set<TPN> since 1.3.0 source
Filter the movies based on search parameters
Params:
Name | Type | Attribute | Description |
searchParameters | searchParameters | search parameters. |
public filterTvSeries(searchParameters: searchParameters): Map<string, Set<TPN>> since 1.5.0 source
Filter the tv-series based on search parameters
Params:
Name | Type | Attribute | Description |
searchParameters | searchParameters | search parameters. |
public hasPathsProvidedByUser(): boolean since 0.0.0 source
Tell us if the user has provided us paths
Example:
TorrentLibraryInstance.addNewPath("C:\Users\jy95\Desktop\New folder","C:\Users\jy95\Desktop\New folder2");
TorrentLibraryInstance.hasPathsProvidedByUser() // TRUE
public removeOldFiles(files: ...string): Promise since 1.0.3 source
Removes files stored in this library
Params:
Name | Type | Attribute | Description |
files | ...string | An array of filePath (for example the keys of allFilesWithCategory) |
Return:
Promise | an resolved or rejected promise |
Emit:
* |
Events#removeOldFiles |
* |
Events#error_in_function |
Example:
// with multiples files
TorrentLibraryInstance.removeOldFiles(
"D:\somePath\Captain Russia The Summer Soldier (2014) 1080p BrRip x264.MKV",
"D:\\workspaceNodeJs\\torrent-files-library\\test\\folder1\\The.Blacklist.S04E21.FRENCH.WEBRip.XviD.avi"
)
public scan(): Promise since 0.0.0 source
Scans the paths in search for new files to be added inside this lib
Return:
Promise | On success the promise will be resolved with "Scanning completed" |
Emit:
* |
Events#scan |
* |
Events#error_in_function |