generated from uwu/neptune-template
-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SongDownloader - Basic native functionality
- Loading branch information
Showing
13 changed files
with
830 additions
and
65 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
import { html } from "@neptune/voby"; | ||
import { getSettings } from "@inrixia/lib/storage"; | ||
import { AudioQualityInverse, AudioQuality, validQualitiesSettings } from "@inrixia/lib/AudioQualityTypes"; | ||
import { AudioQuality, validQualitiesSettings } from "@inrixia/lib/AudioQualityTypes"; | ||
import { DropdownSelect } from "@inrixia/lib/components/DropdownSelect"; | ||
import { TextInput } from "@inrixia/lib/components/TextInput"; | ||
import { SwitchSetting } from "@inrixia/lib/components/SwitchSetting"; | ||
|
||
export const settings = getSettings({ | ||
desiredDownloadQuality: AudioQuality.HiRes, | ||
defaultDownloadPath: "", | ||
alwaysUseDefaultPath: true, | ||
}); | ||
export const Settings = () => html`<div> | ||
<${DropdownSelect} | ||
selected=${settings.desiredDownloadQuality} | ||
onSelect=${(selected: AudioQuality) => (settings.desiredDownloadQuality = selected)} | ||
options=${validQualitiesSettings} | ||
title="Download Quality" | ||
title="Download quality" | ||
/> | ||
<${TextInput} text=${settings.defaultDownloadPath} onText=${(text: string) => (settings.defaultDownloadPath = text)} title="Default save path" /> | ||
<${SwitchSetting} | ||
checked=${settings.defaultDownloadPath !== "" && settings.alwaysUseDefaultPath} | ||
onClick=${() => (settings.alwaysUseDefaultPath = !settings.alwaysUseDefaultPath)} | ||
title="Always use default save path" | ||
/> | ||
<${TextInput} text=${settings.defaultDownloadPath} onText=${(text: string) => (settings.defaultDownloadPath = text)} title="Download Path" /> | ||
Specifying download path to save to will disable download prompt and save all files to the specified path. | ||
</div>`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { requestTrackStream } from "./request/requestTrack.native"; | ||
import type { ExtendedPlayackInfo } from "../../Caches/PlaybackInfoTypes"; | ||
import { createWriteStream } from "fs"; | ||
|
||
export const downloadTrackStream = async (extPlaybackInfo: ExtendedPlayackInfo, filePath: string): Promise<void> => { | ||
const stream = await requestTrackStream(extPlaybackInfo); | ||
return new Promise((res) => stream.pipe(createWriteStream(filePath)).on("finish", res)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { OpenDialogOptions, SaveDialogOptions, SaveDialogReturnValue, OpenDialogReturnValue } from "electron"; | ||
export type { OpenDialogOptions, SaveDialogOptions, SaveDialogReturnValue, OpenDialogReturnValue }; | ||
// @ts-expect-error | ||
const _dialog = electron.dialog; | ||
export const openDialog = (openDialogOptions?: OpenDialogOptions): OpenDialogReturnValue => _dialog.showOpenDialog(openDialogOptions); | ||
export const saveDialog = (openDialogOptions?: SaveDialogOptions): SaveDialogReturnValue => _dialog.showSaveDialog(openDialogOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Writable } from "stream"; | ||
import { requestTrackStream } from "./request/requestTrack.native"; | ||
import type { ExtendedPlayackInfo } from "../../Caches/PlaybackInfoTypes"; | ||
|
||
export const voidTrack = (extPlaybackInfo: ExtendedPlayackInfo): Promise<void> => | ||
new Promise((res) => | ||
requestTrackStream(extPlaybackInfo).then((stream) => | ||
stream | ||
.pipe( | ||
new Writable({ | ||
write: (_: any, __: any, cb: () => void) => cb(), | ||
}) | ||
) | ||
.on("end", res) | ||
) | ||
); |