diff --git a/deploy/linux/spotube/default.desktop b/deploy/linux/spotube/default.desktop deleted file mode 100644 index b4ffcef0..00000000 --- a/deploy/linux/spotube/default.desktop +++ /dev/null @@ -1,8 +0,0 @@ -[Desktop Entry] -Type=Application -Name=Application -Exec=AppRun %F -Icon=default -Comment=Edit this default file -Terminal=true -Categories=Utility; \ No newline at end of file diff --git a/deploy/linux/spotube/spotube.desktop b/deploy/linux/spotube/spotube.desktop new file mode 100644 index 00000000..a5c80915 --- /dev/null +++ b/deploy/linux/spotube/spotube.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=Spotube +Exec=AppRun +Icon=default +Comment=A music streaming app combining the power of Spotify & Youtube +Terminal=true +Categories=Music; diff --git a/deploy/linux/spotube/spotube.jpg b/deploy/linux/spotube/spotube.jpg new file mode 100644 index 00000000..4b544b71 Binary files /dev/null and b/deploy/linux/spotube/spotube.jpg differ diff --git a/src/app.tsx b/src/app.tsx index e4e1a319..ed02e1ec 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -13,6 +13,9 @@ import express from "express"; import open from "open"; import spotifyApi from "./initializations/spotifyApi"; import showError from "./helpers/showError"; +import fs from "fs" +import path from "path"; +import { confDir } from "./conf"; export enum CredentialKeys { credentials = "credentials", @@ -26,7 +29,9 @@ export interface Credentials { const minSize = { width: 700, height: 750 }; const winIcon = new QIcon(nodeguiIcon); -global.localStorage = new LocalStorage("./local"); +const localStorageDir = path.join(confDir, "local"); +fs.mkdirSync(localStorageDir, {recursive: true}); +global.localStorage = new LocalStorage(localStorageDir); const queryClient = new QueryClient({ defaultOptions: { queries: { diff --git a/src/components/Library.tsx b/src/components/Library.tsx index 76e739e2..a7aa19d8 100644 --- a/src/components/Library.tsx +++ b/src/components/Library.tsx @@ -68,8 +68,9 @@ function UserSavedTracks() { - {userTracks?.map(({ track }) => ( + {userTracks?.map(({ track }, index) => ( x.name).join(", ")} name={track.name} diff --git a/src/conf.ts b/src/conf.ts index 5087c25e..dffe27da 100644 --- a/src/conf.ts +++ b/src/conf.ts @@ -1,10 +1,13 @@ import dotenv from "dotenv" +import { homedir } from "os"; import { join } from "path"; const env = dotenv.config({path: join(process.cwd(), ".env")}).parsed as any export const clientId = ""; export const trace = process.argv.find(arg => arg === "--trace") ?? false; export const redirectURI = "http://localhost:4304/auth/spotify/callback" +export const confDir = join(homedir(), ".config", "spotube") +export const cacheDir = join(homedir(), ".cache", "spotube") export enum QueryCacheKeys{ categories="categories", diff --git a/src/helpers/getCachedImageBuffer.ts b/src/helpers/getCachedImageBuffer.ts index 3ef3ca5c..38661f8e 100644 --- a/src/helpers/getCachedImageBuffer.ts +++ b/src/helpers/getCachedImageBuffer.ts @@ -6,6 +6,7 @@ import { Stream } from "stream"; import { streamToBuffer } from "./streamToBuffer"; import Jimp from "jimp"; import du from "du"; +import { cacheDir } from "../conf"; interface ImageDimensions { @@ -18,15 +19,15 @@ const fsm = fs.promises; export async function getCachedImageBuffer(name: string, dims?: ImageDimensions): Promise { try { const MB_5 = 5000000; //5 Megabytes - const cacheFolder = path.join(process.cwd(), "cache", "images"); + const cacheImgFolder = path.join(cacheDir, "images"); // for clearing up the cache if it reaches out of the size const cacheName = `${isUrl(name) ? name.split("/").slice(-1)[0] : name}.cnim`; - const cachePath = path.join(cacheFolder, cacheName); + const cachePath = path.join(cacheImgFolder, cacheName); // checking if the cached image already exists or not if (fs.existsSync(cachePath)) { // automatically removing cache after a certain 50 MB oversize - if ((await du(cacheFolder)) > MB_5) { - fs.rmSync(cacheFolder, { recursive: true, force: true }); + if ((await du(cacheImgFolder)) > MB_5) { + fs.rmSync(cacheImgFolder, { recursive: true, force: true }); } const cachedImg = await fsm.readFile(cachePath); const cachedImgMeta = (await Jimp.read(cachedImg)).bitmap; @@ -35,7 +36,7 @@ export async function getCachedImageBuffer(name: string, dims?: ImageDimensions) // images are removed and replaced with a new one if (dims && (cachedImgMeta.height !== dims.height || cachedImgMeta.width !== dims?.width)) { fs.rmSync(cachePath); - return await imageResizeAndWrite(cachedImg, { cacheFolder, cacheName, dims }); + return await imageResizeAndWrite(cachedImg, { cacheFolder: cacheImgFolder, cacheName, dims }); } return cachedImg; } else { @@ -44,11 +45,11 @@ export async function getCachedImageBuffer(name: string, dims?: ImageDimensions) // converting axios stream to buffer const resImgBuf = await streamToBuffer(imgData); // creating cache_dir - await fsm.mkdir(cacheFolder, { recursive: true }); + await fsm.mkdir(cacheImgFolder, { recursive: true }); if (dims) { - return await imageResizeAndWrite(resImgBuf, { cacheFolder, cacheName, dims }); + return await imageResizeAndWrite(resImgBuf, { cacheFolder: cacheImgFolder, cacheName, dims }); } - await fsm.writeFile(path.join(cacheFolder, cacheName), resImgBuf); + await fsm.writeFile(path.join(cacheImgFolder, cacheName), resImgBuf); return resImgBuf; } } catch (error) {