@ipmanlk/rem-track-hunter
Advanced tools
Comparing version 1.0.3 to 1.0.4
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -45,2 +64,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
var ytsr_1 = __importDefault(require("ytsr")); | ||
var Cache = __importStar(require("../util/cache")); | ||
/** | ||
@@ -66,3 +86,3 @@ * @internal | ||
return __awaiter(this, void 0, void 0, function () { | ||
var youtubeLink, searchResults, e_1; | ||
var youtubeLink, cachedLink, searchResults, e_1; | ||
return __generator(this, function (_a) { | ||
@@ -72,5 +92,12 @@ switch (_a.label) { | ||
youtubeLink = false; | ||
_a.label = 1; | ||
return [4 /*yield*/, Cache.getValue("youtube_url", keyword).catch(function (e) { | ||
console.log("Failed to read youtube_url table."); | ||
})]; | ||
case 1: | ||
_a.trys.push([1, 3, , 5]); | ||
cachedLink = _a.sent(); | ||
if (cachedLink) | ||
return [2 /*return*/, cachedLink]; | ||
_a.label = 2; | ||
case 2: | ||
_a.trys.push([2, 4, , 6]); | ||
return [4 /*yield*/, ytsr_1.default(keyword, { | ||
@@ -80,13 +107,20 @@ limit: 1, | ||
})]; | ||
case 2: | ||
case 3: | ||
searchResults = (_a.sent()); | ||
youtubeLink = searchResults.items[0].link || false; | ||
return [3 /*break*/, 5]; | ||
case 3: | ||
return [3 /*break*/, 6]; | ||
case 4: | ||
e_1 = _a.sent(); | ||
return [4 /*yield*/, searchSearx(keyword)]; | ||
case 4: | ||
case 5: | ||
youtubeLink = _a.sent(); | ||
return [3 /*break*/, 5]; | ||
case 5: return [2 /*return*/, youtubeLink]; | ||
return [3 /*break*/, 6]; | ||
case 6: | ||
// if it's not false, write to cache | ||
if (typeof youtubeLink == "string") { | ||
Cache.saveValue("youtube_url", keyword, youtubeLink).catch(function (e) { | ||
console.log("Failed to write to youtube_url table."); | ||
}); | ||
} | ||
return [2 /*return*/, youtubeLink]; | ||
} | ||
@@ -93,0 +127,0 @@ }); |
@@ -65,24 +65,75 @@ "use strict"; | ||
var common_1 = require("./general/common"); | ||
var Cache = __importStar(require("./util/cache")); | ||
// init cache | ||
Cache.initializeDatabase(); | ||
function getTracks(keywordOrUrl, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var urlType; | ||
var urlType, cachedTracks, e_1, tracks, cachedTracks, e_2, tracks, cachedTracks, e_3, tracks; | ||
return __generator(this, function (_a) { | ||
// when options are not provided, try to guess type or use youtube | ||
if (!options || !options.type) { | ||
urlType = common_1.getUrlType(keywordOrUrl) || "youtube"; | ||
switch (_a.label) { | ||
case 0: | ||
// when options are not provided, try to guess type or use youtube | ||
if (!options || !options.type) { | ||
urlType = common_1.getUrlType(keywordOrUrl) || "youtube"; | ||
} | ||
else { | ||
urlType = options.type; | ||
} | ||
if (!(urlType == "youtube")) return [3 /*break*/, 5]; | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 5]); | ||
return [4 /*yield*/, Cache.getValue("youtube", keywordOrUrl)]; | ||
case 2: | ||
cachedTracks = _a.sent(); | ||
return [2 /*return*/, JSON.parse(cachedTracks)]; | ||
case 3: | ||
e_1 = _a.sent(); | ||
return [4 /*yield*/, Youtube.getTracks(keywordOrUrl)]; | ||
case 4: | ||
tracks = _a.sent(); | ||
Cache.saveValue("youtube", keywordOrUrl, JSON.stringify(tracks)).catch(function (e) { | ||
console.log(e); | ||
}); | ||
return [2 /*return*/, tracks]; | ||
case 5: | ||
if (!(urlType == "spotify")) return [3 /*break*/, 10]; | ||
_a.label = 6; | ||
case 6: | ||
_a.trys.push([6, 8, , 10]); | ||
return [4 /*yield*/, Cache.getSpotifyValue(keywordOrUrl)]; | ||
case 7: | ||
cachedTracks = _a.sent(); | ||
return [2 /*return*/, cachedTracks]; | ||
case 8: | ||
e_2 = _a.sent(); | ||
return [4 /*yield*/, Spotify.getTracks(keywordOrUrl)]; | ||
case 9: | ||
tracks = _a.sent(); | ||
Cache.saveValue("spotify", keywordOrUrl, JSON.stringify(tracks)).catch(function (e) { | ||
console.log(e); | ||
}); | ||
return [2 /*return*/, tracks]; | ||
case 10: | ||
if (!(urlType == "themes.moe")) return [3 /*break*/, 15]; | ||
_a.label = 11; | ||
case 11: | ||
_a.trys.push([11, 13, , 15]); | ||
return [4 /*yield*/, Cache.getValue("themesmoe", keywordOrUrl)]; | ||
case 12: | ||
cachedTracks = _a.sent(); | ||
return [2 /*return*/, JSON.parse(cachedTracks)]; | ||
case 13: | ||
e_3 = _a.sent(); | ||
return [4 /*yield*/, Themesmoe.getTracks(keywordOrUrl)]; | ||
case 14: | ||
tracks = _a.sent(); | ||
Cache.saveValue("themesmoe", keywordOrUrl, JSON.stringify(tracks)).catch(function (e) { | ||
console.log(e); | ||
}); | ||
return [2 /*return*/, tracks]; | ||
case 15: | ||
// if urlType is not matched | ||
throw "Please provide a valid type!."; | ||
} | ||
else { | ||
urlType = options.type; | ||
} | ||
if (urlType == "youtube") { | ||
return [2 /*return*/, Youtube.getTracks(keywordOrUrl)]; | ||
} | ||
if (urlType == "spotify") { | ||
return [2 /*return*/, Spotify.getTracks(keywordOrUrl)]; | ||
} | ||
if (urlType == "themes.moe") { | ||
return [2 /*return*/, Themesmoe.getTracks(keywordOrUrl)]; | ||
} | ||
// if urlType is not matched | ||
throw "Please provide a valid type!."; | ||
}); | ||
@@ -89,0 +140,0 @@ }); |
export * as General from "./general"; | ||
export * as Spotify from "./spotify"; | ||
export * as Anime from "./anime"; | ||
export * as Database from "./database"; |
@@ -22,5 +22,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Anime = exports.Spotify = exports.General = void 0; | ||
exports.Database = exports.Anime = exports.Spotify = exports.General = void 0; | ||
exports.General = __importStar(require("./general")); | ||
exports.Spotify = __importStar(require("./spotify")); | ||
exports.Anime = __importStar(require("./anime")); | ||
exports.Database = __importStar(require("./database")); |
{ | ||
"name": "@ipmanlk/rem-track-hunter", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "", | ||
@@ -23,2 +23,3 @@ "main": "dist/index.js", | ||
"spotify-uri": "^2.1.0", | ||
"sqlite3": "^5.0.0", | ||
"ytpl": "^1.0.1", | ||
@@ -32,2 +33,3 @@ "ytsr": "^1.0.4" | ||
"@types/node-fetch": "^2.5.7", | ||
"@types/sqlite3": "^3.1.6", | ||
"eslint": "^7.11.0", | ||
@@ -34,0 +36,0 @@ "eslint-config-prettier": "^6.14.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99399
36
1405
7
11
2
1
+ Addedsqlite3@^5.0.0
+ Added@gar/promisify@1.1.3(transitive)
+ Added@npmcli/fs@1.1.1(transitive)
+ Added@npmcli/move-file@1.1.2(transitive)
+ Added@tootallnate/once@1.1.2(transitive)
+ Addedabbrev@1.1.1(transitive)
+ Addedagent-base@6.0.2(transitive)
+ Addedagentkeepalive@4.5.0(transitive)
+ Addedaggregate-error@3.1.0(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedaproba@2.0.0(transitive)
+ Addedare-we-there-yet@3.0.1(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbindings@1.5.0(transitive)
+ Addedbl@4.1.0(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedcacache@15.3.0(transitive)
+ Addedchownr@1.1.42.0.0(transitive)
+ Addedclean-stack@2.2.0(transitive)
+ Addedcolor-support@1.1.3(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedconsole-control-strings@1.1.0(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addeddecompress-response@6.0.0(transitive)
+ Addeddeep-extend@0.6.0(transitive)
+ Addeddelegates@1.0.0(transitive)
+ Addeddetect-libc@2.0.3(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedenv-paths@2.2.1(transitive)
+ Addederr-code@2.0.3(transitive)
+ Addedexpand-template@2.0.3(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addedfs-constants@1.0.0(transitive)
+ Addedfs-minipass@2.1.0(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedgauge@4.0.4(transitive)
+ Addedgithub-from-package@0.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-unicode@2.0.1(transitive)
+ Addedhttp-cache-semantics@4.1.1(transitive)
+ Addedhttp-proxy-agent@4.0.1(transitive)
+ Addedhttps-proxy-agent@5.0.1(transitive)
+ Addedhumanize-ms@1.2.1(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedimurmurhash@0.1.4(transitive)
+ Addedindent-string@4.0.0(transitive)
+ Addedinfer-owner@1.0.4(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedini@1.3.8(transitive)
+ Addedip-address@9.0.5(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedis-lambda@1.0.1(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedjsbn@1.1.0(transitive)
+ Addedlru-cache@6.0.0(transitive)
+ Addedmake-fetch-happen@9.1.0(transitive)
+ Addedmimic-response@3.1.0(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedminipass@3.3.65.0.0(transitive)
+ Addedminipass-collect@1.0.2(transitive)
+ Addedminipass-fetch@1.4.1(transitive)
+ Addedminipass-flush@1.0.5(transitive)
+ Addedminipass-pipeline@1.2.4(transitive)
+ Addedminipass-sized@1.0.3(transitive)
+ Addedminizlib@2.1.2(transitive)
+ Addedmkdirp@1.0.4(transitive)
+ Addedmkdirp-classic@0.5.3(transitive)
+ Addedms@2.1.3(transitive)
+ Addednapi-build-utils@1.0.2(transitive)
+ Addednegotiator@0.6.4(transitive)
+ Addednode-abi@3.71.0(transitive)
+ Addednode-addon-api@7.1.1(transitive)
+ Addednode-gyp@8.4.1(transitive)
+ Addednopt@5.0.0(transitive)
+ Addednpmlog@6.0.2(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedp-map@4.0.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedprebuild-install@7.1.2(transitive)
+ Addedpromise-inflight@1.0.1(transitive)
+ Addedpromise-retry@2.0.1(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedrc@1.2.8(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedretry@0.12.0(transitive)
+ Addedrimraf@3.0.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsemver@7.6.3(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedsimple-concat@1.0.1(transitive)
+ Addedsimple-get@4.0.1(transitive)
+ Addedsmart-buffer@4.2.0(transitive)
+ Addedsocks@2.8.3(transitive)
+ Addedsocks-proxy-agent@6.2.1(transitive)
+ Addedsprintf-js@1.1.3(transitive)
+ Addedsqlite3@5.1.7(transitive)
+ Addedssri@8.0.1(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedstrip-json-comments@2.0.1(transitive)
+ Addedtar@6.2.1(transitive)
+ Addedtar-fs@2.1.1(transitive)
+ Addedtar-stream@2.2.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedunique-filename@1.1.1(transitive)
+ Addedunique-slug@2.0.2(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwhich@2.0.2(transitive)
+ Addedwide-align@1.1.5(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedyallist@4.0.0(transitive)