Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ipmanlk/rem-track-hunter

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ipmanlk/rem-track-hunter - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

cache/cache.db

52

dist/general/common.js
"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 @@ });

87

dist/main.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc