@jjdenhertog/plex-music-search 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +2 -0
- package/index.js +15 -9
- package/package.json +1 -1
package/index.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { Metadata } from "./types";
|
1
2
|
import { PlexMusicSearchConfig } from "./types/PlexMusicSearchConfig";
|
2
3
|
import { PlexMusicSearchTrack } from "./types/PlexMusicSearchTrack";
|
3
4
|
import { PlexTrack } from "./types/PlexTrack";
|
@@ -9,6 +10,7 @@ export declare class PlexMusicSearch {
|
|
9
10
|
search(tracks: PlexMusicSearchTrack[]): Promise<SearchResponse[]>;
|
10
11
|
analyze(track: PlexMusicSearchTrack): Promise<SearchResponse>;
|
11
12
|
searchAlbum(tracks: PlexMusicSearchTrack[]): Promise<SearchResponse[]>;
|
13
|
+
getMetaData(key: string): Promise<Metadata[]>;
|
12
14
|
getById(key: string): Promise<PlexTrack>;
|
13
15
|
private _newTrackSearch;
|
14
16
|
private _findTrack;
|
package/index.js
CHANGED
@@ -228,6 +228,9 @@ var PlexMusicSearch = /** @class */ (function () {
|
|
228
228
|
});
|
229
229
|
});
|
230
230
|
};
|
231
|
+
PlexMusicSearch.prototype.getMetaData = function (key) {
|
232
|
+
return (0, getMetadata_1.getMetadata)(this._config.uri, this._config.token, key);
|
233
|
+
};
|
231
234
|
PlexMusicSearch.prototype.getById = function (key) {
|
232
235
|
return __awaiter(this, void 0, void 0, function () {
|
233
236
|
var metaData, item, src;
|
@@ -300,20 +303,21 @@ var PlexMusicSearch = /** @class */ (function () {
|
|
300
303
|
};
|
301
304
|
PlexMusicSearch.prototype._findTrack = function (approaches, find, includeMatching) {
|
302
305
|
return __awaiter(this, void 0, void 0, function () {
|
303
|
-
var searchResult, id, artist, title, _a, album, musicSearch, performSearch, searchApproachIndex, approach, trim, filtered, removeQuotes, searchArtist, searchAlbum, searchTrack, altSearchArtist, altSearchTrack, _e_3;
|
306
|
+
var searchResult, id, artist, title, _a, album, queries, musicSearch, performSearch, searchApproachIndex, approach, approachId, trim, filtered, removeQuotes, searchArtist, searchAlbum, searchTrack, altSearchArtist, altSearchTrack, _e_3;
|
304
307
|
var _this = this;
|
305
308
|
return __generator(this, function (_b) {
|
306
309
|
switch (_b.label) {
|
307
310
|
case 0:
|
308
311
|
searchResult = [];
|
309
312
|
id = find.id, artist = find.artist, title = find.title, _a = find.album, album = _a === void 0 ? '' : _a;
|
313
|
+
queries = [];
|
310
314
|
musicSearch = music_search_1.default.getInstance();
|
311
|
-
performSearch = function (artist_1, title_1, album_2) {
|
315
|
+
performSearch = function (approach_1, artist_1, title_1, album_2) {
|
312
316
|
var args_1 = [];
|
313
|
-
for (var _i =
|
314
|
-
args_1[_i -
|
317
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
318
|
+
args_1[_i - 4] = arguments[_i];
|
315
319
|
}
|
316
|
-
return __awaiter(_this, __spreadArray([artist_1, title_1, album_2], args_1, true), void 0, function (artist, title, album, searchAlbumTracks) {
|
320
|
+
return __awaiter(_this, __spreadArray([approach_1, artist_1, title_1, album_2], args_1, true), void 0, function (approach, artist, title, album, searchAlbumTracks) {
|
317
321
|
var cacheId, foundCache, searchHandler, searchResults, musicSearchResult, plexTracks;
|
318
322
|
if (searchAlbumTracks === void 0) { searchAlbumTracks = false; }
|
319
323
|
return __generator(this, function (_a) {
|
@@ -338,6 +342,7 @@ var PlexMusicSearch = /** @class */ (function () {
|
|
338
342
|
.filter(function (item) { return !!item; })
|
339
343
|
.map(function (item) { return (__assign(__assign({}, (0, hubSearchToPlexTrack_1.default)(item)), { matching: item.matching, reason: item.reason })); });
|
340
344
|
this._cache.push({ id: cacheId, result: plexTracks });
|
345
|
+
queries.push({ approach: approach, artist: artist, title: title, album: album });
|
341
346
|
return [2 /*return*/, plexTracks];
|
342
347
|
}
|
343
348
|
});
|
@@ -355,11 +360,11 @@ var PlexMusicSearch = /** @class */ (function () {
|
|
355
360
|
searchApproachIndex++;
|
356
361
|
return [3 /*break*/, 2];
|
357
362
|
}
|
358
|
-
trim = approach.trim, filtered = approach.filtered, removeQuotes = approach.ignoreQuotes;
|
363
|
+
approachId = approach.id, trim = approach.trim, filtered = approach.filtered, removeQuotes = approach.ignoreQuotes;
|
359
364
|
searchArtist = (0, music_search_1.filterOutWords)(artist.toLowerCase(), filtered, trim, removeQuotes);
|
360
365
|
searchAlbum = (0, music_search_1.filterOutWords)(album.toLowerCase(), filtered, trim, removeQuotes);
|
361
366
|
searchTrack = (0, music_search_1.filterOutWords)(title.toLowerCase(), filtered, trim, removeQuotes);
|
362
|
-
return [4 /*yield*/, performSearch(searchArtist, searchTrack, searchAlbum)
|
367
|
+
return [4 /*yield*/, performSearch(approachId, searchArtist, searchTrack, searchAlbum)
|
363
368
|
////////////////////////////////////////
|
364
369
|
// Rewrite "&"" to "and"
|
365
370
|
////////////////////////////////////////
|
@@ -370,13 +375,13 @@ var PlexMusicSearch = /** @class */ (function () {
|
|
370
375
|
if (!(searchResult.length == 0 && (searchArtist.indexOf("&") || searchTrack.indexOf("&") > -1))) return [3 /*break*/, 5];
|
371
376
|
altSearchArtist = searchArtist.split('&').join('and');
|
372
377
|
altSearchTrack = searchTrack.split('&').join('and');
|
373
|
-
return [4 /*yield*/, performSearch(altSearchArtist, altSearchTrack, searchAlbum)];
|
378
|
+
return [4 /*yield*/, performSearch(approachId, altSearchArtist, altSearchTrack, searchAlbum)];
|
374
379
|
case 4:
|
375
380
|
searchResult = _b.sent();
|
376
381
|
_b.label = 5;
|
377
382
|
case 5:
|
378
383
|
if (!(searchResult.length == 0)) return [3 /*break*/, 7];
|
379
|
-
return [4 /*yield*/, performSearch(searchArtist, searchTrack, searchAlbum, true)];
|
384
|
+
return [4 /*yield*/, performSearch(approachId, searchArtist, searchTrack, searchAlbum, true)];
|
380
385
|
case 6:
|
381
386
|
searchResult = _b.sent();
|
382
387
|
_b.label = 7;
|
@@ -388,6 +393,7 @@ var PlexMusicSearch = /** @class */ (function () {
|
|
388
393
|
artist: artist,
|
389
394
|
album: album,
|
390
395
|
title: title,
|
396
|
+
queries: queries,
|
391
397
|
result: searchResult
|
392
398
|
}];
|
393
399
|
case 9:
|