@jjdenhertog/plex-music-search 1.0.16 → 1.0.18
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/actions/hubSearch.js +7 -0
- package/index.js +13 -14
- package/package.json +1 -1
package/actions/hubSearch.js
CHANGED
@@ -13,6 +13,12 @@ var getAPIUrl_1 = __importDefault(require("../utils/getAPIUrl"));
|
|
13
13
|
function hubSearch(uri, token, query, limit) {
|
14
14
|
if (limit === void 0) { limit = 5; }
|
15
15
|
return new Promise(function (resolve, reject) {
|
16
|
+
// Fix forbidden characters
|
17
|
+
var forbiddenCharacters = ['[', ']'];
|
18
|
+
for (var i = 0; i < forbiddenCharacters.length; i++) {
|
19
|
+
var element = forbiddenCharacters[i];
|
20
|
+
query = query.split(element).join('');
|
21
|
+
}
|
16
22
|
var url = (0, getAPIUrl_1.default)(uri, "/hubs/search?query=".concat(fixedEncodeURIComponent(query.trim()), "&limit=").concat(limit));
|
17
23
|
AxiosRequest_1.AxiosRequest.get(url, token)
|
18
24
|
.then(function (result) {
|
@@ -74,6 +80,7 @@ function hubSearch(uri, token, query, limit) {
|
|
74
80
|
resolve(response);
|
75
81
|
})
|
76
82
|
.catch(function (_error) {
|
83
|
+
console.error("Plex API Request failed:\n".concat(url));
|
77
84
|
reject("Could not connect to server");
|
78
85
|
});
|
79
86
|
});
|
package/index.js
CHANGED
@@ -329,7 +329,6 @@ var PlexMusicSearch = /** @class */ (function () {
|
|
329
329
|
foundCache = this._cache.find(function (item) { return item.id == cacheId; });
|
330
330
|
if (foundCache)
|
331
331
|
return [2 /*return*/, foundCache.result];
|
332
|
-
console.log(artist, title, album);
|
333
332
|
searchHandler = searchAlbumTracks ? searchForAlbumTracks_1.searchForAlbumTracks : searchForTrack_1.searchForTrack;
|
334
333
|
return [4 /*yield*/, searchHandler(this._config.uri, this._config.token, artist, title, album)];
|
335
334
|
case 1:
|
@@ -351,22 +350,22 @@ var PlexMusicSearch = /** @class */ (function () {
|
|
351
350
|
});
|
352
351
|
});
|
353
352
|
};
|
353
|
+
searchApproachIndex = 0;
|
354
354
|
_b.label = 1;
|
355
355
|
case 1:
|
356
|
-
|
357
|
-
searchApproachIndex = 0;
|
358
|
-
_b.label = 2;
|
359
|
-
case 2:
|
360
|
-
if (!approaches[searchApproachIndex]) return [3 /*break*/, 8];
|
356
|
+
if (!approaches[searchApproachIndex]) return [3 /*break*/, 10];
|
361
357
|
approach = approaches[searchApproachIndex];
|
362
358
|
if (searchResult.length > 0) {
|
363
359
|
searchApproachIndex++;
|
364
|
-
return [3 /*break*/,
|
360
|
+
return [3 /*break*/, 1];
|
365
361
|
}
|
366
362
|
approachId = approach.id, trim = approach.trim, filtered = approach.filtered, removeQuotes = approach.ignoreQuotes;
|
367
363
|
searchArtist = (0, music_search_1.filterOutWords)(artist.toLowerCase(), filtered, trim, removeQuotes);
|
368
364
|
searchAlbum = (0, music_search_1.filterOutWords)(album.toLowerCase(), filtered, trim, removeQuotes);
|
369
365
|
searchTrack = (0, music_search_1.filterOutWords)(title.toLowerCase(), filtered, trim, removeQuotes);
|
366
|
+
_b.label = 2;
|
367
|
+
case 2:
|
368
|
+
_b.trys.push([2, 8, , 9]);
|
370
369
|
return [4 /*yield*/, performSearch(approachId, searchArtist, searchTrack, searchAlbum)
|
371
370
|
////////////////////////////////////////
|
372
371
|
// Rewrite "&"" to "and"
|
@@ -388,10 +387,14 @@ var PlexMusicSearch = /** @class */ (function () {
|
|
388
387
|
case 6:
|
389
388
|
searchResult = _b.sent();
|
390
389
|
_b.label = 7;
|
391
|
-
case 7:
|
390
|
+
case 7: return [3 /*break*/, 9];
|
391
|
+
case 8:
|
392
|
+
_e_3 = _b.sent();
|
393
|
+
throw new Error("Something went wrong while searching");
|
394
|
+
case 9:
|
392
395
|
searchApproachIndex++;
|
393
|
-
return [3 /*break*/,
|
394
|
-
case
|
396
|
+
return [3 /*break*/, 1];
|
397
|
+
case 10: return [2 /*return*/, {
|
395
398
|
id: id,
|
396
399
|
artist: artist,
|
397
400
|
album: album,
|
@@ -399,10 +402,6 @@ var PlexMusicSearch = /** @class */ (function () {
|
|
399
402
|
queries: queries,
|
400
403
|
result: searchResult
|
401
404
|
}];
|
402
|
-
case 9:
|
403
|
-
_e_3 = _b.sent();
|
404
|
-
throw new Error("Something went wrong while searching");
|
405
|
-
case 10: return [2 /*return*/];
|
406
405
|
}
|
407
406
|
});
|
408
407
|
});
|