aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/appendMetaToEpisodes.js2
-rw-r--r--utils/getRedisWithPrefix.js13
-rw-r--r--utils/getTimes.js7
-rw-r--r--utils/imageUtils.js22
4 files changed, 43 insertions, 1 deletions
diff --git a/utils/appendMetaToEpisodes.js b/utils/appendMetaToEpisodes.js
index eedcbf5..197788b 100644
--- a/utils/appendMetaToEpisodes.js
+++ b/utils/appendMetaToEpisodes.js
@@ -2,7 +2,7 @@ async function appendMetaToEpisodes(episodesData, images) {
// Create a dictionary for faster lookup of images based on episode number
const episodeImages = {};
images.forEach((image) => {
- episodeImages[image.episode] = image;
+ episodeImages[image.number || image.episode] = image;
});
// Iterate through each provider's episodes data
diff --git a/utils/getRedisWithPrefix.js b/utils/getRedisWithPrefix.js
index 31a466d..b85589b 100644
--- a/utils/getRedisWithPrefix.js
+++ b/utils/getRedisWithPrefix.js
@@ -63,6 +63,19 @@ export async function getValuesWithNumericKeys() {
return values;
}
+export async function getKeysWithNumericKeys() {
+ const allKeys = await redis.keys("*"); // Fetch all keys in Redis
+ const numericKeys = allKeys.filter((key) => /^\d+$/.test(key)); // Filter keys that contain only numbers
+
+ const values = [];
+
+ for (const key of numericKeys) {
+ const value = await redis.del(key);
+ }
+
+ return values;
+}
+
export async function countNumericKeys() {
const allKeys = await redis.keys("*"); // Fetch all keys in Redis
const numericKeys = allKeys.filter((key) => /^\d+$/.test(key)); // Filter keys that contain only numbers
diff --git a/utils/getTimes.js b/utils/getTimes.js
index d06f797..491d139 100644
--- a/utils/getTimes.js
+++ b/utils/getTimes.js
@@ -132,3 +132,10 @@ export function unixTimestampToRelativeTime(unixTimestamp) {
return "just now";
}
+
+export function unixToSeconds(unixTimestamp) {
+ const now = Math.floor(Date.now() / 1000); // Current Unix timestamp in seconds
+ const secondsAgo = now - unixTimestamp;
+
+ return secondsAgo;
+}
diff --git a/utils/imageUtils.js b/utils/imageUtils.js
new file mode 100644
index 0000000..e5ac6a9
--- /dev/null
+++ b/utils/imageUtils.js
@@ -0,0 +1,22 @@
+export function getHeaders(providerId) {
+ switch (providerId) {
+ case "mangahere":
+ return { Referer: "https://mangahere.org" };
+ case "mangadex":
+ return { Referer: "https://mangadex.org" };
+ case "mangakakalot":
+ return { Referer: "https://mangakakalot.com" };
+ case "mangapill":
+ return { Referer: "https://mangapill.com" };
+ case "mangasee123":
+ return { Referer: "https://mangasee123.com" };
+ case "comick":
+ return { Referer: "https://comick.app" };
+ default:
+ return null;
+ }
+}
+
+export function getRandomId() {
+ return Math.random().toString(36).substr(2, 9);
+}