Skip to content
Closed

Fix #201

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
title: ""
labels: bug
assignees: ''

assignees: ""
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand Down
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
title: ""
labels: enhancement
assignees: ''

assignees: ""
---

**Describe the solution you'd like**
Expand Down
12 changes: 8 additions & 4 deletions cli/src/bitrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,19 @@ export function parseBitrate(
settings: Pick<Settings, "maxBitrate">,
bitrate: string
) {
if (typeof bitrate !== "string") {
console.error("Bitrate must be a string");
process.exit(1);
}

const downloadBitrate = getBitrateNumberFromText(bitrate);

if (downloadBitrate) {
settings.maxBitrate = downloadBitrate;
} else {
if (downloadBitrate === undefined) {
displayBitrateHelp(bitrate);

process.exit(1);
}

settings.maxBitrate = downloadBitrate;
}

export function getBitrateNumberFromText(text: string) {
Expand Down
8 changes: 8 additions & 0 deletions cli/src/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ export const downloadLinks = async (
settings: Settings,
spotifyPlugin: SpotifyPlugin
) => {
if (!dz || !urls || !settings || !spotifyPlugin) {
throw new Error("Missing required parameters");
}

if (!Array.isArray(urls)) {
throw new Error("URLs must be an array");
}

const bitrate = settings.maxBitrate ?? TrackFormats.MP3_128;

const downloadObjects = [];
Expand Down
19 changes: 13 additions & 6 deletions cli/src/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,25 @@ import readline from "node:readline/promises";
import path from "path";

export const deezerLogin = async (dz: Deezer, configFolder: string) => {
if (!dz || typeof configFolder !== "string") {
throw new Error("Invalid parameters");
}

const arlFileLocation = path.join(configFolder, ".arl");

if (existsSync(arlFileLocation)) {
const arl = readFileSync(arlFileLocation).toString().trim();
const loggedIn = await dz.loginViaArl(arl);
try {
const arl = readFileSync(arlFileLocation).toString().trim();
if (!arl) throw new Error("Empty ARL file");

const loggedIn = await dz.loginViaArl(arl);
if (!loggedIn) throw new Error("Invalid ARL");

if (loggedIn) {
return true;
} catch (e) {
rmSync(arlFileLocation);
throw e;
}

// If the ARL is invalid, remove it
rmSync(arlFileLocation);
}

const rl = readline.createInterface({
Expand Down
7 changes: 7 additions & 0 deletions deemix/src/decryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ export function reverseStreamURL(url) {
}

export async function streamTrack(writepath, track, downloadObject, listener) {
if (!track || !track.downloadURL) {
throw new Error("Invalid track data - missing downloadURL");
}

if (!writepath) {
throw new Error("Missing writepath parameter");
}
if (downloadObject && downloadObject.isCanceled) throw new DownloadCanceled();
const headers = { "User-Agent": USER_AGENT_HEADER };
let chunkLength = 0;
Expand Down
4 changes: 4 additions & 0 deletions deemix/src/download-objects/Collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export class Collection extends DownloadObject {
collection: any;

constructor(obj) {
if (!obj?.collection) {
throw new Error("Invalid collection data");
}

super(obj);
this.collection = obj.collection;
this.__type__ = "Collection";
Expand Down
11 changes: 11 additions & 0 deletions deemix/src/download-objects/DownloadObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ export class DownloadObject {
__type__: "Single" | "Collection" | "Convertable";

constructor(obj) {
if (!obj || typeof obj !== "object") {
throw new Error("Invalid download object data");
}

if (!obj.type || !obj.id || obj.bitrate === undefined) {
throw new Error("Missing required download object properties");
}

this.type = obj.type;
this.id = obj.id;
this.bitrate = obj.bitrate;
Expand Down Expand Up @@ -94,6 +102,9 @@ export class DownloadObject {
}

updateProgress(listener: Listener) {
if (this.progressNext < 0 || this.progressNext > 100) {
throw new Error("Invalid progress value");
}
if (
Math.floor(this.progressNext) !== this.progress &&
Math.floor(this.progressNext) % 2 === 0 &&
Expand Down
2 changes: 2 additions & 0 deletions deemix/src/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export class Downloader {
settings: Settings,
listener: Listener
) {
if (!dz) throw new Error("Deezer instance is required");
if (!downloadObject) throw new Error("DownloadObject is required");
this.dz = dz;
this.downloadObject = downloadObject;
this.settings = settings || DEFAULT_SETTINGS;
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ services:
ports:
- 6595:6595
volumes:
- "${DEEMIX_CONFIG_PATH}:/config" # Set the `DEEMIX_CONFIG_PATH` environment variable in the shell where `docker-compose up` is being ran
- "${DEEMIX_CONFIG_PATH}:/config" # Set the `DEEMIX_CONFIG_PATH` environment variable in the shell where `docker-compose up` is being ran
- "${DEEMIX_MUSIC_PATH}:/downloads" # Set the `DEEMIX_MUSIC_PATH` environment variable in the shell where `docker-compose up` is being ran
2 changes: 1 addition & 1 deletion gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@electron/rebuild": "^3.7.0",
"@types/yargs": "^17.0.33",
"electron": "33.0.2",
"esbuild": "^0.24.0",
"esbuild": "^0.25.0",
"node-gyp": "^10.2.0",
"tsup": "^8.3.5"
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@types/eslint-config-prettier": "^6.11.3",
"@types/node": "^20.16.3",
"@typescript-eslint/parser": "~8.26.1",
"esbuild": "^0.25.1",
"esbuild": "^0.25.0",
"eslint": "^9.22.0",
"eslint-config-prettier": "^10.1.1",
"eslint-plugin-vue": "^10.0.0",
Expand Down
Loading