mirror of
https://github.com/neosubhamoy/neodlp.git
synced 2026-02-04 23:32:23 +05:30
Compare commits
32 Commits
18
.editorconfig
Normal file
18
.editorconfig
Normal file
@@ -0,0 +1,18 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[docker-compose.yml]
|
||||
indent_size = 4
|
||||
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -1,2 +1,3 @@
|
||||
* text=auto eol=lf
|
||||
|
||||
src-tauri/binaries/* filter=lfs diff=lfs merge=lfs -text
|
||||
src-tauri/resources/binaries/* filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
16
.github/banner.svg
vendored
Normal file
16
.github/banner.svg
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<svg width="600" height="130" viewBox="0 0 600 130" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_3_2)">
|
||||
<path d="M86.9062 11H21.0938C9.44399 11 0 20.444 0 32.0938V97.9062C0 109.556 9.44399 119 21.0938 119H86.9062C98.556 119 108 109.556 108 97.9062V32.0938C108 20.444 98.556 11 86.9062 11Z" fill="url(#paint0_linear_3_2)"/>
|
||||
<path d="M55.8196 96.5455C54.7881 97.5856 53.1065 97.5856 52.075 96.5455L27.028 71.2863C25.3778 69.6221 26.5566 66.793 28.9002 66.793H78.9943C81.3379 66.793 82.5168 69.6221 80.8666 71.2863L55.8196 96.5455Z" fill="#FAFAFA"/>
|
||||
<path d="M67.8164 34.4141H40.0781C38.6219 34.4141 37.4414 35.5946 37.4414 37.0508V68.2695C37.4414 69.7257 38.6219 70.9062 40.0781 70.9062H67.8164C69.2726 70.9062 70.4531 69.7257 70.4531 68.2695V37.0508C70.4531 35.5946 69.2726 34.4141 67.8164 34.4141Z" fill="#FAFAFA"/>
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_3_2" x1="13.6582" y1="26.6621" x2="97.1367" y2="102.02" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#4444FF"/>
|
||||
<stop offset="1" stop-color="#FF43D0"/>
|
||||
</linearGradient>
|
||||
<clipPath id="clip0_3_2">
|
||||
<rect width="108" height="108" fill="white" transform="translate(0 11)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
138
.github/mockup.svg
vendored
Normal file
138
.github/mockup.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 541 KiB |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,6 +11,7 @@ node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
.github/workflows/.secrets
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
|
||||
13
CHANGELOG.md
13
CHANGELOG.md
@@ -1,14 +1,13 @@
|
||||
### ✨ Changelog
|
||||
|
||||
- Migrated to React 19, TailwindCSS 4 and ShadcnUI 2.6
|
||||
- Added new 'Extension' tab
|
||||
- Fixed: Default download directory not updating
|
||||
- Fixed: MacOS large dock icon (#1)
|
||||
- FIXED: Infinite search loop on windows (due to yt-dlp fragment missing error)
|
||||
- Bumped up FFmpeg to 7.1.1 and added FFprobe
|
||||
- Migrated to sonner from shadcn toast and improved toast messages
|
||||
- Other minor fixes and improvements
|
||||
|
||||
### 📝 Notes
|
||||
|
||||
> ⚠️ Linux Users: Make sure yt-dlp is not installed in your distro (otherwise you will get package installation conflict)
|
||||
> ⚠️ Linux Users: Make sure yt-dlp, ffmpeg and ffprobe is not installed in your distro (otherwise you will get package installation conflict). Don't worry, You can still use yt-dlp cli as before (the only difference is that now it will be installed and auto-updated by neo-dlp, which You can also disable from neo-dlp Settings if you don't want to auto-update yt-dlp)
|
||||
|
||||
> This is an Un-Signed Build (Windows doesn't trust this Certificate so, it may flag this as malicious software, in that case, disable Windows SmartScreen and Defender, install it, and then re-enable them)
|
||||
|
||||
@@ -19,8 +18,10 @@
|
||||
| Arch\OS | Windows (msi) ⬆️ | Windows (exe) ⬆️ | Linux (deb) | Linux (rpm) | MacOS (dmg) ⬆️ | MacOS (app) ⬆️ |
|
||||
| :---- | :---- | :---- | :---- | :---- | :---- | :---- |
|
||||
| x86_64 | [Download](https://github.com/neosubhamoy/neodlp/releases/download/<release_tag>/NeoDLP_<version>_x64_en-US.msi) | [Download](https://github.com/neosubhamoy/neodlp/releases/download/<release_tag>/NeoDLP_<version>_x64-setup.exe) | [Download](https://github.com/neosubhamoy/neodlp/releases/download/<release_tag>/NeoDLP_<version>_amd64.deb) | [Download](https://github.com/neosubhamoy/neodlp/releases/download/<release_tag>/NeoDLP-<version>-1.x86_64.rpm) | [Download](https://github.com/neosubhamoy/neodlp/releases/download/<release_tag>/NeoDLP_<version>_x64.dmg) | [Download](https://github.com/neosubhamoy/neodlp/releases/download/<release_tag>/NeoDLP_x64.app.tar.gz) |
|
||||
| ARM64 | N/A | N/A | N/A | N/A | ⚠️ [Download](https://github.com/neosubhamoy/neodlp/releases/download/<release_tag>/NeoDLP_<version>_aarch64.dmg) | ⚠️ [Download](https://github.com/neosubhamoy/neodlp/releases/download/<release_tag>/NeoDLP_aarch64.app.tar.gz) |
|
||||
| ARM64 | N/A | 🪟 [Download](https://github.com/neosubhamoy/neodlp/releases/download/<release_tag>/NeoDLP_<version>_x64-setup.exe) | N/A | N/A | ⚠️ [Download](https://github.com/neosubhamoy/neodlp/releases/download/<release_tag>/NeoDLP_<version>_aarch64.dmg) | ⚠️ [Download](https://github.com/neosubhamoy/neodlp/releases/download/<release_tag>/NeoDLP_aarch64.app.tar.gz) |
|
||||
|
||||
> ⬆️ icon indicates this packaging format supports in-built app-updater
|
||||
|
||||
> 🪟 Windows x86_64 binary also works on ARM64 (Windows on ARM) devices with emulation (Not planning to release native Windows ARM64 build anytime soon as, x86_64 one works fine on ARM64 without noticeable performance impact)
|
||||
|
||||
> ⚠️ MacOS ARM64 binary downloads are experimental and may not open on Apple Silicon Macs if downloaded from browser (You will get 'Damaged File' error) it's because the binaries are not signed (signing MacOS binaries requires 99$/year Apple Developer Account subscription, which I can't afford RN!) and Apple Silicon Macs don't allow unsigned apps (downloaded from browser) to be installed on the system. If you want to use NeoDLP on your Apple Silicon Macs, you can simply use the command line [Curl-Bash Installer](https://neodlp.neosubhamoy.com/download) (Recommended) -OR- [compile it from source](https://github.com/neosubhamoy/neodlp?tab=readme-ov-file#%EF%B8%8F-contributing--building-from-source) in your Mac
|
||||
85
README.md
85
README.md
@@ -1,42 +1,94 @@
|
||||

|
||||
|
||||
# NeoDLP - (Neo Downloader Plus)
|
||||
|
||||
Cross-platform Video/Audio Downloader Desktop App with Modern UI and Browser Integration
|
||||
|
||||
[](https://github.com/neosubhamoy/neodlp)
|
||||
[](https://github.com/neosubhamoy/neodlp)
|
||||
[](https://github.com/neosubhamoy/neodlp/releases)
|
||||
[](https://github.com/neosubhamoy/neodlp)
|
||||
|
||||
> **🥰 Liked this project? Please consider giving it a Star (🌟) on github to show us your appreciation and help the algorythm recommend this project to even more awesome people like you!**
|
||||
|
||||
[](https://repology.org/project/neodlp/versions)
|
||||
|
||||
### ✨ Highlighted Features
|
||||
|
||||
- Download Video/Audio from popular sites (YT, FB, IG, X and other 2.5k+ [supported sites](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md))
|
||||
- Download Video/Audio in your preffered format (MP4, WEBM, MKV, MP3 etc.)
|
||||
- Supports both Video and Playlist download
|
||||
- Supports Combining Video, Audio streams of your choice
|
||||
- Supports Multi-Language Subtitle/Caption (CC) embeding
|
||||
- Different Video/Audio metadata embeding options (info, chapters, thumbnail etc.)
|
||||
- Highly customizable and many more...😉
|
||||
|
||||
### 🧩 Browser Integration
|
||||
|
||||
You can integrate NeoDLP with your favourite browser (any Chrome/Chromium/Firefox based browser) Just, install [NeoDLP Extension](https://github.com/neosubhamoy/neodlp-extension) to get started!
|
||||
|
||||
After installing the extension you can do the following directly from the browser:
|
||||
|
||||
- Quick Search (search current browser address with NeoDLP) (via pressing keyboard shortcut `ALT`+`SHIFT`+`Q`, You can also change this shortcut key combo from browser settings)
|
||||
|
||||
- Right Click Context Menu Action (Download with Neo Downloader Plus - Link, Selection, Media Source)
|
||||
|
||||
### 👀 Sneak Peek
|
||||
|
||||

|
||||
|
||||
### 💻 Supported Platforms
|
||||
|
||||
- Windows (10 / 11)
|
||||
- Linux (Debian / Fedora / Arch Linux base)
|
||||
- MacOS (>10.3)
|
||||
|
||||
### 🌐 Supported Sites
|
||||
> ⚠️ **NOTE:** Though most linux (debian/fedora/arch base) distros are supported but not all packages are tested on all these platforms, to save some time (and brain cells) and ship the software as fast as possible! (Currently only the debian package is tested on Ubuntu 24.04 LTS - So, other linux packages may have issues, test it yourself and feel free to report issues if you found one)
|
||||
|
||||
- All [Supported Sites](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md) by [yt-dlp](https://github.com/yt-dlp/yt-dlp) **(2.5K+)**
|
||||
### 🤝 External Dependencies
|
||||
|
||||
### 🧩 External Dependencies
|
||||
|
||||
- [yt-dlp](https://github.com/yt-dlp/yt-dlp) - The core CLI Tool used to download Video/Audio from the Web
|
||||
- [FFmpeg](https://www.ffmpeg.org) - Used for Video/Audio Post-processing
|
||||
- [YT-DLP](https://github.com/yt-dlp/yt-dlp) - The core CLI tool used to download Video/Audio from the Web (Hero of the show 😎)
|
||||
- [FFmpeg](https://www.ffmpeg.org) - Used for Video/Audio post-processing
|
||||
|
||||
### ⬇️ Download and Installation
|
||||
|
||||
1. Download the latest [NeoDLP](https://github.com/neosubhamoy/neodlp/releases/latest) release based on your OS and CPU Architecture then install it or install it directly from an available distribution channel
|
||||
1. Download the latest [NeoDLP](https://github.com/neosubhamoy/neodlp/releases/latest) release based on your OS and CPU Architecture, then install it! -OR- Install it directly from an available distribution channel (listed below)
|
||||
|
||||
| Arch\OS | Windows | Linux | MacOS |
|
||||
| :---- | :---- | :---- | :---- |
|
||||
| x86_64 | ✅ [Download](https://github.com/neosubhamoy/neodlp/releases/latest) | ✅ [Download](https://github.com/neosubhamoy/neodlp/releases/latest) | ✅ [Download](https://github.com/neosubhamoy/neodlp/releases/latest) |
|
||||
| ARM64 | ❌ N/A | ❌ N/A | ✅ [Download](https://github.com/neosubhamoy/neodlp/releases/latest) |
|
||||
| ARM64 | ✅ Emulation | ❌ N/A | ✅ [Download](https://github.com/neosubhamoy/neodlp/releases/latest) |
|
||||
|
||||
> 📌 **NOTE:** x86_64 Windows binary also works on ARM64 (Windows on ARM) devices with emulation (Not planning to release native Windows ARM64 build anytime soon as, x86_64 one works fine on ARM64 without noticeable performance impact)
|
||||
|
||||
| Platform (OS) | Distribution Channel | Installation Command / Instruction |
|
||||
| :---- | :---- | :---- |
|
||||
| Windows x86_64 | WinGet | `winget install neodlp` |
|
||||
| MacOS Universal | Curl-Bash Installer | `curl -sSL https://neodlp.neosubhamoy.com/neodlp_macos_installer.sh \| bash` |
|
||||
| Windows x86_64 / ARM64 | WinGet | `winget install neodlp` |
|
||||
| MacOS x86_64 / ARM64 | Curl-Bash Installer | `curl -sSL https://neodlp.neosubhamoy.com/neodlp_macos_installer.sh \| bash` |
|
||||
| Linux x86_64 (Arch Linux) | AUR | `yay -S neodlp` |
|
||||
|
||||
### 💝 Support the Development
|
||||
|
||||
NeoDLP is and will be always FREE to Use and Open-Sourced for Everyone. On the other hand the developent process of NeoDLP takes lots of time, effort and even sometimes money! So, if you appriciate my work and have the ability to donate, then please consider supporting the development by donating (even a very small donation matters and helps NeoDLP to be a better product!) Your support is the key to my motivation...🤗
|
||||
|
||||
<a href="https://buymeacoffee.com/neosubhamoy" target="_blank" title="buymeacoffee">
|
||||
<img src="https://iili.io/JoQ0zN9.md.png" alt="buymeacoffee-orange-badge" style="width: 150px;">
|
||||
</a>
|
||||
<br></br>
|
||||
|
||||
> 📌 **NOTE:** You can also donate via UPI by sending donations to this UPI ID directly: **subhamoybiswas636-2@oksbi**
|
||||
|
||||
### 🪜 Roadmap
|
||||
|
||||
- [x] Add support for yt-dlp
|
||||
- [x] Add basic settings and customization
|
||||
- [x] Integrate with browsers
|
||||
- [ ] Add more advanced settings and achive stability **(ongoing)**
|
||||
- [ ] Add media converter
|
||||
- [ ] Add multiple downloader engines
|
||||
- [ ] Add advanced web extractor
|
||||
- [ ] Add more cool stuffs 😉
|
||||
|
||||
### ⚡ Technologies Used
|
||||
|
||||

|
||||
@@ -53,9 +105,10 @@ Want to be part of this? Feel free to contribute...!! Pull Requests are always w
|
||||
* Install [Tauri Prerequisites](https://v2.tauri.app/start/prerequisites/) for your OS / platform
|
||||
1. Fork this repo in your github account.
|
||||
2. Git clone the forked repo in your local machine.
|
||||
3. Install Node.js dependencies: `npm install`
|
||||
4. Run development / build process
|
||||
> ⚠️ Make sure to run the build command once before running the dev command for the first time to avoid build time errors
|
||||
3. Create a git branch (related to the feature you are working on) (Optional - Recommended)
|
||||
4. Install Node.js dependencies: `npm install`
|
||||
5. Run development / build process
|
||||
> ⚠️ **IMPORTANT:** Make sure to run the build command once before running the dev command for the first time to avoid compile time errors
|
||||
```code
|
||||
# for windows and linux users
|
||||
npm run tauri dev # for development
|
||||
@@ -68,9 +121,11 @@ npm run tauri build -- --config "./src-tauri/tauri.macos-aarch64.conf.json"
|
||||
npm run tauri dev -- --config "./src-tauri/tauri.macos-x86_64.conf.json" # for intel x86 macs, development
|
||||
npm run tauri build -- --config "./src-tauri/tauri.macos-x86_64.conf.json" # for intel x86 macs, production build
|
||||
```
|
||||
5. Do the changes, Send a Pull Request with proper Description (NOTE: Pull Requests Without Proper Description will be Rejected)
|
||||
6. Do the changes, Send a Pull Request with proper Description (NOTE: Pull Requests Without Proper Description will be Rejected)
|
||||
|
||||
**⭕ Noticed any Bugs or Want to give us some suggetions? Always feel free to open a GitHub Issue. We would love to hear from you...!!**
|
||||
### ⭕ Bug Report
|
||||
|
||||
Noticed any Bug? or Want to give me some suggetions? Always feel free to open a [GitHub Issue](https://github.com/neosubhamoy/neodlp/issues). I would love to hear from you...!!
|
||||
|
||||
### 📝 License
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ const __dirname = path.dirname(__filename);
|
||||
// Define array of binary source directories
|
||||
const binSrcDirs = [
|
||||
path.join(__dirname, 'src-tauri', 'binaries'),
|
||||
path.join(__dirname, 'src-tauri', 'resources', 'binaries'),
|
||||
];
|
||||
|
||||
function makeFilesExecutable() {
|
||||
|
||||
1516
package-lock.json
generated
1516
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
72
package.json
72
package.json
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "neodlp",
|
||||
"private": true,
|
||||
"version": "0.1.1",
|
||||
"version": "0.2.2",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -10,7 +10,7 @@
|
||||
"tauri": "tauri"
|
||||
},
|
||||
"dependencies": {
|
||||
"@hookform/resolvers": "^5.1.1",
|
||||
"@hookform/resolvers": "^5.2.1",
|
||||
"@radix-ui/react-accordion": "^1.2.11",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.14",
|
||||
"@radix-ui/react-aspect-ratio": "^1.1.7",
|
||||
@@ -38,50 +38,50 @@
|
||||
"@radix-ui/react-toggle": "^1.1.9",
|
||||
"@radix-ui/react-toggle-group": "^1.1.10",
|
||||
"@radix-ui/react-tooltip": "^1.2.7",
|
||||
"@tanstack/react-query": "^5.80.7",
|
||||
"@tanstack/react-query-devtools": "^5.80.7",
|
||||
"@tauri-apps/api": "^2",
|
||||
"@tauri-apps/plugin-dialog": "^2.2.2",
|
||||
"@tauri-apps/plugin-fs": "^2.3.0",
|
||||
"@tauri-apps/plugin-opener": "^2.2.7",
|
||||
"@tauri-apps/plugin-os": "^2.2.1",
|
||||
"@tauri-apps/plugin-process": "^2.2.1",
|
||||
"@tauri-apps/plugin-shell": "^2.2.1",
|
||||
"@tauri-apps/plugin-sql": "^2.2.0",
|
||||
"@tauri-apps/plugin-updater": "^2.7.1",
|
||||
"@tanstack/react-query": "^5.84.2",
|
||||
"@tanstack/react-query-devtools": "^5.84.2",
|
||||
"@tauri-apps/api": "^2.7.0",
|
||||
"@tauri-apps/plugin-dialog": "^2.3.2",
|
||||
"@tauri-apps/plugin-fs": "^2.4.1",
|
||||
"@tauri-apps/plugin-opener": "^2.4.0",
|
||||
"@tauri-apps/plugin-os": "^2.3.0",
|
||||
"@tauri-apps/plugin-process": "^2.3.0",
|
||||
"@tauri-apps/plugin-shell": "^2.3.0",
|
||||
"@tauri-apps/plugin-sql": "^2.3.0",
|
||||
"@tauri-apps/plugin-updater": "^2.9.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"cmdk": "^1.1.1",
|
||||
"date-fns": "^4.1.0",
|
||||
"embla-carousel-react": "^8.6.0",
|
||||
"input-otp": "^1.4.2",
|
||||
"lucide-react": "^0.515.0",
|
||||
"lucide-react": "^0.539.0",
|
||||
"next-themes": "^0.4.6",
|
||||
"react": "^19.1.0",
|
||||
"react-day-picker": "^9.7.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"react-hook-form": "^7.57.0",
|
||||
"react-resizable-panels": "^3.0.2",
|
||||
"react-router-dom": "^7.6.2",
|
||||
"recharts": "^2.15.3",
|
||||
"sonner": "^2.0.5",
|
||||
"react": "^19.1.1",
|
||||
"react-day-picker": "^9.8.1",
|
||||
"react-dom": "^19.1.1",
|
||||
"react-hook-form": "^7.62.0",
|
||||
"react-resizable-panels": "^3.0.4",
|
||||
"react-router-dom": "^7.8.0",
|
||||
"recharts": "^3.1.2",
|
||||
"sonner": "^2.0.7",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"vaul": "^1.1.2",
|
||||
"zod": "^3.25.64",
|
||||
"zustand": "^5.0.5"
|
||||
"zod": "^4.0.17",
|
||||
"zustand": "^5.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4.1.10",
|
||||
"@tailwindcss/vite": "^4.1.10",
|
||||
"@tauri-apps/cli": "^2",
|
||||
"@types/node": "^24.0.1",
|
||||
"@types/react": "^19.1.8",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"@vitejs/plugin-react": "^4.5.2",
|
||||
"postcss": "^8.5.5",
|
||||
"tailwindcss": "^4.1.10",
|
||||
"tw-animate-css": "^1.3.4",
|
||||
"typescript": "~5.8.3",
|
||||
"vite": "^6.3.5"
|
||||
"@tailwindcss/postcss": "^4.1.11",
|
||||
"@tailwindcss/vite": "^4.1.11",
|
||||
"@tauri-apps/cli": "^2.7.1",
|
||||
"@types/node": "^24.2.1",
|
||||
"@types/react": "^19.1.9",
|
||||
"@types/react-dom": "^19.1.7",
|
||||
"@vitejs/plugin-react": "^5.0.0",
|
||||
"postcss": "^8.5.6",
|
||||
"tailwindcss": "^4.1.11",
|
||||
"tw-animate-css": "^1.3.6",
|
||||
"typescript": "~5.9.2",
|
||||
"vite": "^7.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
990
src-tauri/Cargo.lock
generated
990
src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "neodlp"
|
||||
version = "0.1.1"
|
||||
version = "0.2.2"
|
||||
description = "NeoDLP"
|
||||
authors = ["neosubhamoy <hey@neosubhamoy.com>"]
|
||||
edition = "2021"
|
||||
@@ -27,9 +27,9 @@ tokio = { version = "1", features = ["full"] }
|
||||
tokio-tungstenite = "*"
|
||||
sqlx = { version = "0.8", features = [ "sqlite", "runtime-tokio", "tls-native-tls" ] }
|
||||
base64 = "0.22"
|
||||
directories = "5.0"
|
||||
directories = "6.0"
|
||||
futures-util = "0.3"
|
||||
tauri-plugin-opener = "2"
|
||||
tauri-plugin-opener = "2.4.0"
|
||||
tauri-plugin-shell = "2"
|
||||
tauri-plugin-fs = "2"
|
||||
tauri-plugin-os = "2"
|
||||
@@ -38,7 +38,7 @@ tauri-plugin-sql = { version = "2", features = ["sqlite"] }
|
||||
tauri-plugin-process = "2"
|
||||
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||
tauri-plugin-single-instance = "2"
|
||||
tauri-plugin-single-instance = "2.3.2"
|
||||
tauri-plugin-updater = "2"
|
||||
|
||||
[workspace]
|
||||
|
||||
3
src-tauri/binaries/ffmpeg-aarch64-apple-darwin
Normal file
3
src-tauri/binaries/ffmpeg-aarch64-apple-darwin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f908be736c63cfc624ac1e4bce65eb70f167865f7df6e4e66e473043acfe164a
|
||||
size 80263264
|
||||
3
src-tauri/binaries/ffmpeg-x86_64-apple-darwin
Normal file
3
src-tauri/binaries/ffmpeg-x86_64-apple-darwin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f908be736c63cfc624ac1e4bce65eb70f167865f7df6e4e66e473043acfe164a
|
||||
size 80263264
|
||||
3
src-tauri/binaries/ffmpeg-x86_64-pc-windows-msvc.exe
Normal file
3
src-tauri/binaries/ffmpeg-x86_64-pc-windows-msvc.exe
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:418ba93234679b06c3a8e2f653422a78dd855b4bc5800c960623374468b85216
|
||||
size 140249600
|
||||
3
src-tauri/binaries/ffmpeg-x86_64-unknown-linux-gnu
Normal file
3
src-tauri/binaries/ffmpeg-x86_64-unknown-linux-gnu
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7a5290ae0ef64702228565b65295ab0a006671c54fdc150f9e5247f5206ea439
|
||||
size 141267400
|
||||
3
src-tauri/binaries/ffprobe-aarch64-apple-darwin
Normal file
3
src-tauri/binaries/ffprobe-aarch64-apple-darwin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2890fc88a6b99fb7761dae6acd8ac531083a60d75ac82c09c5fe93d10f67cc81
|
||||
size 80089672
|
||||
3
src-tauri/binaries/ffprobe-x86_64-apple-darwin
Normal file
3
src-tauri/binaries/ffprobe-x86_64-apple-darwin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2890fc88a6b99fb7761dae6acd8ac531083a60d75ac82c09c5fe93d10f67cc81
|
||||
size 80089672
|
||||
3
src-tauri/binaries/ffprobe-x86_64-pc-windows-msvc.exe
Normal file
3
src-tauri/binaries/ffprobe-x86_64-pc-windows-msvc.exe
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:99cc32fddcde37108bba108993ae5091609d493970583719385099270bd279b7
|
||||
size 140052992
|
||||
3
src-tauri/binaries/ffprobe-x86_64-unknown-linux-gnu
Normal file
3
src-tauri/binaries/ffprobe-x86_64-unknown-linux-gnu
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:165e68e3df3ba78296b6e4d060906abb0e8f235e103180d0f058cb7f5dea3513
|
||||
size 141063880
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c20996d097127884243f4780d929b3769d55418c0efa9bd7a98999f387b5fbed
|
||||
size 18113133
|
||||
oid sha256:c2fea6db305fbfd58b55d690be0b506ba384bc91995c24a278f0d26989d7d615
|
||||
size 18360370
|
||||
|
||||
@@ -15,6 +15,16 @@
|
||||
"args": true,
|
||||
"sidecar": true
|
||||
},
|
||||
{
|
||||
"name": "binaries/ffmpeg",
|
||||
"args": true,
|
||||
"sidecar": true
|
||||
},
|
||||
{
|
||||
"name": "binaries/ffprobe",
|
||||
"args": true,
|
||||
"sidecar": true
|
||||
},
|
||||
{
|
||||
"name": "pkexec",
|
||||
"cmd": "pkexec",
|
||||
@@ -29,6 +39,16 @@
|
||||
"name": "binaries/yt-dlp",
|
||||
"args": true,
|
||||
"sidecar": true
|
||||
},
|
||||
{
|
||||
"name": "binaries/ffmpeg",
|
||||
"args": true,
|
||||
"sidecar": true
|
||||
},
|
||||
{
|
||||
"name": "binaries/ffprobe",
|
||||
"args": true,
|
||||
"sidecar": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@ license = "MIT"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
tokio-tungstenite = "*"
|
||||
futures-util = "0.3"
|
||||
directories = "5.0"
|
||||
directories = "6.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
@@ -6,7 +6,7 @@
|
||||
<string>com.neosubhamoy.neodlp</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/Applications/neodlp.app/Contents/MacOS/neodlp</string>
|
||||
<string>/Applications/NeoDLP.app/Contents/MacOS/neodlp</string>
|
||||
<string>--hidden</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e607b7f079c4eb0dc666ffca152f225020f8022c8c014dd94d91e6072f57228d
|
||||
size 79945800
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e607b7f079c4eb0dc666ffca152f225020f8022c8c014dd94d91e6072f57228d
|
||||
size 79945800
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c49b5913c9a107120c86b401af95df7965003f7fc6dbb4436f1f03c8ba391e8b
|
||||
size 127473664
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3ee15e5145c9eb4775c193ab824c592d4ff3744bb7f283f8db29bd3c3c961589
|
||||
size 79928672
|
||||
@@ -3,5 +3,5 @@
|
||||
"description": "NeoDLP MsgHost",
|
||||
"path": "/usr/bin/neodlp-msghost",
|
||||
"type": "stdio",
|
||||
"allowed_origins": ["chrome-extension://mehopeailfjmiloiiohgicphlcgpompf/", "chrome-extension://agkddibgemhefmdhlnooiakfnhihhbdb/"]
|
||||
"allowed_origins": ["chrome-extension://mehopeailfjmiloiiohgicphlcgpompf/"]
|
||||
}
|
||||
@@ -3,5 +3,5 @@
|
||||
"description": "NeoDLP MsgHost",
|
||||
"path": "/Applications/NeoDLP.app/Contents/Resources/neodlp-msghost",
|
||||
"type": "stdio",
|
||||
"allowed_origins": ["chrome-extension://mehopeailfjmiloiiohgicphlcgpompf/", "chrome-extension://agkddibgemhefmdhlnooiakfnhihhbdb/"]
|
||||
"allowed_origins": ["chrome-extension://mehopeailfjmiloiiohgicphlcgpompf/"]
|
||||
}
|
||||
@@ -3,5 +3,5 @@
|
||||
"description": "NeoDLP MsgHost",
|
||||
"path": "neodlp-msghost.exe",
|
||||
"type": "stdio",
|
||||
"allowed_origins": ["chrome-extension://mehopeailfjmiloiiohgicphlcgpompf/", "chrome-extension://agkddibgemhefmdhlnooiakfnhihhbdb/"]
|
||||
"allowed_origins": ["chrome-extension://mehopeailfjmiloiiohgicphlcgpompf/"]
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "NeoDLP",
|
||||
"mainBinaryName": "neodlp",
|
||||
"version": "0.1.1",
|
||||
"version": "0.2.2",
|
||||
"identifier": "com.neosubhamoy.neodlp",
|
||||
"build": {
|
||||
"beforeDevCommand": "npm run dev",
|
||||
|
||||
@@ -36,11 +36,10 @@
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"externalBin": [
|
||||
"binaries/yt-dlp"
|
||||
"binaries/yt-dlp",
|
||||
"binaries/ffmpeg",
|
||||
"binaries/ffprobe"
|
||||
],
|
||||
"resources": {
|
||||
"resources/binaries/ffmpeg-x86_64-unknown-linux-gnu": "binaries/ffmpeg-x86_64"
|
||||
},
|
||||
"linux": {
|
||||
"deb": {
|
||||
"files": {
|
||||
|
||||
@@ -36,11 +36,12 @@
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"externalBin": [
|
||||
"binaries/yt-dlp"
|
||||
"binaries/yt-dlp",
|
||||
"binaries/ffmpeg",
|
||||
"binaries/ffprobe"
|
||||
],
|
||||
"resources": {
|
||||
"target/aarch64-apple-darwin/release/neodlp-msghost": "neodlp-msghost",
|
||||
"resources/binaries/ffmpeg-aarch64-apple-darwin": "binaries/ffmpeg-aarch64",
|
||||
"resources/msghost-manifest/macos/chrome.json": "neodlp-msghost.json",
|
||||
"resources/msghost-manifest/macos/firefox.json": "neodlp-msghost-moz.json",
|
||||
"resources/autostart/macos/autostart.plist": "neodlp-autostart.plist"
|
||||
|
||||
@@ -36,11 +36,12 @@
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"externalBin": [
|
||||
"binaries/yt-dlp"
|
||||
"binaries/yt-dlp",
|
||||
"binaries/ffmpeg",
|
||||
"binaries/ffprobe"
|
||||
],
|
||||
"resources": {
|
||||
"target/x86_64-apple-darwin/release/neodlp-msghost": "neodlp-msghost",
|
||||
"resources/binaries/ffmpeg-x86_64-apple-darwin": "binaries/ffmpeg-x86_64",
|
||||
"resources/msghost-manifest/macos/chrome.json": "neodlp-msghost.json",
|
||||
"resources/msghost-manifest/macos/firefox.json": "neodlp-msghost-moz.json",
|
||||
"resources/autostart/macos/autostart.plist": "neodlp-autostart.plist"
|
||||
|
||||
@@ -36,10 +36,11 @@
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"externalBin": [
|
||||
"binaries/yt-dlp"
|
||||
"binaries/yt-dlp",
|
||||
"binaries/ffmpeg",
|
||||
"binaries/ffprobe"
|
||||
],
|
||||
"resources": {
|
||||
"resources/binaries/ffmpeg-x86_64-pc-windows-msvc.exe": "binaries/ffmpeg-x86_64.exe",
|
||||
"target/release/neodlp-msghost.exe": "neodlp-msghost.exe",
|
||||
"resources/msghost-manifest/windows/chrome.json": "neodlp-msghost.json",
|
||||
"resources/msghost-manifest/windows/firefox.json": "neodlp-msghost-moz.json"
|
||||
|
||||
192
src/App.tsx
192
src/App.tsx
@@ -1,13 +1,12 @@
|
||||
import { ThemeProvider } from "@/providers/themeProvider";
|
||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||
import { Toaster } from "@/components/ui/toaster";
|
||||
import { AppContext } from "@/providers/appContextProvider";
|
||||
import { DownloadState } from "@/types/download";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { arch, exeExtension } from "@tauri-apps/plugin-os";
|
||||
import { downloadDir, join, resourceDir, tempDir } from "@tauri-apps/api/path";
|
||||
import { useBasePathsStore, useCurrentVideoMetadataStore, useDownloadStatesStore, useKvPairsStatesStore, useSettingsPageStatesStore } from "@/services/store";
|
||||
import { useBasePathsStore, useCurrentVideoMetadataStore, useDownloaderPageStatesStore, useDownloadStatesStore, useKvPairsStatesStore, useSettingsPageStatesStore } from "@/services/store";
|
||||
import { determineFileType, generateDownloadId, generateSafeFilePath, generateVideoId, isObjEmpty, parseProgressLine, sanitizeFilename } from "@/utils";
|
||||
import { Command } from "@tauri-apps/plugin-shell";
|
||||
import { RawVideoInfo } from "@/types/video";
|
||||
@@ -25,6 +24,8 @@ import { useNavigate } from "react-router-dom";
|
||||
import { platform } from "@tauri-apps/plugin-os";
|
||||
import { useMacOsRegisterer } from "@/helpers/use-macos-registerer";
|
||||
import useAppUpdater from "@/helpers/use-app-updater";
|
||||
import { Toaster as Sonner } from "@/components/ui/sonner";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export default function App({ children }: { children: React.ReactNode }) {
|
||||
const { data: downloadStates, isSuccess: isSuccessFetchingDownloadStates } = useFetchAllDownloadStates();
|
||||
@@ -40,6 +41,8 @@ export default function App({ children }: { children: React.ReactNode }) {
|
||||
const tempDownloadDirPath = useBasePathsStore((state) => state.tempDownloadDirPath);
|
||||
const downloadDirPath = useBasePathsStore((state) => state.downloadDirPath);
|
||||
|
||||
const setSearchPid = useCurrentVideoMetadataStore((state) => state.setSearchPid);
|
||||
|
||||
// const isUsingDefaultSettings = useSettingsPageStatesStore((state) => state.isUsingDefaultSettings);
|
||||
const setIsUsingDefaultSettings = useSettingsPageStatesStore((state) => state.setIsUsingDefaultSettings);
|
||||
const setSettingsKey = useSettingsPageStatesStore((state) => state.setSettingsKey);
|
||||
@@ -53,10 +56,27 @@ export default function App({ children }: { children: React.ReactNode }) {
|
||||
const YTDLP_UPDATE_CHANNEL = useSettingsPageStatesStore(state => state.settings.ytdlp_update_channel);
|
||||
const APP_THEME = useSettingsPageStatesStore(state => state.settings.theme);
|
||||
const MAX_PARALLEL_DOWNLOADS = useSettingsPageStatesStore(state => state.settings.max_parallel_downloads);
|
||||
const MAX_RETRIES = useSettingsPageStatesStore(state => state.settings.max_retries);
|
||||
const DOWNLOAD_DIR = useSettingsPageStatesStore(state => state.settings.download_dir);
|
||||
const PREFER_VIDEO_OVER_PLAYLIST = useSettingsPageStatesStore(state => state.settings.prefer_video_over_playlist);
|
||||
const STRICT_DOWNLOADABILITY_CHECK = useSettingsPageStatesStore(state => state.settings.strict_downloadablity_check);
|
||||
const USE_PROXY = useSettingsPageStatesStore(state => state.settings.use_proxy);
|
||||
const PROXY_URL = useSettingsPageStatesStore(state => state.settings.proxy_url);
|
||||
const USE_RATE_LIMIT = useSettingsPageStatesStore(state => state.settings.use_rate_limit);
|
||||
const RATE_LIMIT = useSettingsPageStatesStore(state => state.settings.rate_limit);
|
||||
const VIDEO_FORMAT = useSettingsPageStatesStore(state => state.settings.video_format);
|
||||
const AUDIO_FORMAT = useSettingsPageStatesStore(state => state.settings.audio_format);
|
||||
const ALWAYS_REENCODE_VIDEO = useSettingsPageStatesStore(state => state.settings.always_reencode_video);
|
||||
const EMBED_VIDEO_METADATA = useSettingsPageStatesStore(state => state.settings.embed_video_metadata);
|
||||
const EMBED_AUDIO_METADATA = useSettingsPageStatesStore(state => state.settings.embed_audio_metadata);
|
||||
const EMBED_AUDIO_THUMBNAIL = useSettingsPageStatesStore(state => state.settings.embed_audio_thumbnail);
|
||||
|
||||
const isErrored = useDownloaderPageStatesStore((state) => state.isErrored);
|
||||
const isErrorExpected = useDownloaderPageStatesStore((state) => state.isErrorExpected);
|
||||
const erroredDownloadId = useDownloaderPageStatesStore((state) => state.erroredDownloadId);
|
||||
const setIsErrored = useDownloaderPageStatesStore((state) => state.setIsErrored);
|
||||
const setIsErrorExpected = useDownloaderPageStatesStore((state) => state.setIsErrorExpected);
|
||||
const setErroredDownloadId = useDownloaderPageStatesStore((state) => state.setErroredDownloadId);
|
||||
|
||||
const appWindow = getCurrentWebviewWindow()
|
||||
const navigate = useNavigate();
|
||||
@@ -85,10 +105,12 @@ export default function App({ children }: { children: React.ReactNode }) {
|
||||
|
||||
const fetchVideoMetadata = async (url: string, formatId?: string, playlistIndex?: string): Promise<RawVideoInfo | null> => {
|
||||
try {
|
||||
const args = [url, '--dump-single-json'];
|
||||
const args = [url, '--dump-single-json', '--no-warnings'];
|
||||
if (formatId) args.push('-f', formatId);
|
||||
if (playlistIndex) args.push('--playlist-items', playlistIndex);
|
||||
if (PREFER_VIDEO_OVER_PLAYLIST) args.push('--no-playlist');
|
||||
if (STRICT_DOWNLOADABILITY_CHECK && !formatId) args.push('--check-all-formats');
|
||||
if (STRICT_DOWNLOADABILITY_CHECK && formatId) args.push('--check-formats');
|
||||
if (USE_PROXY && PROXY_URL) args.push('--proxy', PROXY_URL);
|
||||
const command = Command.sidecar('binaries/yt-dlp', args);
|
||||
|
||||
@@ -99,14 +121,25 @@ export default function App({ children }: { children: React.ReactNode }) {
|
||||
jsonOutput += line;
|
||||
});
|
||||
|
||||
command.on('close', async () => {
|
||||
try {
|
||||
const data: RawVideoInfo = JSON.parse(jsonOutput);
|
||||
resolve(data);
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`Failed to parse JSON: ${e}`);
|
||||
command.on('close', async (data) => {
|
||||
if (data.code !== 0) {
|
||||
console.error(`yt-dlp failed to fetch metadata with code ${data.code}`);
|
||||
resolve(null);
|
||||
} else {
|
||||
try {
|
||||
const matchedJson = jsonOutput.match(/{.*}/);
|
||||
if (!matchedJson) {
|
||||
console.error(`Failed to match JSON: ${jsonOutput}`);
|
||||
resolve(null);
|
||||
return;
|
||||
}
|
||||
const parsedJson: RawVideoInfo = JSON.parse(matchedJson[0]);
|
||||
resolve(parsedJson);
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`Failed to parse JSON: ${e}`);
|
||||
resolve(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -115,7 +148,9 @@ export default function App({ children }: { children: React.ReactNode }) {
|
||||
resolve(null);
|
||||
});
|
||||
|
||||
command.spawn().catch(e => {
|
||||
command.spawn().then(child => {
|
||||
setSearchPid(child.pid);
|
||||
}).catch(e => {
|
||||
console.error(`Failed to spawn command: ${e}`);
|
||||
resolve(null);
|
||||
});
|
||||
@@ -127,6 +162,11 @@ export default function App({ children }: { children: React.ReactNode }) {
|
||||
};
|
||||
|
||||
const startDownload = async (url: string, selectedFormat: string, selectedSubtitles?: string | null, resumeState?: DownloadState, playlistItems?: string) => {
|
||||
// set error states to default
|
||||
setIsErrored(false);
|
||||
setIsErrorExpected(false);
|
||||
setErroredDownloadId(null);
|
||||
|
||||
console.log('Starting download:', { url, selectedFormat, selectedSubtitles, resumeState, playlistItems });
|
||||
if (!ffmpegPath || !tempDownloadDirPath || !downloadDirPath) {
|
||||
console.error('FFmpeg or download paths not found');
|
||||
@@ -138,12 +178,22 @@ export default function App({ children }: { children: React.ReactNode }) {
|
||||
let videoMetadata = await fetchVideoMetadata(url, selectedFormat, isPlaylist && playlistIndex && typeof playlistIndex === 'string' ? playlistIndex : undefined);
|
||||
if (!videoMetadata) {
|
||||
console.error('Failed to fetch video metadata');
|
||||
toast.error("Download Failed", {
|
||||
description: "yt-dlp failed to fetch video metadata. Please try again later.",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Video Metadata:', videoMetadata);
|
||||
videoMetadata = isPlaylist ? videoMetadata.entries[0] : videoMetadata;
|
||||
|
||||
const fileType = determineFileType(videoMetadata.vcodec, videoMetadata.acodec);
|
||||
|
||||
if (fileType !== 'unknown' && (VIDEO_FORMAT !== 'auto' || AUDIO_FORMAT !== 'auto')) {
|
||||
if (VIDEO_FORMAT !== 'auto' && (fileType === 'video+audio' || fileType === 'video')) videoMetadata.ext = VIDEO_FORMAT;
|
||||
if (AUDIO_FORMAT !== 'auto' && fileType === 'audio') videoMetadata.ext = AUDIO_FORMAT;
|
||||
}
|
||||
|
||||
const videoId = resumeState?.video_id || generateVideoId(videoMetadata.id, videoMetadata.webpage_url_domain);
|
||||
const playlistId = isPlaylist ? (resumeState?.playlist_id || generateVideoId(videoMetadata.playlist_id, videoMetadata.webpage_url_domain)) : null;
|
||||
const downloadId = resumeState?.download_id || generateDownloadId(videoMetadata.id, videoMetadata.webpage_url_domain);
|
||||
@@ -158,11 +208,14 @@ export default function App({ children }: { children: React.ReactNode }) {
|
||||
'status:%(progress.status)s,progress:%(progress._percent_str)s,speed:%(progress.speed)f,downloaded:%(progress.downloaded_bytes)d,total:%(progress.total_bytes)d,eta:%(progress.eta)d',
|
||||
'--output',
|
||||
tempDownloadPathForYtdlp,
|
||||
'--ffmpeg-location',
|
||||
ffmpegPath,
|
||||
// '--ffmpeg-location',
|
||||
// ffmpegPath,
|
||||
'-f',
|
||||
selectedFormat,
|
||||
'--no-mtime',
|
||||
'--no-warnings',
|
||||
'--retries',
|
||||
MAX_RETRIES.toString(),
|
||||
];
|
||||
|
||||
if (selectedSubtitles) {
|
||||
@@ -173,6 +226,39 @@ export default function App({ children }: { children: React.ReactNode }) {
|
||||
args.push('--playlist-items', playlistIndex);
|
||||
}
|
||||
|
||||
if (fileType !== 'unknown' && (VIDEO_FORMAT !== 'auto' || AUDIO_FORMAT !== 'auto')) {
|
||||
if (VIDEO_FORMAT !== 'auto' && fileType === 'video+audio') {
|
||||
if (ALWAYS_REENCODE_VIDEO) {
|
||||
args.push('--recode-video', VIDEO_FORMAT);
|
||||
} else {
|
||||
args.push('--merge-output-format', VIDEO_FORMAT);
|
||||
}
|
||||
}
|
||||
if (VIDEO_FORMAT !== 'auto' && fileType === 'video') {
|
||||
if (ALWAYS_REENCODE_VIDEO) {
|
||||
args.push('--recode-video', VIDEO_FORMAT);
|
||||
} else {
|
||||
args.push('--remux-video', VIDEO_FORMAT);
|
||||
}
|
||||
}
|
||||
if (AUDIO_FORMAT !== 'auto' && fileType === 'audio') {
|
||||
args.push('--extract-audio', '--audio-format', AUDIO_FORMAT);
|
||||
}
|
||||
}
|
||||
|
||||
if (fileType !== 'unknown' && (EMBED_VIDEO_METADATA || EMBED_AUDIO_METADATA)) {
|
||||
if (EMBED_VIDEO_METADATA && (fileType === 'video+audio' || fileType === 'video')) {
|
||||
args.push('--embed-metadata');
|
||||
}
|
||||
if (EMBED_AUDIO_METADATA && fileType === 'audio') {
|
||||
args.push('--embed-metadata');
|
||||
}
|
||||
}
|
||||
|
||||
if (EMBED_AUDIO_THUMBNAIL && fileType === 'audio') {
|
||||
args.push('--embed-thumbnail');
|
||||
}
|
||||
|
||||
if (resumeState) {
|
||||
args.push('--continue');
|
||||
} else {
|
||||
@@ -183,26 +269,25 @@ export default function App({ children }: { children: React.ReactNode }) {
|
||||
args.push('--proxy', PROXY_URL);
|
||||
}
|
||||
|
||||
if (USE_RATE_LIMIT && RATE_LIMIT) {
|
||||
args.push('--limit-rate', `${RATE_LIMIT}`);
|
||||
}
|
||||
|
||||
console.log('Starting download with args:', args);
|
||||
const command = Command.sidecar('binaries/yt-dlp', args);
|
||||
|
||||
command.on('close', async data => {
|
||||
command.on('close', async (data) => {
|
||||
if (data.code !== 0) {
|
||||
console.error(`Download failed with code ${data.code}`);
|
||||
if (!isErrorExpected) {
|
||||
setIsErrored(true);
|
||||
setErroredDownloadId(downloadId);
|
||||
}
|
||||
} else {
|
||||
downloadStatusUpdater.mutate({ download_id: downloadId, download_status: 'completed' }, {
|
||||
onSuccess: (data) => {
|
||||
console.log("Download status updated successfully:", data);
|
||||
queryClient.invalidateQueries({ queryKey: ['download-states'] });
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error("Failed to update download status:", error);
|
||||
}
|
||||
})
|
||||
|
||||
if (await fs.exists(tempDownloadPath)) {
|
||||
downloadFilePath = await generateSafeFilePath(downloadFilePath);
|
||||
await fs.rename(tempDownloadPath, downloadFilePath);
|
||||
await fs.copyFile(tempDownloadPath, downloadFilePath);
|
||||
await fs.remove(tempDownloadPath);
|
||||
}
|
||||
|
||||
downloadFilePathUpdater.mutate({ download_id: downloadId, filepath: downloadFilePath }, {
|
||||
@@ -214,11 +299,23 @@ export default function App({ children }: { children: React.ReactNode }) {
|
||||
console.error("Failed to update download filepath:", error);
|
||||
}
|
||||
})
|
||||
|
||||
downloadStatusUpdater.mutate({ download_id: downloadId, download_status: 'completed' }, {
|
||||
onSuccess: (data) => {
|
||||
console.log("Download status updated successfully:", data);
|
||||
queryClient.invalidateQueries({ queryKey: ['download-states'] });
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error("Failed to update download status:", error);
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
command.on('error', error => {
|
||||
console.error(`Error: ${error}`);
|
||||
setIsErrored(true);
|
||||
setErroredDownloadId(downloadId);
|
||||
});
|
||||
|
||||
command.stdout.on('data', line => {
|
||||
@@ -380,8 +477,11 @@ export default function App({ children }: { children: React.ReactNode }) {
|
||||
|
||||
const pauseDownload = async (downloadState: DownloadState) => {
|
||||
try {
|
||||
console.log("Killing process with PID:", downloadState.process_id);
|
||||
await invoke('kill_all_process', { pid: downloadState.process_id });
|
||||
if ((downloadState.download_status === 'downloading' && downloadState.process_id) || (downloadState.download_status === 'starting' && downloadState.process_id)) {
|
||||
setIsErrorExpected(true); // Set error expected to true to handle UI state
|
||||
console.log("Killing process with PID:", downloadState.process_id);
|
||||
await invoke('kill_all_process', { pid: downloadState.process_id });
|
||||
}
|
||||
downloadStatusUpdater.mutate({ download_id: downloadState.download_id, download_status: 'paused' }, {
|
||||
onSuccess: (data) => {
|
||||
console.log("Download status updated successfully:", data);
|
||||
@@ -424,6 +524,7 @@ export default function App({ children }: { children: React.ReactNode }) {
|
||||
const cancelDownload = async (downloadState: DownloadState) => {
|
||||
try {
|
||||
if ((downloadState.download_status === 'downloading' && downloadState.process_id) || (downloadState.download_status === 'starting' && downloadState.process_id)) {
|
||||
setIsErrorExpected(true); // Set error expected to true to handle UI state
|
||||
console.log("Killing process with PID:", downloadState.process_id);
|
||||
await invoke('kill_all_process', { pid: downloadState.process_id });
|
||||
}
|
||||
@@ -757,12 +858,47 @@ export default function App({ children }: { children: React.ReactNode }) {
|
||||
return () => clearTimeout(timeoutId);
|
||||
}, [processQueuedDownloads, ongoingDownloads, queuedDownloads]);
|
||||
|
||||
// show a toast and pause the download when yt-dlp exits unexpectedly
|
||||
useEffect(() => {
|
||||
if (isErrored && !isErrorExpected) {
|
||||
toast.error("Download Failed", {
|
||||
description: "yt-dlp exited unexpectedly. Please try again later",
|
||||
});
|
||||
if (erroredDownloadId) {
|
||||
downloadStatusUpdater.mutate({ download_id: erroredDownloadId, download_status: 'paused' }, {
|
||||
onSuccess: (data) => {
|
||||
console.log("Download status updated successfully:", data);
|
||||
queryClient.invalidateQueries({ queryKey: ['download-states'] });
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error("Failed to update download status:", error);
|
||||
}
|
||||
})
|
||||
setErroredDownloadId(null);
|
||||
}
|
||||
setIsErrored(false);
|
||||
setIsErrorExpected(false);
|
||||
}
|
||||
}, [isErrored, isErrorExpected, erroredDownloadId, setIsErrored, setIsErrorExpected, setErroredDownloadId]);
|
||||
|
||||
// auto reset error states after 3 seconds of expecting an error
|
||||
useEffect(() => {
|
||||
if (isErrorExpected) {
|
||||
const timeoutId = setTimeout(() => {
|
||||
setIsErrored(false);
|
||||
setIsErrorExpected(false);
|
||||
setErroredDownloadId(null);
|
||||
}, 3000);
|
||||
return () => clearTimeout(timeoutId);
|
||||
}
|
||||
}, [isErrorExpected, setIsErrorExpected]);
|
||||
|
||||
return (
|
||||
<AppContext.Provider value={{ fetchVideoMetadata, startDownload, pauseDownload, resumeDownload, cancelDownload }}>
|
||||
<ThemeProvider defaultTheme={APP_THEME || "system"} storageKey="vite-ui-theme">
|
||||
<TooltipProvider delayDuration={1000}>
|
||||
{children}
|
||||
<Toaster />
|
||||
<Sonner closeButton />
|
||||
</TooltipProvider>
|
||||
</ThemeProvider>
|
||||
</AppContext.Provider>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { config } from "@/config";
|
||||
import { Link, useLocation } from "react-router-dom";
|
||||
import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, useSidebar } from "@/components/ui/sidebar";
|
||||
import { CircleArrowUp, Download, Puzzle, Settings, SquarePlay, } from "lucide-react";
|
||||
import { CircleArrowUp, Download, Settings, SquarePlay, } from "lucide-react";
|
||||
import { isActive as isActiveSidebarItem } from "@/utils";
|
||||
import { RoutesObj } from "@/types/route";
|
||||
import { useDownloadStatesStore, useSettingsPageStatesStore } from "@/services/store";
|
||||
@@ -29,6 +29,7 @@ export function AppSidebar() {
|
||||
const { open } = useSidebar();
|
||||
const { downloadAndInstallAppUpdate } = useAppUpdater();
|
||||
const [showBadge, setShowBadge] = useState(false);
|
||||
const [showUpdateCard, setShowUpdateCard] = useState(false);
|
||||
|
||||
const topItems: Array<RoutesObj> = [
|
||||
{
|
||||
@@ -40,11 +41,6 @@ export function AppSidebar() {
|
||||
title: "Library",
|
||||
url: "/library",
|
||||
icon: SquarePlay,
|
||||
},
|
||||
{
|
||||
title: "Extension",
|
||||
url: "/extension",
|
||||
icon: Puzzle,
|
||||
}
|
||||
];
|
||||
|
||||
@@ -61,9 +57,11 @@ export function AppSidebar() {
|
||||
if (open) {
|
||||
timeout = setTimeout(() => {
|
||||
setShowBadge(true);
|
||||
setShowUpdateCard(true);
|
||||
}, 300);
|
||||
} else {
|
||||
setShowBadge(false);
|
||||
setShowUpdateCard(false);
|
||||
}
|
||||
|
||||
return () => {
|
||||
@@ -153,13 +151,14 @@ export function AppSidebar() {
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
)}
|
||||
{appUpdate && open && (
|
||||
<Card>
|
||||
{appUpdate && open && showUpdateCard && (
|
||||
<Card className="gap-4 py-0">
|
||||
<CardHeader className="p-4 pb-0">
|
||||
<CardTitle className="text-sm">Update Available (v{appUpdate.version})</CardTitle>
|
||||
<CardDescription>
|
||||
A new version of {config.appName} is available. Please update to the latest version for the best experience.
|
||||
A newer version of {config.appName} is available. Please update to the latest version for the best experience.
|
||||
</CardDescription>
|
||||
<a className="text-xs font-semibold cursor-pointer mt-1" href={`https://github.com/neosubhamoy/neodlp/releases/tag/v${appUpdate.version}`} target="_blank">✨ Read Changelog</a>
|
||||
</CardHeader>
|
||||
<CardContent className="grid gap-2.5 p-4">
|
||||
<AlertDialog>
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
import * as React from "react"
|
||||
import * as RechartsPrimitive from "recharts"
|
||||
import type { LegendPayload } from "recharts/types/component/DefaultLegendContent"
|
||||
import {
|
||||
NameType,
|
||||
Payload,
|
||||
ValueType,
|
||||
} from "recharts/types/component/DefaultTooltipContent"
|
||||
import type { Props as LegendProps } from "recharts/types/component/Legend"
|
||||
import { TooltipContentProps } from "recharts/types/component/Tooltip"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
@@ -20,6 +28,36 @@ type ChartContextProps = {
|
||||
config: ChartConfig
|
||||
}
|
||||
|
||||
export type CustomTooltipProps = TooltipContentProps<ValueType, NameType> & {
|
||||
className?: string
|
||||
hideLabel?: boolean
|
||||
hideIndicator?: boolean
|
||||
indicator?: "line" | "dot" | "dashed"
|
||||
nameKey?: string
|
||||
labelKey?: string
|
||||
labelFormatter?: (
|
||||
label: TooltipContentProps<number, string>["label"],
|
||||
payload: TooltipContentProps<number, string>["payload"]
|
||||
) => React.ReactNode
|
||||
formatter?: (
|
||||
value: number | string,
|
||||
name: string,
|
||||
item: Payload<number | string, string>,
|
||||
index: number,
|
||||
payload: ReadonlyArray<Payload<number | string, string>>
|
||||
) => React.ReactNode
|
||||
labelClassName?: string
|
||||
color?: string
|
||||
}
|
||||
|
||||
export type ChartLegendContentProps = {
|
||||
className?: string
|
||||
hideIcon?: boolean
|
||||
verticalAlign?: LegendProps["verticalAlign"]
|
||||
payload?: LegendPayload[]
|
||||
nameKey?: string
|
||||
}
|
||||
|
||||
const ChartContext = React.createContext<ChartContextProps | null>(null)
|
||||
|
||||
function useChart() {
|
||||
@@ -82,17 +120,17 @@ const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
||||
__html: Object.entries(THEMES)
|
||||
.map(
|
||||
([theme, prefix]) => `
|
||||
${prefix} [data-chart=${id}] {
|
||||
${colorConfig
|
||||
.map(([key, itemConfig]) => {
|
||||
const color =
|
||||
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
|
||||
itemConfig.color
|
||||
return color ? ` --color-${key}: ${color};` : null
|
||||
})
|
||||
.join("\n")}
|
||||
}
|
||||
`
|
||||
${prefix} [data-chart=${id}] {
|
||||
${colorConfig
|
||||
.map(([key, itemConfig]) => {
|
||||
const color =
|
||||
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
|
||||
itemConfig.color
|
||||
return color ? ` --color-${key}: ${color};` : null
|
||||
})
|
||||
.join("\n")}
|
||||
}
|
||||
`
|
||||
)
|
||||
.join("\n"),
|
||||
}}
|
||||
@@ -105,25 +143,18 @@ const ChartTooltip = RechartsPrimitive.Tooltip
|
||||
function ChartTooltipContent({
|
||||
active,
|
||||
payload,
|
||||
label,
|
||||
className,
|
||||
indicator = "dot",
|
||||
hideLabel = false,
|
||||
hideIndicator = false,
|
||||
label,
|
||||
labelFormatter,
|
||||
labelClassName,
|
||||
formatter,
|
||||
labelClassName,
|
||||
color,
|
||||
nameKey,
|
||||
labelKey,
|
||||
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
||||
React.ComponentProps<"div"> & {
|
||||
hideLabel?: boolean
|
||||
hideIndicator?: boolean
|
||||
indicator?: "line" | "dot" | "dashed"
|
||||
nameKey?: string
|
||||
labelKey?: string
|
||||
}) {
|
||||
}: CustomTooltipProps) {
|
||||
const { config } = useChart()
|
||||
|
||||
const tooltipLabel = React.useMemo(() => {
|
||||
@@ -134,10 +165,14 @@ function ChartTooltipContent({
|
||||
const [item] = payload
|
||||
const key = `${labelKey || item?.dataKey || item?.name || "value"}`
|
||||
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
||||
const value =
|
||||
!labelKey && typeof label === "string"
|
||||
? config[label as keyof typeof config]?.label || label
|
||||
: itemConfig?.label
|
||||
const value = (() => {
|
||||
const v =
|
||||
!labelKey && typeof label === "string"
|
||||
? config[label as keyof typeof config]?.label ?? label
|
||||
: itemConfig?.label
|
||||
|
||||
return typeof v === "string" || typeof v === "number" ? v : undefined
|
||||
})()
|
||||
|
||||
if (labelFormatter) {
|
||||
return (
|
||||
@@ -254,11 +289,7 @@ function ChartLegendContent({
|
||||
payload,
|
||||
verticalAlign = "bottom",
|
||||
nameKey,
|
||||
}: React.ComponentProps<"div"> &
|
||||
Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {
|
||||
hideIcon?: boolean
|
||||
nameKey?: string
|
||||
}) {
|
||||
}: ChartLegendContentProps) {
|
||||
const { config } = useChart()
|
||||
|
||||
if (!payload?.length) {
|
||||
|
||||
@@ -15,6 +15,12 @@ const Toaster = ({ ...props }: ToasterProps) => {
|
||||
"--normal-border": "var(--border)",
|
||||
} as React.CSSProperties
|
||||
}
|
||||
toastOptions={{
|
||||
classNames: {
|
||||
toast: "group",
|
||||
icon: "group-data-[type=error]:!text-red-500 group-data-[type=success]:!text-green-500 group-data-[type=warning]:!text-amber-500 group-data-[type=info]:!text-sky-500",
|
||||
},
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -31,15 +31,16 @@ export default function useAppUpdater() {
|
||||
switch (event.event) {
|
||||
case 'Started':
|
||||
contentLength = event.data.contentLength;
|
||||
console.log(`started downloading ${event.data.contentLength} bytes`);
|
||||
console.log(`started downloading app update of ${event.data.contentLength} bytes`);
|
||||
break;
|
||||
case 'Progress':
|
||||
downloaded += event.data.chunkLength;
|
||||
setDownloadProgress(downloaded / (contentLength || 0));
|
||||
console.log(`downloaded ${downloaded} from ${contentLength}`);
|
||||
const progress = (downloaded / (contentLength || 1)) * 100;
|
||||
setDownloadProgress(Math.round(progress * 10) / 10);
|
||||
console.log(`downloaded ${downloaded} bytes from ${contentLength} bytes of app update`);
|
||||
break;
|
||||
case 'Finished':
|
||||
console.log('download finished');
|
||||
console.log('app update download finished');
|
||||
setIsUpdating(false);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { toast } from "sonner";
|
||||
import { useResetSettings, useSaveSettingsKey } from "@/services/mutations";
|
||||
import { useSettingsPageStatesStore } from "@/services/store";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
export function useSettings() {
|
||||
const { toast } = useToast();
|
||||
const queryClient = useQueryClient();
|
||||
const setSettingsKey = useSettingsPageStatesStore(state => state.setSettingsKey);
|
||||
const resetSettingsState = useSettingsPageStatesStore(state => state.resetSettings);
|
||||
@@ -22,10 +21,8 @@ export function useSettings() {
|
||||
onError: (error) => {
|
||||
console.error("Error saving settings key:", error);
|
||||
queryClient.invalidateQueries({ queryKey: ["settings"] });
|
||||
toast({
|
||||
title: "Failed to update settings",
|
||||
toast.error("Failed to update settings", {
|
||||
description: `Failed to update ${key}`,
|
||||
variant: "destructive",
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -39,26 +36,21 @@ export function useSettings() {
|
||||
resetSettingsState();
|
||||
console.log("Settings reset successfully");
|
||||
queryClient.invalidateQueries({ queryKey: ["settings"] });
|
||||
toast({
|
||||
title: "Settings reset successfully",
|
||||
toast.success("Settings reset successfully", {
|
||||
description: "All settings have been reset to default.",
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error resetting settings:", error);
|
||||
toast({
|
||||
title: "Failed to reset settings",
|
||||
toast.error("Failed to reset settings", {
|
||||
description: "Failed to reset settings to default.",
|
||||
variant: "destructive",
|
||||
});
|
||||
return;
|
||||
}
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error("Error resetting settings:", error);
|
||||
toast({
|
||||
title: "Failed to reset settings",
|
||||
toast.error("Failed to reset settings", {
|
||||
description: "Failed to reset settings to default.",
|
||||
variant: "destructive",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -8,7 +8,6 @@ import RootLayout from "@/pages/layout/root";
|
||||
import DownloaderPage from "@/pages/downloader";
|
||||
import LibraryPage from "@/pages/library";
|
||||
import SettingsPage from "@/pages/settings";
|
||||
import ExtensionPage from "@/pages/extension";
|
||||
|
||||
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
||||
<React.StrictMode>
|
||||
@@ -19,7 +18,6 @@ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
||||
<Route path="/" element={<RootLayout />}>
|
||||
<Route index element={<DownloaderPage />} />
|
||||
<Route path="/library" element={<LibraryPage />} />
|
||||
<Route path="/extension" element={<ExtensionPage />} />
|
||||
<Route path="/settings" element={<SettingsPage />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,77 +0,0 @@
|
||||
import { SlidingButton } from "@/components/custom/slidingButton";
|
||||
import Heading from "@/components/heading";
|
||||
import { ArrowRight } from "lucide-react";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
export default function ExtensionPage() {
|
||||
const { toast } = useToast();
|
||||
const openLink = async (url: string, app: string | null) => {
|
||||
try {
|
||||
await invoke('open_file_with_app', { filePath: url, appName: app }).then(() => {
|
||||
toast({
|
||||
title: 'Opening Link',
|
||||
description: `Opening link with ${app ? app : 'default app'}.`,
|
||||
})
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
toast({
|
||||
title: 'Failed to open link',
|
||||
description: 'An error occurred while trying to open the link.',
|
||||
variant: "destructive"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="container mx-auto p-4 space-y-4">
|
||||
<Heading title="Extension" description="Integrate NeoDLP with your favourite browser" />
|
||||
<div className="flex items-center gap-4">
|
||||
<SlidingButton
|
||||
slidingContent={
|
||||
<div className="flex items-center justify-center gap-2 text-white dark:text-black">
|
||||
<ArrowRight className="size-4" />
|
||||
<span>Get Now</span>
|
||||
</div>
|
||||
}
|
||||
onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'chrome')}
|
||||
>
|
||||
<span className="font-semibold flex items-center gap-2">
|
||||
<svg className="size-4 fill-white dark:fill-black" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
||||
<path d="M0 256C0 209.4 12.5 165.6 34.3 127.1L144.1 318.3C166 357.5 207.9 384 256 384C270.3 384 283.1 381.7 296.8 377.4L220.5 509.6C95.9 492.3 0 385.3 0 256zM365.1 321.6C377.4 302.4 384 279.1 384 256C384 217.8 367.2 183.5 340.7 160H493.4C505.4 189.6 512 222.1 512 256C512 397.4 397.4 511.1 256 512L365.1 321.6zM477.8 128H256C193.1 128 142.3 172.1 130.5 230.7L54.2 98.5C101 38.5 174 0 256 0C350.8 0 433.5 51.5 477.8 128V128zM168 256C168 207.4 207.4 168 256 168C304.6 168 344 207.4 344 256C344 304.6 304.6 344 256 344C207.4 344 168 304.6 168 256z"/>
|
||||
</svg>
|
||||
Get Chrome Extension
|
||||
</span>
|
||||
<span className="text-xs">from Chrome Web Store</span>
|
||||
</SlidingButton>
|
||||
<SlidingButton
|
||||
slidingContent={
|
||||
<div className="flex items-center justify-center gap-2 text-white dark:text-black">
|
||||
<ArrowRight className="size-4" />
|
||||
<span>Get Now</span>
|
||||
</div>
|
||||
}
|
||||
onClick={() => openLink('https://addons.mozilla.org/en-US/firefox/addon/neo-downloader-plus', 'firefox')}
|
||||
>
|
||||
<span className="font-semibold flex items-center gap-2">
|
||||
<svg className="size-4 fill-white dark:fill-black" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
||||
<path d="M130.2 127.5C130.4 127.6 130.3 127.6 130.2 127.5V127.5zM481.6 172.9C471 147.4 449.6 119.9 432.7 111.2C446.4 138.1 454.4 165 457.4 185.2C457.4 185.3 457.4 185.4 457.5 185.6C429.9 116.8 383.1 89.1 344.9 28.7C329.9 5.1 334 3.5 331.8 4.1L331.7 4.2C285 30.1 256.4 82.5 249.1 126.9C232.5 127.8 216.2 131.9 201.2 139C199.8 139.6 198.7 140.7 198.1 142C197.4 143.4 197.2 144.9 197.5 146.3C197.7 147.2 198.1 148 198.6 148.6C199.1 149.3 199.8 149.9 200.5 150.3C201.3 150.7 202.1 151 203 151.1C203.8 151.1 204.7 151 205.5 150.8L206 150.6C221.5 143.3 238.4 139.4 255.5 139.2C318.4 138.7 352.7 183.3 363.2 201.5C350.2 192.4 326.8 183.3 304.3 187.2C392.1 231.1 368.5 381.8 247 376.4C187.5 373.8 149.9 325.5 146.4 285.6C146.4 285.6 157.7 243.7 227 243.7C234.5 243.7 256 222.8 256.4 216.7C256.3 214.7 213.8 197.8 197.3 181.5C188.4 172.8 184.2 168.6 180.5 165.5C178.5 163.8 176.4 162.2 174.2 160.7C168.6 141.2 168.4 120.6 173.5 101.1C148.5 112.5 129 130.5 114.8 146.4H114.7C105 134.2 105.7 93.8 106.3 85.3C106.1 84.8 99 89 98.1 89.7C89.5 95.7 81.6 102.6 74.3 110.1C58 126.7 30.1 160.2 18.8 211.3C14.2 231.7 12 255.7 12 263.6C12 398.3 121.2 507.5 255.9 507.5C376.6 507.5 478.9 420.3 496.4 304.9C507.9 228.2 481.6 173.8 481.6 172.9z"/>
|
||||
</svg>
|
||||
Get Firefox Extension
|
||||
</span>
|
||||
<span className="text-xs">from Mozilla Addons Store</span>
|
||||
</SlidingButton>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button variant="outline" onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'msedge')}>Edge</Button>
|
||||
<Button variant="outline" onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'opera')}>Opera</Button>
|
||||
<Button variant="outline" onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'brave')}>Brave</Button>
|
||||
<Button variant="outline" onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'arc')}>Arc</Button>
|
||||
<Button variant="outline" onClick={() => openLink('https://addons.mozilla.org/en-US/firefox/addon/neo-downloader-plus', 'zen')}>Zen</Button>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground mb-2">* These links opens with coresponding browsers only. Make sure the browser is installed befor clicking the link</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -4,11 +4,11 @@ import { AspectRatio } from "@/components/ui/aspect-ratio";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { toast } from "sonner";
|
||||
import { useAppContext } from "@/providers/appContextProvider";
|
||||
import { useDownloadActionStatesStore, useDownloadStatesStore } from "@/services/store";
|
||||
import { useDownloadActionStatesStore, useDownloadStatesStore, useLibraryPageStatesStore } from "@/services/store";
|
||||
import { formatBitrate, formatCodec, formatDurationString, formatFileSize, formatSecToTimeString, formatSpeed } from "@/utils";
|
||||
import { AudioLines, Clock, CloudDownload, File, FileAudio2, FileQuestion, FileVideo2, FolderInput, ListVideo, Loader2, Music, PackageCheck, Pause, Play, Trash2, Video, X } from "lucide-react";
|
||||
import { AudioLines, Clock, File, FileAudio2, FileQuestion, FileVideo2, FolderInput, ListVideo, Loader2, Music, Pause, Play, Square, Trash2, Video, X } from "lucide-react";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import * as fs from "@tauri-apps/plugin-fs";
|
||||
import { DownloadState } from "@/types/download";
|
||||
@@ -18,9 +18,13 @@ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent,
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import Heading from "@/components/heading";
|
||||
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
|
||||
export default function LibraryPage() {
|
||||
const activeTab = useLibraryPageStatesStore(state => state.activeTab);
|
||||
const setActiveTab = useLibraryPageStatesStore(state => state.setActiveTab);
|
||||
|
||||
const downloadStates = useDownloadStatesStore(state => state.downloadStates);
|
||||
const downloadActions = useDownloadActionStatesStore(state => state.downloadActions);
|
||||
const setIsResumingDownload = useDownloadActionStatesStore(state => state.setIsResumingDownload);
|
||||
@@ -29,36 +33,33 @@ export default function LibraryPage() {
|
||||
const setIsDeleteFileChecked = useDownloadActionStatesStore(state => state.setIsDeleteFileChecked);
|
||||
|
||||
const { pauseDownload, resumeDownload, cancelDownload } = useAppContext()
|
||||
const { toast } = useToast();
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
const downloadStateDeleter = useDeleteDownloadState();
|
||||
|
||||
const incompleteDownloads = downloadStates.filter(state => state.download_status !== 'completed');
|
||||
const completedDownloads = downloadStates.filter(state => state.download_status === 'completed');
|
||||
const ongoingDownloads = downloadStates.filter(state =>
|
||||
['starting', 'downloading', 'queued'].includes(state.download_status)
|
||||
);
|
||||
|
||||
const openFile = async (filePath: string | null, app: string | null) => {
|
||||
if (filePath && await fs.exists(filePath)) {
|
||||
try {
|
||||
await invoke('open_file_with_app', { filePath: filePath, appName: app }).then(() => {
|
||||
toast({
|
||||
title: 'Opening file',
|
||||
toast.info("Opening file", {
|
||||
description: `Opening the file with ${app ? app : 'default app'}.`,
|
||||
})
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
toast({
|
||||
title: 'Failed to open file',
|
||||
description: 'An error occurred while trying to open the file.',
|
||||
variant: "destructive"
|
||||
toast.error("Failed to open file", {
|
||||
description: "An error occurred while trying to open the file.",
|
||||
})
|
||||
}
|
||||
} else {
|
||||
toast({
|
||||
title: 'File unavailable',
|
||||
description: 'The file you are trying to open does not exist.',
|
||||
variant: "destructive"
|
||||
toast.info("File unavailable", {
|
||||
description: "The file you are trying to open does not exist.",
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -80,345 +81,393 @@ export default function LibraryPage() {
|
||||
onSuccess: (data) => {
|
||||
console.log("Download State deleted successfully:", data);
|
||||
queryClient.invalidateQueries({ queryKey: ['download-states'] });
|
||||
toast({
|
||||
title: 'Removed from downloads',
|
||||
description: 'The download has been removed successfully.',
|
||||
})
|
||||
toast.success("Removed from downloads", {
|
||||
description: "The download has been removed successfully.",
|
||||
});
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error("Failed to delete download state:", error);
|
||||
toast({
|
||||
title: 'Failed to remove download',
|
||||
description: 'An error occurred while trying to remove the download.',
|
||||
variant: "destructive"
|
||||
})
|
||||
toast.error("Failed to remove download", {
|
||||
description: "An error occurred while trying to remove the download.",
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const stopOngoingDownloads = async () => {
|
||||
if (ongoingDownloads.length > 0) {
|
||||
for (const state of ongoingDownloads) {
|
||||
setIsPausingDownload(state.download_id, true);
|
||||
try {
|
||||
await pauseDownload(state);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
toast.error("Failed to stop download", {
|
||||
description: `An error occurred while trying to stop the download for ${state.title}.`,
|
||||
});
|
||||
} finally {
|
||||
setIsPausingDownload(state.download_id, false);
|
||||
}
|
||||
}
|
||||
if (ongoingDownloads.length === 0) {
|
||||
toast.success("Stopped ongoing downloads", {
|
||||
description: "All ongoing downloads have been stopped successfully.",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
toast.info("No ongoing downloads", {
|
||||
description: "There are no ongoing downloads to stop.",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="container mx-auto p-4 space-y-4">
|
||||
<Heading title="Library" description="Manage all your downloads in one place" />
|
||||
<div className="w-full fle flex-col">
|
||||
<div className="flex w-full items-center gap-3 mb-2">
|
||||
<CloudDownload className="size-5" />
|
||||
<h3 className="text-nowrap font-semibold">Incomplete Downloads</h3>
|
||||
<Tabs value={activeTab} onValueChange={setActiveTab}>
|
||||
<div className="w-full flex items-center justify-between mb-4">
|
||||
<TabsList>
|
||||
<TabsTrigger value="completed">Completed {completedDownloads.length > 0 && (`(${completedDownloads.length})`)}</TabsTrigger>
|
||||
<TabsTrigger value="incomplete">Incomplete {(incompleteDownloads.length > 0 && ongoingDownloads.length <= 0) && (`(${incompleteDownloads.length})`)} {ongoingDownloads.length > 0 && (<Badge className="h-4 min-w-4 rounded-full px-1 font-mono tabular-nums ml-1">{ongoingDownloads.length}</Badge>)}</TabsTrigger>
|
||||
</TabsList>
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button
|
||||
className="w-fit"
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
disabled={ongoingDownloads.length <= 0}
|
||||
>
|
||||
<Square className="h-4 w-4" />
|
||||
Stop
|
||||
</Button>
|
||||
</AlertDialogTrigger>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Stop all ongoing downloads?</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
Are you sure you want to stop all ongoing downloads? This will pause all downloads including the download queue.
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={() => stopOngoingDownloads()}
|
||||
>Stop</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
<Separator orientation="horizontal" className="" />
|
||||
</div>
|
||||
<div className="w-full flex flex-col gap-2">
|
||||
{incompleteDownloads.length > 0 ? (
|
||||
incompleteDownloads.map((state) => {
|
||||
const itemActionStates = downloadActions[state.download_id] || {
|
||||
isResuming: false,
|
||||
isPausing: false,
|
||||
isCanceling: false,
|
||||
isDeleteFileChecked: false,
|
||||
};
|
||||
return (
|
||||
<div className="p-4 border border-border rounded-lg flex gap-4" key={state.download_id}>
|
||||
<div className="w-[30%] flex flex-col justify-between gap-2">
|
||||
<AspectRatio ratio={16 / 9} className="w-full rounded-lg overflow-hidden border border-border">
|
||||
<ProxyImage src={state.thumbnail || ""} alt="thumbnail" className="" />
|
||||
</AspectRatio>
|
||||
{state.ext && (
|
||||
<span className="w-full flex items-center justify-center text-xs border border-border py-1 px-2 rounded">
|
||||
{state.filetype && (state.filetype === 'video' || state.filetype === 'video+audio') && (
|
||||
<Video className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{state.filetype && state.filetype === 'audio' && (
|
||||
<Music className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{(!state.filetype) || (state.filetype && state.filetype !== 'video' && state.filetype !== 'audio' && state.filetype !== 'video+audio') && (
|
||||
<File className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{state.ext.toUpperCase()} {state.resolution ? `(${state.resolution})` : null}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="w-full flex flex-col justify-between">
|
||||
<div className="flex flex-col gap-1">
|
||||
<h4>{state.title}</h4>
|
||||
{((state.download_status === 'starting') || (state.download_status === 'downloading' && state.status === 'finished')) && (
|
||||
<IndeterminateProgress indeterminate={true} className="w-full" />
|
||||
)}
|
||||
{(state.download_status === 'downloading' || state.download_status === 'paused') && state.progress && state.status !== 'finished' && (
|
||||
<div className="w-full flex items-center gap-2">
|
||||
<span className="text-sm text-nowrap">{state.progress}%</span>
|
||||
<Progress value={state.progress} />
|
||||
<span className="text-sm text-nowrap">{
|
||||
state.downloaded && state.total
|
||||
? `(${formatFileSize(state.downloaded)} / ${formatFileSize(state.total)})`
|
||||
: null
|
||||
}</span>
|
||||
<TabsContent value="completed">
|
||||
<div className="w-full flex flex-col gap-2">
|
||||
{completedDownloads.length > 0 ? (
|
||||
completedDownloads.map((state) => {
|
||||
const itemActionStates = downloadActions[state.download_id] || {
|
||||
isResuming: false,
|
||||
isPausing: false,
|
||||
isCanceling: false,
|
||||
isDeleteFileChecked: false,
|
||||
};
|
||||
return (
|
||||
<div className="p-4 border border-border rounded-lg flex gap-4" key={state.download_id}>
|
||||
<div className="w-[30%] flex flex-col justify-between gap-2">
|
||||
<AspectRatio ratio={16 / 9} className="w-full rounded-lg overflow-hidden border border-border mb-2">
|
||||
<ProxyImage src={state.thumbnail || ""} alt="thumbnail" className="" />
|
||||
</AspectRatio>
|
||||
<span className="w-full flex items-center justify-center text-xs border border-border py-1 px-2 rounded">
|
||||
{state.filetype && (state.filetype === 'video' || state.filetype === 'video+audio') && (
|
||||
<Video className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{state.filetype && state.filetype === 'audio' && (
|
||||
<Music className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{(!state.filetype) || (state.filetype && state.filetype !== 'video' && state.filetype !== 'audio' && state.filetype !== 'video+audio') && (
|
||||
<File className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{state.ext?.toUpperCase()} {state.resolution ? `(${state.resolution})` : null}
|
||||
</span>
|
||||
</div>
|
||||
<div className="w-full flex flex-col justify-between gap-2">
|
||||
<div className="flex flex-col gap-1">
|
||||
<h4 className="">{state.title}</h4>
|
||||
<p className="text-xs text-muted-foreground">{state.channel ? state.channel : 'unknown'} {state.host ? `• ${state.host}` : 'unknown'}</p>
|
||||
<div className="flex items-center mt-1">
|
||||
<span className="text-xs text-muted-foreground flex items-center pr-3"><Clock className="w-4 h-4 mr-2"/> {state.duration_string ? formatDurationString(state.duration_string) : 'unknown'}</span>
|
||||
<Separator orientation="vertical" />
|
||||
<span className="text-xs text-muted-foreground flex items-center px-3">
|
||||
{state.filetype && (state.filetype === 'video' || state.filetype === 'video+audio') && (
|
||||
<FileVideo2 className="w-4 h-4 mr-2"/>
|
||||
)}
|
||||
{state.filetype && state.filetype === 'audio' && (
|
||||
<FileAudio2 className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{(!state.filetype) || (state.filetype && state.filetype !== 'video' && state.filetype !== 'audio' && state.filetype !== 'video+audio') && (
|
||||
<FileQuestion className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{state.filesize ? formatFileSize(state.filesize) : 'unknown'}
|
||||
</span>
|
||||
<Separator orientation="vertical" />
|
||||
<span className="text-xs text-muted-foreground flex items-center pl-3"><AudioLines className="w-4 h-4 mr-2"/>
|
||||
{state.vbr && state.abr ? (
|
||||
formatBitrate(state.vbr + state.abr)
|
||||
) : state.vbr ? (
|
||||
formatBitrate(state.vbr)
|
||||
) : state.abr ? (
|
||||
formatBitrate(state.abr)
|
||||
) : (
|
||||
'unknown'
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="hidden xl:flex items-center mt-1 gap-2 flex-wrap text-xs">
|
||||
{state.playlist_id && state.playlist_index && (
|
||||
<span
|
||||
className="border border-border py-1 px-2 rounded flex items-center cursor-pointer"
|
||||
title={`${state.playlist_title ?? 'UNKNOWN PLAYLIST'}` + ' by ' + `${state.playlist_channel ?? 'UNKNOWN CHANNEL'}`}
|
||||
>
|
||||
<ListVideo className="w-4 h-4 mr-2" /> Playlist ({state.playlist_index} of {state.playlist_n_entries})
|
||||
</span>
|
||||
)}
|
||||
{state.vcodec && (
|
||||
<span className="border border-border py-1 px-2 rounded">{formatCodec(state.vcodec)}</span>
|
||||
)}
|
||||
{state.acodec && (
|
||||
<span className="border border-border py-1 px-2 rounded">{formatCodec(state.acodec)}</span>
|
||||
)}
|
||||
{state.dynamic_range && state.dynamic_range !== 'SDR' && (
|
||||
<span className="border border-border py-1 px-2 rounded">{state.dynamic_range}</span>
|
||||
)}
|
||||
{state.subtitle_id && (
|
||||
<span
|
||||
className="border border-border py-1 px-2 rounded cursor-pointer"
|
||||
title={`EMBEDED SUBTITLE (${state.subtitle_id})`}
|
||||
>
|
||||
ESUB
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="text-xs text-muted-foreground">{ state.download_status && (
|
||||
`${state.download_status === 'downloading' && state.status === 'finished' ? 'Processing' : state.download_status.charAt(0).toUpperCase() + state.download_status.slice(1)} ${state.download_status === 'downloading' && state.status !== 'finished' && state.speed ? `• Speed: ${formatSpeed(state.speed)}` : ""} ${state.download_status === 'downloading' && state.eta ? `• ETA: ${formatSecToTimeString(state.eta)}` : ""}`
|
||||
)}</div>
|
||||
</div>
|
||||
<div className="w-full flex items-center gap-2 mt-2">
|
||||
{state.download_status === 'paused' ? (
|
||||
<Button
|
||||
size="sm"
|
||||
className="w-fill"
|
||||
onClick={async () => {
|
||||
setIsResumingDownload(state.download_id, true);
|
||||
try {
|
||||
await resumeDownload(state)
|
||||
// toast({
|
||||
// title: 'Resumed Download',
|
||||
// description: 'Download resumed, it will re-start shortly.',
|
||||
// })
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
toast({
|
||||
title: 'Failed to Resume Download',
|
||||
description: 'An error occurred while trying to resume the download.',
|
||||
variant: "destructive"
|
||||
})
|
||||
} finally {
|
||||
setIsResumingDownload(state.download_id, false);
|
||||
}
|
||||
}}
|
||||
disabled={itemActionStates.isResuming || itemActionStates.isCanceling}
|
||||
>
|
||||
{itemActionStates.isResuming ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
Resuming
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Play className="w-4 h-4" />
|
||||
Resume
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
size="sm"
|
||||
className="w-fill"
|
||||
onClick={async () => {
|
||||
setIsPausingDownload(state.download_id, true);
|
||||
try {
|
||||
await pauseDownload(state)
|
||||
// toast({
|
||||
// title: 'Paused Download',
|
||||
// description: 'Download paused successfully.',
|
||||
// })
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
toast({
|
||||
title: 'Failed to Pause Download',
|
||||
description: 'An error occurred while trying to pause the download.',
|
||||
variant: "destructive"
|
||||
})
|
||||
} finally {
|
||||
setIsPausingDownload(state.download_id, false);
|
||||
}
|
||||
}}
|
||||
disabled={itemActionStates.isPausing || itemActionStates.isCanceling || state.download_status !== 'downloading' || (state.download_status === 'downloading' && state.status === 'finished')}
|
||||
>
|
||||
{itemActionStates.isPausing ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
Pausing
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Pause className="w-4 h-4" />
|
||||
Pause
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
size="sm"
|
||||
variant="destructive"
|
||||
onClick={async () => {
|
||||
setIsCancelingDownload(state.download_id, true);
|
||||
try {
|
||||
await cancelDownload(state)
|
||||
toast({
|
||||
title: 'Canceled Download',
|
||||
description: 'Download canceled successfully.',
|
||||
})
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
toast({
|
||||
title: 'Failed to Cancel Download',
|
||||
description: 'An error occurred while trying to cancel the download.',
|
||||
variant: "destructive"
|
||||
})
|
||||
} finally {
|
||||
setIsCancelingDownload(state.download_id, false);
|
||||
}
|
||||
}}
|
||||
disabled={itemActionStates.isCanceling || itemActionStates.isResuming || itemActionStates.isPausing || state.download_status === 'starting' || (state.download_status === 'downloading' && state.status === 'finished')}
|
||||
>
|
||||
{itemActionStates.isCanceling ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
Canceling
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<X className="w-4 h-4" />
|
||||
Cancel
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
) : (
|
||||
<div className="w-full flex items-center justify-center text-muted-foreground text-sm">No Incomplete downloads!</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="w-full fle flex-col">
|
||||
<div className="flex w-full items-center gap-3 mb-2">
|
||||
<PackageCheck className="size-5" />
|
||||
<h3 className="text-nowrap font-semibold">Completed Downloads</h3>
|
||||
</div>
|
||||
<Separator orientation="horizontal" className="" />
|
||||
</div>
|
||||
<div className="w-full flex flex-col gap-2">
|
||||
{completedDownloads.length > 0 ? (
|
||||
completedDownloads.map((state) => {
|
||||
const itemActionStates = downloadActions[state.download_id] || {
|
||||
isResuming: false,
|
||||
isPausing: false,
|
||||
isCanceling: false,
|
||||
isDeleteFileChecked: false,
|
||||
};
|
||||
return (
|
||||
<div className="p-4 border border-border rounded-lg flex gap-4" key={state.download_id}>
|
||||
<div className="w-[30%] flex flex-col justify-between gap-2">
|
||||
<AspectRatio ratio={16 / 9} className="w-full rounded-lg overflow-hidden border border-border mb-2">
|
||||
<ProxyImage src={state.thumbnail || ""} alt="thumbnail" className="" />
|
||||
</AspectRatio>
|
||||
<span className="w-full flex items-center justify-center text-xs border border-border py-1 px-2 rounded">
|
||||
{state.filetype && (state.filetype === 'video' || state.filetype === 'video+audio') && (
|
||||
<Video className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{state.filetype && state.filetype === 'audio' && (
|
||||
<Music className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{(!state.filetype) || (state.filetype && state.filetype !== 'video' && state.filetype !== 'audio' && state.filetype !== 'video+audio') && (
|
||||
<File className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{state.ext?.toUpperCase()} {state.resolution ? `(${state.resolution})` : null}
|
||||
</span>
|
||||
</div>
|
||||
<div className="w-full flex flex-col justify-between gap-2">
|
||||
<div className="flex flex-col gap-1">
|
||||
<h4 className="">{state.title}</h4>
|
||||
<p className="text-xs text-muted-foreground">{state.channel ? state.channel : 'unknown'} {state.host ? `• ${state.host}` : 'unknown'}</p>
|
||||
<div className="flex items-center mt-1">
|
||||
<span className="text-xs text-muted-foreground flex items-center pr-3"><Clock className="w-4 h-4 mr-2"/> {state.duration_string ? formatDurationString(state.duration_string) : 'unknown'}</span>
|
||||
<Separator orientation="vertical" />
|
||||
<span className="text-xs text-muted-foreground flex items-center px-3">
|
||||
{state.filetype && (state.filetype === 'video' || state.filetype === 'video+audio') && (
|
||||
<FileVideo2 className="w-4 h-4 mr-2"/>
|
||||
)}
|
||||
{state.filetype && state.filetype === 'audio' && (
|
||||
<FileAudio2 className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{(!state.filetype) || (state.filetype && state.filetype !== 'video' && state.filetype !== 'audio' && state.filetype !== 'video+audio') && (
|
||||
<FileQuestion className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{state.filesize ? formatFileSize(state.filesize) : 'unknown'}
|
||||
</span>
|
||||
<Separator orientation="vertical" />
|
||||
<span className="text-xs text-muted-foreground flex items-center pl-3"><AudioLines className="w-4 h-4 mr-2"/>
|
||||
{state.vbr && state.abr ? (
|
||||
formatBitrate(state.vbr + state.abr)
|
||||
) : state.vbr ? (
|
||||
formatBitrate(state.vbr)
|
||||
) : state.abr ? (
|
||||
formatBitrate(state.abr)
|
||||
) : (
|
||||
'unknown'
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="hidden xl:flex items-center mt-1 gap-2 flex-wrap text-xs">
|
||||
{state.playlist_id && state.playlist_index && (
|
||||
<span
|
||||
className="border border-border py-1 px-2 rounded flex items-center cursor-pointer"
|
||||
title={`${state.playlist_title ?? 'UNKNOWN PLAYLIST'}` + ' by ' + `${state.playlist_channel ?? 'UNKNOWN CHANNEL'}`}
|
||||
>
|
||||
<ListVideo className="w-4 h-4 mr-2" /> Playlist ({state.playlist_index} of {state.playlist_n_entries})
|
||||
</span>
|
||||
)}
|
||||
{state.vcodec && (
|
||||
<span className="border border-border py-1 px-2 rounded">{formatCodec(state.vcodec)}</span>
|
||||
)}
|
||||
{state.acodec && (
|
||||
<span className="border border-border py-1 px-2 rounded">{formatCodec(state.acodec)}</span>
|
||||
)}
|
||||
{state.dynamic_range && state.dynamic_range !== 'SDR' && (
|
||||
<span className="border border-border py-1 px-2 rounded">{state.dynamic_range}</span>
|
||||
)}
|
||||
{state.subtitle_id && (
|
||||
<span
|
||||
className="border border-border py-1 px-2 rounded cursor-pointer"
|
||||
title={`EMBEDED SUBTITLE (${state.subtitle_id})`}
|
||||
>
|
||||
ESUB
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="w-full flex items-center gap-2">
|
||||
<Button size="sm" onClick={() => openFile(state.filepath, null)}>
|
||||
<Play className="w-4 h-4" />
|
||||
Open
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={() => openFile(state.filepath, 'explorer')}>
|
||||
<FolderInput className="w-4 h-4" />
|
||||
Open in Explorer
|
||||
</Button>
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button size="sm" variant="destructive">
|
||||
<Trash2 className="w-4 h-4" />
|
||||
Remove
|
||||
<div className="w-full flex items-center gap-2">
|
||||
<Button size="sm" onClick={() => openFile(state.filepath, null)}>
|
||||
<Play className="w-4 h-4" />
|
||||
Open
|
||||
</Button>
|
||||
</AlertDialogTrigger>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
This action cannot be undone! it will permanently remove this from downloads.
|
||||
</AlertDialogDescription>
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox id="delete-file" checked={itemActionStates.isDeleteFileChecked} onCheckedChange={() => {setIsDeleteFileChecked(state.download_id, !itemActionStates.isDeleteFileChecked)}} />
|
||||
<Label htmlFor="delete-file">Delete the downloaded file</Label>
|
||||
</div>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction onClick={
|
||||
() => removeFromDownloads(state, itemActionStates.isDeleteFileChecked).then(() => {
|
||||
setIsDeleteFileChecked(state.download_id, false);
|
||||
})
|
||||
}>Remove</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<Button size="sm" variant="outline" onClick={() => openFile(state.filepath, 'explorer')}>
|
||||
<FolderInput className="w-4 h-4" />
|
||||
Open in Explorer
|
||||
</Button>
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button size="sm" variant="destructive">
|
||||
<Trash2 className="w-4 h-4" />
|
||||
Remove
|
||||
</Button>
|
||||
</AlertDialogTrigger>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Remove from library?</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
Are you sure you want to remove this download from the library? You can also delete the downloaded file by cheking the box below. This action cannot be undone.
|
||||
</AlertDialogDescription>
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox id="delete-file" checked={itemActionStates.isDeleteFileChecked} onCheckedChange={() => {setIsDeleteFileChecked(state.download_id, !itemActionStates.isDeleteFileChecked)}} />
|
||||
<Label htmlFor="delete-file">Delete the downloaded file</Label>
|
||||
</div>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction onClick={
|
||||
() => removeFromDownloads(state, itemActionStates.isDeleteFileChecked).then(() => {
|
||||
setIsDeleteFileChecked(state.download_id, false);
|
||||
})
|
||||
}>Remove</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
) : (
|
||||
<div className="w-full flex flex-col items-center gap-2 justify-center mt-27">
|
||||
<h4 className="text-4xl font-bold text-muted-foreground/80 dark:text-muted">Nothing!</h4>
|
||||
<p className="text-lg font-semibold text-muted-foreground/50">No Completed Downloads</p>
|
||||
<p className="max-w-[50%] text-center text-xs text-muted-foreground/70">You have not completed any downloads yet. Complete downloading something to see here :)</p>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
) : (
|
||||
<div className="w-full flex items-center justify-center text-muted-foreground text-sm">No Completed downloads!</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</TabsContent>
|
||||
<TabsContent value="incomplete">
|
||||
<div className="w-full flex flex-col gap-2">
|
||||
{incompleteDownloads.length > 0 ? (
|
||||
incompleteDownloads.map((state) => {
|
||||
const itemActionStates = downloadActions[state.download_id] || {
|
||||
isResuming: false,
|
||||
isPausing: false,
|
||||
isCanceling: false,
|
||||
isDeleteFileChecked: false,
|
||||
};
|
||||
return (
|
||||
<div className="p-4 border border-border rounded-lg flex gap-4" key={state.download_id}>
|
||||
<div className="w-[30%] flex flex-col justify-between gap-2">
|
||||
<AspectRatio ratio={16 / 9} className="w-full rounded-lg overflow-hidden border border-border">
|
||||
<ProxyImage src={state.thumbnail || ""} alt="thumbnail" className="" />
|
||||
</AspectRatio>
|
||||
{state.ext && (
|
||||
<span className="w-full flex items-center justify-center text-xs border border-border py-1 px-2 rounded">
|
||||
{state.filetype && (state.filetype === 'video' || state.filetype === 'video+audio') && (
|
||||
<Video className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{state.filetype && state.filetype === 'audio' && (
|
||||
<Music className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{(!state.filetype) || (state.filetype && state.filetype !== 'video' && state.filetype !== 'audio' && state.filetype !== 'video+audio') && (
|
||||
<File className="w-4 h-4 mr-2" />
|
||||
)}
|
||||
{state.ext.toUpperCase()} {state.resolution ? `(${state.resolution})` : null}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="w-full flex flex-col justify-between">
|
||||
<div className="flex flex-col gap-1">
|
||||
<h4>{state.title}</h4>
|
||||
{((state.download_status === 'starting') || (state.download_status === 'downloading' && state.status === 'finished')) && (
|
||||
<IndeterminateProgress indeterminate={true} className="w-full" />
|
||||
)}
|
||||
{(state.download_status === 'downloading' || state.download_status === 'paused') && state.progress && state.status !== 'finished' && (
|
||||
<div className="w-full flex items-center gap-2">
|
||||
<span className="text-sm text-nowrap">{state.progress}%</span>
|
||||
<Progress value={state.progress} />
|
||||
<span className="text-sm text-nowrap">{
|
||||
state.downloaded && state.total
|
||||
? `(${formatFileSize(state.downloaded)} / ${formatFileSize(state.total)})`
|
||||
: null
|
||||
}</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="text-xs text-muted-foreground">{ state.download_status && (
|
||||
`${state.download_status === 'downloading' && state.status === 'finished' ? 'Processing' : state.download_status.charAt(0).toUpperCase() + state.download_status.slice(1)} ${state.download_status === 'downloading' && state.status !== 'finished' && state.speed ? `• Speed: ${formatSpeed(state.speed)}` : ""} ${state.download_status === 'downloading' && state.eta ? `• ETA: ${formatSecToTimeString(state.eta)}` : ""}`
|
||||
)}</div>
|
||||
</div>
|
||||
<div className="w-full flex items-center gap-2 mt-2">
|
||||
{state.download_status === 'paused' ? (
|
||||
<Button
|
||||
size="sm"
|
||||
className="w-fill"
|
||||
onClick={async () => {
|
||||
setIsResumingDownload(state.download_id, true);
|
||||
try {
|
||||
await resumeDownload(state)
|
||||
// toast.success("Resumed Download", {
|
||||
// description: "Download resumed, it will re-start shortly.",
|
||||
// })
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
toast.error("Failed to Resume Download", {
|
||||
description: "An error occurred while trying to resume the download.",
|
||||
})
|
||||
} finally {
|
||||
setIsResumingDownload(state.download_id, false);
|
||||
}
|
||||
}}
|
||||
disabled={itemActionStates.isResuming || itemActionStates.isCanceling}
|
||||
>
|
||||
{itemActionStates.isResuming ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
Resuming
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Play className="w-4 h-4" />
|
||||
Resume
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
size="sm"
|
||||
className="w-fill"
|
||||
onClick={async () => {
|
||||
setIsPausingDownload(state.download_id, true);
|
||||
try {
|
||||
await pauseDownload(state)
|
||||
// toast.success("Paused Download", {
|
||||
// description: "Download paused successfully.",
|
||||
// })
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
toast.error("Failed to Pause Download", {
|
||||
description: "An error occurred while trying to pause the download."
|
||||
})
|
||||
} finally {
|
||||
setIsPausingDownload(state.download_id, false);
|
||||
}
|
||||
}}
|
||||
disabled={itemActionStates.isPausing || itemActionStates.isCanceling || state.download_status !== 'downloading' || (state.download_status === 'downloading' && state.status === 'finished')}
|
||||
>
|
||||
{itemActionStates.isPausing ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
Pausing
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Pause className="w-4 h-4" />
|
||||
Pause
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
size="sm"
|
||||
variant="destructive"
|
||||
onClick={async () => {
|
||||
setIsCancelingDownload(state.download_id, true);
|
||||
try {
|
||||
await cancelDownload(state)
|
||||
toast.success("Canceled Download", {
|
||||
description: "Download canceled successfully.",
|
||||
})
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
toast.error("Failed to Cancel Download", {
|
||||
description: "An error occurred while trying to cancel the download.",
|
||||
})
|
||||
} finally {
|
||||
setIsCancelingDownload(state.download_id, false);
|
||||
}
|
||||
}}
|
||||
disabled={itemActionStates.isCanceling || itemActionStates.isResuming || itemActionStates.isPausing || state.download_status === 'starting' || (state.download_status === 'downloading' && state.status === 'finished')}
|
||||
>
|
||||
{itemActionStates.isCanceling ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
Canceling
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<X className="w-4 h-4" />
|
||||
Cancel
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
) : (
|
||||
<div className="w-full flex flex-col items-center gap-2 justify-center mt-27">
|
||||
<h4 className="text-4xl font-bold text-muted-foreground/80 dark:text-muted">Nothing!</h4>
|
||||
<p className="text-lg font-semibold text-muted-foreground/50">No Incomplete Downloads</p>
|
||||
<p className="max-w-[50%] text-center text-xs text-muted-foreground/70">You have all caught up! Sit back and relax or just spin up a new download to see here :)</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -6,8 +6,8 @@ import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrig
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { ExternalLink, FolderOpen, Loader2, LucideIcon, Monitor, Moon, Radio, RotateCcw, RotateCw, Sun, Terminal } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { ArrowDownToLine, ArrowRight, BrushCleaning, EthernetPort, ExternalLink, FileVideo, Folder, FolderOpen, Info, Loader2, LucideIcon, Monitor, Moon, Radio, RotateCcw, RotateCw, Sun, Terminal, WandSparkles, Wifi, Wrench } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useEffect } from "react";
|
||||
import { useTheme } from "@/providers/themeProvider";
|
||||
@@ -22,11 +22,19 @@ import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { Form, FormControl, FormField, FormItem, FormMessage } from "@/components/ui/form";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@/components/ui/alert-dialog";
|
||||
import { SlidingButton } from "@/components/custom/slidingButton";
|
||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
||||
import * as fs from "@tauri-apps/plugin-fs";
|
||||
import { join } from "@tauri-apps/api/path";
|
||||
import { formatSpeed } from "@/utils";
|
||||
|
||||
const websocketPortSchema = z.object({
|
||||
port: z.coerce.number({
|
||||
required_error: "Websocket Port is required",
|
||||
invalid_type_error: "Websocket Port must be a valid number",
|
||||
port: z.coerce.number<number>({
|
||||
error: (issue) => issue.input === undefined || issue.input === null || issue.input === ""
|
||||
? "Websocket Port is required"
|
||||
: "Websocket Port must be a valid number"
|
||||
}).int({
|
||||
message: "Websocket Port must be an integer"
|
||||
}).min(50000, {
|
||||
message: "Websocket Port must be at least 50000"
|
||||
}).max(60000, {
|
||||
@@ -35,15 +43,36 @@ const websocketPortSchema = z.object({
|
||||
})
|
||||
|
||||
const proxyUrlSchema = z.object({
|
||||
url: z.string().min(1, { message: "Proxy URL is required" }).url({ message: "Invalid URL format" })
|
||||
url: z.url({
|
||||
error: (issue) => issue.input === undefined || issue.input === null || issue.input === ""
|
||||
? "Proxy URL is required"
|
||||
: "Invalid URL format"
|
||||
})
|
||||
});
|
||||
|
||||
const rateLimitSchema = z.object({
|
||||
rate_limit: z.coerce.number<number>({
|
||||
error: (issue) => issue.input === undefined || issue.input === null || issue.input === ""
|
||||
? "Rate Limit is required"
|
||||
: "Rate Limit must be a valid number"
|
||||
}).int({
|
||||
message: "Rate Limit must be an integer"
|
||||
}).min(1024, {
|
||||
message: "Rate Limit must be at least 1024 bytes/s (1 KB/s)"
|
||||
}).max(104857600, {
|
||||
message: "Rate Limit must be at most 104857600 bytes/s (100 MB/s)"
|
||||
}),
|
||||
});
|
||||
|
||||
export default function SettingsPage() {
|
||||
const { toast } = useToast();
|
||||
const { setTheme } = useTheme();
|
||||
|
||||
const activeTab = useSettingsPageStatesStore(state => state.activeTab);
|
||||
const activeSubAppTab = useSettingsPageStatesStore(state => state.activeSubAppTab);
|
||||
const activeSubExtTab = useSettingsPageStatesStore(state => state.activeSubExtTab);
|
||||
const setActiveTab = useSettingsPageStatesStore(state => state.setActiveTab);
|
||||
const setActiveSubAppTab = useSettingsPageStatesStore(state => state.setActiveSubAppTab);
|
||||
const setActiveSubExtTab = useSettingsPageStatesStore(state => state.setActiveSubExtTab);
|
||||
|
||||
const isUsingDefaultSettings = useSettingsPageStatesStore(state => state.isUsingDefaultSettings);
|
||||
const ytDlpVersion = useSettingsPageStatesStore(state => state.ytDlpVersion);
|
||||
@@ -53,9 +82,19 @@ export default function SettingsPage() {
|
||||
const ytDlpAutoUpdate = useSettingsPageStatesStore(state => state.settings.ytdlp_auto_update);
|
||||
const appTheme = useSettingsPageStatesStore(state => state.settings.theme);
|
||||
const maxParallelDownloads = useSettingsPageStatesStore(state => state.settings.max_parallel_downloads);
|
||||
const maxRetries = useSettingsPageStatesStore(state => state.settings.max_retries);
|
||||
const preferVideoOverPlaylist = useSettingsPageStatesStore(state => state.settings.prefer_video_over_playlist);
|
||||
const strictDownloadabilityCheck = useSettingsPageStatesStore(state => state.settings.strict_downloadablity_check);
|
||||
const useProxy = useSettingsPageStatesStore(state => state.settings.use_proxy);
|
||||
const proxyUrl = useSettingsPageStatesStore(state => state.settings.proxy_url);
|
||||
const useRateLimit = useSettingsPageStatesStore(state => state.settings.use_rate_limit);
|
||||
const rateLimit = useSettingsPageStatesStore(state => state.settings.rate_limit);
|
||||
const videoFormat = useSettingsPageStatesStore(state => state.settings.video_format);
|
||||
const audioFormat = useSettingsPageStatesStore(state => state.settings.audio_format);
|
||||
const alwaysReencodeVideo = useSettingsPageStatesStore(state => state.settings.always_reencode_video);
|
||||
const embedVideoMetadata = useSettingsPageStatesStore(state => state.settings.embed_video_metadata);
|
||||
const embedAudioMetadata = useSettingsPageStatesStore(state => state.settings.embed_audio_metadata);
|
||||
const embedAudioThumbnail = useSettingsPageStatesStore(state => state.settings.embed_audio_thumbnail);
|
||||
const websocketPort = useSettingsPageStatesStore(state => state.settings.websocket_port);
|
||||
const isChangingWebSocketPort = useSettingsPageStatesStore(state => state.isChangingWebSocketPort);
|
||||
const setIsChangingWebSocketPort = useSettingsPageStatesStore(state => state.setIsChangingWebSocketPort);
|
||||
@@ -68,6 +107,7 @@ export default function SettingsPage() {
|
||||
);
|
||||
|
||||
const downloadDirPath = useBasePathsStore((state) => state.downloadDirPath);
|
||||
const tempDownloadDirPath = useBasePathsStore((state) => state.tempDownloadDirPath);
|
||||
const setPath = useBasePathsStore((state) => state.setPath);
|
||||
const { saveSettingsKey, resetSettings } = useSettings();
|
||||
const { updateYtDlp } = useYtDlpUpdater();
|
||||
@@ -79,6 +119,46 @@ export default function SettingsPage() {
|
||||
{ value: 'system', icon: Monitor, label: 'System' },
|
||||
];
|
||||
|
||||
const openLink = async (url: string, app: string | null) => {
|
||||
try {
|
||||
await invoke('open_file_with_app', { filePath: url, appName: app }).then(() => {
|
||||
toast.info("Opening link", {
|
||||
description: `Opening link with ${app ? app : 'default app'}.`,
|
||||
})
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
toast.error("Failed to open link", {
|
||||
description: "An error occurred while trying to open the link.",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const cleanTemporaryDownloads = async () => {
|
||||
const tempFiles = await fs.readDir(tempDownloadDirPath ?? '');
|
||||
if (tempFiles.length > 0) {
|
||||
try {
|
||||
for (const file of tempFiles) {
|
||||
if (file.isFile) {
|
||||
const filePath = await join(tempDownloadDirPath ?? '', file.name);
|
||||
await fs.remove(filePath);
|
||||
}
|
||||
}
|
||||
toast.success("Temporary Downloads Cleaned", {
|
||||
description: "All temporary downloads have been successfully cleaned up.",
|
||||
});
|
||||
} catch (e) {
|
||||
toast.error("Temporary Downloads Cleanup Failed", {
|
||||
description: "An error occurred while trying to clean up temporary downloads. Please try again.",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
toast.info("No Temporary Downloads", {
|
||||
description: "There are no temporary downloads to clean up.",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const proxyUrlForm = useForm<z.infer<typeof proxyUrlSchema>>({
|
||||
resolver: zodResolver(proxyUrlSchema),
|
||||
defaultValues: {
|
||||
@@ -92,16 +172,37 @@ export default function SettingsPage() {
|
||||
function handleProxyUrlSubmit(values: z.infer<typeof proxyUrlSchema>) {
|
||||
try {
|
||||
saveSettingsKey('proxy_url', values.url);
|
||||
toast({
|
||||
title: "Proxy URL updated",
|
||||
toast.success("Proxy URL updated", {
|
||||
description: `Proxy URL changed to ${values.url}`,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error changing proxy URL:", error);
|
||||
toast({
|
||||
title: "Failed to change proxy URL",
|
||||
description: "Please try again.",
|
||||
variant: "destructive",
|
||||
toast.error("Failed to change proxy URL", {
|
||||
description: "An error occurred while trying to change the proxy URL. Please try again.",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const rateLimitForm = useForm<z.infer<typeof rateLimitSchema>>({
|
||||
resolver: zodResolver(rateLimitSchema),
|
||||
defaultValues: {
|
||||
rate_limit: rateLimit,
|
||||
},
|
||||
mode: "onChange",
|
||||
});
|
||||
const watchedRateLimit = rateLimitForm.watch("rate_limit");
|
||||
const { errors: rateLimitFormErrors } = rateLimitForm.formState;
|
||||
|
||||
function handleRateLimitSubmit(values: z.infer<typeof rateLimitSchema>) {
|
||||
try {
|
||||
saveSettingsKey('rate_limit', values.rate_limit);
|
||||
toast.success("Rate Limit updated", {
|
||||
description: `Rate Limit changed to ${values.rate_limit} bytes/s`,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error changing rate limit:", error);
|
||||
toast.error("Failed to change rate limit", {
|
||||
description: "An error occurred while trying to change the rate limit. Please try again.",
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -130,16 +231,13 @@ export default function SettingsPage() {
|
||||
}
|
||||
});
|
||||
saveSettingsKey('websocket_port', updatedConfig.port);
|
||||
toast({
|
||||
title: "Websocket port updated",
|
||||
toast.success("Websocket port updated", {
|
||||
description: `Websocket port changed to ${values.port}`,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error changing websocket port:", error);
|
||||
toast({
|
||||
title: "Failed to change websocket port",
|
||||
description: "Please try again.",
|
||||
variant: "destructive",
|
||||
toast.error("Failed to change websocket port", {
|
||||
description: "An error occurred while trying to change the websocket port. Please try again.",
|
||||
});
|
||||
} finally {
|
||||
setIsChangingWebSocketPort(false);
|
||||
@@ -157,11 +255,40 @@ export default function SettingsPage() {
|
||||
<div className="container mx-auto p-4 space-y-4 min-h-screen">
|
||||
<Heading title="Settings" description="Manage your preferences and app settings" />
|
||||
<Tabs value={activeTab} onValueChange={setActiveTab}>
|
||||
<TabsList>
|
||||
<TabsTrigger value="general">General</TabsTrigger>
|
||||
<TabsTrigger value="extension">Extension</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent value="general">
|
||||
<div className="w-full flex items-center justify-between">
|
||||
<TabsList>
|
||||
<TabsTrigger value="app">Application</TabsTrigger>
|
||||
<TabsTrigger value="extension">Extension</TabsTrigger>
|
||||
</TabsList>
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button
|
||||
className="w-fit"
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
disabled={isUsingDefaultSettings}
|
||||
>
|
||||
<RotateCcw className="h-4 w-4" />
|
||||
Reset
|
||||
</Button>
|
||||
</AlertDialogTrigger>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Reset settings to default?</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
Are you sure you want to reset all settings to their default values? This action cannot be undone!
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction onClick={
|
||||
() => resetSettings()
|
||||
}>Reset</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
<TabsContent value="app">
|
||||
<Card className="p-4 space-y-4 my-4">
|
||||
<div className="w-full flex gap-4 items-center justify-between">
|
||||
<div className="flex gap-4 items-center">
|
||||
@@ -220,124 +347,354 @@ export default function SettingsPage() {
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<div className="flex flex-col w-[50%] gap-4">
|
||||
<div className="app-theme">
|
||||
<h3 className="font-semibold">Theme</h3>
|
||||
<p className="text-sm text-muted-foreground mb-3">Choose app interface theme</p>
|
||||
<div className={cn('inline-flex gap-1 rounded-lg p-1 bg-muted')}>
|
||||
{themeOptions.map(({ value, icon: Icon, label }) => (
|
||||
<button
|
||||
key={value}
|
||||
onClick={() => saveSettingsKey('theme', value)}
|
||||
className={cn(
|
||||
'flex items-center rounded-md px-3.5 py-1.5 transition-colors',
|
||||
appTheme === value
|
||||
? 'bg-white shadow-xs dark:bg-neutral-700 dark:text-neutral-100'
|
||||
: 'text-neutral-500 hover:bg-neutral-200/60 hover:text-black dark:text-neutral-400 dark:hover:bg-neutral-700/60',
|
||||
)}
|
||||
>
|
||||
<Icon className="-ml-1 h-4 w-4" />
|
||||
<span className="ml-1.5 text-sm">{label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="download-dir">
|
||||
<h3 className="font-semibold">Download Directory</h3>
|
||||
<p className="text-sm text-muted-foreground mb-3">Set default download directory</p>
|
||||
<div className="flex items-center gap-4">
|
||||
<Input className="focus-visible:ring-0" type="text" placeholder="Select download directory" value={downloadDirPath ?? 'Unknown'} readOnly/>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={async () => {
|
||||
try {
|
||||
const folder = await open({
|
||||
multiple: false,
|
||||
directory: true,
|
||||
});
|
||||
if (folder) {
|
||||
saveSettingsKey('download_dir', folder);
|
||||
setPath('downloadDirPath', folder);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error selecting folder:", error);
|
||||
toast({
|
||||
title: "Failed to select folder",
|
||||
description: "Please try again.",
|
||||
variant: "destructive",
|
||||
});
|
||||
}
|
||||
}}
|
||||
>
|
||||
<FolderOpen className="w-4 h-4" /> Browse
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="max-parallel-downloads">
|
||||
<h3 className="font-semibold">Max Parallel Downloads</h3>
|
||||
<p className="text-sm text-muted-foreground mb-3">Set maximum number of allowed parallel downloads</p>
|
||||
<Slider
|
||||
id="max-parallel-downloads"
|
||||
className="w-[350px] mb-2"
|
||||
value={[maxParallelDownloads]}
|
||||
min={1}
|
||||
max={5}
|
||||
onValueChange={(value) => saveSettingsKey('max_parallel_downloads', value[0])}
|
||||
/>
|
||||
<Label htmlFor="max-parallel-downloads" className="text-xs text-muted-foreground">(Current: {maxParallelDownloads}) (Default: 2, Maximum: 5)</Label>
|
||||
</div>
|
||||
<div className="prefer-video-over-playlist">
|
||||
<h3 className="font-semibold">Prefer Video Over Playlist</h3>
|
||||
<p className="text-sm text-muted-foreground mb-3">Prefer only the video, if the URL refers to a video and a playlist</p>
|
||||
<Switch
|
||||
id="prefer-video-over-playlist"
|
||||
checked={preferVideoOverPlaylist}
|
||||
onCheckedChange={(checked) => saveSettingsKey('prefer_video_over_playlist', checked)}
|
||||
/>
|
||||
</div>
|
||||
<div className="proxy">
|
||||
<h3 className="font-semibold">Proxy</h3>
|
||||
<p className="text-sm text-muted-foreground mb-3">Use proxy for downloads, Unblocks blocked sites in your region (Download speed may affect, Some sites may not work)</p>
|
||||
<div className="flex items-center space-x-2 mb-4">
|
||||
<Switch
|
||||
id="use-proxy"
|
||||
checked={useProxy}
|
||||
onCheckedChange={(checked) => saveSettingsKey('use_proxy', checked)}
|
||||
/>
|
||||
<Label htmlFor="use-proxy">Use Proxy</Label>
|
||||
</div>
|
||||
<div className="flex items-center gap-4">
|
||||
<Form {...proxyUrlForm}>
|
||||
<form onSubmit={proxyUrlForm.handleSubmit(handleProxyUrlSubmit)} className="flex gap-4 w-full" autoComplete="off">
|
||||
<FormField
|
||||
control={proxyUrlForm.control}
|
||||
name="url"
|
||||
disabled={!useProxy}
|
||||
render={({ field }) => (
|
||||
<FormItem className="w-full">
|
||||
<FormControl>
|
||||
<Input
|
||||
className="focus-visible:ring-0"
|
||||
placeholder="Enter proxy URL"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<Label htmlFor="url" className="text-xs text-muted-foreground">(Configured: {proxyUrl ? 'Yes' : 'No'}, Status: {useProxy ? 'Enabled' : 'Disabled'})</Label>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<Tabs
|
||||
className="w-full flex flex-row items-start gap-4 mt-7"
|
||||
orientation="vertical"
|
||||
value={activeSubAppTab}
|
||||
onValueChange={setActiveSubAppTab}
|
||||
>
|
||||
<TabsList className="shrink-0 grid grid-cols-1 gap-1 p-0 bg-background min-w-45">
|
||||
<TabsTrigger
|
||||
key="general"
|
||||
value="general"
|
||||
className="data-[state=active]:bg-primary data-[state=active]:text-primary-foreground justify-start px-3 py-1.5 gap-2"
|
||||
><Wrench className="size-4" /> General</TabsTrigger>
|
||||
<TabsTrigger
|
||||
key="appearance"
|
||||
value="appearance"
|
||||
className="data-[state=active]:bg-primary data-[state=active]:text-primary-foreground justify-start px-3 py-1.5 gap-2"
|
||||
><WandSparkles className="size-4" /> Appearance</TabsTrigger>
|
||||
<TabsTrigger
|
||||
key="folders"
|
||||
value="folders"
|
||||
className="data-[state=active]:bg-primary data-[state=active]:text-primary-foreground justify-start px-3 py-1.5 gap-2"
|
||||
><Folder className="size-4" /> Folders</TabsTrigger>
|
||||
<TabsTrigger
|
||||
key="formats"
|
||||
value="formats"
|
||||
className="data-[state=active]:bg-primary data-[state=active]:text-primary-foreground justify-start px-3 py-1.5 gap-2"
|
||||
><FileVideo className="size-4" /> Formats</TabsTrigger>
|
||||
<TabsTrigger
|
||||
key="metadata"
|
||||
value="metadata"
|
||||
className="data-[state=active]:bg-primary data-[state=active]:text-primary-foreground justify-start px-3 py-1.5 gap-2"
|
||||
><Info className="size-4" /> Metadata</TabsTrigger>
|
||||
<TabsTrigger
|
||||
key="network"
|
||||
value="network"
|
||||
className="data-[state=active]:bg-primary data-[state=active]:text-primary-foreground justify-start px-3 py-1.5 gap-2"
|
||||
><Wifi className="size-4" /> Network</TabsTrigger>
|
||||
</TabsList>
|
||||
<div className="min-h-full flex flex-col max-w-[55%] w-full border-l border-border pl-4">
|
||||
<TabsContent key="general" value="general" className="flex flex-col gap-4 min-h-[235px]">
|
||||
<div className="max-parallel-downloads">
|
||||
<h3 className="font-semibold">Max Parallel Downloads</h3>
|
||||
<p className="text-xs text-muted-foreground mb-3">Set maximum number of allowed parallel downloads</p>
|
||||
<Slider
|
||||
id="max-parallel-downloads"
|
||||
className="w-[350px] mb-2"
|
||||
value={[maxParallelDownloads]}
|
||||
min={1}
|
||||
max={5}
|
||||
onValueChange={(value) => saveSettingsKey('max_parallel_downloads', value[0])}
|
||||
/>
|
||||
<Label htmlFor="max-parallel-downloads" className="text-xs text-muted-foreground">(Current: {maxParallelDownloads}) (Default: 2, Maximum: 5)</Label>
|
||||
</div>
|
||||
<div className="prefer-video-over-playlist">
|
||||
<h3 className="font-semibold">Prefer Video Over Playlist</h3>
|
||||
<p className="text-xs text-muted-foreground mb-3">Prefer only the video, if the URL refers to a video and a playlist</p>
|
||||
<Switch
|
||||
id="prefer-video-over-playlist"
|
||||
checked={preferVideoOverPlaylist}
|
||||
onCheckedChange={(checked) => saveSettingsKey('prefer_video_over_playlist', checked)}
|
||||
/>
|
||||
</div>
|
||||
<div className="strict-downloadability-check">
|
||||
<h3 className="font-semibold">Strict Downloadablity Check</h3>
|
||||
<p className="text-xs text-muted-foreground mb-3">Only show streams that are actualy downloadable, also check formats before downloading (high quality results, takes longer time to search)</p>
|
||||
<Switch
|
||||
id="strict-downloadablity-check"
|
||||
checked={strictDownloadabilityCheck}
|
||||
onCheckedChange={(checked) => saveSettingsKey('strict_downloadablity_check', checked)}
|
||||
/>
|
||||
</div>
|
||||
<div className="max-retries">
|
||||
<h3 className="font-semibold">Max Retries</h3>
|
||||
<p className="text-xs text-muted-foreground mb-3">Set maximum number of retries for a download before giving up</p>
|
||||
<Slider
|
||||
id="max-retries"
|
||||
className="w-[350px] mb-2"
|
||||
value={[maxRetries]}
|
||||
min={1}
|
||||
max={100}
|
||||
onValueChange={(value) => saveSettingsKey('max_retries', value[0])}
|
||||
/>
|
||||
<Label htmlFor="max-retries" className="text-xs text-muted-foreground">(Current: {maxRetries}) (Default: 5, Maximum: 100)</Label>
|
||||
</div>
|
||||
</TabsContent>
|
||||
<TabsContent key="appearance" value="appearance" className="flex flex-col gap-4 min-h-[235px]">
|
||||
<div className="app-theme">
|
||||
<h3 className="font-semibold">Theme</h3>
|
||||
<p className="text-xs text-muted-foreground mb-3">Choose app interface theme</p>
|
||||
<div className={cn('inline-flex gap-1 rounded-lg p-1 bg-muted')}>
|
||||
{themeOptions.map(({ value, icon: Icon, label }) => (
|
||||
<button
|
||||
key={value}
|
||||
onClick={() => saveSettingsKey('theme', value)}
|
||||
className={cn(
|
||||
'flex items-center rounded-md px-3.5 py-1.5 transition-colors',
|
||||
appTheme === value
|
||||
? 'bg-white shadow-xs dark:bg-neutral-700 dark:text-neutral-100'
|
||||
: 'text-neutral-500 hover:bg-neutral-200/60 hover:text-black dark:text-neutral-400 dark:hover:bg-neutral-700/60',
|
||||
)}
|
||||
>
|
||||
<Icon className="-ml-1 h-4 w-4" />
|
||||
<span className="ml-1.5 text-sm">{label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</TabsContent>
|
||||
<TabsContent key="folders" value="folders" className="flex flex-col gap-4 min-h-[235px]">
|
||||
<div className="download-dir">
|
||||
<h3 className="font-semibold">Download Folder</h3>
|
||||
<p className="text-xs text-muted-foreground mb-3">Set default download folder (directory)</p>
|
||||
<div className="flex items-center gap-4">
|
||||
<Input className="focus-visible:ring-0" type="text" placeholder="Select download directory" value={downloadDirPath ?? 'Unknown'} readOnly/>
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={!watchedProxyUrl || watchedProxyUrl === proxyUrl || Object.keys(proxyUrlFormErrors).length > 0 || !useProxy}
|
||||
variant="outline"
|
||||
onClick={async () => {
|
||||
try {
|
||||
const folder = await open({
|
||||
multiple: false,
|
||||
directory: true,
|
||||
});
|
||||
if (folder) {
|
||||
saveSettingsKey('download_dir', folder);
|
||||
setPath('downloadDirPath', folder);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error selecting folder:", error);
|
||||
toast.error("Failed to select folder", {
|
||||
description: "An error occurred while trying to select the download folder. Please try again.",
|
||||
});
|
||||
}
|
||||
}}
|
||||
>
|
||||
Save
|
||||
<FolderOpen className="w-4 h-4" /> Browse
|
||||
</Button>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="temporary-download-dir">
|
||||
<h3 className="font-semibold">Temporary Download Folder</h3>
|
||||
<p className="text-xs text-muted-foreground mb-3">Clean up temporary downloads (broken, cancelled, paused downloads)</p>
|
||||
<div className="flex items-center gap-4">
|
||||
<Input className="focus-visible:ring-0" type="text" placeholder="Temporary download directory" value={tempDownloadDirPath ?? 'Unknown'} readOnly/>
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button
|
||||
variant="destructive"
|
||||
disabled={ongoingDownloads.length > 0}
|
||||
>
|
||||
<BrushCleaning className="size-4" /> Clean
|
||||
</Button>
|
||||
</AlertDialogTrigger>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Clean up all temporary downloads?</AlertDialogTitle>
|
||||
<AlertDialogDescription>Are you sure you want to clean up all temporary downloads? This will remove all broken, cancelled and paused downloads from the temporary folder. Paused downloads will re-start from the begining. This action cannot be undone!</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={() => cleanTemporaryDownloads()}
|
||||
>Clean</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
</div>
|
||||
</TabsContent>
|
||||
<TabsContent key="formats" value="formats" className="flex flex-col gap-4 min-h-[235px]">
|
||||
<div className="video-format">
|
||||
<h3 className="font-semibold">Video Format</h3>
|
||||
<p className="text-xs text-muted-foreground mb-3">Choose in which format the final video file will be saved</p>
|
||||
<RadioGroup
|
||||
orientation="horizontal"
|
||||
className="flex items-center gap-4"
|
||||
value={videoFormat}
|
||||
onValueChange={(value) => saveSettingsKey('video_format', value)}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<RadioGroupItem value="auto" id="v-auto" />
|
||||
<Label htmlFor="v-auto">Auto (Default)</Label>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<RadioGroupItem value="mp4" id="v-mp4" />
|
||||
<Label htmlFor="v-mp4">MP4</Label>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<RadioGroupItem value="webm" id="v-webm" />
|
||||
<Label htmlFor="v-webm">WEBM</Label>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<RadioGroupItem value="mkv" id="v-mkv" />
|
||||
<Label htmlFor="v-mkv">MKV</Label>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
<div className="audio-format">
|
||||
<h3 className="font-semibold">Audio Format</h3>
|
||||
<p className="text-xs text-muted-foreground mb-3">Choose in which format the final audio file will be saved</p>
|
||||
<RadioGroup
|
||||
orientation="horizontal"
|
||||
className="flex items-center gap-4"
|
||||
value={audioFormat}
|
||||
onValueChange={(value) => saveSettingsKey('audio_format', value)}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<RadioGroupItem value="auto" id="a-auto" />
|
||||
<Label htmlFor="a-auto">Auto (Default)</Label>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<RadioGroupItem value="m4a" id="a-m4a" />
|
||||
<Label htmlFor="a-m4a">M4A</Label>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<RadioGroupItem value="opus" id="a-opus" />
|
||||
<Label htmlFor="a-opus">OPUS</Label>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<RadioGroupItem value="mp3" id="a-mp3" />
|
||||
<Label htmlFor="a-mp3">MP3</Label>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
<div className="always-reencode-video">
|
||||
<h3 className="font-semibold">Always Re-Encode Video</h3>
|
||||
<p className="text-xs text-muted-foreground mb-3">Instead of remuxing (simple container change) always re-encode the video to the target format with best compatible codecs (better compatibility, takes longer processing time)</p>
|
||||
<Switch
|
||||
id="always-reencode-video"
|
||||
checked={alwaysReencodeVideo}
|
||||
onCheckedChange={(checked) => saveSettingsKey('always_reencode_video', checked)}
|
||||
/>
|
||||
</div>
|
||||
</TabsContent>
|
||||
<TabsContent key="metadata" value="metadata" className="flex flex-col gap-4 min-h-[235px]">
|
||||
<div className="embed-video-metadata">
|
||||
<h3 className="font-semibold">Embed Metadata</h3>
|
||||
<p className="text-xs text-muted-foreground mb-3">Wheather to embed metadata in video/audio files (info, chapters)</p>
|
||||
<div className="flex items-center space-x-2 mb-3">
|
||||
<Switch
|
||||
id="embed-video-metadata"
|
||||
checked={embedVideoMetadata}
|
||||
onCheckedChange={(checked) => saveSettingsKey('embed_video_metadata', checked)}
|
||||
/>
|
||||
<Label htmlFor="embed-video-metadata">Video</Label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<Switch
|
||||
id="embed-audio-metadata"
|
||||
checked={embedAudioMetadata}
|
||||
onCheckedChange={(checked) => saveSettingsKey('embed_audio_metadata', checked)}
|
||||
/>
|
||||
<Label htmlFor="embed-audio-metadata">Audio</Label>
|
||||
</div>
|
||||
</div>
|
||||
<div className="embed-audio-thumbnail">
|
||||
<h3 className="font-semibold">Embed Thumbnail in Audio</h3>
|
||||
<p className="text-xs text-muted-foreground mb-3">Wheather to embed thumbnail in audio files (as cover art)</p>
|
||||
<Switch
|
||||
id="embed-audio-thumbnail"
|
||||
checked={embedAudioThumbnail}
|
||||
onCheckedChange={(checked) => saveSettingsKey('embed_audio_thumbnail', checked)}
|
||||
/>
|
||||
</div>
|
||||
</TabsContent>
|
||||
<TabsContent key="network" value="network" className="flex flex-col gap-4 min-h-[235px]">
|
||||
<div className="proxy">
|
||||
<h3 className="font-semibold">Proxy</h3>
|
||||
<p className="text-xs text-muted-foreground mb-3">Use proxy for downloads, Unblocks blocked sites in your region (download speed may affect, some sites may not work)</p>
|
||||
<div className="flex items-center space-x-2 mb-4">
|
||||
<Switch
|
||||
id="use-proxy"
|
||||
checked={useProxy}
|
||||
onCheckedChange={(checked) => saveSettingsKey('use_proxy', checked)}
|
||||
/>
|
||||
<Label htmlFor="use-proxy">Use Proxy</Label>
|
||||
</div>
|
||||
<Form {...proxyUrlForm}>
|
||||
<form onSubmit={proxyUrlForm.handleSubmit(handleProxyUrlSubmit)} className="flex gap-4 w-full" autoComplete="off">
|
||||
<FormField
|
||||
control={proxyUrlForm.control}
|
||||
name="url"
|
||||
disabled={!useProxy}
|
||||
render={({ field }) => (
|
||||
<FormItem className="w-full">
|
||||
<FormControl>
|
||||
<Input
|
||||
className="focus-visible:ring-0"
|
||||
placeholder="Enter proxy URL"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<Label htmlFor="url" className="text-xs text-muted-foreground">(Configured: {proxyUrl ? 'Yes' : 'No'}, Status: {useProxy ? 'Enabled' : 'Disabled'})</Label>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={!watchedProxyUrl || watchedProxyUrl === proxyUrl || Object.keys(proxyUrlFormErrors).length > 0 || !useProxy}
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
<div className="rate-limit">
|
||||
<h3 className="font-semibold">Rate Limit</h3>
|
||||
<p className="text-xs text-muted-foreground mb-3">Limit download speed to prevent network congestion. Rate limit is applied per-download basis (not in the whole app)</p>
|
||||
<div className="flex items-center space-x-2 mb-4">
|
||||
<Switch
|
||||
id="use-rate-limit"
|
||||
checked={useRateLimit}
|
||||
onCheckedChange={(checked) => saveSettingsKey('use_rate_limit', checked)}
|
||||
/>
|
||||
<Label htmlFor="use-rate-limit">Use Rate Limit</Label>
|
||||
</div>
|
||||
<Form {...rateLimitForm}>
|
||||
<form onSubmit={rateLimitForm.handleSubmit(handleRateLimitSubmit)} className="flex gap-4 w-full" autoComplete="off">
|
||||
<FormField
|
||||
control={rateLimitForm.control}
|
||||
name="rate_limit"
|
||||
disabled={!useRateLimit}
|
||||
render={({ field }) => (
|
||||
<FormItem className="w-full">
|
||||
<FormControl>
|
||||
<Input
|
||||
className="focus-visible:ring-0"
|
||||
placeholder="Enter rate limit in bytes/s"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<Label htmlFor="rate_limit" className="text-xs text-muted-foreground">(Configured: {rateLimit ? `${rateLimit} = ${formatSpeed(rateLimit)}` : 'No'}, Status: {useRateLimit ? 'Enabled' : 'Disabled'}) (Default: 1048576, Range: 1024-104857600)</Label>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={!watchedRateLimit || Number(watchedRateLimit) === rateLimit || Object.keys(rateLimitFormErrors).length > 0 || !useRateLimit}
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
</TabsContent>
|
||||
</div>
|
||||
</div>
|
||||
</Tabs>
|
||||
</TabsContent>
|
||||
<TabsContent value="extension">
|
||||
<Card className="p-4 space-y-4 my-4">
|
||||
@@ -348,7 +705,13 @@ export default function SettingsPage() {
|
||||
</div>
|
||||
<div className="flex flex-col">
|
||||
<h3 className="">Extension Websocket Server</h3>
|
||||
<p className="text-xs text-muted-foreground">{isChangingWebSocketPort || isRestartingWebSocketServer ? 'Restarting...' : 'Running' }</p>
|
||||
<div className="text-xs flex items-center">
|
||||
{isChangingWebSocketPort || isRestartingWebSocketServer ? (
|
||||
<><div className="h-1.5 w-1.5 rounded-full bg-amber-600 dark:bg-amber-500 mr-1.5 mt-0.5" /><span className="text-amber-600 dark:text-amber-500">Restarting...</span></>
|
||||
) : (
|
||||
<><div className="h-1.5 w-1.5 rounded-full bg-emerald-600 dark:bg-emerald-500 mr-1.5 mt-0.5" /><span className="text-emerald-600 dark:text-emerald-500">Running</span></>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-4 items-center">
|
||||
@@ -357,16 +720,13 @@ export default function SettingsPage() {
|
||||
setIsRestartingWebSocketServer(true);
|
||||
try {
|
||||
await invoke("restart_websocket_server");
|
||||
toast({
|
||||
title: "Websocket server restarted",
|
||||
toast.success("Websocket server restarted", {
|
||||
description: "Websocket server restarted successfully.",
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error restarting websocket server:", error);
|
||||
toast({
|
||||
title: "Failed to restart websocket server",
|
||||
description: "Please try again.",
|
||||
variant: "destructive",
|
||||
toast.error("Failed to restart websocket server", {
|
||||
description: "An error occurred while trying to restart the websocket server. Please try again.",
|
||||
});
|
||||
} finally {
|
||||
setIsRestartingWebSocketServer(false);
|
||||
@@ -389,81 +749,122 @@ export default function SettingsPage() {
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<div className="flex flex-col w-[50%] gap-4">
|
||||
<div className="websocket-port">
|
||||
<h3 className="font-semibold">Websocket Port</h3>
|
||||
<p className="text-sm text-muted-foreground mb-3">Change extension websocket server port</p>
|
||||
<div className="flex items-center gap-4">
|
||||
<Form {...websocketPortForm}>
|
||||
<form onSubmit={websocketPortForm.handleSubmit(handleWebsocketPortSubmit)} className="flex gap-4 w-full" autoComplete="off">
|
||||
<FormField
|
||||
control={websocketPortForm.control}
|
||||
name="port"
|
||||
disabled={isChangingWebSocketPort}
|
||||
render={({ field }) => (
|
||||
<FormItem className="w-full">
|
||||
<FormControl>
|
||||
<Input
|
||||
className="focus-visible:ring-0"
|
||||
placeholder="Enter port number"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<Label htmlFor="port" className="text-xs text-muted-foreground">(Current: {websocketPort}) (Default: 53511, Range: 50000-60000)</Label>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={!watchedPort || Number(watchedPort) === websocketPort || Object.keys(websocketPortFormErrors).length > 0 || isChangingWebSocketPort || isRestartingWebSocketServer}
|
||||
>
|
||||
{isChangingWebSocketPort ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
Changing
|
||||
</>
|
||||
) : (
|
||||
'Change'
|
||||
)}
|
||||
</Button>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
<Tabs
|
||||
className="w-full flex flex-row items-start gap-4 mt-7"
|
||||
orientation="vertical"
|
||||
value={activeSubExtTab}
|
||||
onValueChange={setActiveSubExtTab}
|
||||
>
|
||||
<TabsList className="shrink-0 grid grid-cols-1 gap-1 p-0 bg-background min-w-45">
|
||||
<TabsTrigger
|
||||
key="install"
|
||||
value="install"
|
||||
className="data-[state=active]:bg-primary data-[state=active]:text-primary-foreground justify-start px-3 py-1.5 gap-2"
|
||||
><ArrowDownToLine className="size-4" /> Install</TabsTrigger>
|
||||
<TabsTrigger
|
||||
key="port"
|
||||
value="port"
|
||||
className="data-[state=active]:bg-primary data-[state=active]:text-primary-foreground justify-start px-3 py-1.5 gap-2"
|
||||
><EthernetPort className="size-4" /> Port</TabsTrigger>
|
||||
</TabsList>
|
||||
<div className="min-h-full flex flex-col w-full border-l border-border pl-4">
|
||||
<TabsContent key="install" value="install" className="flex flex-col gap-4 min-h-[150px] max-w-[90%]">
|
||||
<div className="install-neodlp-extension">
|
||||
<h3 className="font-semibold">NeoDLP Extension</h3>
|
||||
<p className="text-xs text-muted-foreground mb-4">Integrate NeoDLP with your favourite browser</p>
|
||||
<div className="flex items-center gap-4 mb-4">
|
||||
<SlidingButton
|
||||
slidingContent={
|
||||
<div className="flex items-center justify-center gap-2 text-white dark:text-black">
|
||||
<ArrowRight className="size-4" />
|
||||
<span>Get Now</span>
|
||||
</div>
|
||||
}
|
||||
onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'chrome')}
|
||||
>
|
||||
<span className="font-semibold flex items-center gap-2">
|
||||
<svg className="size-4 fill-white dark:fill-black" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
||||
<path d="M0 256C0 209.4 12.5 165.6 34.3 127.1L144.1 318.3C166 357.5 207.9 384 256 384C270.3 384 283.1 381.7 296.8 377.4L220.5 509.6C95.9 492.3 0 385.3 0 256zM365.1 321.6C377.4 302.4 384 279.1 384 256C384 217.8 367.2 183.5 340.7 160H493.4C505.4 189.6 512 222.1 512 256C512 397.4 397.4 511.1 256 512L365.1 321.6zM477.8 128H256C193.1 128 142.3 172.1 130.5 230.7L54.2 98.5C101 38.5 174 0 256 0C350.8 0 433.5 51.5 477.8 128V128zM168 256C168 207.4 207.4 168 256 168C304.6 168 344 207.4 344 256C344 304.6 304.6 344 256 344C207.4 344 168 304.6 168 256z"/>
|
||||
</svg>
|
||||
Get Chrome Extension
|
||||
</span>
|
||||
<span className="text-xs">from Chrome Web Store</span>
|
||||
</SlidingButton>
|
||||
<SlidingButton
|
||||
slidingContent={
|
||||
<div className="flex items-center justify-center gap-2 text-white dark:text-black">
|
||||
<ArrowRight className="size-4" />
|
||||
<span>Get Now</span>
|
||||
</div>
|
||||
}
|
||||
onClick={() => openLink('https://addons.mozilla.org/en-US/firefox/addon/neo-downloader-plus', 'firefox')}
|
||||
>
|
||||
<span className="font-semibold flex items-center gap-2">
|
||||
<svg className="size-4 fill-white dark:fill-black" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
||||
<path d="M130.2 127.5C130.4 127.6 130.3 127.6 130.2 127.5V127.5zM481.6 172.9C471 147.4 449.6 119.9 432.7 111.2C446.4 138.1 454.4 165 457.4 185.2C457.4 185.3 457.4 185.4 457.5 185.6C429.9 116.8 383.1 89.1 344.9 28.7C329.9 5.1 334 3.5 331.8 4.1L331.7 4.2C285 30.1 256.4 82.5 249.1 126.9C232.5 127.8 216.2 131.9 201.2 139C199.8 139.6 198.7 140.7 198.1 142C197.4 143.4 197.2 144.9 197.5 146.3C197.7 147.2 198.1 148 198.6 148.6C199.1 149.3 199.8 149.9 200.5 150.3C201.3 150.7 202.1 151 203 151.1C203.8 151.1 204.7 151 205.5 150.8L206 150.6C221.5 143.3 238.4 139.4 255.5 139.2C318.4 138.7 352.7 183.3 363.2 201.5C350.2 192.4 326.8 183.3 304.3 187.2C392.1 231.1 368.5 381.8 247 376.4C187.5 373.8 149.9 325.5 146.4 285.6C146.4 285.6 157.7 243.7 227 243.7C234.5 243.7 256 222.8 256.4 216.7C256.3 214.7 213.8 197.8 197.3 181.5C188.4 172.8 184.2 168.6 180.5 165.5C178.5 163.8 176.4 162.2 174.2 160.7C168.6 141.2 168.4 120.6 173.5 101.1C148.5 112.5 129 130.5 114.8 146.4H114.7C105 134.2 105.7 93.8 106.3 85.3C106.1 84.8 99 89 98.1 89.7C89.5 95.7 81.6 102.6 74.3 110.1C58 126.7 30.1 160.2 18.8 211.3C14.2 231.7 12 255.7 12 263.6C12 398.3 121.2 507.5 255.9 507.5C376.6 507.5 478.9 420.3 496.4 304.9C507.9 228.2 481.6 173.8 481.6 172.9z"/>
|
||||
</svg>
|
||||
Get Firefox Extension
|
||||
</span>
|
||||
<span className="text-xs">from Mozilla Addons Store</span>
|
||||
</SlidingButton>
|
||||
</div>
|
||||
<div className="flex gap-2 mb-4">
|
||||
<Button variant="outline" onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'msedge')}>Edge</Button>
|
||||
<Button variant="outline" onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'opera')}>Opera</Button>
|
||||
<Button variant="outline" onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'brave')}>Brave</Button>
|
||||
<Button variant="outline" onClick={() => openLink('https://chromewebstore.google.com/detail/neo-downloader-plus/mehopeailfjmiloiiohgicphlcgpompf', 'arc')}>Arc</Button>
|
||||
<Button variant="outline" onClick={() => openLink('https://addons.mozilla.org/en-US/firefox/addon/neo-downloader-plus', 'zen')}>Zen</Button>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground mb-2">* These links opens with coresponding browsers only. Make sure the browser is installed before clicking the link</p>
|
||||
</div>
|
||||
</TabsContent>
|
||||
<TabsContent key="port" value="port" className="flex flex-col gap-4 min-h-[150px] max-w-[70%]">
|
||||
<div className="websocket-port">
|
||||
<h3 className="font-semibold">Websocket Port</h3>
|
||||
<p className="text-xs text-muted-foreground mb-3">Change extension websocket server port</p>
|
||||
<div className="flex items-center gap-4">
|
||||
<Form {...websocketPortForm}>
|
||||
<form onSubmit={websocketPortForm.handleSubmit(handleWebsocketPortSubmit)} className="flex gap-4 w-full" autoComplete="off">
|
||||
<FormField
|
||||
control={websocketPortForm.control}
|
||||
name="port"
|
||||
disabled={isChangingWebSocketPort}
|
||||
render={({ field }) => (
|
||||
<FormItem className="w-full">
|
||||
<FormControl>
|
||||
<Input
|
||||
className="focus-visible:ring-0"
|
||||
placeholder="Enter port number"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<Label htmlFor="port" className="text-xs text-muted-foreground">(Current: {websocketPort}) (Default: 53511, Range: 50000-60000)</Label>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={!watchedPort || Number(watchedPort) === websocketPort || Object.keys(websocketPortFormErrors).length > 0 || isChangingWebSocketPort || isRestartingWebSocketServer}
|
||||
>
|
||||
{isChangingWebSocketPort ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
Changing
|
||||
</>
|
||||
) : (
|
||||
'Change'
|
||||
)}
|
||||
</Button>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
</TabsContent>
|
||||
</div>
|
||||
</div>
|
||||
</Tabs>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
<div className="flex flex-col">
|
||||
<h3 className="font-semibold">Reset Settings</h3>
|
||||
<p className="text-sm text-muted-foreground mb-3">Reset all setting to default</p>
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button
|
||||
className="w-fit"
|
||||
variant="destructive"
|
||||
disabled={isUsingDefaultSettings}
|
||||
>
|
||||
<RotateCcw className="h-4 w-4" />
|
||||
Reset Default
|
||||
</Button>
|
||||
</AlertDialogTrigger>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
This action cannot be undone! it will permanently reset all settings to default.
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction onClick={
|
||||
() => resetSettings()
|
||||
}>Reset</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Download, Puzzle, Settings, SquarePlay } from "lucide-react";
|
||||
import { Download, Settings, SquarePlay } from "lucide-react";
|
||||
import { RoutesObj } from "@/types/route";
|
||||
|
||||
export const AllRoutes: Array<RoutesObj> = [
|
||||
@@ -12,11 +12,6 @@ export const AllRoutes: Array<RoutesObj> = [
|
||||
url: "/library",
|
||||
icon: SquarePlay,
|
||||
},
|
||||
{
|
||||
title: "Extension",
|
||||
url: "/extension",
|
||||
icon: Puzzle,
|
||||
},
|
||||
{
|
||||
title: "Settings",
|
||||
url: "/settings",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BasePathsStore, CurrentVideoMetadataStore, DownloadActionStatesStore, DownloaderPageStatesStore, DownloadStatesStore, KvPairsStatesStore, SettingsPageStatesStore } from '@/types/store';
|
||||
import { BasePathsStore, CurrentVideoMetadataStore, DownloadActionStatesStore, DownloaderPageStatesStore, DownloadStatesStore, KvPairsStatesStore, LibraryPageStatesStore, SettingsPageStatesStore } from '@/types/store';
|
||||
import { create } from 'zustand';
|
||||
|
||||
export const useBasePathsStore = create<BasePathsStore>((set) => ({
|
||||
@@ -34,22 +34,43 @@ export const useCurrentVideoMetadataStore = create<CurrentVideoMetadataStore>((s
|
||||
isMetadataLoading: false,
|
||||
requestedUrl: '',
|
||||
autoSubmitSearch: false,
|
||||
searchPid: null,
|
||||
showSearchError: true,
|
||||
setVideoUrl: (url) => set(() => ({ videoUrl: url })),
|
||||
setVideoMetadata: (metadata) => set(() => ({ videoMetadata: metadata })),
|
||||
setIsMetadataLoading: (isLoading) => set(() => ({ isMetadataLoading: isLoading })),
|
||||
setRequestedUrl: (url) => set(() => ({ requestedUrl: url })),
|
||||
setAutoSubmitSearch: (autoSubmit) => set(() => ({ autoSubmitSearch: autoSubmit })),
|
||||
setSearchPid: (pid) => set(() => ({ searchPid: pid })),
|
||||
setShowSearchError: (showError) => set(() => ({ showSearchError: showError }))
|
||||
}));
|
||||
|
||||
export const useDownloaderPageStatesStore = create<DownloaderPageStatesStore>((set) => ({
|
||||
activeDownloadModeTab: 'selective',
|
||||
isStartingDownload: false,
|
||||
selctedDownloadFormat: 'best',
|
||||
selectedDownloadFormat: 'best',
|
||||
selectedCombinableVideoFormat: '',
|
||||
selectedCombinableAudioFormat: '',
|
||||
selectedSubtitles: [],
|
||||
selectedPlaylistVideoIndex: '1',
|
||||
isErrored: false,
|
||||
isErrorExpected: false,
|
||||
erroredDownloadId: null,
|
||||
setActiveDownloadModeTab: (tab) => set(() => ({ activeDownloadModeTab: tab })),
|
||||
setIsStartingDownload: (isStarting) => set(() => ({ isStartingDownload: isStarting })),
|
||||
setSelctedDownloadFormat: (format) => set(() => ({ selctedDownloadFormat: format })),
|
||||
setSelectedDownloadFormat: (format) => set(() => ({ selectedDownloadFormat: format })),
|
||||
setSelectedCombinableVideoFormat: (format) => set(() => ({ selectedCombinableVideoFormat: format })),
|
||||
setSelectedCombinableAudioFormat: (format) => set(() => ({ selectedCombinableAudioFormat: format })),
|
||||
setSelectedSubtitles: (subtitles) => set(() => ({ selectedSubtitles: subtitles })),
|
||||
setSelectedPlaylistVideoIndex: (index) => set(() => ({ selectedPlaylistVideoIndex: index }))
|
||||
setSelectedPlaylistVideoIndex: (index) => set(() => ({ selectedPlaylistVideoIndex: index })),
|
||||
setIsErrored: (isErrored) => set(() => ({ isErrored: isErrored })),
|
||||
setIsErrorExpected: (isErrorExpected) => set(() => ({ isErrorExpected: isErrorExpected })),
|
||||
setErroredDownloadId: (downloadId) => set(() => ({ erroredDownloadId: downloadId })),
|
||||
}));
|
||||
|
||||
export const useLibraryPageStatesStore = create<LibraryPageStatesStore>((set) => ({
|
||||
activeTab: 'completed',
|
||||
setActiveTab: (tab) => set(() => ({ activeTab: tab }))
|
||||
}));
|
||||
|
||||
export const useDownloadActionStatesStore = create<DownloadActionStatesStore>((set) => ({
|
||||
@@ -93,7 +114,9 @@ export const useDownloadActionStatesStore = create<DownloadActionStatesStore>((s
|
||||
}));
|
||||
|
||||
export const useSettingsPageStatesStore = create<SettingsPageStatesStore>((set) => ({
|
||||
activeTab: 'general',
|
||||
activeTab: 'app',
|
||||
activeSubAppTab: 'general',
|
||||
activeSubExtTab: 'install',
|
||||
appVersion: null,
|
||||
isFetchingAppVersion: false,
|
||||
ytDlpVersion: null,
|
||||
@@ -105,9 +128,19 @@ export const useSettingsPageStatesStore = create<SettingsPageStatesStore>((set)
|
||||
theme: 'system',
|
||||
download_dir: '',
|
||||
prefer_video_over_playlist: true,
|
||||
strict_downloadablity_check: false,
|
||||
max_parallel_downloads: 2,
|
||||
max_retries: 5,
|
||||
use_proxy: false,
|
||||
proxy_url: '',
|
||||
use_rate_limit: false,
|
||||
rate_limit: 1048576, // 1 MB/s
|
||||
video_format: 'auto',
|
||||
audio_format: 'auto',
|
||||
always_reencode_video: false,
|
||||
embed_video_metadata: false,
|
||||
embed_audio_metadata: true,
|
||||
embed_audio_thumbnail: true,
|
||||
websocket_port: 53511
|
||||
},
|
||||
isUsingDefaultSettings: true,
|
||||
@@ -118,6 +151,8 @@ export const useSettingsPageStatesStore = create<SettingsPageStatesStore>((set)
|
||||
isUpdatingApp: false,
|
||||
appUpdateDownloadProgress: 0,
|
||||
setActiveTab: (tab) => set(() => ({ activeTab: tab })),
|
||||
setActiveSubAppTab: (tab) => set(() => ({ activeSubAppTab: tab })),
|
||||
setActiveSubExtTab: (tab) => set(() => ({ activeSubExtTab: tab })),
|
||||
setAppVersion: (version) => set(() => ({ appVersion: version })),
|
||||
setIsFetchingAppVersion: (isFetching) => set(() => ({ isFetchingAppVersion: isFetching })),
|
||||
setYtDlpVersion: (version) => set(() => ({ ytDlpVersion: version })),
|
||||
@@ -137,9 +172,19 @@ export const useSettingsPageStatesStore = create<SettingsPageStatesStore>((set)
|
||||
theme: 'system',
|
||||
download_dir: '',
|
||||
prefer_video_over_playlist: true,
|
||||
strict_downloadablity_check: false,
|
||||
max_parallel_downloads: 2,
|
||||
max_retries: 5,
|
||||
use_proxy: false,
|
||||
proxy_url: '',
|
||||
use_rate_limit: false,
|
||||
rate_limit: 1048576, // 1 MB/s
|
||||
video_format: 'auto',
|
||||
audio_format: 'auto',
|
||||
always_reencode_video: false,
|
||||
embed_video_metadata: false,
|
||||
embed_audio_metadata: true,
|
||||
embed_audio_thumbnail: true,
|
||||
websocket_port: 53511
|
||||
},
|
||||
isUsingDefaultSettings: true
|
||||
|
||||
@@ -9,8 +9,19 @@ export interface Settings {
|
||||
theme: 'dark' | 'light' | 'system';
|
||||
download_dir: string;
|
||||
max_parallel_downloads: number;
|
||||
max_retries: number;
|
||||
prefer_video_over_playlist: boolean;
|
||||
strict_downloadablity_check: boolean;
|
||||
use_proxy: boolean;
|
||||
proxy_url: string;
|
||||
use_rate_limit: boolean;
|
||||
rate_limit: number;
|
||||
video_format: string;
|
||||
audio_format: string;
|
||||
always_reencode_video: boolean;
|
||||
embed_video_metadata: boolean;
|
||||
embed_audio_metadata: boolean;
|
||||
embed_audio_thumbnail: boolean;
|
||||
// extension settings
|
||||
websocket_port: number;
|
||||
}
|
||||
@@ -23,22 +23,43 @@ export interface CurrentVideoMetadataStore {
|
||||
isMetadataLoading: boolean;
|
||||
requestedUrl: string;
|
||||
autoSubmitSearch: boolean;
|
||||
searchPid: number | null;
|
||||
showSearchError: boolean;
|
||||
setVideoUrl: (url: string) => void;
|
||||
setVideoMetadata: (metadata: RawVideoInfo | null) => void;
|
||||
setIsMetadataLoading: (isLoading: boolean) => void;
|
||||
setRequestedUrl: (url: string) => void;
|
||||
setAutoSubmitSearch: (autoSubmit: boolean) => void;
|
||||
setSearchPid: (pid: number | null) => void;
|
||||
setShowSearchError: (showError: boolean) => void;
|
||||
}
|
||||
|
||||
export interface DownloaderPageStatesStore {
|
||||
activeDownloadModeTab: string;
|
||||
isStartingDownload: boolean;
|
||||
selctedDownloadFormat: string;
|
||||
selectedDownloadFormat: string;
|
||||
selectedCombinableVideoFormat: string;
|
||||
selectedCombinableAudioFormat: string;
|
||||
selectedSubtitles: string[];
|
||||
selectedPlaylistVideoIndex: string;
|
||||
isErrored: boolean;
|
||||
isErrorExpected: boolean;
|
||||
erroredDownloadId: string | null;
|
||||
setActiveDownloadModeTab: (tab: string) => void;
|
||||
setIsStartingDownload: (isStarting: boolean) => void;
|
||||
setSelctedDownloadFormat: (format: string) => void;
|
||||
setSelectedDownloadFormat: (format: string) => void;
|
||||
setSelectedCombinableVideoFormat: (format: string) => void;
|
||||
setSelectedCombinableAudioFormat: (format: string) => void;
|
||||
setSelectedSubtitles: (subtitles: string[]) => void;
|
||||
setSelectedPlaylistVideoIndex: (index: string) => void;
|
||||
setIsErrored: (isErrored: boolean) => void;
|
||||
setIsErrorExpected: (isErrorExpected: boolean) => void;
|
||||
setErroredDownloadId: (downloadId: string | null) => void;
|
||||
}
|
||||
|
||||
export interface LibraryPageStatesStore {
|
||||
activeTab: string;
|
||||
setActiveTab: (tab: string) => void;
|
||||
}
|
||||
|
||||
export interface DownloadActionStatesStore {
|
||||
@@ -58,6 +79,8 @@ export interface DownloadActionStatesStore {
|
||||
|
||||
export interface SettingsPageStatesStore {
|
||||
activeTab: string;
|
||||
activeSubAppTab: string;
|
||||
activeSubExtTab: string;
|
||||
appVersion: string | null;
|
||||
isFetchingAppVersion: boolean;
|
||||
ytDlpVersion: string | null;
|
||||
@@ -72,6 +95,8 @@ export interface SettingsPageStatesStore {
|
||||
isUpdatingApp: boolean;
|
||||
appUpdateDownloadProgress: number;
|
||||
setActiveTab: (tab: string) => void;
|
||||
setActiveSubAppTab: (tab: string) => void;
|
||||
setActiveSubExtTab: (tab: string) => void;
|
||||
setAppVersion: (version: string | null) => void;
|
||||
setIsFetchingAppVersion: (isFetching: boolean) => void;
|
||||
setYtDlpVersion: (version: string | null) => void;
|
||||
|
||||
@@ -9,7 +9,9 @@ const host = process.env.TAURI_DEV_HOST;
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(async () => ({
|
||||
plugins: [react(), tailwindcss()],
|
||||
|
||||
build: {
|
||||
chunkSizeWarningLimit: 1024, // 1MB
|
||||
},
|
||||
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
|
||||
//
|
||||
// 1. prevent vite from obscuring rust errors
|
||||
|
||||
Reference in New Issue
Block a user