Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ee3c2f653 | |||
| 73d8205f6f | |||
| 17fe37fbb7 | |||
| afe55db107 | |||
| 8a553774c6 | |||
| 869bf50330 | |||
| 1c03aaa92f | |||
| 1423a32528 | |||
| 633812faab | |||
| 355b68c8de | |||
| 884716069c | |||
| 44658f6ba6 | |||
| f9974d4a3e | |||
| 840f26dd6f | |||
| 5831a45839 | |||
| d1bd7da2de | |||
| 033980bbd2 | |||
| 3ae039d7db | |||
| 436a98c606 | |||
| d90221b835 |
+54
-24
@@ -55,10 +55,11 @@ jobs:
|
|||||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Setup pnpm cache
|
- name: Setup pnpm cache
|
||||||
|
continue-on-error: true
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ${{ env.STORE_PATH }}
|
path: ${{ env.STORE_PATH }}
|
||||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('frontend/pnpm-lock.yaml') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-pnpm-store-
|
${{ runner.os }}-pnpm-store-
|
||||||
|
|
||||||
@@ -77,13 +78,13 @@ jobs:
|
|||||||
- name: Prepare artifacts
|
- name: Prepare artifacts
|
||||||
run: |
|
run: |
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
Copy-Item -Path "build\bin\SpotiFLAC.exe" -Destination "dist\SpotiFLAC-${{ steps.version.outputs.version }}.exe"
|
Copy-Item -Path "build\bin\SpotiFLAC.exe" -Destination "dist\SpotiFLAC.exe"
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: windows-portable
|
name: windows-portable
|
||||||
path: dist/SpotiFLAC-${{ steps.version.outputs.version }}.exe
|
path: dist/SpotiFLAC.exe
|
||||||
retention-days: 7
|
retention-days: 7
|
||||||
|
|
||||||
build-macos:
|
build-macos:
|
||||||
@@ -123,10 +124,11 @@ jobs:
|
|||||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Setup pnpm cache
|
- name: Setup pnpm cache
|
||||||
|
continue-on-error: true
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ${{ env.STORE_PATH }}
|
path: ${{ env.STORE_PATH }}
|
||||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('frontend/pnpm-lock.yaml') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-pnpm-store-
|
${{ runner.os }}-pnpm-store-
|
||||||
|
|
||||||
@@ -157,16 +159,16 @@ jobs:
|
|||||||
--icon "SpotiFLAC.app" 175 120 \
|
--icon "SpotiFLAC.app" 175 120 \
|
||||||
--hide-extension "SpotiFLAC.app" \
|
--hide-extension "SpotiFLAC.app" \
|
||||||
--app-drop-link 425 120 \
|
--app-drop-link 425 120 \
|
||||||
"dist/SpotiFLAC-${{ steps.version.outputs.version }}.dmg" \
|
"dist/SpotiFLAC.dmg" \
|
||||||
"build/bin/SpotiFLAC.app" || \
|
"build/bin/SpotiFLAC.app" || \
|
||||||
# Fallback to hdiutil if create-dmg fails
|
# Fallback to hdiutil if create-dmg fails
|
||||||
hdiutil create -volname SpotiFLAC -srcfolder build/bin/SpotiFLAC.app -ov -format UDZO dist/SpotiFLAC-${{ steps.version.outputs.version }}.dmg
|
hdiutil create -volname SpotiFLAC -srcfolder build/bin/SpotiFLAC.app -ov -format UDZO dist/SpotiFLAC.dmg
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: macos-portable
|
name: macos-portable
|
||||||
path: dist/SpotiFLAC-${{ steps.version.outputs.version }}.dmg
|
path: dist/SpotiFLAC.dmg
|
||||||
retention-days: 7
|
retention-days: 7
|
||||||
|
|
||||||
build-linux:
|
build-linux:
|
||||||
@@ -206,10 +208,11 @@ jobs:
|
|||||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Setup pnpm cache
|
- name: Setup pnpm cache
|
||||||
|
continue-on-error: true
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ${{ env.STORE_PATH }}
|
path: ${{ env.STORE_PATH }}
|
||||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('frontend/pnpm-lock.yaml') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-pnpm-store-
|
${{ runner.os }}-pnpm-store-
|
||||||
|
|
||||||
@@ -245,36 +248,35 @@ jobs:
|
|||||||
mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps
|
mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps
|
||||||
|
|
||||||
# Copy binary
|
# Copy binary
|
||||||
cp build/bin/SpotiFLAC AppDir/usr/bin/spotiflac
|
cp build/bin/SpotiFLAC AppDir/usr/bin/
|
||||||
|
|
||||||
# Create desktop file
|
# Create desktop file
|
||||||
cat > AppDir/spotiflac.desktop << 'EOF'
|
cat > AppDir/spotiflac.desktop << 'EOF'
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Name=SpotiFLAC
|
Name=SpotiFLAC
|
||||||
Exec=spotiflac
|
Exec=SpotiFLAC
|
||||||
Icon=spotiflac
|
Icon=spotiflac
|
||||||
Type=Application
|
Type=Application
|
||||||
Categories=Audio;AudioVideo;
|
Categories=Audio;AudioVideo;
|
||||||
Comment=Get Spotify tracks in true FLAC from Tidal/Deezer
|
Comment=Get Spotify tracks in true FLAC from Tidal/Deezer
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Copy desktop file to usr/share/applications
|
|
||||||
cp AppDir/spotiflac.desktop AppDir/usr/share/applications/
|
cp AppDir/spotiflac.desktop AppDir/usr/share/applications/
|
||||||
|
|
||||||
# Use existing icon from build or convert SVG to PNG
|
# Create icon
|
||||||
if [ -f "build/appicon.png" ]; then
|
if [ -f "build/appicon.png" ]; then
|
||||||
# Resize to 256x256 if needed
|
|
||||||
convert build/appicon.png -resize 256x256 AppDir/spotiflac.png
|
convert build/appicon.png -resize 256x256 AppDir/spotiflac.png
|
||||||
elif [ -f "frontend/public/icon.svg" ]; then
|
elif [ -f "frontend/public/icon.svg" ]; then
|
||||||
# Convert SVG to PNG
|
|
||||||
convert -background none -size 256x256 frontend/public/icon.svg AppDir/spotiflac.png
|
convert -background none -size 256x256 frontend/public/icon.svg AppDir/spotiflac.png
|
||||||
else
|
else
|
||||||
# Fallback: create simple icon
|
echo "Warning: No icon found, building without icon"
|
||||||
convert -size 256x256 radial-gradient:#FFD700-#FFA500 AppDir/spotiflac.png
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp AppDir/spotiflac.png AppDir/usr/share/icons/hicolor/256x256/apps/
|
# Copy icon if exists
|
||||||
cp AppDir/spotiflac.png AppDir/.DirIcon
|
if [ -f "AppDir/spotiflac.png" ]; then
|
||||||
|
cp AppDir/spotiflac.png AppDir/usr/share/icons/hicolor/256x256/apps/
|
||||||
|
cp AppDir/spotiflac.png AppDir/.DirIcon
|
||||||
|
fi
|
||||||
|
|
||||||
# Create AppRun
|
# Create AppRun
|
||||||
cat > AppDir/AppRun << 'EOF'
|
cat > AppDir/AppRun << 'EOF'
|
||||||
@@ -283,19 +285,19 @@ jobs:
|
|||||||
HERE=${SELF%/*}
|
HERE=${SELF%/*}
|
||||||
export PATH="${HERE}/usr/bin/:${PATH}"
|
export PATH="${HERE}/usr/bin/:${PATH}"
|
||||||
export LD_LIBRARY_PATH="${HERE}/usr/lib/:${LD_LIBRARY_PATH}"
|
export LD_LIBRARY_PATH="${HERE}/usr/lib/:${LD_LIBRARY_PATH}"
|
||||||
exec "${HERE}/usr/bin/spotiflac" "$@"
|
exec "${HERE}/usr/bin/SpotiFLAC" "$@"
|
||||||
EOF
|
EOF
|
||||||
chmod +x AppDir/AppRun
|
chmod +x AppDir/AppRun
|
||||||
|
|
||||||
# Create AppImage
|
# Create AppImage
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
ARCH=x86_64 ./appimagetool --no-appstream AppDir dist/SpotiFLAC-${{ steps.version.outputs.version }}.AppImage
|
ARCH=x86_64 ./appimagetool --no-appstream AppDir dist/SpotiFLAC.AppImage
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: linux-portable
|
name: linux-portable
|
||||||
path: dist/SpotiFLAC-${{ steps.version.outputs.version }}.AppImage
|
path: dist/SpotiFLAC.AppImage
|
||||||
retention-days: 7
|
retention-days: 7
|
||||||
|
|
||||||
create-release:
|
create-release:
|
||||||
@@ -334,9 +336,37 @@ jobs:
|
|||||||
|
|
||||||
## Downloads
|
## Downloads
|
||||||
|
|
||||||
- `SpotiFLAC-${{ steps.version.outputs.version }}.exe` - Windows
|
- `SpotiFLAC.exe` - Windows
|
||||||
- `SpotiFLAC-${{ steps.version.outputs.version }}.dmg` - macOS
|
- `SpotiFLAC.dmg` - macOS
|
||||||
- `SpotiFLAC-${{ steps.version.outputs.version }}.AppImage` - Linux
|
- `SpotiFLAC.AppImage` - Linux
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><b>Linux Requirements</b></summary>
|
||||||
|
|
||||||
|
The AppImage requires `webkit2gtk-4.1` to be installed on your system:
|
||||||
|
|
||||||
|
**Ubuntu/Debian:**
|
||||||
|
```bash
|
||||||
|
sudo apt install libwebkit2gtk-4.1-0
|
||||||
|
```
|
||||||
|
|
||||||
|
**Arch Linux:**
|
||||||
|
```bash
|
||||||
|
sudo pacman -S webkit2gtk-4.1
|
||||||
|
```
|
||||||
|
|
||||||
|
**Fedora:**
|
||||||
|
```bash
|
||||||
|
sudo dnf install webkit2gtk4.1
|
||||||
|
```
|
||||||
|
|
||||||
|
After installing the dependency, make the AppImage executable:
|
||||||
|
```bash
|
||||||
|
chmod +x SpotiFLAC.AppImage
|
||||||
|
./SpotiFLAC.AppImage
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
files: |
|
files: |
|
||||||
artifacts/windows-portable/*.exe
|
artifacts/windows-portable/*.exe
|
||||||
artifacts/macos-portable/*.dmg
|
artifacts/macos-portable/*.dmg
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
Get Spotify tracks in true FLAC from Tidal/Deezer — no account required.
|
Get Spotify tracks in true FLAC from Tidal, Deezer, Qobuz & Amazon Music — no account required.
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||

|

|
||||||
@@ -17,12 +18,22 @@ Get Spotify tracks in true FLAC from Tidal/Deezer — no account required.
|
|||||||
|
|
||||||
## Screenshot
|
## Screenshot
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Lossless Audio Check
|
## Lossless Audio Check
|
||||||
|
|
||||||
|
A simple utility for verifying the authenticity of FLAC files (lossless/lossy detection).
|
||||||
|
|
||||||
|
#### [Download](https://github.com/afkarxyz/SpotiFLAC/releases/download/v0/FLAC-Checker.zip) - Windows only
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### [Download](https://github.com/afkarxyz/SpotiFLAC/releases/download/v0/FLAC-Checker.zip)
|
## Other projects
|
||||||
|
|
||||||
|
### [SpotiDownloader](https://github.com/afkarxyz/SpotiDownloader)
|
||||||
|
|
||||||
|
Get Spotify tracks in MP3 and FLAC via the spotidownloader.com API
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"spotiflac/backend"
|
"spotiflac/backend"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -34,25 +37,51 @@ type SpotifyMetadataRequest struct {
|
|||||||
|
|
||||||
// DownloadRequest represents the request structure for downloading tracks
|
// DownloadRequest represents the request structure for downloading tracks
|
||||||
type DownloadRequest struct {
|
type DownloadRequest struct {
|
||||||
ISRC string `json:"isrc"`
|
ISRC string `json:"isrc"`
|
||||||
Service string `json:"service"`
|
Service string `json:"service"`
|
||||||
Query string `json:"query,omitempty"`
|
Query string `json:"query,omitempty"`
|
||||||
TrackName string `json:"track_name,omitempty"`
|
TrackName string `json:"track_name,omitempty"`
|
||||||
ArtistName string `json:"artist_name,omitempty"`
|
ArtistName string `json:"artist_name,omitempty"`
|
||||||
AlbumName string `json:"album_name,omitempty"`
|
AlbumName string `json:"album_name,omitempty"`
|
||||||
ApiURL string `json:"api_url,omitempty"`
|
ApiURL string `json:"api_url,omitempty"`
|
||||||
OutputDir string `json:"output_dir,omitempty"`
|
OutputDir string `json:"output_dir,omitempty"`
|
||||||
AudioFormat string `json:"audio_format,omitempty"`
|
AudioFormat string `json:"audio_format,omitempty"`
|
||||||
FilenameFormat string `json:"filename_format,omitempty"`
|
FilenameFormat string `json:"filename_format,omitempty"`
|
||||||
TrackNumber bool `json:"track_number,omitempty"`
|
TrackNumber bool `json:"track_number,omitempty"`
|
||||||
|
Position int `json:"position,omitempty"` // Position in playlist/album (1-based)
|
||||||
|
UseAlbumTrackNumber bool `json:"use_album_track_number,omitempty"` // Use album track number instead of playlist position
|
||||||
|
SpotifyID string `json:"spotify_id,omitempty"` // Spotify track ID
|
||||||
|
ServiceURL string `json:"service_url,omitempty"` // Direct service URL (Tidal/Deezer/Amazon) to skip song.link API call
|
||||||
}
|
}
|
||||||
|
|
||||||
// DownloadResponse represents the response structure for download operations
|
// DownloadResponse represents the response structure for download operations
|
||||||
type DownloadResponse struct {
|
type DownloadResponse struct {
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
File string `json:"file,omitempty"`
|
File string `json:"file,omitempty"`
|
||||||
Error string `json:"error,omitempty"`
|
Error string `json:"error,omitempty"`
|
||||||
|
AlreadyExists bool `json:"already_exists,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetStreamingURLs fetches all streaming URLs from song.link API
|
||||||
|
func (a *App) GetStreamingURLs(spotifyTrackID string) (string, error) {
|
||||||
|
if spotifyTrackID == "" {
|
||||||
|
return "", fmt.Errorf("spotify track ID is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("[GetStreamingURLs] Called for track ID: %s\n", spotifyTrackID)
|
||||||
|
client := backend.NewSongLinkClient()
|
||||||
|
urls, err := client.GetAllURLsFromSpotify(spotifyTrackID)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonData, err := json.Marshal(urls)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to encode response: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(jsonData), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSpotifyMetadata fetches metadata from Spotify
|
// GetSpotifyMetadata fetches metadata from Spotify
|
||||||
@@ -113,30 +142,100 @@ func (a *App) DownloadTrack(req DownloadRequest) (DownloadResponse, error) {
|
|||||||
req.FilenameFormat = "title-artist"
|
req.FilenameFormat = "title-artist"
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Service == "tidal" {
|
// Early check: Check if file with same ISRC already exists
|
||||||
searchQuery := req.Query
|
if existingFile, exists := backend.CheckISRCExists(req.OutputDir, req.ISRC); exists {
|
||||||
if searchQuery == "" {
|
fmt.Printf("File with ISRC %s already exists: %s\n", req.ISRC, existingFile)
|
||||||
searchQuery = req.ISRC
|
return DownloadResponse{
|
||||||
|
Success: true,
|
||||||
|
Message: "File with same ISRC already exists",
|
||||||
|
File: existingFile,
|
||||||
|
AlreadyExists: true,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback: if we have track metadata, check if file already exists by filename
|
||||||
|
if req.TrackName != "" && req.ArtistName != "" {
|
||||||
|
expectedFilename := backend.BuildExpectedFilename(req.TrackName, req.ArtistName, req.FilenameFormat, req.TrackNumber, req.Position, req.UseAlbumTrackNumber)
|
||||||
|
expectedPath := filepath.Join(req.OutputDir, expectedFilename)
|
||||||
|
|
||||||
|
if fileInfo, err := os.Stat(expectedPath); err == nil && fileInfo.Size() > 0 {
|
||||||
|
return DownloadResponse{
|
||||||
|
Success: true,
|
||||||
|
Message: "File already exists",
|
||||||
|
File: expectedPath,
|
||||||
|
AlreadyExists: true,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set downloading state
|
||||||
|
backend.SetDownloading(true)
|
||||||
|
defer backend.SetDownloading(false)
|
||||||
|
|
||||||
|
switch req.Service {
|
||||||
|
case "amazon":
|
||||||
|
downloader := backend.NewAmazonDownloader()
|
||||||
|
if req.ServiceURL != "" {
|
||||||
|
// Use provided URL directly
|
||||||
|
filename, err = downloader.DownloadByURL(req.ServiceURL, req.OutputDir, req.FilenameFormat, req.TrackNumber, req.Position, req.TrackName, req.ArtistName, req.AlbumName, req.UseAlbumTrackNumber)
|
||||||
|
} else {
|
||||||
|
if req.SpotifyID == "" {
|
||||||
|
return DownloadResponse{
|
||||||
|
Success: false,
|
||||||
|
Error: "Spotify ID is required for Amazon Music",
|
||||||
|
}, fmt.Errorf("spotify ID is required for Amazon Music")
|
||||||
|
}
|
||||||
|
filename, err = downloader.DownloadBySpotifyID(req.SpotifyID, req.OutputDir, req.FilenameFormat, req.TrackNumber, req.Position, req.TrackName, req.ArtistName, req.AlbumName, req.UseAlbumTrackNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "tidal":
|
||||||
if req.ApiURL == "" || req.ApiURL == "auto" {
|
if req.ApiURL == "" || req.ApiURL == "auto" {
|
||||||
downloader := backend.NewTidalDownloader("")
|
downloader := backend.NewTidalDownloader("")
|
||||||
filename, err = downloader.DownloadWithFallback(searchQuery, req.ISRC, req.OutputDir, req.AudioFormat, req.FilenameFormat, req.TrackNumber, req.TrackName, req.ArtistName, req.AlbumName)
|
if req.ServiceURL != "" {
|
||||||
|
// Use provided URL directly with fallback to multiple APIs
|
||||||
|
filename, err = downloader.DownloadByURLWithFallback(req.ServiceURL, req.OutputDir, req.AudioFormat, req.FilenameFormat, req.TrackNumber, req.Position, req.TrackName, req.ArtistName, req.AlbumName, req.UseAlbumTrackNumber)
|
||||||
|
} else {
|
||||||
|
if req.SpotifyID == "" {
|
||||||
|
return DownloadResponse{
|
||||||
|
Success: false,
|
||||||
|
Error: "Spotify ID is required for Tidal",
|
||||||
|
}, fmt.Errorf("spotify ID is required for Tidal")
|
||||||
|
}
|
||||||
|
filename, err = downloader.DownloadWithFallback(req.SpotifyID, req.OutputDir, req.AudioFormat, req.FilenameFormat, req.TrackNumber, req.Position, req.TrackName, req.ArtistName, req.AlbumName, req.UseAlbumTrackNumber)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
downloader := backend.NewTidalDownloader(req.ApiURL)
|
downloader := backend.NewTidalDownloader(req.ApiURL)
|
||||||
filename, err = downloader.Download(searchQuery, req.ISRC, req.OutputDir, req.AudioFormat, req.FilenameFormat, req.TrackNumber, req.TrackName, req.ArtistName, req.AlbumName)
|
if req.ServiceURL != "" {
|
||||||
|
// Use provided URL directly with specific API
|
||||||
|
filename, err = downloader.DownloadByURL(req.ServiceURL, req.OutputDir, req.AudioFormat, req.FilenameFormat, req.TrackNumber, req.Position, req.TrackName, req.ArtistName, req.AlbumName, req.UseAlbumTrackNumber)
|
||||||
|
} else {
|
||||||
|
if req.SpotifyID == "" {
|
||||||
|
return DownloadResponse{
|
||||||
|
Success: false,
|
||||||
|
Error: "Spotify ID is required for Tidal",
|
||||||
|
}, fmt.Errorf("spotify ID is required for Tidal")
|
||||||
|
}
|
||||||
|
filename, err = downloader.Download(req.SpotifyID, req.OutputDir, req.AudioFormat, req.FilenameFormat, req.TrackNumber, req.Position, req.TrackName, req.ArtistName, req.AlbumName, req.UseAlbumTrackNumber)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if req.Service == "qobuz" {
|
|
||||||
|
case "qobuz":
|
||||||
downloader := backend.NewQobuzDownloader()
|
downloader := backend.NewQobuzDownloader()
|
||||||
err = downloader.DownloadByISRC(req.ISRC, req.OutputDir, req.AudioFormat, req.FilenameFormat, req.TrackNumber, req.TrackName, req.ArtistName, req.AlbumName)
|
filename, err = downloader.DownloadByISRC(req.ISRC, req.OutputDir, req.AudioFormat, req.FilenameFormat, req.TrackNumber, req.Position, req.TrackName, req.ArtistName, req.AlbumName, req.UseAlbumTrackNumber)
|
||||||
if err == nil {
|
|
||||||
filename = "Downloaded via Qobuz"
|
default: // deezer
|
||||||
}
|
|
||||||
} else {
|
|
||||||
downloader := backend.NewDeezerDownloader()
|
downloader := backend.NewDeezerDownloader()
|
||||||
err = downloader.DownloadByISRC(req.ISRC, req.OutputDir, req.FilenameFormat, req.TrackNumber, req.TrackName, req.ArtistName, req.AlbumName)
|
if req.ServiceURL != "" {
|
||||||
if err == nil {
|
// Use provided URL directly
|
||||||
filename = "Downloaded via Deezer"
|
filename, err = downloader.DownloadByURL(req.ServiceURL, req.OutputDir, req.FilenameFormat, req.TrackNumber, req.Position, req.TrackName, req.ArtistName, req.AlbumName, req.UseAlbumTrackNumber)
|
||||||
|
} else {
|
||||||
|
if req.SpotifyID == "" {
|
||||||
|
return DownloadResponse{
|
||||||
|
Success: false,
|
||||||
|
Error: "Spotify ID is required for Deezer",
|
||||||
|
}, fmt.Errorf("spotify ID is required for Deezer")
|
||||||
|
}
|
||||||
|
filename, err = downloader.DownloadBySpotifyID(req.SpotifyID, req.OutputDir, req.FilenameFormat, req.TrackNumber, req.Position, req.TrackName, req.ArtistName, req.AlbumName, req.UseAlbumTrackNumber)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,10 +246,23 @@ func (a *App) DownloadTrack(req DownloadRequest) (DownloadResponse, error) {
|
|||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if file already existed
|
||||||
|
alreadyExists := false
|
||||||
|
if strings.HasPrefix(filename, "EXISTS:") {
|
||||||
|
alreadyExists = true
|
||||||
|
filename = strings.TrimPrefix(filename, "EXISTS:")
|
||||||
|
}
|
||||||
|
|
||||||
|
message := "Download completed successfully"
|
||||||
|
if alreadyExists {
|
||||||
|
message = "File already exists"
|
||||||
|
}
|
||||||
|
|
||||||
return DownloadResponse{
|
return DownloadResponse{
|
||||||
Success: true,
|
Success: true,
|
||||||
Message: "Download completed successfully",
|
Message: message,
|
||||||
File: filename,
|
File: filename,
|
||||||
|
AlreadyExists: alreadyExists,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,3 +291,14 @@ func (a *App) GetDefaults() map[string]string {
|
|||||||
"downloadPath": backend.GetDefaultMusicPath(),
|
"downloadPath": backend.GetDefaultMusicPath(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDownloadProgress returns current download progress
|
||||||
|
func (a *App) GetDownloadProgress() backend.ProgressInfo {
|
||||||
|
return backend.GetDownloadProgress()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Quit closes the application
|
||||||
|
func (a *App) Quit() {
|
||||||
|
// You can add cleanup logic here if needed
|
||||||
|
panic("quit") // This will trigger Wails to close the app
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,432 @@
|
|||||||
|
package backend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AmazonDownloader struct {
|
||||||
|
client *http.Client
|
||||||
|
regions []string
|
||||||
|
lastAPICallTime time.Time
|
||||||
|
apiCallCount int
|
||||||
|
apiCallResetTime time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
type SongLinkResponse struct {
|
||||||
|
LinksByPlatform map[string]struct {
|
||||||
|
URL string `json:"url"`
|
||||||
|
} `json:"linksByPlatform"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DoubleDoubleSubmitResponse struct {
|
||||||
|
Success bool `json:"success"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DoubleDoubleStatusResponse struct {
|
||||||
|
Status string `json:"status"`
|
||||||
|
FriendlyStatus string `json:"friendlyStatus"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
Current struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Artist string `json:"artist"`
|
||||||
|
} `json:"current"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAmazonDownloader() *AmazonDownloader {
|
||||||
|
return &AmazonDownloader{
|
||||||
|
client: &http.Client{
|
||||||
|
Timeout: 120 * time.Second,
|
||||||
|
},
|
||||||
|
regions: []string{"us", "eu"},
|
||||||
|
apiCallResetTime: time.Now(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AmazonDownloader) getRandomUserAgent() string {
|
||||||
|
return fmt.Sprintf("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_%d_%d) AppleWebKit/%d.%d (KHTML, like Gecko) Chrome/%d.0.%d.%d Safari/%d.%d",
|
||||||
|
rand.Intn(4)+11, rand.Intn(5)+4,
|
||||||
|
rand.Intn(7)+530, rand.Intn(7)+30,
|
||||||
|
rand.Intn(25)+80, rand.Intn(1500)+3000, rand.Intn(65)+60,
|
||||||
|
rand.Intn(7)+530, rand.Intn(6)+30)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AmazonDownloader) GetAmazonURLFromSpotify(spotifyTrackID string) (string, error) {
|
||||||
|
// Rate limiting: max 10 requests per minute (song.link API limit)
|
||||||
|
// Reset counter every minute
|
||||||
|
now := time.Now()
|
||||||
|
if now.Sub(a.apiCallResetTime) >= time.Minute {
|
||||||
|
a.apiCallCount = 0
|
||||||
|
a.apiCallResetTime = now
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we've hit the limit, wait until the next minute
|
||||||
|
if a.apiCallCount >= 9 { // Use 9 to be safe (limit is 10)
|
||||||
|
waitTime := time.Minute - now.Sub(a.apiCallResetTime)
|
||||||
|
if waitTime > 0 {
|
||||||
|
fmt.Printf("Rate limit reached, waiting %v...\n", waitTime.Round(time.Second))
|
||||||
|
time.Sleep(waitTime)
|
||||||
|
a.apiCallCount = 0
|
||||||
|
a.apiCallResetTime = time.Now()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add delay between requests (6 seconds = 10 requests per minute)
|
||||||
|
if !a.lastAPICallTime.IsZero() {
|
||||||
|
timeSinceLastCall := now.Sub(a.lastAPICallTime)
|
||||||
|
minDelay := 7 * time.Second // 7 seconds to be safe
|
||||||
|
if timeSinceLastCall < minDelay {
|
||||||
|
waitTime := minDelay - timeSinceLastCall
|
||||||
|
fmt.Printf("Rate limiting: waiting %v...\n", waitTime.Round(time.Second))
|
||||||
|
time.Sleep(waitTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode base64 API URL
|
||||||
|
spotifyBase, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly9vcGVuLnNwb3RpZnkuY29tL3RyYWNrLw==")
|
||||||
|
spotifyURL := fmt.Sprintf("%s%s", string(spotifyBase), spotifyTrackID)
|
||||||
|
|
||||||
|
apiBase, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly9hcGkuc29uZy5saW5rL3YxLWFscGhhLjEvbGlua3M/dXJsPQ==")
|
||||||
|
apiURL := fmt.Sprintf("%s%s", string(apiBase), url.QueryEscape(spotifyURL))
|
||||||
|
|
||||||
|
req, err := http.NewRequest("GET", apiURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to create request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("User-Agent", a.getRandomUserAgent())
|
||||||
|
|
||||||
|
fmt.Println("Getting Amazon URL...")
|
||||||
|
|
||||||
|
// Retry logic for rate limit errors
|
||||||
|
maxRetries := 3
|
||||||
|
var resp *http.Response
|
||||||
|
for i := 0; i < maxRetries; i++ {
|
||||||
|
resp, err = a.client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to get Amazon URL: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update rate limit tracking
|
||||||
|
a.lastAPICallTime = time.Now()
|
||||||
|
a.apiCallCount++
|
||||||
|
|
||||||
|
if resp.StatusCode == 429 { // Too Many Requests
|
||||||
|
resp.Body.Close()
|
||||||
|
if i < maxRetries-1 {
|
||||||
|
waitTime := 15 * time.Second
|
||||||
|
fmt.Printf("Rate limited by API, waiting %v before retry...\n", waitTime)
|
||||||
|
time.Sleep(waitTime)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return "", fmt.Errorf("API rate limit exceeded after %d retries", maxRetries)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
resp.Body.Close()
|
||||||
|
return "", fmt.Errorf("API returned status %d", resp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
var songLinkResp SongLinkResponse
|
||||||
|
if err := json.NewDecoder(resp.Body).Decode(&songLinkResp); err != nil {
|
||||||
|
return "", fmt.Errorf("failed to decode response: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
amazonLink, ok := songLinkResp.LinksByPlatform["amazonMusic"]
|
||||||
|
if !ok || amazonLink.URL == "" {
|
||||||
|
return "", fmt.Errorf("amazon Music link not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
amazonURL := amazonLink.URL
|
||||||
|
|
||||||
|
// Convert album URL to track URL if needed
|
||||||
|
if strings.Contains(amazonURL, "trackAsin=") {
|
||||||
|
parts := strings.Split(amazonURL, "trackAsin=")
|
||||||
|
if len(parts) > 1 {
|
||||||
|
trackAsin := strings.Split(parts[1], "&")[0]
|
||||||
|
musicBase, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly9tdXNpYy5hbWF6b24uY29tL3RyYWNrcy8=")
|
||||||
|
amazonURL = fmt.Sprintf("%s%s?musicTerritory=US", string(musicBase), trackAsin)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Found Amazon URL: %s\n", amazonURL)
|
||||||
|
return amazonURL, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AmazonDownloader) DownloadFromService(amazonURL, outputDir string) (string, error) {
|
||||||
|
var lastError error
|
||||||
|
|
||||||
|
for _, region := range a.regions {
|
||||||
|
fmt.Printf("\nTrying region: %s...\n", region)
|
||||||
|
// Decode base64 service URL
|
||||||
|
serviceBase, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly8=")
|
||||||
|
serviceDomain, _ := base64.StdEncoding.DecodeString("LmRvdWJsZWRvdWJsZS50b3A=")
|
||||||
|
baseURL := fmt.Sprintf("%s%s%s", string(serviceBase), region, string(serviceDomain))
|
||||||
|
|
||||||
|
// Step 1: Submit download request
|
||||||
|
encodedURL := url.QueryEscape(amazonURL)
|
||||||
|
submitURL := fmt.Sprintf("%s/dl?url=%s", baseURL, encodedURL)
|
||||||
|
|
||||||
|
req, err := http.NewRequest("GET", submitURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
lastError = fmt.Errorf("failed to create request: %w", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("User-Agent", a.getRandomUserAgent())
|
||||||
|
|
||||||
|
fmt.Println("Submitting download request...")
|
||||||
|
resp, err := a.client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
lastError = fmt.Errorf("failed to submit request: %w", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
resp.Body.Close()
|
||||||
|
lastError = fmt.Errorf("submit failed with status %d", resp.StatusCode)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var submitResp DoubleDoubleSubmitResponse
|
||||||
|
if err := json.NewDecoder(resp.Body).Decode(&submitResp); err != nil {
|
||||||
|
resp.Body.Close()
|
||||||
|
lastError = fmt.Errorf("failed to decode submit response: %w", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
resp.Body.Close()
|
||||||
|
|
||||||
|
if !submitResp.Success || submitResp.ID == "" {
|
||||||
|
lastError = fmt.Errorf("submit request failed")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadID := submitResp.ID
|
||||||
|
fmt.Printf("Download ID: %s\n", downloadID)
|
||||||
|
|
||||||
|
// Step 2: Poll for completion
|
||||||
|
statusURL := fmt.Sprintf("%s/dl/%s", baseURL, downloadID)
|
||||||
|
fmt.Println("Waiting for download to complete...")
|
||||||
|
|
||||||
|
maxWait := 300 * time.Second
|
||||||
|
elapsed := time.Duration(0)
|
||||||
|
pollInterval := 3 * time.Second
|
||||||
|
|
||||||
|
for elapsed < maxWait {
|
||||||
|
time.Sleep(pollInterval)
|
||||||
|
elapsed += pollInterval
|
||||||
|
|
||||||
|
statusReq, err := http.NewRequest("GET", statusURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
statusReq.Header.Set("User-Agent", a.getRandomUserAgent())
|
||||||
|
|
||||||
|
statusResp, err := a.client.Do(statusReq)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("\rStatus check failed, retrying...")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if statusResp.StatusCode != 200 {
|
||||||
|
statusResp.Body.Close()
|
||||||
|
fmt.Printf("\rStatus check failed (status %d), retrying...", statusResp.StatusCode)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var status DoubleDoubleStatusResponse
|
||||||
|
if err := json.NewDecoder(statusResp.Body).Decode(&status); err != nil {
|
||||||
|
statusResp.Body.Close()
|
||||||
|
fmt.Printf("\rInvalid JSON response, retrying...")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
statusResp.Body.Close()
|
||||||
|
|
||||||
|
if status.Status == "done" {
|
||||||
|
fmt.Println("\nDownload ready!")
|
||||||
|
|
||||||
|
// Build download URL
|
||||||
|
fileURL := status.URL
|
||||||
|
if strings.HasPrefix(fileURL, "./") {
|
||||||
|
fileURL = fmt.Sprintf("%s/%s", baseURL, fileURL[2:])
|
||||||
|
} else if strings.HasPrefix(fileURL, "/") {
|
||||||
|
fileURL = fmt.Sprintf("%s%s", baseURL, fileURL)
|
||||||
|
}
|
||||||
|
|
||||||
|
trackName := status.Current.Name
|
||||||
|
artist := status.Current.Artist
|
||||||
|
|
||||||
|
fmt.Printf("Downloading: %s - %s\n", artist, trackName)
|
||||||
|
|
||||||
|
// Download file
|
||||||
|
downloadReq, err := http.NewRequest("GET", fileURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
lastError = fmt.Errorf("failed to create download request: %w", err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadReq.Header.Set("User-Agent", a.getRandomUserAgent())
|
||||||
|
|
||||||
|
fileResp, err := a.client.Do(downloadReq)
|
||||||
|
if err != nil {
|
||||||
|
lastError = fmt.Errorf("failed to download file: %w", err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
defer fileResp.Body.Close()
|
||||||
|
|
||||||
|
if fileResp.StatusCode != 200 {
|
||||||
|
lastError = fmt.Errorf("download failed with status %d", fileResp.StatusCode)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate filename
|
||||||
|
fileName := fmt.Sprintf("%s - %s.flac", artist, trackName)
|
||||||
|
for _, char := range `<>:"/\|?*` {
|
||||||
|
fileName = strings.ReplaceAll(fileName, string(char), "")
|
||||||
|
}
|
||||||
|
fileName = strings.TrimSpace(fileName)
|
||||||
|
|
||||||
|
filePath := filepath.Join(outputDir, fileName)
|
||||||
|
|
||||||
|
// Save file
|
||||||
|
out, err := os.Create(filePath)
|
||||||
|
if err != nil {
|
||||||
|
lastError = fmt.Errorf("failed to create file: %w", err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
defer out.Close()
|
||||||
|
|
||||||
|
fmt.Println("Downloading...")
|
||||||
|
// Use progress writer to track download
|
||||||
|
pw := NewProgressWriter(out)
|
||||||
|
_, err = io.Copy(pw, fileResp.Body)
|
||||||
|
if err != nil {
|
||||||
|
out.Close()
|
||||||
|
return "", fmt.Errorf("failed to write file: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print final size
|
||||||
|
fmt.Printf("\rDownloaded: %.2f MB (Complete)\n", float64(pw.GetTotal())/(1024*1024))
|
||||||
|
fmt.Println("Download complete!")
|
||||||
|
return filePath, nil
|
||||||
|
|
||||||
|
} else if status.Status == "error" {
|
||||||
|
errorMsg := status.FriendlyStatus
|
||||||
|
if errorMsg == "" {
|
||||||
|
errorMsg = "Unknown error"
|
||||||
|
}
|
||||||
|
lastError = fmt.Errorf("processing failed: %s", errorMsg)
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
// Still processing
|
||||||
|
friendlyStatus := status.FriendlyStatus
|
||||||
|
if friendlyStatus == "" {
|
||||||
|
friendlyStatus = status.Status
|
||||||
|
}
|
||||||
|
fmt.Printf("\r%s...", friendlyStatus)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if elapsed >= maxWait {
|
||||||
|
lastError = fmt.Errorf("download timeout")
|
||||||
|
fmt.Printf("\nError with %s region: %v\n", region, lastError)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if lastError != nil {
|
||||||
|
fmt.Printf("\nError with %s region: %v\n", region, lastError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", fmt.Errorf("all regions failed. Last error: %v", lastError)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AmazonDownloader) DownloadByURL(amazonURL, outputDir, filenameFormat string, includeTrackNumber bool, position int, spotifyTrackName, spotifyArtistName, spotifyAlbumName string, useAlbumTrackNumber bool) (string, error) {
|
||||||
|
// Create output directory if needed
|
||||||
|
if outputDir != "." {
|
||||||
|
if err := os.MkdirAll(outputDir, 0755); err != nil {
|
||||||
|
return "", fmt.Errorf("failed to create output directory: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if file with expected name already exists (Amazon doesn't provide ISRC before download)
|
||||||
|
if spotifyTrackName != "" && spotifyArtistName != "" {
|
||||||
|
expectedFilename := BuildExpectedFilename(spotifyTrackName, spotifyArtistName, filenameFormat, includeTrackNumber, position, useAlbumTrackNumber)
|
||||||
|
expectedPath := filepath.Join(outputDir, expectedFilename)
|
||||||
|
|
||||||
|
if fileInfo, err := os.Stat(expectedPath); err == nil && fileInfo.Size() > 0 {
|
||||||
|
fmt.Printf("File already exists: %s (%.2f MB)\n", expectedPath, float64(fileInfo.Size())/(1024*1024))
|
||||||
|
return "EXISTS:" + expectedPath, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Using Amazon URL: %s\n", amazonURL)
|
||||||
|
|
||||||
|
// Download from service
|
||||||
|
filePath, err := a.DownloadFromService(amazonURL, outputDir)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
// File already has embedded metadata, just rename if needed
|
||||||
|
if spotifyTrackName != "" && spotifyArtistName != "" {
|
||||||
|
safeArtist := sanitizeFilename(spotifyArtistName)
|
||||||
|
safeTitle := sanitizeFilename(spotifyTrackName)
|
||||||
|
|
||||||
|
// Build filename based on format settings
|
||||||
|
var newFilename string
|
||||||
|
switch filenameFormat {
|
||||||
|
case "artist-title":
|
||||||
|
newFilename = fmt.Sprintf("%s - %s", safeArtist, safeTitle)
|
||||||
|
case "title":
|
||||||
|
newFilename = safeTitle
|
||||||
|
default: // "title-artist"
|
||||||
|
newFilename = fmt.Sprintf("%s - %s", safeTitle, safeArtist)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add track number prefix if enabled
|
||||||
|
if includeTrackNumber && position > 0 {
|
||||||
|
newFilename = fmt.Sprintf("%02d. %s", position, newFilename)
|
||||||
|
}
|
||||||
|
|
||||||
|
newFilename = newFilename + ".flac"
|
||||||
|
newFilePath := filepath.Join(outputDir, newFilename)
|
||||||
|
|
||||||
|
// Rename file
|
||||||
|
if err := os.Rename(filePath, newFilePath); err != nil {
|
||||||
|
fmt.Printf("Warning: Failed to rename file: %v\n", err)
|
||||||
|
} else {
|
||||||
|
filePath = newFilePath
|
||||||
|
fmt.Printf("Renamed to: %s\n", newFilename)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Done")
|
||||||
|
fmt.Println("✓ Downloaded successfully from Amazon Music")
|
||||||
|
return filePath, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AmazonDownloader) DownloadBySpotifyID(spotifyTrackID, outputDir, filenameFormat string, includeTrackNumber bool, position int, spotifyTrackName, spotifyArtistName, spotifyAlbumName string, useAlbumTrackNumber bool) (string, error) {
|
||||||
|
// Get Amazon URL from Spotify track ID
|
||||||
|
amazonURL, err := a.GetAmazonURLFromSpotify(spotifyTrackID)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return a.DownloadByURL(amazonURL, outputDir, filenameFormat, includeTrackNumber, position, spotifyTrackName, spotifyArtistName, spotifyAlbumName, useAlbumTrackNumber)
|
||||||
|
}
|
||||||
+132
-29
@@ -8,7 +8,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -57,10 +56,75 @@ func NewDeezerDownloader() *DeezerDownloader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DeezerDownloader) GetTrackByISRC(isrc string) (*DeezerTrack, error) {
|
func (d *DeezerDownloader) GetDeezerURLFromSpotify(spotifyTrackID string) (string, error) {
|
||||||
// Decode base64 API URL
|
// Decode base64 API URL
|
||||||
apiBase, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly9hcGkuZGVlemVyLmNvbS8yLjAvdHJhY2svaXNyYzo=")
|
spotifyBase, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly9vcGVuLnNwb3RpZnkuY29tL3RyYWNrLw==")
|
||||||
url := fmt.Sprintf("%s%s", string(apiBase), isrc)
|
spotifyURL := fmt.Sprintf("%s%s", string(spotifyBase), spotifyTrackID)
|
||||||
|
|
||||||
|
apiBase, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly9hcGkuc29uZy5saW5rL3YxLWFscGhhLjEvbGlua3M/dXJsPQ==")
|
||||||
|
apiURL := fmt.Sprintf("%s%s", string(apiBase), spotifyURL)
|
||||||
|
|
||||||
|
req, err := http.NewRequest("GET", apiURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to create request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Getting Deezer URL...")
|
||||||
|
|
||||||
|
resp, err := d.client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to get Deezer URL: %w", err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
return "", fmt.Errorf("API returned status %d", resp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
var songLinkResp struct {
|
||||||
|
LinksByPlatform map[string]struct {
|
||||||
|
URL string `json:"url"`
|
||||||
|
} `json:"linksByPlatform"`
|
||||||
|
}
|
||||||
|
if err := json.NewDecoder(resp.Body).Decode(&songLinkResp); err != nil {
|
||||||
|
return "", fmt.Errorf("failed to decode response: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
deezerLink, ok := songLinkResp.LinksByPlatform["deezer"]
|
||||||
|
if !ok || deezerLink.URL == "" {
|
||||||
|
return "", fmt.Errorf("deezer link not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
deezerURL := deezerLink.URL
|
||||||
|
fmt.Printf("Found Deezer URL: %s\n", deezerURL)
|
||||||
|
return deezerURL, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DeezerDownloader) GetTrackIDFromURL(deezerURL string) (int64, error) {
|
||||||
|
// Extract track ID from Deezer URL
|
||||||
|
// Format: https://www.deezer.com/track/3412534581
|
||||||
|
parts := strings.Split(deezerURL, "/track/")
|
||||||
|
if len(parts) < 2 {
|
||||||
|
return 0, fmt.Errorf("invalid Deezer URL format")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the track ID part and remove any query parameters
|
||||||
|
trackIDStr := strings.Split(parts[1], "?")[0]
|
||||||
|
trackIDStr = strings.TrimSpace(trackIDStr)
|
||||||
|
|
||||||
|
var trackID int64
|
||||||
|
_, err := fmt.Sscanf(trackIDStr, "%d", &trackID)
|
||||||
|
if err != nil {
|
||||||
|
return 0, fmt.Errorf("failed to parse track ID: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return trackID, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DeezerDownloader) GetTrackByID(trackID int64) (*DeezerTrack, error) {
|
||||||
|
// Decode base64 API URL
|
||||||
|
apiBase, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly9hcGkuZGVlemVyLmNvbS8yLjAvdHJhY2sv")
|
||||||
|
url := fmt.Sprintf("%s%d", string(apiBase), trackID)
|
||||||
|
|
||||||
resp, err := d.client.Get(url)
|
resp, err := d.client.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -78,7 +142,7 @@ func (d *DeezerDownloader) GetTrackByISRC(isrc string) (*DeezerTrack, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if track.ID == 0 {
|
if track.ID == 0 {
|
||||||
return nil, fmt.Errorf("track not found for ISRC: %s", isrc)
|
return nil, fmt.Errorf("track not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &track, nil
|
return &track, nil
|
||||||
@@ -124,11 +188,16 @@ func (d *DeezerDownloader) DownloadFile(url, filepath string) error {
|
|||||||
}
|
}
|
||||||
defer out.Close()
|
defer out.Close()
|
||||||
|
|
||||||
_, err = io.Copy(out, resp.Body)
|
fmt.Println("Downloading...")
|
||||||
|
// Use progress writer to track download
|
||||||
|
pw := NewProgressWriter(out)
|
||||||
|
_, err = io.Copy(pw, resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to write file: %w", err)
|
return fmt.Errorf("failed to write file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Print final size
|
||||||
|
fmt.Printf("\rDownloaded: %.2f MB (Complete)\n", float64(pw.GetTotal())/(1024*1024))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,17 +226,7 @@ func (d *DeezerDownloader) DownloadCoverArt(coverURL, filepath string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func sanitizeFilename(name string) string {
|
func buildFilename(title, artist string, trackNumber int, format string, includeTrackNumber bool, position int, useAlbumTrackNumber bool) string {
|
||||||
re := regexp.MustCompile(`[<>:"/\\|?*]`)
|
|
||||||
sanitized := re.ReplaceAllString(name, "_")
|
|
||||||
sanitized = strings.TrimSpace(sanitized)
|
|
||||||
if sanitized == "" {
|
|
||||||
return "Unknown"
|
|
||||||
}
|
|
||||||
return sanitized
|
|
||||||
}
|
|
||||||
|
|
||||||
func buildFilename(title, artist string, trackNumber int, format string, includeTrackNumber bool) string {
|
|
||||||
var filename string
|
var filename string
|
||||||
|
|
||||||
// Build base filename based on format
|
// Build base filename based on format
|
||||||
@@ -181,19 +240,31 @@ func buildFilename(title, artist string, trackNumber int, format string, include
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add track number prefix if enabled
|
// Add track number prefix if enabled
|
||||||
if includeTrackNumber && trackNumber > 0 {
|
if includeTrackNumber && position > 0 {
|
||||||
filename = fmt.Sprintf("%02d. %s", trackNumber, filename)
|
// Use album track number if in album folder structure, otherwise use playlist position
|
||||||
|
numberToUse := position
|
||||||
|
if useAlbumTrackNumber && trackNumber > 0 {
|
||||||
|
numberToUse = trackNumber
|
||||||
|
}
|
||||||
|
filename = fmt.Sprintf("%02d. %s", numberToUse, filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
return filename + ".flac"
|
return filename + ".flac"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DeezerDownloader) DownloadByISRC(isrc, outputDir, filenameFormat string, includeTrackNumber bool, spotifyTrackName, spotifyArtistName, spotifyAlbumName string) error {
|
func (d *DeezerDownloader) DownloadByURL(deezerURL, outputDir, filenameFormat string, includeTrackNumber bool, position int, spotifyTrackName, spotifyArtistName, spotifyAlbumName string, useAlbumTrackNumber bool) (string, error) {
|
||||||
fmt.Printf("Fetching track info for ISRC: %s\n", isrc)
|
fmt.Printf("Using Deezer URL: %s\n", deezerURL)
|
||||||
|
|
||||||
track, err := d.GetTrackByISRC(isrc)
|
// Extract track ID from URL
|
||||||
|
trackID, err := d.GetTrackIDFromURL(deezerURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get track info by ID
|
||||||
|
track, err := d.GetTrackByID(trackID)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use Spotify metadata if provided, otherwise fallback to Deezer metadata
|
// Use Spotify metadata if provided, otherwise fallback to Deezer metadata
|
||||||
@@ -229,19 +300,30 @@ func (d *DeezerDownloader) DownloadByISRC(isrc, outputDir, filenameFormat string
|
|||||||
|
|
||||||
downloadURL, err := d.GetDownloadURL(track.ID)
|
downloadURL, err := d.GetDownloadURL(track.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
safeArtist := sanitizeFilename(artists)
|
safeArtist := sanitizeFilename(artists)
|
||||||
safeTitle := sanitizeFilename(trackTitle)
|
safeTitle := sanitizeFilename(trackTitle)
|
||||||
|
|
||||||
|
// Check if file with same ISRC already exists
|
||||||
|
if existingFile, exists := CheckISRCExists(outputDir, track.ISRC); exists {
|
||||||
|
fmt.Printf("File with ISRC %s already exists: %s\n", track.ISRC, existingFile)
|
||||||
|
return "EXISTS:" + existingFile, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Build filename based on format settings
|
// Build filename based on format settings
|
||||||
filename := buildFilename(safeTitle, safeArtist, track.TrackPos, filenameFormat, includeTrackNumber)
|
filename := buildFilename(safeTitle, safeArtist, track.TrackPos, filenameFormat, includeTrackNumber, position, useAlbumTrackNumber)
|
||||||
filepath := filepath.Join(outputDir, filename)
|
filepath := filepath.Join(outputDir, filename)
|
||||||
|
|
||||||
|
if fileInfo, err := os.Stat(filepath); err == nil && fileInfo.Size() > 0 {
|
||||||
|
fmt.Printf("File already exists: %s (%.2f MB)\n", filepath, float64(fileInfo.Size())/(1024*1024))
|
||||||
|
return "EXISTS:" + filepath, nil
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println("Downloading FLAC file...")
|
fmt.Println("Downloading FLAC file...")
|
||||||
if err := d.DownloadFile(downloadURL, filepath); err != nil {
|
if err := d.DownloadFile(downloadURL, filepath); err != nil {
|
||||||
return err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Downloaded: %s\n", filepath)
|
fmt.Printf("Downloaded: %s\n", filepath)
|
||||||
@@ -258,20 +340,41 @@ func (d *DeezerDownloader) DownloadByISRC(isrc, outputDir, filenameFormat string
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Embedding metadata and cover art...")
|
fmt.Println("Embedding metadata and cover art...")
|
||||||
|
// Use album track number if in album folder structure, otherwise use playlist position
|
||||||
|
trackNumberToEmbed := 0
|
||||||
|
if position > 0 {
|
||||||
|
if useAlbumTrackNumber && track.TrackPos > 0 {
|
||||||
|
trackNumberToEmbed = track.TrackPos
|
||||||
|
} else {
|
||||||
|
trackNumberToEmbed = position
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
metadata := Metadata{
|
metadata := Metadata{
|
||||||
Title: trackTitle,
|
Title: trackTitle,
|
||||||
Artist: artists,
|
Artist: artists,
|
||||||
Album: albumTitle,
|
Album: albumTitle,
|
||||||
Date: track.ReleaseDate,
|
Date: track.ReleaseDate,
|
||||||
TrackNumber: track.TrackPos,
|
TrackNumber: trackNumberToEmbed,
|
||||||
DiscNumber: track.DiskNumber,
|
DiscNumber: track.DiskNumber,
|
||||||
ISRC: track.ISRC,
|
ISRC: track.ISRC,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := EmbedMetadata(filepath, metadata, coverPath); err != nil {
|
if err := EmbedMetadata(filepath, metadata, coverPath); err != nil {
|
||||||
return fmt.Errorf("failed to embed metadata: %w", err)
|
return "", fmt.Errorf("failed to embed metadata: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Metadata embedded successfully!")
|
fmt.Println("Metadata embedded successfully!")
|
||||||
return nil
|
fmt.Println("✓ Downloaded successfully from Deezer")
|
||||||
|
return filepath, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DeezerDownloader) DownloadBySpotifyID(spotifyTrackID, outputDir, filenameFormat string, includeTrackNumber bool, position int, spotifyTrackName, spotifyArtistName, spotifyAlbumName string, useAlbumTrackNumber bool) (string, error) {
|
||||||
|
// Get Deezer URL from Spotify track ID
|
||||||
|
deezerURL, err := d.GetDeezerURLFromSpotify(spotifyTrackID)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return d.DownloadByURL(deezerURL, outputDir, filenameFormat, includeTrackNumber, position, spotifyTrackName, spotifyArtistName, spotifyAlbumName, useAlbumTrackNumber)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package backend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BuildExpectedFilename builds the expected filename based on track metadata and settings
|
||||||
|
func BuildExpectedFilename(trackName, artistName, filenameFormat string, includeTrackNumber bool, position int, useAlbumTrackNumber bool) string {
|
||||||
|
// Sanitize track name and artist name
|
||||||
|
safeTitle := sanitizeFilename(trackName)
|
||||||
|
safeArtist := sanitizeFilename(artistName)
|
||||||
|
|
||||||
|
var filename string
|
||||||
|
|
||||||
|
// Build base filename based on format
|
||||||
|
switch filenameFormat {
|
||||||
|
case "artist-title":
|
||||||
|
filename = fmt.Sprintf("%s - %s", safeArtist, safeTitle)
|
||||||
|
case "title":
|
||||||
|
filename = safeTitle
|
||||||
|
default: // "title-artist"
|
||||||
|
filename = fmt.Sprintf("%s - %s", safeTitle, safeArtist)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add track number prefix if enabled
|
||||||
|
// Note: We can't determine the exact track number without fetching from API
|
||||||
|
// So we only add it if position > 0 (bulk download)
|
||||||
|
if includeTrackNumber && position > 0 {
|
||||||
|
filename = fmt.Sprintf("%02d. %s", position, filename)
|
||||||
|
}
|
||||||
|
|
||||||
|
return filename + ".flac"
|
||||||
|
}
|
||||||
|
|
||||||
|
// sanitizeFilename removes invalid characters from filename
|
||||||
|
func sanitizeFilename(name string) string {
|
||||||
|
re := regexp.MustCompile(`[<>:"/\\|?*]`)
|
||||||
|
sanitized := re.ReplaceAllString(name, "_")
|
||||||
|
sanitized = strings.TrimSpace(sanitized)
|
||||||
|
if sanitized == "" {
|
||||||
|
return "Unknown"
|
||||||
|
}
|
||||||
|
return sanitized
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/go-flac/flacpicture"
|
"github.com/go-flac/flacpicture"
|
||||||
"github.com/go-flac/flacvorbis"
|
"github.com/go-flac/flacvorbis"
|
||||||
@@ -111,3 +112,73 @@ func fileExists(path string) bool {
|
|||||||
_, err := os.Stat(path)
|
_, err := os.Stat(path)
|
||||||
return err == nil
|
return err == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadISRCFromFile reads ISRC metadata from a FLAC file
|
||||||
|
func ReadISRCFromFile(filepath string) (string, error) {
|
||||||
|
if !fileExists(filepath) {
|
||||||
|
return "", fmt.Errorf("file does not exist")
|
||||||
|
}
|
||||||
|
|
||||||
|
f, err := flac.ParseFile(filepath)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to parse FLAC file: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find VorbisComment block
|
||||||
|
for _, block := range f.Meta {
|
||||||
|
if block.Type == flac.VorbisComment {
|
||||||
|
cmt, err := flacvorbis.ParseFromMetaDataBlock(*block)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get ISRC field
|
||||||
|
isrcValues, err := cmt.Get(flacvorbis.FIELD_ISRC)
|
||||||
|
if err == nil && len(isrcValues) > 0 {
|
||||||
|
return isrcValues[0], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", nil // No ISRC found
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckISRCExists checks if a file with the given ISRC already exists in the directory
|
||||||
|
func CheckISRCExists(outputDir string, targetISRC string) (string, bool) {
|
||||||
|
if targetISRC == "" {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read all .flac files in directory
|
||||||
|
entries, err := os.ReadDir(outputDir)
|
||||||
|
if err != nil {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, entry := range entries {
|
||||||
|
if entry.IsDir() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check only .flac files
|
||||||
|
filename := entry.Name()
|
||||||
|
if len(filename) < 5 || filename[len(filename)-5:] != ".flac" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
filepath := fmt.Sprintf("%s/%s", outputDir, filename)
|
||||||
|
|
||||||
|
// Read ISRC from file
|
||||||
|
isrc, err := ReadISRCFromFile(filepath)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare ISRC (case-insensitive)
|
||||||
|
if isrc != "" && strings.EqualFold(isrc, targetISRC) {
|
||||||
|
return filepath, true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,135 @@
|
|||||||
|
package backend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Global progress tracker
|
||||||
|
var (
|
||||||
|
currentProgress float64
|
||||||
|
currentProgressLock sync.RWMutex
|
||||||
|
isDownloading bool
|
||||||
|
downloadingLock sync.RWMutex
|
||||||
|
currentSpeed float64
|
||||||
|
speedLock sync.RWMutex
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProgressInfo represents download progress information
|
||||||
|
type ProgressInfo struct {
|
||||||
|
IsDownloading bool `json:"is_downloading"`
|
||||||
|
MBDownloaded float64 `json:"mb_downloaded"`
|
||||||
|
SpeedMBps float64 `json:"speed_mbps"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDownloadProgress returns current download progress
|
||||||
|
func GetDownloadProgress() ProgressInfo {
|
||||||
|
downloadingLock.RLock()
|
||||||
|
downloading := isDownloading
|
||||||
|
downloadingLock.RUnlock()
|
||||||
|
|
||||||
|
currentProgressLock.RLock()
|
||||||
|
progress := currentProgress
|
||||||
|
currentProgressLock.RUnlock()
|
||||||
|
|
||||||
|
speedLock.RLock()
|
||||||
|
speed := currentSpeed
|
||||||
|
speedLock.RUnlock()
|
||||||
|
|
||||||
|
return ProgressInfo{
|
||||||
|
IsDownloading: downloading,
|
||||||
|
MBDownloaded: progress,
|
||||||
|
SpeedMBps: speed,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetDownloadSpeed updates the current download speed
|
||||||
|
func SetDownloadSpeed(mbps float64) {
|
||||||
|
speedLock.Lock()
|
||||||
|
currentSpeed = mbps
|
||||||
|
speedLock.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetDownloadProgress updates the current download progress
|
||||||
|
func SetDownloadProgress(mbDownloaded float64) {
|
||||||
|
currentProgressLock.Lock()
|
||||||
|
currentProgress = mbDownloaded
|
||||||
|
currentProgressLock.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetDownloading sets the downloading state
|
||||||
|
func SetDownloading(downloading bool) {
|
||||||
|
downloadingLock.Lock()
|
||||||
|
isDownloading = downloading
|
||||||
|
downloadingLock.Unlock()
|
||||||
|
|
||||||
|
if !downloading {
|
||||||
|
// Reset progress when download completes
|
||||||
|
SetDownloadProgress(0)
|
||||||
|
SetDownloadSpeed(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProgressWriter wraps an io.Writer and reports download progress
|
||||||
|
type ProgressWriter struct {
|
||||||
|
writer io.Writer
|
||||||
|
total int64
|
||||||
|
lastPrinted int64
|
||||||
|
startTime int64
|
||||||
|
lastTime int64
|
||||||
|
lastBytes int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewProgressWriter(writer io.Writer) *ProgressWriter {
|
||||||
|
now := getCurrentTimeMillis()
|
||||||
|
return &ProgressWriter{
|
||||||
|
writer: writer,
|
||||||
|
total: 0,
|
||||||
|
lastPrinted: 0,
|
||||||
|
startTime: now,
|
||||||
|
lastTime: now,
|
||||||
|
lastBytes: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getCurrentTimeMillis() int64 {
|
||||||
|
return time.Now().UnixMilli()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pw *ProgressWriter) Write(p []byte) (int, error) {
|
||||||
|
n, err := pw.writer.Write(p)
|
||||||
|
pw.total += int64(n)
|
||||||
|
|
||||||
|
// Report progress every 256KB for smoother updates
|
||||||
|
if pw.total-pw.lastPrinted >= 256*1024 {
|
||||||
|
mbDownloaded := float64(pw.total) / (1024 * 1024)
|
||||||
|
|
||||||
|
// Calculate speed (MB/s)
|
||||||
|
now := getCurrentTimeMillis()
|
||||||
|
timeDiff := float64(now-pw.lastTime) / 1000.0 // seconds
|
||||||
|
bytesDiff := float64(pw.total - pw.lastBytes)
|
||||||
|
|
||||||
|
if timeDiff > 0 {
|
||||||
|
speedMBps := (bytesDiff / (1024 * 1024)) / timeDiff
|
||||||
|
SetDownloadSpeed(speedMBps)
|
||||||
|
fmt.Printf("\rDownloaded: %.2f MB (%.2f MB/s)", mbDownloaded, speedMBps)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("\rDownloaded: %.2f MB", mbDownloaded)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update global progress
|
||||||
|
SetDownloadProgress(mbDownloaded)
|
||||||
|
|
||||||
|
pw.lastPrinted = pw.total
|
||||||
|
pw.lastTime = now
|
||||||
|
pw.lastBytes = pw.total
|
||||||
|
}
|
||||||
|
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pw *ProgressWriter) GetTotal() int64 {
|
||||||
|
return pw.total
|
||||||
|
}
|
||||||
+45
-16
@@ -184,13 +184,16 @@ func (q *QobuzDownloader) DownloadFile(url, filepath string) error {
|
|||||||
}
|
}
|
||||||
defer out.Close()
|
defer out.Close()
|
||||||
|
|
||||||
fmt.Println("Writing file content...")
|
fmt.Println("Downloading...")
|
||||||
written, err := io.Copy(out, resp.Body)
|
// Use progress writer to track download
|
||||||
|
pw := NewProgressWriter(out)
|
||||||
|
_, err = io.Copy(pw, resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to write file: %w", err)
|
return fmt.Errorf("failed to write file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("✓ Downloaded %d bytes\n", written)
|
// Print final size
|
||||||
|
fmt.Printf("\rDownloaded: %.2f MB (Complete)\n", float64(pw.GetTotal())/(1024*1024))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +222,7 @@ func (q *QobuzDownloader) DownloadCoverArt(coverURL, filepath string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildQobuzFilename(title, artist string, trackNumber int, format string, includeTrackNumber bool) string {
|
func buildQobuzFilename(title, artist string, trackNumber int, format string, includeTrackNumber bool, position int, useAlbumTrackNumber bool) string {
|
||||||
var filename string
|
var filename string
|
||||||
|
|
||||||
// Build base filename based on format
|
// Build base filename based on format
|
||||||
@@ -233,26 +236,31 @@ func buildQobuzFilename(title, artist string, trackNumber int, format string, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add track number prefix if enabled
|
// Add track number prefix if enabled
|
||||||
if includeTrackNumber && trackNumber > 0 {
|
if includeTrackNumber && position > 0 {
|
||||||
filename = fmt.Sprintf("%02d. %s", trackNumber, filename)
|
// Use album track number if in album folder structure, otherwise use playlist position
|
||||||
|
numberToUse := position
|
||||||
|
if useAlbumTrackNumber && trackNumber > 0 {
|
||||||
|
numberToUse = trackNumber
|
||||||
|
}
|
||||||
|
filename = fmt.Sprintf("%02d. %s", numberToUse, filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
return filename + ".flac"
|
return filename + ".flac"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *QobuzDownloader) DownloadByISRC(isrc, outputDir, quality, filenameFormat string, includeTrackNumber bool, spotifyTrackName, spotifyArtistName, spotifyAlbumName string) error {
|
func (q *QobuzDownloader) DownloadByISRC(isrc, outputDir, quality, filenameFormat string, includeTrackNumber bool, position int, spotifyTrackName, spotifyArtistName, spotifyAlbumName string, useAlbumTrackNumber bool) (string, error) {
|
||||||
fmt.Printf("Fetching track info for ISRC: %s\n", isrc)
|
fmt.Printf("Fetching track info for ISRC: %s\n", isrc)
|
||||||
|
|
||||||
// Create output directory if it doesn't exist
|
// Create output directory if it doesn't exist
|
||||||
if outputDir != "." {
|
if outputDir != "." {
|
||||||
if err := os.MkdirAll(outputDir, 0755); err != nil {
|
if err := os.MkdirAll(outputDir, 0755); err != nil {
|
||||||
return fmt.Errorf("failed to create output directory: %w", err)
|
return "", fmt.Errorf("failed to create output directory: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
track, err := q.SearchByISRC(isrc)
|
track, err := q.SearchByISRC(isrc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use Spotify metadata if provided, otherwise fallback to Qobuz metadata
|
// Use Spotify metadata if provided, otherwise fallback to Qobuz metadata
|
||||||
@@ -290,11 +298,11 @@ func (q *QobuzDownloader) DownloadByISRC(isrc, outputDir, quality, filenameForma
|
|||||||
fmt.Println("Getting download URL...")
|
fmt.Println("Getting download URL...")
|
||||||
downloadURL, err := q.GetDownloadURL(track.ID, quality)
|
downloadURL, err := q.GetDownloadURL(track.ID, quality)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get download URL: %w", err)
|
return "", fmt.Errorf("failed to get download URL: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if downloadURL == "" {
|
if downloadURL == "" {
|
||||||
return fmt.Errorf("received empty download URL")
|
return "", fmt.Errorf("received empty download URL")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show partial URL for security
|
// Show partial URL for security
|
||||||
@@ -307,13 +315,24 @@ func (q *QobuzDownloader) DownloadByISRC(isrc, outputDir, quality, filenameForma
|
|||||||
safeArtist := sanitizeFilename(artists)
|
safeArtist := sanitizeFilename(artists)
|
||||||
safeTitle := sanitizeFilename(trackTitle)
|
safeTitle := sanitizeFilename(trackTitle)
|
||||||
|
|
||||||
|
// Check if file with same ISRC already exists
|
||||||
|
if existingFile, exists := CheckISRCExists(outputDir, track.ISRC); exists {
|
||||||
|
fmt.Printf("File with ISRC %s already exists: %s\n", track.ISRC, existingFile)
|
||||||
|
return "EXISTS:" + existingFile, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Build filename based on format settings
|
// Build filename based on format settings
|
||||||
filename := buildQobuzFilename(safeTitle, safeArtist, track.TrackNumber, filenameFormat, includeTrackNumber)
|
filename := buildQobuzFilename(safeTitle, safeArtist, track.TrackNumber, filenameFormat, includeTrackNumber, position, useAlbumTrackNumber)
|
||||||
filepath := filepath.Join(outputDir, filename)
|
filepath := filepath.Join(outputDir, filename)
|
||||||
|
|
||||||
|
if fileInfo, err := os.Stat(filepath); err == nil && fileInfo.Size() > 0 {
|
||||||
|
fmt.Printf("File already exists: %s (%.2f MB)\n", filepath, float64(fileInfo.Size())/(1024*1024))
|
||||||
|
return "EXISTS:" + filepath, nil
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Printf("Downloading FLAC file to: %s\n", filepath)
|
fmt.Printf("Downloading FLAC file to: %s\n", filepath)
|
||||||
if err := q.DownloadFile(downloadURL, filepath); err != nil {
|
if err := q.DownloadFile(downloadURL, filepath); err != nil {
|
||||||
return fmt.Errorf("failed to download file: %w", err)
|
return "", fmt.Errorf("failed to download file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Downloaded: %s\n", filepath)
|
fmt.Printf("Downloaded: %s\n", filepath)
|
||||||
@@ -336,20 +355,30 @@ func (q *QobuzDownloader) DownloadByISRC(isrc, outputDir, quality, filenameForma
|
|||||||
releaseYear = track.ReleaseDateOriginal[:4]
|
releaseYear = track.ReleaseDateOriginal[:4]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use album track number if in album folder structure, otherwise use playlist position
|
||||||
|
trackNumberToEmbed := 0
|
||||||
|
if position > 0 {
|
||||||
|
if useAlbumTrackNumber && track.TrackNumber > 0 {
|
||||||
|
trackNumberToEmbed = track.TrackNumber
|
||||||
|
} else {
|
||||||
|
trackNumberToEmbed = position
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
metadata := Metadata{
|
metadata := Metadata{
|
||||||
Title: trackTitle,
|
Title: trackTitle,
|
||||||
Artist: artists,
|
Artist: artists,
|
||||||
Album: albumTitle,
|
Album: albumTitle,
|
||||||
Date: releaseYear,
|
Date: releaseYear,
|
||||||
TrackNumber: track.TrackNumber,
|
TrackNumber: trackNumberToEmbed,
|
||||||
DiscNumber: track.MediaNumber,
|
DiscNumber: track.MediaNumber,
|
||||||
ISRC: track.ISRC,
|
ISRC: track.ISRC,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := EmbedMetadata(filepath, metadata, coverPath); err != nil {
|
if err := EmbedMetadata(filepath, metadata, coverPath); err != nil {
|
||||||
return fmt.Errorf("failed to embed metadata: %w", err)
|
return "", fmt.Errorf("failed to embed metadata: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Metadata embedded successfully!")
|
fmt.Println("Metadata embedded successfully!")
|
||||||
return nil
|
return filepath, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,150 @@
|
|||||||
|
package backend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SongLinkClient struct {
|
||||||
|
client *http.Client
|
||||||
|
lastAPICallTime time.Time
|
||||||
|
apiCallCount int
|
||||||
|
apiCallResetTime time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
type SongLinkURLs struct {
|
||||||
|
TidalURL string `json:"tidal_url"`
|
||||||
|
DeezerURL string `json:"deezer_url"`
|
||||||
|
AmazonURL string `json:"amazon_url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSongLinkClient() *SongLinkClient {
|
||||||
|
return &SongLinkClient{
|
||||||
|
client: &http.Client{
|
||||||
|
Timeout: 30 * time.Second,
|
||||||
|
},
|
||||||
|
apiCallResetTime: time.Now(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SongLinkClient) GetAllURLsFromSpotify(spotifyTrackID string) (*SongLinkURLs, error) {
|
||||||
|
// Rate limiting: max 10 requests per minute (song.link API limit)
|
||||||
|
now := time.Now()
|
||||||
|
if now.Sub(s.apiCallResetTime) >= time.Minute {
|
||||||
|
s.apiCallCount = 0
|
||||||
|
s.apiCallResetTime = now
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we've hit the limit, wait until the next minute
|
||||||
|
if s.apiCallCount >= 9 {
|
||||||
|
waitTime := time.Minute - now.Sub(s.apiCallResetTime)
|
||||||
|
if waitTime > 0 {
|
||||||
|
fmt.Printf("Rate limit reached, waiting %v...\n", waitTime.Round(time.Second))
|
||||||
|
time.Sleep(waitTime)
|
||||||
|
s.apiCallCount = 0
|
||||||
|
s.apiCallResetTime = time.Now()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add delay between requests (7 seconds to be safe)
|
||||||
|
if !s.lastAPICallTime.IsZero() {
|
||||||
|
timeSinceLastCall := now.Sub(s.lastAPICallTime)
|
||||||
|
minDelay := 7 * time.Second
|
||||||
|
if timeSinceLastCall < minDelay {
|
||||||
|
waitTime := minDelay - timeSinceLastCall
|
||||||
|
fmt.Printf("Rate limiting: waiting %v...\n", waitTime.Round(time.Second))
|
||||||
|
time.Sleep(waitTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode base64 API URL
|
||||||
|
spotifyBase, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly9vcGVuLnNwb3RpZnkuY29tL3RyYWNrLw==")
|
||||||
|
spotifyURL := fmt.Sprintf("%s%s", string(spotifyBase), spotifyTrackID)
|
||||||
|
|
||||||
|
apiBase, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly9hcGkuc29uZy5saW5rL3YxLWFscGhhLjEvbGlua3M/dXJsPQ==")
|
||||||
|
apiURL := fmt.Sprintf("%s%s", string(apiBase), url.QueryEscape(spotifyURL))
|
||||||
|
|
||||||
|
req, err := http.NewRequest("GET", apiURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to create request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Getting streaming URLs from song.link...")
|
||||||
|
|
||||||
|
// Retry logic for rate limit errors
|
||||||
|
maxRetries := 3
|
||||||
|
var resp *http.Response
|
||||||
|
for i := 0; i < maxRetries; i++ {
|
||||||
|
resp, err = s.client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to get URLs: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update rate limit tracking
|
||||||
|
s.lastAPICallTime = time.Now()
|
||||||
|
s.apiCallCount++
|
||||||
|
|
||||||
|
if resp.StatusCode == 429 {
|
||||||
|
resp.Body.Close()
|
||||||
|
if i < maxRetries-1 {
|
||||||
|
waitTime := 15 * time.Second
|
||||||
|
fmt.Printf("Rate limited by API, waiting %v before retry...\n", waitTime)
|
||||||
|
time.Sleep(waitTime)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("API rate limit exceeded after %d retries", maxRetries)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
resp.Body.Close()
|
||||||
|
return nil, fmt.Errorf("API returned status %d", resp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
var songLinkResp struct {
|
||||||
|
LinksByPlatform map[string]struct {
|
||||||
|
URL string `json:"url"`
|
||||||
|
} `json:"linksByPlatform"`
|
||||||
|
}
|
||||||
|
if err := json.NewDecoder(resp.Body).Decode(&songLinkResp); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to decode response: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
urls := &SongLinkURLs{}
|
||||||
|
|
||||||
|
// Extract Tidal URL
|
||||||
|
if tidalLink, ok := songLinkResp.LinksByPlatform["tidal"]; ok && tidalLink.URL != "" {
|
||||||
|
urls.TidalURL = tidalLink.URL
|
||||||
|
fmt.Printf("✓ Tidal URL found\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract Deezer URL
|
||||||
|
if deezerLink, ok := songLinkResp.LinksByPlatform["deezer"]; ok && deezerLink.URL != "" {
|
||||||
|
urls.DeezerURL = deezerLink.URL
|
||||||
|
fmt.Printf("✓ Deezer URL found\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract Amazon URL
|
||||||
|
if amazonLink, ok := songLinkResp.LinksByPlatform["amazonMusic"]; ok && amazonLink.URL != "" {
|
||||||
|
amazonURL := amazonLink.URL
|
||||||
|
// Convert album URL to track URL if needed
|
||||||
|
if len(amazonURL) > 0 {
|
||||||
|
urls.AmazonURL = amazonURL
|
||||||
|
fmt.Printf("✓ Amazon URL found\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if at least one URL was found
|
||||||
|
if urls.TidalURL == "" && urls.DeezerURL == "" && urls.AmazonURL == "" {
|
||||||
|
return nil, fmt.Errorf("no streaming URLs found")
|
||||||
|
}
|
||||||
|
|
||||||
|
return urls, nil
|
||||||
|
}
|
||||||
@@ -29,7 +29,7 @@ const (
|
|||||||
trackBaseURL = "https://api.spotify.com/v1/tracks/%s"
|
trackBaseURL = "https://api.spotify.com/v1/tracks/%s"
|
||||||
artistBaseURL = "https://api.spotify.com/v1/artists/%s"
|
artistBaseURL = "https://api.spotify.com/v1/artists/%s"
|
||||||
artistAlbumsBaseURL = "https://api.spotify.com/v1/artists/%s/albums"
|
artistAlbumsBaseURL = "https://api.spotify.com/v1/artists/%s/albums"
|
||||||
secretBytesRemotePath = "https://raw.githubusercontent.com/afkarxyz/secretBytes/refs/heads/main/secrets/secretBytes.json"
|
secretBytesRemotePath = "https://cdn.jsdelivr.net/gh/afkarxyz/secretBytes@refs/heads/main/secrets/secretBytes.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -66,6 +66,7 @@ type TrackMetadata struct {
|
|||||||
TrackNumber int `json:"track_number"`
|
TrackNumber int `json:"track_number"`
|
||||||
ExternalURL string `json:"external_urls"`
|
ExternalURL string `json:"external_urls"`
|
||||||
ISRC string `json:"isrc"`
|
ISRC string `json:"isrc"`
|
||||||
|
SpotifyID string `json:"spotify_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AlbumTrackMetadata holds per-track info for album / playlist formatting.
|
// AlbumTrackMetadata holds per-track info for album / playlist formatting.
|
||||||
@@ -80,6 +81,7 @@ type AlbumTrackMetadata struct {
|
|||||||
ExternalURL string `json:"external_urls"`
|
ExternalURL string `json:"external_urls"`
|
||||||
ISRC string `json:"isrc"`
|
ISRC string `json:"isrc"`
|
||||||
AlbumType string `json:"album_type,omitempty"`
|
AlbumType string `json:"album_type,omitempty"`
|
||||||
|
SpotifyID string `json:"spotify_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TrackResponse struct {
|
type TrackResponse struct {
|
||||||
@@ -269,11 +271,6 @@ type artistResponse struct {
|
|||||||
Popularity int `json:"popularity"`
|
Popularity int `json:"popularity"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type artistAlbumsResponse struct {
|
|
||||||
Items []albumSimplified `json:"items"`
|
|
||||||
Next string `json:"next"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type playlistRaw struct {
|
type playlistRaw struct {
|
||||||
Data playlistResponse
|
Data playlistResponse
|
||||||
BatchEnabled bool
|
BatchEnabled bool
|
||||||
@@ -319,7 +316,7 @@ func (c *SpotifyMetadataClient) GetFilteredData(ctx context.Context, spotifyURL
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.processSpotifyData(ctx, raw, parsed.Type)
|
return c.processSpotifyData(ctx, raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *SpotifyMetadataClient) getRawSpotifyData(ctx context.Context, parsed spotifyURI, token string, batch bool, delay time.Duration) (interface{}, error) {
|
func (c *SpotifyMetadataClient) getRawSpotifyData(ctx context.Context, parsed spotifyURI, token string, batch bool, delay time.Duration) (interface{}, error) {
|
||||||
@@ -339,7 +336,7 @@ func (c *SpotifyMetadataClient) getRawSpotifyData(ctx context.Context, parsed sp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *SpotifyMetadataClient) processSpotifyData(ctx context.Context, raw interface{}, dataType string) (interface{}, error) {
|
func (c *SpotifyMetadataClient) processSpotifyData(ctx context.Context, raw interface{}) (interface{}, error) {
|
||||||
switch payload := raw.(type) {
|
switch payload := raw.(type) {
|
||||||
case *playlistRaw:
|
case *playlistRaw:
|
||||||
return c.formatPlaylistData(payload), nil
|
return c.formatPlaylistData(payload), nil
|
||||||
@@ -487,6 +484,7 @@ func (c *SpotifyMetadataClient) formatPlaylistData(raw *playlistRaw) PlaylistRes
|
|||||||
TrackNumber: item.Track.TrackNumber,
|
TrackNumber: item.Track.TrackNumber,
|
||||||
ExternalURL: item.Track.ExternalURL.Spotify,
|
ExternalURL: item.Track.ExternalURL.Spotify,
|
||||||
ISRC: item.Track.ExternalID.ISRC,
|
ISRC: item.Track.ExternalID.ISRC,
|
||||||
|
SpotifyID: item.Track.ID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,6 +521,7 @@ func (c *SpotifyMetadataClient) formatAlbumData(ctx context.Context, raw *albumR
|
|||||||
TrackNumber: item.TrackNumber,
|
TrackNumber: item.TrackNumber,
|
||||||
ExternalURL: item.ExternalURL.Spotify,
|
ExternalURL: item.ExternalURL.Spotify,
|
||||||
ISRC: isrc,
|
ISRC: isrc,
|
||||||
|
SpotifyID: item.ID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,6 +587,7 @@ func (c *SpotifyMetadataClient) formatArtistDiscographyData(ctx context.Context,
|
|||||||
TrackNumber: tr.TrackNumber,
|
TrackNumber: tr.TrackNumber,
|
||||||
ExternalURL: tr.ExternalURL.Spotify,
|
ExternalURL: tr.ExternalURL.Spotify,
|
||||||
ISRC: isrc,
|
ISRC: isrc,
|
||||||
|
SpotifyID: tr.ID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -628,6 +628,7 @@ func formatTrackData(raw *trackFull) TrackResponse {
|
|||||||
TrackNumber: raw.TrackNumber,
|
TrackNumber: raw.TrackNumber,
|
||||||
ExternalURL: raw.ExternalURL.Spotify,
|
ExternalURL: raw.ExternalURL.Spotify,
|
||||||
ISRC: raw.ExternalID.ISRC,
|
ISRC: raw.ExternalID.ISRC,
|
||||||
|
SpotifyID: raw.ID,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -873,8 +874,16 @@ func (c *SpotifyMetadataClient) generateTOTP(ctx context.Context) (string, int64
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *SpotifyMetadataClient) fetchSecretBytes(ctx context.Context) ([]secretEntry, bool, error) {
|
func (c *SpotifyMetadataClient) fetchSecretBytes(ctx context.Context) ([]secretEntry, bool, error) {
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, secretBytesRemotePath, nil)
|
// Add cache busting parameter with current timestamp
|
||||||
|
urlWithCacheBust := fmt.Sprintf("%s?t=%d", secretBytesRemotePath, time.Now().Unix())
|
||||||
|
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, urlWithCacheBust, nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
// Add headers to bypass cache
|
||||||
|
req.Header.Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||||
|
req.Header.Set("Pragma", "no-cache")
|
||||||
|
req.Header.Set("Expires", "0")
|
||||||
|
|
||||||
resp, err := c.httpClient.Do(req)
|
resp, err := c.httpClient.Do(req)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
body, readErr := io.ReadAll(resp.Body)
|
body, readErr := io.ReadAll(resp.Body)
|
||||||
|
|||||||
+211
-87
@@ -22,13 +22,6 @@ type TidalDownloader struct {
|
|||||||
apiURL string
|
apiURL string
|
||||||
}
|
}
|
||||||
|
|
||||||
type TidalSearchResponse struct {
|
|
||||||
Limit int `json:"limit"`
|
|
||||||
Offset int `json:"offset"`
|
|
||||||
TotalNumberOfItems int `json:"totalNumberOfItems"`
|
|
||||||
Items []TidalTrack `json:"items"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TidalTrack struct {
|
type TidalTrack struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
@@ -68,6 +61,26 @@ func NewTidalDownloader(apiURL string) *TidalDownloader {
|
|||||||
clientID, _ := base64.StdEncoding.DecodeString("NkJEU1JkcEs5aHFFQlRnVQ==")
|
clientID, _ := base64.StdEncoding.DecodeString("NkJEU1JkcEs5aHFFQlRnVQ==")
|
||||||
clientSecret, _ := base64.StdEncoding.DecodeString("eGV1UG1ZN25icFo5SUliTEFjUTkzc2hrYTFWTmhlVUFxTjZJY3N6alRHOD0=")
|
clientSecret, _ := base64.StdEncoding.DecodeString("eGV1UG1ZN25icFo5SUliTEFjUTkzc2hrYTFWTmhlVUFxTjZJY3N6alRHOD0=")
|
||||||
|
|
||||||
|
// If apiURL is empty, try to get first available API
|
||||||
|
if apiURL == "" {
|
||||||
|
downloader := &TidalDownloader{
|
||||||
|
client: &http.Client{
|
||||||
|
Timeout: 60 * time.Second,
|
||||||
|
},
|
||||||
|
timeout: 30 * time.Second,
|
||||||
|
maxRetries: 3,
|
||||||
|
clientID: string(clientID),
|
||||||
|
clientSecret: string(clientSecret),
|
||||||
|
apiURL: "",
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to get available APIs
|
||||||
|
apis, err := downloader.GetAvailableAPIs()
|
||||||
|
if err == nil && len(apis) > 0 {
|
||||||
|
apiURL = apis[0] // Use first available API
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &TidalDownloader{
|
return &TidalDownloader{
|
||||||
client: &http.Client{
|
client: &http.Client{
|
||||||
Timeout: 60 * time.Second,
|
Timeout: 60 * time.Second,
|
||||||
@@ -83,7 +96,22 @@ func NewTidalDownloader(apiURL string) *TidalDownloader {
|
|||||||
func (t *TidalDownloader) GetAvailableAPIs() ([]string, error) {
|
func (t *TidalDownloader) GetAvailableAPIs() ([]string, error) {
|
||||||
// Decode base64 API URL
|
// Decode base64 API URL
|
||||||
apiURL, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2Fma2FyeHl6L1Nwb3RpRkxBQy9yZWZzL2hlYWRzL21haW4vdGlkYWwuanNvbg==")
|
apiURL, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2Fma2FyeHl6L1Nwb3RpRkxBQy9yZWZzL2hlYWRzL21haW4vdGlkYWwuanNvbg==")
|
||||||
resp, err := http.Get(string(apiURL))
|
|
||||||
|
// Add cache-busting parameter with current timestamp
|
||||||
|
urlWithCacheBust := fmt.Sprintf("%s?t=%d", string(apiURL), time.Now().Unix())
|
||||||
|
|
||||||
|
// Create request with cache bypass headers
|
||||||
|
req, err := http.NewRequest("GET", urlWithCacheBust, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to create request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add headers to bypass cache
|
||||||
|
req.Header.Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||||
|
req.Header.Set("Pragma", "no-cache")
|
||||||
|
req.Header.Set("Expires", "0")
|
||||||
|
|
||||||
|
resp, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to fetch API list: %w", err)
|
return nil, fmt.Errorf("failed to fetch API list: %w", err)
|
||||||
}
|
}
|
||||||
@@ -140,17 +168,83 @@ func (t *TidalDownloader) GetAccessToken() (string, error) {
|
|||||||
return result.AccessToken, nil
|
return result.AccessToken, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TidalDownloader) SearchTracks(query string) (*TidalSearchResponse, error) {
|
func (t *TidalDownloader) GetTidalURLFromSpotify(spotifyTrackID string) (string, error) {
|
||||||
|
// Decode base64 API URL
|
||||||
|
spotifyBase, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly9vcGVuLnNwb3RpZnkuY29tL3RyYWNrLw==")
|
||||||
|
spotifyURL := fmt.Sprintf("%s%s", string(spotifyBase), spotifyTrackID)
|
||||||
|
|
||||||
|
apiBase, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly9hcGkuc29uZy5saW5rL3YxLWFscGhhLjEvbGlua3M/dXJsPQ==")
|
||||||
|
apiURL := fmt.Sprintf("%s%s", string(apiBase), url.QueryEscape(spotifyURL))
|
||||||
|
|
||||||
|
req, err := http.NewRequest("GET", apiURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to create request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Getting Tidal URL...")
|
||||||
|
|
||||||
|
resp, err := t.client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to get Tidal URL: %w", err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
return "", fmt.Errorf("API returned status %d", resp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
var songLinkResp struct {
|
||||||
|
LinksByPlatform map[string]struct {
|
||||||
|
URL string `json:"url"`
|
||||||
|
} `json:"linksByPlatform"`
|
||||||
|
}
|
||||||
|
if err := json.NewDecoder(resp.Body).Decode(&songLinkResp); err != nil {
|
||||||
|
return "", fmt.Errorf("failed to decode response: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
tidalLink, ok := songLinkResp.LinksByPlatform["tidal"]
|
||||||
|
if !ok || tidalLink.URL == "" {
|
||||||
|
return "", fmt.Errorf("tidal link not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
tidalURL := tidalLink.URL
|
||||||
|
fmt.Printf("Found Tidal URL: %s\n", tidalURL)
|
||||||
|
return tidalURL, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TidalDownloader) GetTrackIDFromURL(tidalURL string) (int64, error) {
|
||||||
|
// Extract track ID from Tidal URL
|
||||||
|
// Format: https://listen.tidal.com/track/441821360
|
||||||
|
// or: https://tidal.com/browse/track/123456789
|
||||||
|
parts := strings.Split(tidalURL, "/track/")
|
||||||
|
if len(parts) < 2 {
|
||||||
|
return 0, fmt.Errorf("invalid tidal URL format")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the track ID part and remove any query parameters
|
||||||
|
trackIDStr := strings.Split(parts[1], "?")[0]
|
||||||
|
trackIDStr = strings.TrimSpace(trackIDStr)
|
||||||
|
|
||||||
|
var trackID int64
|
||||||
|
_, err := fmt.Sscanf(trackIDStr, "%d", &trackID)
|
||||||
|
if err != nil {
|
||||||
|
return 0, fmt.Errorf("failed to parse track ID: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return trackID, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TidalDownloader) GetTrackInfoByID(trackID int64) (*TidalTrack, error) {
|
||||||
token, err := t.GetAccessToken()
|
token, err := t.GetAccessToken()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get access token: %w", err)
|
return nil, fmt.Errorf("failed to get access token: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode base64 API URL and encode the query parameter
|
// Decode base64 API URL
|
||||||
searchBase, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly9hcGkudGlkYWwuY29tL3YxL3NlYXJjaC90cmFja3M/cXVlcnk9")
|
trackBase, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly9hcGkudGlkYWwuY29tL3YxL3RyYWNrcy8=")
|
||||||
searchURL := fmt.Sprintf("%s%s&limit=25&offset=0&countryCode=US", string(searchBase), url.QueryEscape(query))
|
trackURL := fmt.Sprintf("%s%d?countryCode=US", string(trackBase), trackID)
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", searchURL, nil)
|
req, err := http.NewRequest("GET", trackURL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -165,106 +259,55 @@ func (t *TidalDownloader) SearchTracks(query string) (*TidalSearchResponse, erro
|
|||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
body, _ := io.ReadAll(resp.Body)
|
body, _ := io.ReadAll(resp.Body)
|
||||||
return nil, fmt.Errorf("search failed: HTTP %d - %s", resp.StatusCode, string(body))
|
return nil, fmt.Errorf("failed to get track info: HTTP %d - %s", resp.StatusCode, string(body))
|
||||||
}
|
}
|
||||||
|
|
||||||
var result TidalSearchResponse
|
var trackInfo TidalTrack
|
||||||
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
|
if err := json.NewDecoder(resp.Body).Decode(&trackInfo); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &result, nil
|
fmt.Printf("Found: %s (%s)\n", trackInfo.Title, trackInfo.AudioQuality)
|
||||||
}
|
return &trackInfo, nil
|
||||||
|
|
||||||
func (t *TidalDownloader) GetTrackInfo(query, isrc string) (*TidalTrack, error) {
|
|
||||||
fmt.Printf("Fetching: %s", query)
|
|
||||||
if isrc != "" {
|
|
||||||
fmt.Printf(" (ISRC: %s)", isrc)
|
|
||||||
}
|
|
||||||
fmt.Println()
|
|
||||||
|
|
||||||
result, err := t.SearchTracks(query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(result.Items) == 0 {
|
|
||||||
return nil, fmt.Errorf("no tracks found for query: %s", query)
|
|
||||||
}
|
|
||||||
|
|
||||||
var selectedTrack *TidalTrack
|
|
||||||
|
|
||||||
if isrc != "" {
|
|
||||||
var isrcMatches []TidalTrack
|
|
||||||
for _, item := range result.Items {
|
|
||||||
if item.ISRC == isrc {
|
|
||||||
isrcMatches = append(isrcMatches, item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(isrcMatches) > 1 {
|
|
||||||
for _, item := range isrcMatches {
|
|
||||||
for _, tag := range item.MediaMetadata.Tags {
|
|
||||||
if tag == "HIRES_LOSSLESS" {
|
|
||||||
selectedTrack = &item
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if selectedTrack != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if selectedTrack == nil {
|
|
||||||
selectedTrack = &isrcMatches[0]
|
|
||||||
}
|
|
||||||
} else if len(isrcMatches) == 1 {
|
|
||||||
selectedTrack = &isrcMatches[0]
|
|
||||||
} else {
|
|
||||||
selectedTrack = &result.Items[0]
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
selectedTrack = &result.Items[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
if selectedTrack == nil {
|
|
||||||
return nil, fmt.Errorf("track not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("Found: %s (%s)\n", selectedTrack.Title, selectedTrack.AudioQuality)
|
|
||||||
return selectedTrack, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TidalDownloader) GetDownloadURL(trackID int64, quality string) (string, error) {
|
func (t *TidalDownloader) GetDownloadURL(trackID int64, quality string) (string, error) {
|
||||||
fmt.Println("Fetching URL...")
|
fmt.Println("Fetching URL...")
|
||||||
|
|
||||||
url := fmt.Sprintf("%s/track/?id=%d&quality=%s", t.apiURL, trackID, quality)
|
url := fmt.Sprintf("%s/track/?id=%d&quality=%s", t.apiURL, trackID, quality)
|
||||||
|
fmt.Printf("Tidal API URL: %s\n", url)
|
||||||
|
|
||||||
resp, err := t.client.Get(url)
|
resp, err := t.client.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Printf("✗ Tidal API request failed: %v\n", err)
|
||||||
return "", fmt.Errorf("failed to get download URL: %w", err)
|
return "", fmt.Errorf("failed to get download URL: %w", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
|
fmt.Printf("✗ Tidal API returned status code: %d\n", resp.StatusCode)
|
||||||
return "", fmt.Errorf("API returned status code: %d", resp.StatusCode)
|
return "", fmt.Errorf("API returned status code: %d", resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
var apiResponses []TidalAPIResponse
|
var apiResponses []TidalAPIResponse
|
||||||
if err := json.NewDecoder(resp.Body).Decode(&apiResponses); err != nil {
|
if err := json.NewDecoder(resp.Body).Decode(&apiResponses); err != nil {
|
||||||
|
fmt.Printf("✗ Failed to decode Tidal API response: %v\n", err)
|
||||||
return "", fmt.Errorf("failed to decode response: %w", err)
|
return "", fmt.Errorf("failed to decode response: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(apiResponses) == 0 {
|
if len(apiResponses) == 0 {
|
||||||
|
fmt.Println("✗ Tidal API returned empty response")
|
||||||
return "", fmt.Errorf("no download URL in response")
|
return "", fmt.Errorf("no download URL in response")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range apiResponses {
|
for _, item := range apiResponses {
|
||||||
if item.OriginalTrackURL != "" {
|
if item.OriginalTrackURL != "" {
|
||||||
fmt.Println("URL found")
|
fmt.Println("✓ Tidal download URL found")
|
||||||
return item.OriginalTrackURL, nil
|
return item.OriginalTrackURL, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println("✗ No valid download URL in Tidal API response")
|
||||||
return "", fmt.Errorf("download URL not found in response")
|
return "", fmt.Errorf("download URL not found in response")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,23 +347,37 @@ func (t *TidalDownloader) DownloadFile(url, filepath string) error {
|
|||||||
}
|
}
|
||||||
defer out.Close()
|
defer out.Close()
|
||||||
|
|
||||||
_, err = io.Copy(out, resp.Body)
|
// Use progress writer to track download
|
||||||
|
pw := NewProgressWriter(out)
|
||||||
|
_, err = io.Copy(pw, resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to write file: %w", err)
|
return fmt.Errorf("failed to write file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Print final size
|
||||||
|
fmt.Printf("\rDownloaded: %.2f MB (Complete)\n", float64(pw.GetTotal())/(1024*1024))
|
||||||
|
|
||||||
fmt.Println("Download complete")
|
fmt.Println("Download complete")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TidalDownloader) Download(query, isrc, outputDir, quality, filenameFormat string, includeTrackNumber bool, spotifyTrackName, spotifyArtistName, spotifyAlbumName string) (string, error) {
|
func (t *TidalDownloader) DownloadByURL(tidalURL, outputDir, quality, filenameFormat string, includeTrackNumber bool, position int, spotifyTrackName, spotifyArtistName, spotifyAlbumName string, useAlbumTrackNumber bool) (string, error) {
|
||||||
if outputDir != "." {
|
if outputDir != "." {
|
||||||
if err := os.MkdirAll(outputDir, 0755); err != nil {
|
if err := os.MkdirAll(outputDir, 0755); err != nil {
|
||||||
return "", fmt.Errorf("directory error: %w", err)
|
return "", fmt.Errorf("directory error: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trackInfo, err := t.GetTrackInfo(query, isrc)
|
fmt.Printf("Using Tidal URL: %s\n", tidalURL)
|
||||||
|
|
||||||
|
// Extract track ID from URL
|
||||||
|
trackID, err := t.GetTrackIDFromURL(tidalURL)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get track info by ID
|
||||||
|
trackInfo, err := t.GetTrackInfoByID(trackID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@@ -365,13 +422,19 @@ func (t *TidalDownloader) Download(query, isrc, outputDir, quality, filenameForm
|
|||||||
albumTitle = trackInfo.Album.Title
|
albumTitle = trackInfo.Album.Title
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if file with same ISRC already exists
|
||||||
|
if existingFile, exists := CheckISRCExists(outputDir, trackInfo.ISRC); exists {
|
||||||
|
fmt.Printf("File with ISRC %s already exists: %s\n", trackInfo.ISRC, existingFile)
|
||||||
|
return "EXISTS:" + existingFile, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Build filename based on format settings
|
// Build filename based on format settings
|
||||||
filename := buildTidalFilename(trackTitle, artistName, trackInfo.TrackNumber, filenameFormat, includeTrackNumber)
|
filename := buildTidalFilename(trackTitle, artistName, trackInfo.TrackNumber, filenameFormat, includeTrackNumber, position, useAlbumTrackNumber)
|
||||||
outputFilename := filepath.Join(outputDir, filename)
|
outputFilename := filepath.Join(outputDir, filename)
|
||||||
|
|
||||||
if fileInfo, err := os.Stat(outputFilename); err == nil && fileInfo.Size() > 0 {
|
if fileInfo, err := os.Stat(outputFilename); err == nil && fileInfo.Size() > 0 {
|
||||||
fmt.Printf("File already exists: %s (%.2f MB)\n", outputFilename, float64(fileInfo.Size())/(1024*1024))
|
fmt.Printf("File already exists: %s (%.2f MB)\n", outputFilename, float64(fileInfo.Size())/(1024*1024))
|
||||||
return outputFilename, nil
|
return "EXISTS:" + outputFilename, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadURL, err := t.GetDownloadURL(trackInfo.ID, quality)
|
downloadURL, err := t.GetDownloadURL(trackInfo.ID, quality)
|
||||||
@@ -407,12 +470,22 @@ func (t *TidalDownloader) Download(query, isrc, outputDir, quality, filenameForm
|
|||||||
releaseYear = trackInfo.Album.ReleaseDate[:4]
|
releaseYear = trackInfo.Album.ReleaseDate[:4]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use album track number if in album folder structure, otherwise use playlist position
|
||||||
|
trackNumberToEmbed := 0
|
||||||
|
if position > 0 {
|
||||||
|
if useAlbumTrackNumber && trackInfo.TrackNumber > 0 {
|
||||||
|
trackNumberToEmbed = trackInfo.TrackNumber
|
||||||
|
} else {
|
||||||
|
trackNumberToEmbed = position
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
metadata := Metadata{
|
metadata := Metadata{
|
||||||
Title: trackTitle,
|
Title: trackTitle,
|
||||||
Artist: artistName,
|
Artist: artistName,
|
||||||
Album: albumTitle,
|
Album: albumTitle,
|
||||||
Date: releaseYear,
|
Date: releaseYear,
|
||||||
TrackNumber: trackInfo.TrackNumber,
|
TrackNumber: trackNumberToEmbed,
|
||||||
DiscNumber: trackInfo.VolumeNumber,
|
DiscNumber: trackInfo.VolumeNumber,
|
||||||
ISRC: trackInfo.ISRC,
|
ISRC: trackInfo.ISRC,
|
||||||
}
|
}
|
||||||
@@ -424,22 +497,68 @@ func (t *TidalDownloader) Download(query, isrc, outputDir, quality, filenameForm
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Done")
|
fmt.Println("Done")
|
||||||
|
fmt.Println("✓ Downloaded successfully from Tidal")
|
||||||
return outputFilename, nil
|
return outputFilename, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TidalDownloader) DownloadWithFallback(query, isrc, outputDir, quality, filenameFormat string, includeTrackNumber bool, spotifyTrackName, spotifyArtistName, spotifyAlbumName string) (string, error) {
|
func (t *TidalDownloader) DownloadByURLWithFallback(tidalURL, outputDir, quality, filenameFormat string, includeTrackNumber bool, position int, spotifyTrackName, spotifyArtistName, spotifyAlbumName string, useAlbumTrackNumber bool) (string, error) {
|
||||||
apis, err := t.GetAvailableAPIs()
|
apis, err := t.GetAvailableAPIs()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("no APIs available for fallback: %w", err)
|
return "", fmt.Errorf("no APIs available for fallback: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lastError error
|
||||||
|
for i, apiURL := range apis {
|
||||||
|
fmt.Printf("[Tidal API %d/%d] Trying: %s\n", i+1, len(apis), apiURL)
|
||||||
|
|
||||||
|
fallbackDownloader := NewTidalDownloader(apiURL)
|
||||||
|
|
||||||
|
result, err := fallbackDownloader.DownloadByURL(tidalURL, outputDir, quality, filenameFormat, includeTrackNumber, position, spotifyTrackName, spotifyArtistName, spotifyAlbumName, useAlbumTrackNumber)
|
||||||
|
if err == nil {
|
||||||
|
fmt.Printf("✓ Success with: %s\n", apiURL)
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
lastError = err
|
||||||
|
errMsg := err.Error()
|
||||||
|
if len(errMsg) > 80 {
|
||||||
|
errMsg = errMsg[:80]
|
||||||
|
}
|
||||||
|
fmt.Printf("✗ Failed with %s: %s\n", apiURL, errMsg)
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", fmt.Errorf("all %d Tidal APIs failed. Last error: %v", len(apis), lastError)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TidalDownloader) Download(spotifyTrackID, outputDir, quality, filenameFormat string, includeTrackNumber bool, position int, spotifyTrackName, spotifyArtistName, spotifyAlbumName string, useAlbumTrackNumber bool) (string, error) {
|
||||||
|
// Get Tidal URL from Spotify track ID
|
||||||
|
tidalURL, err := t.GetTidalURLFromSpotify(spotifyTrackID)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return t.DownloadByURLWithFallback(tidalURL, outputDir, quality, filenameFormat, includeTrackNumber, position, spotifyTrackName, spotifyArtistName, spotifyAlbumName, useAlbumTrackNumber)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TidalDownloader) DownloadWithFallback(spotifyTrackID, outputDir, quality, filenameFormat string, includeTrackNumber bool, position int, spotifyTrackName, spotifyArtistName, spotifyAlbumName string, useAlbumTrackNumber bool) (string, error) {
|
||||||
|
apis, err := t.GetAvailableAPIs()
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("no APIs available for fallback: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get Tidal URL once
|
||||||
|
tidalURL, err := t.GetTidalURLFromSpotify(spotifyTrackID)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
var lastError error
|
var lastError error
|
||||||
for i, apiURL := range apis {
|
for i, apiURL := range apis {
|
||||||
fmt.Printf("[Auto Fallback %d/%d] Trying: %s\n", i+1, len(apis), apiURL)
|
fmt.Printf("[Auto Fallback %d/%d] Trying: %s\n", i+1, len(apis), apiURL)
|
||||||
|
|
||||||
fallbackDownloader := NewTidalDownloader(apiURL)
|
fallbackDownloader := NewTidalDownloader(apiURL)
|
||||||
|
|
||||||
result, err := fallbackDownloader.Download(query, isrc, outputDir, quality, filenameFormat, includeTrackNumber, spotifyTrackName, spotifyArtistName, spotifyAlbumName)
|
result, err := fallbackDownloader.DownloadByURL(tidalURL, outputDir, quality, filenameFormat, includeTrackNumber, position, spotifyTrackName, spotifyArtistName, spotifyAlbumName, useAlbumTrackNumber)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
fmt.Printf("✓ Success with: %s\n", apiURL)
|
fmt.Printf("✓ Success with: %s\n", apiURL)
|
||||||
return result, nil
|
return result, nil
|
||||||
@@ -456,7 +575,7 @@ func (t *TidalDownloader) DownloadWithFallback(query, isrc, outputDir, quality,
|
|||||||
return "", fmt.Errorf("all %d APIs failed. Last error: %v", len(apis), lastError)
|
return "", fmt.Errorf("all %d APIs failed. Last error: %v", len(apis), lastError)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildTidalFilename(title, artist string, trackNumber int, format string, includeTrackNumber bool) string {
|
func buildTidalFilename(title, artist string, trackNumber int, format string, includeTrackNumber bool, position int, useAlbumTrackNumber bool) string {
|
||||||
var filename string
|
var filename string
|
||||||
|
|
||||||
// Build base filename based on format
|
// Build base filename based on format
|
||||||
@@ -470,8 +589,13 @@ func buildTidalFilename(title, artist string, trackNumber int, format string, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add track number prefix if enabled
|
// Add track number prefix if enabled
|
||||||
if includeTrackNumber && trackNumber > 0 {
|
if includeTrackNumber && position > 0 {
|
||||||
filename = fmt.Sprintf("%02d. %s", trackNumber, filename)
|
// Use album track number if in album folder structure, otherwise use playlist position
|
||||||
|
numberToUse := position
|
||||||
|
if useAlbumTrackNumber && trackNumber > 0 {
|
||||||
|
numberToUse = trackNumber
|
||||||
|
}
|
||||||
|
filename = fmt.Sprintf("%02d. %s", numberToUse, filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
return filename + ".flac"
|
return filename + ".flac"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@radix-ui/react-checkbox": "^1.3.3",
|
"@radix-ui/react-checkbox": "^1.3.3",
|
||||||
|
"@radix-ui/react-context-menu": "^2.2.16",
|
||||||
"@radix-ui/react-dialog": "^1.1.15",
|
"@radix-ui/react-dialog": "^1.1.15",
|
||||||
"@radix-ui/react-label": "^2.1.8",
|
"@radix-ui/react-label": "^2.1.8",
|
||||||
"@radix-ui/react-progress": "^1.1.8",
|
"@radix-ui/react-progress": "^1.1.8",
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
e00813ca84dd3deaade9854c0df093cd
|
72728e016fdcbb66d395ba3a681b8945
|
||||||
Generated
+69
@@ -11,6 +11,9 @@ importers:
|
|||||||
'@radix-ui/react-checkbox':
|
'@radix-ui/react-checkbox':
|
||||||
specifier: ^1.3.3
|
specifier: ^1.3.3
|
||||||
version: 1.3.3(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
version: 1.3.3(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-context-menu':
|
||||||
|
specifier: ^2.2.16
|
||||||
|
version: 2.2.16(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
'@radix-ui/react-dialog':
|
'@radix-ui/react-dialog':
|
||||||
specifier: ^1.1.15
|
specifier: ^1.1.15
|
||||||
version: 1.1.15(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
version: 1.1.15(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
@@ -641,6 +644,19 @@ packages:
|
|||||||
'@types/react':
|
'@types/react':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@radix-ui/react-context-menu@2.2.16':
|
||||||
|
resolution: {integrity: sha512-O8morBEW+HsVG28gYDZPTrT9UUovQUlJue5YO836tiTJhuIWBm/zQHc7j388sHWtdH/xUZurK9olD2+pcqx5ww==}
|
||||||
|
peerDependencies:
|
||||||
|
'@types/react': '*'
|
||||||
|
'@types/react-dom': '*'
|
||||||
|
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@types/react':
|
||||||
|
optional: true
|
||||||
|
'@types/react-dom':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@radix-ui/react-context@1.1.2':
|
'@radix-ui/react-context@1.1.2':
|
||||||
resolution: {integrity: sha512-jCi/QKUM2r1Ju5a3J64TH2A5SpKAgh0LpknyqdQ4m6DCV0xJ2HG1xARRwNGPQfi1SLdLWZ1OJz6F4OMBBNiGJA==}
|
resolution: {integrity: sha512-jCi/QKUM2r1Ju5a3J64TH2A5SpKAgh0LpknyqdQ4m6DCV0xJ2HG1xARRwNGPQfi1SLdLWZ1OJz6F4OMBBNiGJA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -738,6 +754,19 @@ packages:
|
|||||||
'@types/react-dom':
|
'@types/react-dom':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@radix-ui/react-menu@2.1.16':
|
||||||
|
resolution: {integrity: sha512-72F2T+PLlphrqLcAotYPp0uJMr5SjP5SL01wfEspJbru5Zs5vQaSHb4VB3ZMJPimgHHCHG7gMOeOB9H3Hdmtxg==}
|
||||||
|
peerDependencies:
|
||||||
|
'@types/react': '*'
|
||||||
|
'@types/react-dom': '*'
|
||||||
|
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@types/react':
|
||||||
|
optional: true
|
||||||
|
'@types/react-dom':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@radix-ui/react-popper@1.2.8':
|
'@radix-ui/react-popper@1.2.8':
|
||||||
resolution: {integrity: sha512-0NJQ4LFFUuWkE7Oxf0htBKS6zLkkjBH+hM1uk7Ng705ReR8m/uelduy1DBo0PyBXPKVnBA6YBlU94MBGXrSBCw==}
|
resolution: {integrity: sha512-0NJQ4LFFUuWkE7Oxf0htBKS6zLkkjBH+hM1uk7Ng705ReR8m/uelduy1DBo0PyBXPKVnBA6YBlU94MBGXrSBCw==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -2479,6 +2508,20 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@types/react': 19.2.6
|
'@types/react': 19.2.6
|
||||||
|
|
||||||
|
'@radix-ui/react-context-menu@2.2.16(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)':
|
||||||
|
dependencies:
|
||||||
|
'@radix-ui/primitive': 1.1.3
|
||||||
|
'@radix-ui/react-context': 1.1.2(@types/react@19.2.6)(react@19.2.0)
|
||||||
|
'@radix-ui/react-menu': 2.1.16(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-primitive': 2.1.3(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.6)(react@19.2.0)
|
||||||
|
'@radix-ui/react-use-controllable-state': 1.2.2(@types/react@19.2.6)(react@19.2.0)
|
||||||
|
react: 19.2.0
|
||||||
|
react-dom: 19.2.0(react@19.2.0)
|
||||||
|
optionalDependencies:
|
||||||
|
'@types/react': 19.2.6
|
||||||
|
'@types/react-dom': 19.2.3(@types/react@19.2.6)
|
||||||
|
|
||||||
'@radix-ui/react-context@1.1.2(@types/react@19.2.6)(react@19.2.0)':
|
'@radix-ui/react-context@1.1.2(@types/react@19.2.6)(react@19.2.0)':
|
||||||
dependencies:
|
dependencies:
|
||||||
react: 19.2.0
|
react: 19.2.0
|
||||||
@@ -2565,6 +2608,32 @@ snapshots:
|
|||||||
'@types/react': 19.2.6
|
'@types/react': 19.2.6
|
||||||
'@types/react-dom': 19.2.3(@types/react@19.2.6)
|
'@types/react-dom': 19.2.3(@types/react@19.2.6)
|
||||||
|
|
||||||
|
'@radix-ui/react-menu@2.1.16(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)':
|
||||||
|
dependencies:
|
||||||
|
'@radix-ui/primitive': 1.1.3
|
||||||
|
'@radix-ui/react-collection': 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.6)(react@19.2.0)
|
||||||
|
'@radix-ui/react-context': 1.1.2(@types/react@19.2.6)(react@19.2.0)
|
||||||
|
'@radix-ui/react-direction': 1.1.1(@types/react@19.2.6)(react@19.2.0)
|
||||||
|
'@radix-ui/react-dismissable-layer': 1.1.11(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-focus-guards': 1.1.3(@types/react@19.2.6)(react@19.2.0)
|
||||||
|
'@radix-ui/react-focus-scope': 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-id': 1.1.1(@types/react@19.2.6)(react@19.2.0)
|
||||||
|
'@radix-ui/react-popper': 1.2.8(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-portal': 1.1.9(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-presence': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-primitive': 2.1.3(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-roving-focus': 1.1.11(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-slot': 1.2.3(@types/react@19.2.6)(react@19.2.0)
|
||||||
|
'@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.6)(react@19.2.0)
|
||||||
|
aria-hidden: 1.2.6
|
||||||
|
react: 19.2.0
|
||||||
|
react-dom: 19.2.0(react@19.2.0)
|
||||||
|
react-remove-scroll: 2.7.1(@types/react@19.2.6)(react@19.2.0)
|
||||||
|
optionalDependencies:
|
||||||
|
'@types/react': 19.2.6
|
||||||
|
'@types/react-dom': 19.2.3(@types/react@19.2.6)
|
||||||
|
|
||||||
'@radix-ui/react-popper@1.2.8(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)':
|
'@radix-ui/react-popper@1.2.8(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@floating-ui/react-dom': 2.1.6(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
'@floating-ui/react-dom': 2.1.6(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
|||||||
+20
-8
@@ -18,12 +18,14 @@ import { OpenFolder } from "../wailsjs/go/main/App";
|
|||||||
import { toastWithSound as toast } from "@/lib/toast-with-sound";
|
import { toastWithSound as toast } from "@/lib/toast-with-sound";
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
|
import { TitleBar } from "@/components/TitleBar";
|
||||||
import { Header } from "@/components/Header";
|
import { Header } from "@/components/Header";
|
||||||
import { SearchBar } from "@/components/SearchBar";
|
import { SearchBar } from "@/components/SearchBar";
|
||||||
import { TrackInfo } from "@/components/TrackInfo";
|
import { TrackInfo } from "@/components/TrackInfo";
|
||||||
import { AlbumInfo } from "@/components/AlbumInfo";
|
import { AlbumInfo } from "@/components/AlbumInfo";
|
||||||
import { PlaylistInfo } from "@/components/PlaylistInfo";
|
import { PlaylistInfo } from "@/components/PlaylistInfo";
|
||||||
import { ArtistInfo } from "@/components/ArtistInfo";
|
import { ArtistInfo } from "@/components/ArtistInfo";
|
||||||
|
import { DownloadProgressToast } from "@/components/DownloadProgressToast";
|
||||||
|
|
||||||
// Hooks
|
// Hooks
|
||||||
import { useDownload } from "@/hooks/useDownload";
|
import { useDownload } from "@/hooks/useDownload";
|
||||||
@@ -38,7 +40,7 @@ function App() {
|
|||||||
const [hasUpdate, setHasUpdate] = useState(false);
|
const [hasUpdate, setHasUpdate] = useState(false);
|
||||||
|
|
||||||
const ITEMS_PER_PAGE = 50;
|
const ITEMS_PER_PAGE = 50;
|
||||||
const CURRENT_VERSION = "5.7";
|
const CURRENT_VERSION = "6.1";
|
||||||
|
|
||||||
const download = useDownload();
|
const download = useDownload();
|
||||||
const metadata = useMetadata();
|
const metadata = useMetadata();
|
||||||
@@ -76,7 +78,7 @@ function App() {
|
|||||||
const checkForUpdates = async () => {
|
const checkForUpdates = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
"https://raw.githubusercontent.com/afkarxyz/SpotiFLAC/refs/heads/main/version.json"
|
"https://cdn.jsdelivr.net/gh/afkarxyz/SpotiFLAC@refs/heads/main/version.json"
|
||||||
);
|
);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
const latestVersion = data.version;
|
const latestVersion = data.version;
|
||||||
@@ -142,6 +144,7 @@ function App() {
|
|||||||
isDownloading={download.isDownloading}
|
isDownloading={download.isDownloading}
|
||||||
downloadingTrack={download.downloadingTrack}
|
downloadingTrack={download.downloadingTrack}
|
||||||
isDownloaded={download.downloadedTracks.has(track.isrc)}
|
isDownloaded={download.downloadedTracks.has(track.isrc)}
|
||||||
|
isFailed={download.failedTracks.has(track.isrc)}
|
||||||
onDownload={download.handleDownloadTrack}
|
onDownload={download.handleDownloadTrack}
|
||||||
onOpenFolder={handleOpenFolder}
|
onOpenFolder={handleOpenFolder}
|
||||||
/>
|
/>
|
||||||
@@ -158,6 +161,7 @@ function App() {
|
|||||||
sortBy={sortBy}
|
sortBy={sortBy}
|
||||||
selectedTracks={selectedTracks}
|
selectedTracks={selectedTracks}
|
||||||
downloadedTracks={download.downloadedTracks}
|
downloadedTracks={download.downloadedTracks}
|
||||||
|
failedTracks={download.failedTracks}
|
||||||
downloadingTrack={download.downloadingTrack}
|
downloadingTrack={download.downloadingTrack}
|
||||||
isDownloading={download.isDownloading}
|
isDownloading={download.isDownloading}
|
||||||
bulkDownloadType={download.bulkDownloadType}
|
bulkDownloadType={download.bulkDownloadType}
|
||||||
@@ -191,6 +195,7 @@ function App() {
|
|||||||
sortBy={sortBy}
|
sortBy={sortBy}
|
||||||
selectedTracks={selectedTracks}
|
selectedTracks={selectedTracks}
|
||||||
downloadedTracks={download.downloadedTracks}
|
downloadedTracks={download.downloadedTracks}
|
||||||
|
failedTracks={download.failedTracks}
|
||||||
downloadingTrack={download.downloadingTrack}
|
downloadingTrack={download.downloadingTrack}
|
||||||
isDownloading={download.isDownloading}
|
isDownloading={download.isDownloading}
|
||||||
bulkDownloadType={download.bulkDownloadType}
|
bulkDownloadType={download.bulkDownloadType}
|
||||||
@@ -229,6 +234,7 @@ function App() {
|
|||||||
sortBy={sortBy}
|
sortBy={sortBy}
|
||||||
selectedTracks={selectedTracks}
|
selectedTracks={selectedTracks}
|
||||||
downloadedTracks={download.downloadedTracks}
|
downloadedTracks={download.downloadedTracks}
|
||||||
|
failedTracks={download.failedTracks}
|
||||||
downloadingTrack={download.downloadingTrack}
|
downloadingTrack={download.downloadingTrack}
|
||||||
isDownloading={download.isDownloading}
|
isDownloading={download.isDownloading}
|
||||||
bulkDownloadType={download.bulkDownloadType}
|
bulkDownloadType={download.bulkDownloadType}
|
||||||
@@ -258,9 +264,14 @@ function App() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
<div className="min-h-screen bg-background p-4 md:p-8">
|
<div className="min-h-screen bg-background flex flex-col">
|
||||||
<div className="max-w-4xl mx-auto space-y-6">
|
<TitleBar />
|
||||||
<Header version={CURRENT_VERSION} hasUpdate={hasUpdate} />
|
<div className="flex-1 p-4 md:p-8">
|
||||||
|
<div className="max-w-4xl mx-auto space-y-6">
|
||||||
|
<Header version={CURRENT_VERSION} hasUpdate={hasUpdate} />
|
||||||
|
|
||||||
|
{/* Download Progress Toast */}
|
||||||
|
<DownloadProgressToast />
|
||||||
|
|
||||||
{/* Timeout Dialog */}
|
{/* Timeout Dialog */}
|
||||||
<Dialog
|
<Dialog
|
||||||
@@ -300,7 +311,7 @@ function App() {
|
|||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={metadata.handleConfirmFetch}>
|
<Button onClick={metadata.handleConfirmFetch}>
|
||||||
<Search className="h-4 w-4 mr-2" />
|
<Search className="h-4 w-4" />
|
||||||
Fetch
|
Fetch
|
||||||
</Button>
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
@@ -326,7 +337,7 @@ function App() {
|
|||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={metadata.handleConfirmAlbumFetch}>
|
<Button onClick={metadata.handleConfirmAlbumFetch}>
|
||||||
<Search className="h-4 w-4 mr-2" />
|
<Search className="h-4 w-4" />
|
||||||
Fetch Album
|
Fetch Album
|
||||||
</Button>
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
@@ -340,7 +351,8 @@ function App() {
|
|||||||
onFetch={handleFetchMetadata}
|
onFetch={handleFetchMetadata}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{metadata.metadata && renderMetadata()}
|
{metadata.metadata && renderMetadata()}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</TooltipProvider>
|
</TooltipProvider>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ interface AlbumInfoProps {
|
|||||||
sortBy: string;
|
sortBy: string;
|
||||||
selectedTracks: string[];
|
selectedTracks: string[];
|
||||||
downloadedTracks: Set<string>;
|
downloadedTracks: Set<string>;
|
||||||
|
failedTracks: Set<string>;
|
||||||
downloadingTrack: string | null;
|
downloadingTrack: string | null;
|
||||||
isDownloading: boolean;
|
isDownloading: boolean;
|
||||||
bulkDownloadType: "all" | "selected" | null;
|
bulkDownloadType: "all" | "selected" | null;
|
||||||
@@ -46,6 +47,7 @@ export function AlbumInfo({
|
|||||||
sortBy,
|
sortBy,
|
||||||
selectedTracks,
|
selectedTracks,
|
||||||
downloadedTracks,
|
downloadedTracks,
|
||||||
|
failedTracks,
|
||||||
downloadingTrack,
|
downloadingTrack,
|
||||||
isDownloading,
|
isDownloading,
|
||||||
bulkDownloadType,
|
bulkDownloadType,
|
||||||
@@ -91,7 +93,6 @@ export function AlbumInfo({
|
|||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Button
|
<Button
|
||||||
onClick={onDownloadAll}
|
onClick={onDownloadAll}
|
||||||
className="gap-2"
|
|
||||||
disabled={isDownloading}
|
disabled={isDownloading}
|
||||||
>
|
>
|
||||||
{isDownloading && bulkDownloadType === "all" ? (
|
{isDownloading && bulkDownloadType === "all" ? (
|
||||||
@@ -105,7 +106,6 @@ export function AlbumInfo({
|
|||||||
<Button
|
<Button
|
||||||
onClick={onDownloadSelected}
|
onClick={onDownloadSelected}
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
className="gap-2"
|
|
||||||
disabled={isDownloading}
|
disabled={isDownloading}
|
||||||
>
|
>
|
||||||
{isDownloading && bulkDownloadType === "selected" ? (
|
{isDownloading && bulkDownloadType === "selected" ? (
|
||||||
@@ -117,7 +117,7 @@ export function AlbumInfo({
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{downloadedTracks.size > 0 && (
|
{downloadedTracks.size > 0 && (
|
||||||
<Button onClick={onOpenFolder} variant="outline" className="gap-2">
|
<Button onClick={onOpenFolder} variant="outline">
|
||||||
<FolderOpen className="h-4 w-4" />
|
<FolderOpen className="h-4 w-4" />
|
||||||
Open Folder
|
Open Folder
|
||||||
</Button>
|
</Button>
|
||||||
@@ -147,6 +147,7 @@ export function AlbumInfo({
|
|||||||
sortBy={sortBy}
|
sortBy={sortBy}
|
||||||
selectedTracks={selectedTracks}
|
selectedTracks={selectedTracks}
|
||||||
downloadedTracks={downloadedTracks}
|
downloadedTracks={downloadedTracks}
|
||||||
|
failedTracks={failedTracks}
|
||||||
downloadingTrack={downloadingTrack}
|
downloadingTrack={downloadingTrack}
|
||||||
isDownloading={isDownloading}
|
isDownloading={isDownloading}
|
||||||
currentPage={currentPage}
|
currentPage={currentPage}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ interface ArtistInfoProps {
|
|||||||
sortBy: string;
|
sortBy: string;
|
||||||
selectedTracks: string[];
|
selectedTracks: string[];
|
||||||
downloadedTracks: Set<string>;
|
downloadedTracks: Set<string>;
|
||||||
|
failedTracks: Set<string>;
|
||||||
downloadingTrack: string | null;
|
downloadingTrack: string | null;
|
||||||
isDownloading: boolean;
|
isDownloading: boolean;
|
||||||
bulkDownloadType: "all" | "selected" | null;
|
bulkDownloadType: "all" | "selected" | null;
|
||||||
@@ -55,6 +56,7 @@ export function ArtistInfo({
|
|||||||
sortBy,
|
sortBy,
|
||||||
selectedTracks,
|
selectedTracks,
|
||||||
downloadedTracks,
|
downloadedTracks,
|
||||||
|
failedTracks,
|
||||||
downloadingTrack,
|
downloadingTrack,
|
||||||
isDownloading,
|
isDownloading,
|
||||||
bulkDownloadType,
|
bulkDownloadType,
|
||||||
@@ -146,7 +148,6 @@ export function ArtistInfo({
|
|||||||
<Button
|
<Button
|
||||||
onClick={onDownloadAll}
|
onClick={onDownloadAll}
|
||||||
size="sm"
|
size="sm"
|
||||||
className="gap-2"
|
|
||||||
disabled={isDownloading}
|
disabled={isDownloading}
|
||||||
>
|
>
|
||||||
{isDownloading && bulkDownloadType === "all" ? (
|
{isDownloading && bulkDownloadType === "all" ? (
|
||||||
@@ -161,7 +162,6 @@ export function ArtistInfo({
|
|||||||
onClick={onDownloadSelected}
|
onClick={onDownloadSelected}
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
className="gap-2"
|
|
||||||
disabled={isDownloading}
|
disabled={isDownloading}
|
||||||
>
|
>
|
||||||
{isDownloading && bulkDownloadType === "selected" ? (
|
{isDownloading && bulkDownloadType === "selected" ? (
|
||||||
@@ -173,7 +173,7 @@ export function ArtistInfo({
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{downloadedTracks.size > 0 && (
|
{downloadedTracks.size > 0 && (
|
||||||
<Button onClick={onOpenFolder} size="sm" variant="outline" className="gap-2">
|
<Button onClick={onOpenFolder} size="sm" variant="outline">
|
||||||
<FolderOpen className="h-4 w-4" />
|
<FolderOpen className="h-4 w-4" />
|
||||||
Open Folder
|
Open Folder
|
||||||
</Button>
|
</Button>
|
||||||
@@ -199,6 +199,7 @@ export function ArtistInfo({
|
|||||||
sortBy={sortBy}
|
sortBy={sortBy}
|
||||||
selectedTracks={selectedTracks}
|
selectedTracks={selectedTracks}
|
||||||
downloadedTracks={downloadedTracks}
|
downloadedTracks={downloadedTracks}
|
||||||
|
failedTracks={failedTracks}
|
||||||
downloadingTrack={downloadingTrack}
|
downloadingTrack={downloadingTrack}
|
||||||
isDownloading={isDownloading}
|
isDownloading={isDownloading}
|
||||||
currentPage={currentPage}
|
currentPage={currentPage}
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ export function DownloadProgress({ progress, currentTrack, onStop }: DownloadPro
|
|||||||
<div className="w-full space-y-2 mt-4">
|
<div className="w-full space-y-2 mt-4">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Progress value={progress} className="h-2 flex-1" />
|
<Progress value={progress} className="h-2 flex-1" />
|
||||||
<Button variant="destructive" size="sm" onClick={onStop}>
|
<Button variant="destructive" size="sm" onClick={onStop} className="gap-1.5">
|
||||||
<StopCircle className="h-4 w-4 mr-2" />
|
<StopCircle className="h-4 w-4" />
|
||||||
Stop
|
Stop
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { useDownloadProgress } from "@/hooks/useDownloadProgress";
|
||||||
|
import { Download } from "lucide-react";
|
||||||
|
|
||||||
|
export function DownloadProgressToast() {
|
||||||
|
const progress = useDownloadProgress();
|
||||||
|
|
||||||
|
if (!progress.is_downloading) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="fixed bottom-4 left-4 z-50 animate-in slide-in-from-bottom-5 data-[state=closed]:animate-out data-[state=closed]:slide-out-to-bottom-5">
|
||||||
|
<div className="bg-background border rounded-lg shadow-lg p-3">
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<Download className="h-4 w-4 text-primary animate-bounce" />
|
||||||
|
<div className="flex flex-col min-w-[80px]">
|
||||||
|
<p className="text-sm font-medium font-mono tabular-nums">
|
||||||
|
{progress.mb_downloaded.toFixed(2)} MB
|
||||||
|
</p>
|
||||||
|
{progress.speed_mbps > 0 && (
|
||||||
|
<p className="text-xs text-muted-foreground font-mono tabular-nums">
|
||||||
|
{progress.speed_mbps.toFixed(2)} MB/s
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -49,7 +49,7 @@ export function Header({ version, hasUpdate }: HeaderProps) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">
|
||||||
Get Spotify tracks in true FLAC from Tidal/Deezer — no account required.
|
Get Spotify tracks in true FLAC from Tidal, Deezer, Qobuz & Amazon Music — no account required.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="absolute right-0 top-0 flex gap-2">
|
<div className="absolute right-0 top-0 flex gap-2">
|
||||||
@@ -68,7 +68,7 @@ export function Header({ version, hasUpdate }: HeaderProps) {
|
|||||||
</a>
|
</a>
|
||||||
</Button>
|
</Button>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent>
|
<TooltipContent side="left">
|
||||||
<p>Report bug or request feature</p>
|
<p>Report bug or request feature</p>
|
||||||
</TooltipContent>
|
</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ interface PlaylistInfoProps {
|
|||||||
sortBy: string;
|
sortBy: string;
|
||||||
selectedTracks: string[];
|
selectedTracks: string[];
|
||||||
downloadedTracks: Set<string>;
|
downloadedTracks: Set<string>;
|
||||||
|
failedTracks: Set<string>;
|
||||||
downloadingTrack: string | null;
|
downloadingTrack: string | null;
|
||||||
isDownloading: boolean;
|
isDownloading: boolean;
|
||||||
bulkDownloadType: "all" | "selected" | null;
|
bulkDownloadType: "all" | "selected" | null;
|
||||||
@@ -52,6 +53,7 @@ export function PlaylistInfo({
|
|||||||
sortBy,
|
sortBy,
|
||||||
selectedTracks,
|
selectedTracks,
|
||||||
downloadedTracks,
|
downloadedTracks,
|
||||||
|
failedTracks,
|
||||||
downloadingTrack,
|
downloadingTrack,
|
||||||
isDownloading,
|
isDownloading,
|
||||||
bulkDownloadType,
|
bulkDownloadType,
|
||||||
@@ -97,7 +99,6 @@ export function PlaylistInfo({
|
|||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Button
|
<Button
|
||||||
onClick={onDownloadAll}
|
onClick={onDownloadAll}
|
||||||
className="gap-2"
|
|
||||||
disabled={isDownloading}
|
disabled={isDownloading}
|
||||||
>
|
>
|
||||||
{isDownloading && bulkDownloadType === "all" ? (
|
{isDownloading && bulkDownloadType === "all" ? (
|
||||||
@@ -111,7 +112,6 @@ export function PlaylistInfo({
|
|||||||
<Button
|
<Button
|
||||||
onClick={onDownloadSelected}
|
onClick={onDownloadSelected}
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
className="gap-2"
|
|
||||||
disabled={isDownloading}
|
disabled={isDownloading}
|
||||||
>
|
>
|
||||||
{isDownloading && bulkDownloadType === "selected" ? (
|
{isDownloading && bulkDownloadType === "selected" ? (
|
||||||
@@ -123,7 +123,7 @@ export function PlaylistInfo({
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{downloadedTracks.size > 0 && (
|
{downloadedTracks.size > 0 && (
|
||||||
<Button onClick={onOpenFolder} variant="outline" className="gap-2">
|
<Button onClick={onOpenFolder} variant="outline">
|
||||||
<FolderOpen className="h-4 w-4" />
|
<FolderOpen className="h-4 w-4" />
|
||||||
Open Folder
|
Open Folder
|
||||||
</Button>
|
</Button>
|
||||||
@@ -153,6 +153,7 @@ export function PlaylistInfo({
|
|||||||
sortBy={sortBy}
|
sortBy={sortBy}
|
||||||
selectedTracks={selectedTracks}
|
selectedTracks={selectedTracks}
|
||||||
downloadedTracks={downloadedTracks}
|
downloadedTracks={downloadedTracks}
|
||||||
|
failedTracks={failedTracks}
|
||||||
downloadingTrack={downloadingTrack}
|
downloadingTrack={downloadingTrack}
|
||||||
isDownloading={isDownloading}
|
isDownloading={isDownloading}
|
||||||
currentPage={currentPage}
|
currentPage={currentPage}
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ export function SearchAndSort({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Select value={sortBy} onValueChange={onSortChange}>
|
<Select value={sortBy} onValueChange={onSortChange}>
|
||||||
<SelectTrigger className="w-[200px]">
|
<SelectTrigger className="w-[200px] gap-1.5">
|
||||||
<ArrowUpDown className="h-4 w-4 mr-2" />
|
<ArrowUpDown className="h-4 w-4" />
|
||||||
<SelectValue placeholder="Sort by" />
|
<SelectValue placeholder="Sort by" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { InputWithContext } from "@/components/ui/input-with-context";
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { Search, Info, XCircle } from "lucide-react";
|
import { Search, Info, XCircle } from "lucide-react";
|
||||||
import { Spinner } from "@/components/ui/spinner";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
@@ -19,56 +18,52 @@ interface SearchBarProps {
|
|||||||
|
|
||||||
export function SearchBar({ url, loading, onUrlChange, onFetch }: SearchBarProps) {
|
export function SearchBar({ url, loading, onUrlChange, onFetch }: SearchBarProps) {
|
||||||
return (
|
return (
|
||||||
<Card>
|
<div className="space-y-2">
|
||||||
<CardContent className="px-6 py-6 space-y-4">
|
<div className="flex items-center gap-2">
|
||||||
<div className="space-y-2">
|
<Label htmlFor="spotify-url">Spotify URL</Label>
|
||||||
<div className="flex items-center gap-2">
|
<Tooltip>
|
||||||
<Label htmlFor="spotify-url">Spotify URL</Label>
|
<TooltipTrigger asChild>
|
||||||
<Tooltip>
|
<Info className="h-4 w-4 text-muted-foreground cursor-help" />
|
||||||
<TooltipTrigger asChild>
|
</TooltipTrigger>
|
||||||
<Info className="h-4 w-4 text-muted-foreground cursor-help" />
|
<TooltipContent side="right">
|
||||||
</TooltipTrigger>
|
<p>Supports track, album, playlist, and artist URLs</p>
|
||||||
<TooltipContent side="right">
|
</TooltipContent>
|
||||||
<p>Supports track, album, playlist, and artist URLs</p>
|
</Tooltip>
|
||||||
</TooltipContent>
|
</div>
|
||||||
</Tooltip>
|
<div className="flex gap-2">
|
||||||
</div>
|
<div className="relative flex-1">
|
||||||
<div className="flex gap-2">
|
<InputWithContext
|
||||||
<div className="relative flex-1">
|
id="spotify-url"
|
||||||
<Input
|
placeholder="https://open.spotify.com/..."
|
||||||
id="spotify-url"
|
value={url}
|
||||||
placeholder="https://open.spotify.com/..."
|
onChange={(e) => onUrlChange(e.target.value)}
|
||||||
value={url}
|
onKeyDown={(e) => e.key === "Enter" && onFetch()}
|
||||||
onChange={(e) => onUrlChange(e.target.value)}
|
className="pr-8"
|
||||||
onKeyDown={(e) => e.key === "Enter" && onFetch()}
|
/>
|
||||||
className="pr-8"
|
{url && (
|
||||||
/>
|
<button
|
||||||
{url && (
|
type="button"
|
||||||
<button
|
className="absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors"
|
||||||
type="button"
|
onClick={() => onUrlChange("")}
|
||||||
className="absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors"
|
>
|
||||||
onClick={() => onUrlChange("")}
|
<XCircle className="h-4 w-4" />
|
||||||
>
|
</button>
|
||||||
<XCircle className="h-4 w-4" />
|
)}
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<Button onClick={onFetch} disabled={loading}>
|
|
||||||
{loading ? (
|
|
||||||
<>
|
|
||||||
<Spinner />
|
|
||||||
Fetching...
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<Search className="h-4 w-4" />
|
|
||||||
Fetch
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
<Button onClick={onFetch} disabled={loading}>
|
||||||
</Card>
|
{loading ? (
|
||||||
|
<>
|
||||||
|
<Spinner />
|
||||||
|
Fetching...
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Search className="h-4 w-4" />
|
||||||
|
Fetch
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { InputWithContext } from "@/components/ui/input-with-context";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
@@ -19,7 +19,8 @@ import {
|
|||||||
} from "@/components/ui/select";
|
} from "@/components/ui/select";
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
||||||
import { Settings as SettingsIcon, FolderOpen, Save, RotateCcw } from "lucide-react";
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||||
|
import { Settings as SettingsIcon, FolderOpen, Save, RotateCcw, Info } from "lucide-react";
|
||||||
import { getSettings, getSettingsWithDefaults, saveSettings, resetToDefaultSettings, applyThemeMode, type Settings as SettingsType } from "@/lib/settings";
|
import { getSettings, getSettingsWithDefaults, saveSettings, resetToDefaultSettings, applyThemeMode, type Settings as SettingsType } from "@/lib/settings";
|
||||||
import { themes, applyTheme } from "@/lib/themes";
|
import { themes, applyTheme } from "@/lib/themes";
|
||||||
import { SelectFolder } from "../../wailsjs/go/main/App";
|
import { SelectFolder } from "../../wailsjs/go/main/App";
|
||||||
@@ -45,6 +46,13 @@ const QobuzIcon = () => (
|
|||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const AmazonIcon = () => (
|
||||||
|
<svg viewBox="0 0 24 24" fill="currentColor" style={{ display: "block", width: "1.1em", height: "1.1em" }} className="inline-block mr-2">
|
||||||
|
<path fillRule="evenodd" d="M15.62 11.13c-.15.1-.37.18-.64.18-.42 0-.82-.05-1.21-.18l-.22-.04c-.08 0-.1.04-.1.14v.25c0 .08.02.12.05.17.02.03.07.08.15.1.4.18.84.25 1.33.25.52 0 .91-.12 1.24-.37.32-.25.47-.57.47-.99 0-.3-.08-.52-.23-.72-.15-.17-.4-.34-.74-.47l-.7-.27c-.26-.1-.46-.2-.53-.3a.47.47 0 0 1-.15-.36c0-.38.27-.57.84-.57.32 0 .64.05.94.15l.2.04c.07 0 .12-.04.12-.14v-.25c0-.08-.03-.12-.05-.17-.03-.05-.08-.08-.15-.1-.37-.13-.74-.2-1.11-.2-.47 0-.87.12-1.16.35-.3.22-.45.54-.45.91 0 .57.32.99.97 1.24l.74.27c.24.1.4.17.5.27.09.1.12.2.12.35 0 .2-.08.37-.23.46Zm-3.88-3.55v3.28c-.42.28-.84.42-1.26.42-.27 0-.47-.07-.6-.22-.11-.15-.16-.37-.16-.7V7.59c0-.13-.05-.18-.18-.18h-.52c-.12 0-.17.05-.17.18v3.06c0 .42.1.77.32.99.22.22.55.35.97.35.56 0 1.13-.2 1.68-.6l.05.3c0 .07.02.1.07.12.02.03.07.03.15.03h.37c.12 0 .17-.05.17-.18V7.58c0-.13-.05-.18-.17-.18h-.52c-.15 0-.2.08-.2.18Zm-4.69 4.27h.52c.12 0 .17-.05.17-.17v-3.1c0-.41-.1-.73-.32-.95a1.25 1.25 0 0 0-.94-.35c-.57 0-1.16.2-1.73.62-.2-.42-.57-.62-1.11-.62-.55 0-1.1.2-1.64.57l-.04-.27c0-.08-.03-.1-.08-.13-.02-.02-.07-.02-.12-.02h-.4c-.12 0-.17.05-.17.17v4.1c0 .13.05.18.17.18h.52c.12 0 .17-.05.17-.18V8.37c.42-.25.84-.4 1.29-.4.25 0 .42.08.52.22.1.15.17.35.17.65v2.84c0 .12.05.17.17.17h.52c.13 0 .18-.05.18-.17V8.37c.44-.27.86-.4 1.28-.4.25 0 .42.08.52.22.1.15.17.35.17.65v2.84c0 .12.05.17.18.17Zm13.47 3.29a21.8 21.8 0 0 1-8.3 1.7c-3.96 0-7.8-1.08-10.88-2.89a.35.35 0 0 0-.15-.05c-.17 0-.27.2-.1.37a16.11 16.11 0 0 0 10.87 4.16c3.02 0 6.5-.94 8.9-2.72.42-.3.08-.74-.34-.57Zm-.08-6.74c.22-.26.57-.38 1.06-.38.25 0 .5.03.72.1l.15.02c.07 0 .12-.04.12-.17v-.25c0-.07-.02-.14-.05-.17a.54.54 0 0 0-.12-.1c-.32-.07-.64-.15-.94-.15-.7 0-1.21.2-1.6.62-.38.4-.57 1-.57 1.73 0 .74.17 1.31.54 1.7.37.4.89.6 1.58.6.37 0 .72-.05.99-.17.07-.03.12-.05.15-.1.02-.03.02-.1.02-.17v-.25c0-.13-.05-.17-.12-.17-.03 0-.07 0-.12.02-.28.07-.55.12-.8.12-.46 0-.81-.12-1.03-.37-.23-.24-.32-.64-.32-1.16v-.12c.02-.55.12-.94.34-1.19Z" clipRule="evenodd"></path>
|
||||||
|
<path fillRule="evenodd" d="M21.55 17.46c1.29-1.09 1.64-3.33 1.36-3.68-.12-.15-.71-.3-1.45-.3-.8 0-1.73.18-2.45.67-.22.15-.17.35.05.32.76-.1 2.5-.3 2.82.1.3.4-.35 2.03-.65 2.74-.07.23.1.3.32.15ZM18.12 7.4h-.52c-.12 0-.17.05-.17.18v4.1c0 .12.05.17.17.17h.52c.12 0 .17-.05.17-.17v-4.1c0-.1-.05-.18-.17-.18Zm.15-1.68a.58.58 0 0 0-.42-.15c-.18 0-.3.05-.4.15a.5.5 0 0 0-.15.37c0 .15.05.3.15.37.1.1.22.15.4.15.17 0 .3-.05.4-.15a.5.5 0 0 0 .14-.37c0-.15-.02-.3-.12-.37Z" clipRule="evenodd"></path>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
export function Settings() {
|
export function Settings() {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [savedSettings, setSavedSettings] = useState<SettingsType>(getSettings());
|
const [savedSettings, setSavedSettings] = useState<SettingsType>(getSettings());
|
||||||
@@ -155,7 +163,7 @@ export function Settings() {
|
|||||||
setTempSettings((prev) => ({ ...prev, downloadPath: value }));
|
setTempSettings((prev) => ({ ...prev, downloadPath: value }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDownloaderChange = (value: "auto" | "deezer" | "tidal" | "qobuz") => {
|
const handleDownloaderChange = (value: "auto" | "deezer" | "tidal" | "qobuz" | "amazon") => {
|
||||||
setTempSettings((prev) => ({ ...prev, downloader: value }));
|
setTempSettings((prev) => ({ ...prev, downloader: value }));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -191,98 +199,138 @@ export function Settings() {
|
|||||||
<SettingsIcon className="h-5 w-5" />
|
<SettingsIcon className="h-5 w-5" />
|
||||||
</Button>
|
</Button>
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
<DialogContent className="sm:max-w-[500px] max-h-[85vh] flex flex-col" aria-describedby={undefined}>
|
<DialogContent className="sm:max-w-[700px] flex flex-col" aria-describedby={undefined}>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>Settings</DialogTitle>
|
<DialogTitle>Settings</DialogTitle>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="grid gap-4 py-2 overflow-y-auto flex-1">
|
<div className="grid grid-cols-2 gap-6 py-2">
|
||||||
{/* Download Path */}
|
{/* Left Column */}
|
||||||
<div className="space-y-2">
|
<div className="space-y-4">
|
||||||
<Label htmlFor="download-path">Download Path</Label>
|
{/* Download Path */}
|
||||||
<div className="flex gap-2">
|
<div className="space-y-2">
|
||||||
<Input
|
<Label htmlFor="download-path">Download Path</Label>
|
||||||
id="download-path"
|
<div className="flex gap-2">
|
||||||
value={tempSettings.downloadPath}
|
<InputWithContext
|
||||||
onChange={(e) => handleDownloadPathChange(e.target.value)}
|
id="download-path"
|
||||||
placeholder="C:\Users\YourUsername\Music"
|
value={tempSettings.downloadPath}
|
||||||
/>
|
onChange={(e) => handleDownloadPathChange(e.target.value)}
|
||||||
<Button type="button" onClick={handleBrowseFolder}>
|
placeholder="C:\Users\YourUsername\Music"
|
||||||
<FolderOpen className="h-4 w-4 mr-2" />
|
/>
|
||||||
Browse
|
<Button type="button" onClick={handleBrowseFolder} className="gap-1.5">
|
||||||
</Button>
|
<FolderOpen className="h-4 w-4" />
|
||||||
|
Browse
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Source Selection */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="downloader">Source</Label>
|
||||||
|
<Select
|
||||||
|
value={tempSettings.downloader}
|
||||||
|
onValueChange={handleDownloaderChange}
|
||||||
|
>
|
||||||
|
<SelectTrigger id="downloader">
|
||||||
|
<SelectValue placeholder="Select a source" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="auto">Auto</SelectItem>
|
||||||
|
<SelectItem value="tidal">
|
||||||
|
<span className="flex items-center">
|
||||||
|
<TidalIcon />
|
||||||
|
Tidal
|
||||||
|
</span>
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="deezer">
|
||||||
|
<span className="flex items-center">
|
||||||
|
<DeezerIcon />
|
||||||
|
Deezer
|
||||||
|
</span>
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="qobuz">
|
||||||
|
<span className="flex items-center">
|
||||||
|
<QobuzIcon />
|
||||||
|
Qobuz
|
||||||
|
</span>
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="amazon">
|
||||||
|
<span className="flex items-center">
|
||||||
|
<AmazonIcon />
|
||||||
|
Amazon Music
|
||||||
|
</span>
|
||||||
|
</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Theme Mode Selection */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="theme-mode">Theme</Label>
|
||||||
|
<Select value={tempSettings.themeMode} onValueChange={handleThemeModeChange}>
|
||||||
|
<SelectTrigger id="theme-mode">
|
||||||
|
<SelectValue placeholder="Select theme mode" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="auto">Auto</SelectItem>
|
||||||
|
<SelectItem value="light">Light</SelectItem>
|
||||||
|
<SelectItem value="dark">Dark</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Theme Color Selection */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="theme">Theme Color</Label>
|
||||||
|
<Select value={tempSettings.theme} onValueChange={handleThemeChange}>
|
||||||
|
<SelectTrigger id="theme">
|
||||||
|
<SelectValue placeholder="Select a theme" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{themes.map((theme) => (
|
||||||
|
<SelectItem key={theme.name} value={theme.name}>
|
||||||
|
<span className="flex items-center gap-2">
|
||||||
|
<span
|
||||||
|
className="w-3 h-3 rounded-full"
|
||||||
|
style={{ backgroundColor: theme.cssVars.light.primary }}
|
||||||
|
/>
|
||||||
|
{theme.label}
|
||||||
|
</span>
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Source Selection */}
|
{/* Right Column */}
|
||||||
<div className="space-y-2">
|
<div className="space-y-4">
|
||||||
<Label htmlFor="downloader">Source</Label>
|
|
||||||
<Select
|
|
||||||
value={tempSettings.downloader}
|
|
||||||
onValueChange={handleDownloaderChange}
|
|
||||||
>
|
|
||||||
<SelectTrigger id="downloader">
|
|
||||||
<SelectValue placeholder="Select a source" />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value="auto">
|
|
||||||
<span className="flex items-center">
|
|
||||||
<TidalIcon />
|
|
||||||
<DeezerIcon />
|
|
||||||
<QobuzIcon />
|
|
||||||
Auto (Tidal → Deezer → Qobuz)
|
|
||||||
</span>
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem value="tidal">
|
|
||||||
<span className="flex items-center">
|
|
||||||
<TidalIcon />
|
|
||||||
Tidal
|
|
||||||
</span>
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem value="deezer">
|
|
||||||
<span className="flex items-center">
|
|
||||||
<DeezerIcon />
|
|
||||||
Deezer
|
|
||||||
</span>
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem value="qobuz">
|
|
||||||
<span className="flex items-center">
|
|
||||||
<QobuzIcon />
|
|
||||||
Qobuz
|
|
||||||
</span>
|
|
||||||
</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* File Settings */}
|
|
||||||
<div className="space-y-3 pt-3 border-t">
|
|
||||||
<h3 className="font-medium text-sm">File Settings</h3>
|
|
||||||
|
|
||||||
{/* Filename Format */}
|
{/* Filename Format */}
|
||||||
<div className="space-y-1.5">
|
<div className="space-y-2">
|
||||||
<Label className="text-sm">Filename Format</Label>
|
<Label className="text-sm">Filename Format</Label>
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
value={tempSettings.filenameFormat}
|
value={tempSettings.filenameFormat}
|
||||||
onValueChange={(value) => setTempSettings(prev => ({ ...prev, filenameFormat: value as any }))}
|
onValueChange={(value) => setTempSettings(prev => ({ ...prev, filenameFormat: value as any }))}
|
||||||
className="flex flex-wrap gap-3"
|
|
||||||
>
|
>
|
||||||
<div className="flex items-center space-x-1.5">
|
<div className="flex items-center space-x-2">
|
||||||
<RadioGroupItem value="title-artist" id="title-artist" />
|
<RadioGroupItem value="title-artist" id="title-artist" />
|
||||||
<Label htmlFor="title-artist" className="cursor-pointer font-normal text-xs">Title - Artist</Label>
|
<Label htmlFor="title-artist" className="cursor-pointer font-normal text-sm">Title - Artist</Label>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center space-x-1.5">
|
<div className="flex items-center space-x-2">
|
||||||
<RadioGroupItem value="artist-title" id="artist-title" />
|
<RadioGroupItem value="artist-title" id="artist-title" />
|
||||||
<Label htmlFor="artist-title" className="cursor-pointer font-normal text-xs">Artist - Title</Label>
|
<Label htmlFor="artist-title" className="cursor-pointer font-normal text-sm">Artist - Title</Label>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center space-x-1.5">
|
<div className="flex items-center space-x-2">
|
||||||
<RadioGroupItem value="title" id="title" />
|
<RadioGroupItem value="title" id="title" />
|
||||||
<Label htmlFor="title" className="cursor-pointer font-normal text-xs">Title</Label>
|
<Label htmlFor="title" className="cursor-pointer font-normal text-sm">Title</Label>
|
||||||
</div>
|
</div>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Subfolder Options */}
|
<div className="border-t" />
|
||||||
|
|
||||||
|
{/* Folder Settings */}
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
|
<h3 className="font-medium text-sm">Folder Settings</h3>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
id="track-number"
|
id="track-number"
|
||||||
@@ -290,6 +338,14 @@ export function Settings() {
|
|||||||
onCheckedChange={(checked) => setTempSettings(prev => ({ ...prev, trackNumber: checked as boolean }))}
|
onCheckedChange={(checked) => setTempSettings(prev => ({ ...prev, trackNumber: checked as boolean }))}
|
||||||
/>
|
/>
|
||||||
<Label htmlFor="track-number" className="cursor-pointer text-sm">Track Number</Label>
|
<Label htmlFor="track-number" className="cursor-pointer text-sm">Track Number</Label>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger asChild>
|
||||||
|
<Info className="h-3.5 w-3.5 text-muted-foreground cursor-help" />
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent side="top" className="max-w-xs">
|
||||||
|
<p className="text-xs text-center">Adds track numbers to filenames. Uses album track numbers when Album Subfolder is enabled, otherwise uses playlist position</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
@@ -297,7 +353,7 @@ export function Settings() {
|
|||||||
checked={tempSettings.artistSubfolder}
|
checked={tempSettings.artistSubfolder}
|
||||||
onCheckedChange={(checked) => setTempSettings(prev => ({ ...prev, artistSubfolder: checked as boolean }))}
|
onCheckedChange={(checked) => setTempSettings(prev => ({ ...prev, artistSubfolder: checked as boolean }))}
|
||||||
/>
|
/>
|
||||||
<Label htmlFor="artist-subfolder" className="cursor-pointer text-sm">Artist Subfolder (Playlist only)</Label>
|
<Label htmlFor="artist-subfolder" className="cursor-pointer text-sm">Artist Subfolder <span className="font-normal">(Playlist only)</span></Label>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
@@ -305,42 +361,10 @@ export function Settings() {
|
|||||||
checked={tempSettings.albumSubfolder}
|
checked={tempSettings.albumSubfolder}
|
||||||
onCheckedChange={(checked) => setTempSettings(prev => ({ ...prev, albumSubfolder: checked as boolean }))}
|
onCheckedChange={(checked) => setTempSettings(prev => ({ ...prev, albumSubfolder: checked as boolean }))}
|
||||||
/>
|
/>
|
||||||
<Label htmlFor="album-subfolder" className="cursor-pointer text-sm">Album Subfolder (Playlist & Discography)</Label>
|
<Label htmlFor="album-subfolder" className="cursor-pointer text-sm">Album Subfolder <span className="font-normal">(Playlist & Discography)</span></Label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Theme Mode Selection */}
|
|
||||||
<div className="space-y-1.5 pt-3 border-t">
|
|
||||||
<Label htmlFor="theme-mode" className="text-sm">Theme</Label>
|
|
||||||
<Select value={tempSettings.themeMode} onValueChange={handleThemeModeChange}>
|
|
||||||
<SelectTrigger id="theme-mode">
|
|
||||||
<SelectValue placeholder="Select theme mode" />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value="auto">Auto</SelectItem>
|
|
||||||
<SelectItem value="light">Light</SelectItem>
|
|
||||||
<SelectItem value="dark">Dark</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Theme Color Selection */}
|
|
||||||
<div className="space-y-1.5">
|
|
||||||
<Label htmlFor="theme" className="text-sm">Theme Color</Label>
|
|
||||||
<Select value={tempSettings.theme} onValueChange={handleThemeChange}>
|
|
||||||
<SelectTrigger id="theme">
|
|
||||||
<SelectValue placeholder="Select a theme" />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
{themes.map((theme) => (
|
|
||||||
<SelectItem key={theme.name} value={theme.name}>
|
|
||||||
{theme.label}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<DialogFooter className="gap-2 sm:justify-between">
|
<DialogFooter className="gap-2 sm:justify-between">
|
||||||
<Button variant="outline" onClick={handleReset} size="sm" className="gap-1.5">
|
<Button variant="outline" onClick={handleReset} size="sm" className="gap-1.5">
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import { X, Minus, Square } from "lucide-react";
|
||||||
|
import { WindowMinimise, WindowToggleMaximise, Quit } from "../../wailsjs/runtime/runtime";
|
||||||
|
|
||||||
|
export function TitleBar() {
|
||||||
|
const [hoveredButton, setHoveredButton] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const handleMinimize = () => {
|
||||||
|
WindowMinimise();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMaximize = () => {
|
||||||
|
WindowToggleMaximise();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
Quit();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{/* Draggable area */}
|
||||||
|
<div
|
||||||
|
className="fixed top-0 left-0 right-0 h-12 z-40"
|
||||||
|
style={{ "--wails-draggable": "drag" } as React.CSSProperties}
|
||||||
|
onDoubleClick={handleMaximize}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Window control buttons */}
|
||||||
|
<div className="fixed top-4 left-4 z-50 flex gap-2">
|
||||||
|
<button
|
||||||
|
onClick={handleClose}
|
||||||
|
onMouseEnter={() => setHoveredButton("close")}
|
||||||
|
onMouseLeave={() => setHoveredButton(null)}
|
||||||
|
className="w-3 h-3 rounded-full bg-red-500 hover:bg-red-600 transition-colors flex items-center justify-center"
|
||||||
|
style={{ "--wails-draggable": "no-drag" } as React.CSSProperties}
|
||||||
|
aria-label="Close"
|
||||||
|
>
|
||||||
|
{hoveredButton === "close" && (
|
||||||
|
<X className="w-2 h-2 text-red-900" strokeWidth={3} />
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={handleMinimize}
|
||||||
|
onMouseEnter={() => setHoveredButton("minimize")}
|
||||||
|
onMouseLeave={() => setHoveredButton(null)}
|
||||||
|
className="w-3 h-3 rounded-full bg-yellow-500 hover:bg-yellow-600 transition-colors flex items-center justify-center"
|
||||||
|
style={{ "--wails-draggable": "no-drag" } as React.CSSProperties}
|
||||||
|
aria-label="Minimize"
|
||||||
|
>
|
||||||
|
{hoveredButton === "minimize" && (
|
||||||
|
<Minus className="w-2 h-2 text-yellow-900" strokeWidth={3} />
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={handleMaximize}
|
||||||
|
onMouseEnter={() => setHoveredButton("maximize")}
|
||||||
|
onMouseLeave={() => setHoveredButton(null)}
|
||||||
|
className="w-3 h-3 rounded-full bg-green-500 hover:bg-green-600 transition-colors flex items-center justify-center"
|
||||||
|
style={{ "--wails-draggable": "no-drag" } as React.CSSProperties}
|
||||||
|
aria-label="Maximize"
|
||||||
|
>
|
||||||
|
{hoveredButton === "maximize" && (
|
||||||
|
<Square className="w-1.5 h-1.5 text-green-900" strokeWidth={3} />
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from "@/components/ui/card";
|
||||||
import { Download, FolderOpen } from "lucide-react";
|
import { Download, FolderOpen, CheckCircle, XCircle } from "lucide-react";
|
||||||
import { Spinner } from "@/components/ui/spinner";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
import type { TrackMetadata } from "@/types/api";
|
import type { TrackMetadata } from "@/types/api";
|
||||||
|
|
||||||
@@ -9,7 +9,8 @@ interface TrackInfoProps {
|
|||||||
isDownloading: boolean;
|
isDownloading: boolean;
|
||||||
downloadingTrack: string | null;
|
downloadingTrack: string | null;
|
||||||
isDownloaded: boolean;
|
isDownloaded: boolean;
|
||||||
onDownload: (isrc: string, name: string, artists: string) => void;
|
isFailed: boolean;
|
||||||
|
onDownload: (isrc: string, name: string, artists: string, albumName?: string, spotifyId?: string) => void;
|
||||||
onOpenFolder: () => void;
|
onOpenFolder: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@ export function TrackInfo({
|
|||||||
isDownloading,
|
isDownloading,
|
||||||
downloadingTrack,
|
downloadingTrack,
|
||||||
isDownloaded,
|
isDownloaded,
|
||||||
|
isFailed,
|
||||||
onDownload,
|
onDownload,
|
||||||
onOpenFolder,
|
onOpenFolder,
|
||||||
}: TrackInfoProps) {
|
}: TrackInfoProps) {
|
||||||
@@ -34,7 +36,15 @@ export function TrackInfo({
|
|||||||
)}
|
)}
|
||||||
<div className="flex-1 space-y-4 min-w-0">
|
<div className="flex-1 space-y-4 min-w-0">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<h1 className="text-3xl font-bold wrap-break-word">{track.name}</h1>
|
<div className="flex items-center gap-3">
|
||||||
|
<h1 className="text-3xl font-bold wrap-break-word">{track.name}</h1>
|
||||||
|
{isDownloaded && (
|
||||||
|
<CheckCircle className="h-6 w-6 text-green-500 shrink-0" />
|
||||||
|
)}
|
||||||
|
{isFailed && (
|
||||||
|
<XCircle className="h-6 w-6 text-red-500 shrink-0" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<p className="text-lg text-muted-foreground">{track.artists}</p>
|
<p className="text-lg text-muted-foreground">{track.artists}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-2 gap-3 text-sm">
|
<div className="grid grid-cols-2 gap-3 text-sm">
|
||||||
@@ -50,20 +60,20 @@ export function TrackInfo({
|
|||||||
{track.isrc && (
|
{track.isrc && (
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Button
|
<Button
|
||||||
onClick={() => onDownload(track.isrc, track.name, track.artists)}
|
onClick={() => onDownload(track.isrc, track.name, track.artists, track.album_name, track.spotify_id)}
|
||||||
disabled={isDownloading || downloadingTrack === track.isrc}
|
disabled={isDownloading || downloadingTrack === track.isrc}
|
||||||
>
|
>
|
||||||
{downloadingTrack === track.isrc ? (
|
{downloadingTrack === track.isrc ? (
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Download className="h-4 w-4 mr-2" />
|
<Download className="h-4 w-4" />
|
||||||
Download
|
Download
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
{isDownloaded && (
|
{isDownloaded && (
|
||||||
<Button onClick={onOpenFolder} variant="outline" className="gap-2">
|
<Button onClick={onOpenFolder} variant="outline">
|
||||||
<FolderOpen className="h-4 w-4" />
|
<FolderOpen className="h-4 w-4" />
|
||||||
Open Folder
|
Open Folder
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
import { Download, CheckCircle } from "lucide-react";
|
import { Download, CheckCircle, XCircle } from "lucide-react";
|
||||||
import { Spinner } from "@/components/ui/spinner";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
import {
|
import {
|
||||||
Pagination,
|
Pagination,
|
||||||
@@ -18,6 +18,7 @@ interface TrackListProps {
|
|||||||
sortBy: string;
|
sortBy: string;
|
||||||
selectedTracks: string[];
|
selectedTracks: string[];
|
||||||
downloadedTracks: Set<string>;
|
downloadedTracks: Set<string>;
|
||||||
|
failedTracks: Set<string>;
|
||||||
downloadingTrack: string | null;
|
downloadingTrack: string | null;
|
||||||
isDownloading: boolean;
|
isDownloading: boolean;
|
||||||
currentPage: number;
|
currentPage: number;
|
||||||
@@ -36,6 +37,7 @@ export function TrackList({
|
|||||||
sortBy,
|
sortBy,
|
||||||
selectedTracks,
|
selectedTracks,
|
||||||
downloadedTracks,
|
downloadedTracks,
|
||||||
|
failedTracks,
|
||||||
downloadingTrack,
|
downloadingTrack,
|
||||||
isDownloading,
|
isDownloading,
|
||||||
currentPage,
|
currentPage,
|
||||||
@@ -165,6 +167,9 @@ export function TrackList({
|
|||||||
{downloadedTracks.has(track.isrc) && (
|
{downloadedTracks.has(track.isrc) && (
|
||||||
<CheckCircle className="h-4 w-4 text-green-500 shrink-0" />
|
<CheckCircle className="h-4 w-4 text-green-500 shrink-0" />
|
||||||
)}
|
)}
|
||||||
|
{failedTracks.has(track.isrc) && (
|
||||||
|
<XCircle className="h-4 w-4 text-red-500 shrink-0" />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<span className="text-sm text-muted-foreground">
|
<span className="text-sm text-muted-foreground">
|
||||||
{track.artists}
|
{track.artists}
|
||||||
@@ -187,13 +192,14 @@ export function TrackList({
|
|||||||
onDownloadTrack(track.isrc, track.name, track.artists, track.album_name)
|
onDownloadTrack(track.isrc, track.name, track.artists, track.album_name)
|
||||||
}
|
}
|
||||||
size="sm"
|
size="sm"
|
||||||
|
className="gap-1.5"
|
||||||
disabled={isDownloading || downloadingTrack === track.isrc}
|
disabled={isDownloading || downloadingTrack === track.isrc}
|
||||||
>
|
>
|
||||||
{downloadingTrack === track.isrc ? (
|
{downloadingTrack === track.isrc ? (
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Download className="h-4 w-4 mr-2" />
|
<Download className="h-4 w-4" />
|
||||||
Download
|
Download
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { cva, type VariantProps } from "class-variance-authority"
|
|||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
const buttonVariants = cva(
|
const buttonVariants = cva(
|
||||||
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all cursor-pointer disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
||||||
{
|
{
|
||||||
variants: {
|
variants: {
|
||||||
variant: {
|
variant: {
|
||||||
|
|||||||
@@ -0,0 +1,252 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu"
|
||||||
|
import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function ContextMenu({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Root>) {
|
||||||
|
return <ContextMenuPrimitive.Root data-slot="context-menu" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContextMenuTrigger({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Trigger>) {
|
||||||
|
return (
|
||||||
|
<ContextMenuPrimitive.Trigger data-slot="context-menu-trigger" {...props} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContextMenuGroup({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Group>) {
|
||||||
|
return (
|
||||||
|
<ContextMenuPrimitive.Group data-slot="context-menu-group" {...props} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContextMenuPortal({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Portal>) {
|
||||||
|
return (
|
||||||
|
<ContextMenuPrimitive.Portal data-slot="context-menu-portal" {...props} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContextMenuSub({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Sub>) {
|
||||||
|
return <ContextMenuPrimitive.Sub data-slot="context-menu-sub" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContextMenuRadioGroup({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ContextMenuPrimitive.RadioGroup>) {
|
||||||
|
return (
|
||||||
|
<ContextMenuPrimitive.RadioGroup
|
||||||
|
data-slot="context-menu-radio-group"
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContextMenuSubTrigger({
|
||||||
|
className,
|
||||||
|
inset,
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ContextMenuPrimitive.SubTrigger> & {
|
||||||
|
inset?: boolean
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<ContextMenuPrimitive.SubTrigger
|
||||||
|
data-slot="context-menu-sub-trigger"
|
||||||
|
data-inset={inset}
|
||||||
|
className={cn(
|
||||||
|
"focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
<ChevronRightIcon className="ml-auto" />
|
||||||
|
</ContextMenuPrimitive.SubTrigger>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContextMenuSubContent({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ContextMenuPrimitive.SubContent>) {
|
||||||
|
return (
|
||||||
|
<ContextMenuPrimitive.SubContent
|
||||||
|
data-slot="context-menu-sub-content"
|
||||||
|
className={cn(
|
||||||
|
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-32 origin-(--radix-context-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContextMenuContent({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Content>) {
|
||||||
|
return (
|
||||||
|
<ContextMenuPrimitive.Portal>
|
||||||
|
<ContextMenuPrimitive.Content
|
||||||
|
data-slot="context-menu-content"
|
||||||
|
className={cn(
|
||||||
|
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-context-menu-content-available-height) min-w-32 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
</ContextMenuPrimitive.Portal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContextMenuItem({
|
||||||
|
className,
|
||||||
|
inset,
|
||||||
|
variant = "default",
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Item> & {
|
||||||
|
inset?: boolean
|
||||||
|
variant?: "default" | "destructive"
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<ContextMenuPrimitive.Item
|
||||||
|
data-slot="context-menu-item"
|
||||||
|
data-inset={inset}
|
||||||
|
data-variant={variant}
|
||||||
|
className={cn(
|
||||||
|
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive! [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContextMenuCheckboxItem({
|
||||||
|
className,
|
||||||
|
children,
|
||||||
|
checked,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ContextMenuPrimitive.CheckboxItem>) {
|
||||||
|
return (
|
||||||
|
<ContextMenuPrimitive.CheckboxItem
|
||||||
|
data-slot="context-menu-checkbox-item"
|
||||||
|
className={cn(
|
||||||
|
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
checked={checked}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
||||||
|
<ContextMenuPrimitive.ItemIndicator>
|
||||||
|
<CheckIcon className="size-4" />
|
||||||
|
</ContextMenuPrimitive.ItemIndicator>
|
||||||
|
</span>
|
||||||
|
{children}
|
||||||
|
</ContextMenuPrimitive.CheckboxItem>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContextMenuRadioItem({
|
||||||
|
className,
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ContextMenuPrimitive.RadioItem>) {
|
||||||
|
return (
|
||||||
|
<ContextMenuPrimitive.RadioItem
|
||||||
|
data-slot="context-menu-radio-item"
|
||||||
|
className={cn(
|
||||||
|
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
||||||
|
<ContextMenuPrimitive.ItemIndicator>
|
||||||
|
<CircleIcon className="size-2 fill-current" />
|
||||||
|
</ContextMenuPrimitive.ItemIndicator>
|
||||||
|
</span>
|
||||||
|
{children}
|
||||||
|
</ContextMenuPrimitive.RadioItem>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContextMenuLabel({
|
||||||
|
className,
|
||||||
|
inset,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Label> & {
|
||||||
|
inset?: boolean
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<ContextMenuPrimitive.Label
|
||||||
|
data-slot="context-menu-label"
|
||||||
|
data-inset={inset}
|
||||||
|
className={cn(
|
||||||
|
"text-foreground px-2 py-1.5 text-sm font-medium data-inset:pl-8",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContextMenuSeparator({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Separator>) {
|
||||||
|
return (
|
||||||
|
<ContextMenuPrimitive.Separator
|
||||||
|
data-slot="context-menu-separator"
|
||||||
|
className={cn("bg-border -mx-1 my-1 h-px", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContextMenuShortcut({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"span">) {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
data-slot="context-menu-shortcut"
|
||||||
|
className={cn(
|
||||||
|
"text-muted-foreground ml-auto text-xs tracking-widest",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
ContextMenu,
|
||||||
|
ContextMenuTrigger,
|
||||||
|
ContextMenuContent,
|
||||||
|
ContextMenuItem,
|
||||||
|
ContextMenuCheckboxItem,
|
||||||
|
ContextMenuRadioItem,
|
||||||
|
ContextMenuLabel,
|
||||||
|
ContextMenuSeparator,
|
||||||
|
ContextMenuShortcut,
|
||||||
|
ContextMenuGroup,
|
||||||
|
ContextMenuPortal,
|
||||||
|
ContextMenuSub,
|
||||||
|
ContextMenuSubContent,
|
||||||
|
ContextMenuSubTrigger,
|
||||||
|
ContextMenuRadioGroup,
|
||||||
|
}
|
||||||
@@ -0,0 +1,214 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import {
|
||||||
|
ContextMenu,
|
||||||
|
ContextMenuContent,
|
||||||
|
ContextMenuItem,
|
||||||
|
ContextMenuSeparator,
|
||||||
|
ContextMenuTrigger,
|
||||||
|
} from "@/components/ui/context-menu";
|
||||||
|
import { Scissors, Copy, Clipboard, Type } from "lucide-react";
|
||||||
|
|
||||||
|
export interface InputWithContextProps
|
||||||
|
extends React.InputHTMLAttributes<HTMLInputElement> {
|
||||||
|
onValueChange?: (value: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const InputWithContext = React.forwardRef<HTMLInputElement, InputWithContextProps>(
|
||||||
|
({ className, type, onValueChange, onChange, ...props }, ref) => {
|
||||||
|
const inputRef = React.useRef<HTMLInputElement>(null);
|
||||||
|
const [hasSelection, setHasSelection] = React.useState(false);
|
||||||
|
const [canPaste, setCanPaste] = React.useState(false);
|
||||||
|
|
||||||
|
// Combine refs
|
||||||
|
React.useImperativeHandle(ref, () => inputRef.current as HTMLInputElement);
|
||||||
|
|
||||||
|
// Check selection state
|
||||||
|
const updateSelectionState = () => {
|
||||||
|
const input = inputRef.current;
|
||||||
|
if (!input) return;
|
||||||
|
const start = input.selectionStart ?? 0;
|
||||||
|
const end = input.selectionEnd ?? 0;
|
||||||
|
setHasSelection(start !== end);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check clipboard permission
|
||||||
|
const checkClipboard = async () => {
|
||||||
|
try {
|
||||||
|
const text = await navigator.clipboard.readText();
|
||||||
|
setCanPaste(text.length > 0);
|
||||||
|
} catch {
|
||||||
|
setCanPaste(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
checkClipboard();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleCut = async () => {
|
||||||
|
const input = inputRef.current;
|
||||||
|
if (!input) return;
|
||||||
|
|
||||||
|
const start = input.selectionStart ?? 0;
|
||||||
|
const end = input.selectionEnd ?? 0;
|
||||||
|
const selectedText = input.value.substring(start, end);
|
||||||
|
|
||||||
|
if (selectedText) {
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(selectedText);
|
||||||
|
const newValue = input.value.substring(0, start) + input.value.substring(end);
|
||||||
|
|
||||||
|
// Update value and trigger change
|
||||||
|
input.value = newValue;
|
||||||
|
input.setSelectionRange(start, start);
|
||||||
|
|
||||||
|
// Trigger React onChange
|
||||||
|
if (onChange) {
|
||||||
|
const event = {
|
||||||
|
target: input,
|
||||||
|
currentTarget: input,
|
||||||
|
} as React.ChangeEvent<HTMLInputElement>;
|
||||||
|
onChange(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onValueChange) {
|
||||||
|
onValueChange(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
input.focus();
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to cut:", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCopy = async () => {
|
||||||
|
const input = inputRef.current;
|
||||||
|
if (!input) return;
|
||||||
|
|
||||||
|
const start = input.selectionStart ?? 0;
|
||||||
|
const end = input.selectionEnd ?? 0;
|
||||||
|
const selectedText = input.value.substring(start, end);
|
||||||
|
|
||||||
|
if (selectedText) {
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(selectedText);
|
||||||
|
input.focus();
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to copy:", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePaste = async () => {
|
||||||
|
const input = inputRef.current;
|
||||||
|
if (!input) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const text = await navigator.clipboard.readText();
|
||||||
|
const start = input.selectionStart ?? 0;
|
||||||
|
const end = input.selectionEnd ?? 0;
|
||||||
|
|
||||||
|
const newValue =
|
||||||
|
input.value.substring(0, start) + text + input.value.substring(end);
|
||||||
|
|
||||||
|
// Update value and trigger change
|
||||||
|
input.value = newValue;
|
||||||
|
const newPosition = start + text.length;
|
||||||
|
input.setSelectionRange(newPosition, newPosition);
|
||||||
|
|
||||||
|
// Trigger React onChange
|
||||||
|
if (onChange) {
|
||||||
|
const event = {
|
||||||
|
target: input,
|
||||||
|
currentTarget: input,
|
||||||
|
} as React.ChangeEvent<HTMLInputElement>;
|
||||||
|
onChange(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onValueChange) {
|
||||||
|
onValueChange(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
input.focus();
|
||||||
|
await checkClipboard();
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to paste:", err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSelectAll = () => {
|
||||||
|
const input = inputRef.current;
|
||||||
|
if (!input) return;
|
||||||
|
input.select();
|
||||||
|
input.focus();
|
||||||
|
updateSelectionState();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
if (onChange) {
|
||||||
|
onChange(e);
|
||||||
|
}
|
||||||
|
if (onValueChange) {
|
||||||
|
onValueChange(e.target.value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ContextMenu onOpenChange={checkClipboard}>
|
||||||
|
<ContextMenuTrigger asChild>
|
||||||
|
<Input
|
||||||
|
ref={inputRef}
|
||||||
|
type={type}
|
||||||
|
className={className}
|
||||||
|
onChange={handleInputChange}
|
||||||
|
onSelect={updateSelectionState}
|
||||||
|
onMouseUp={updateSelectionState}
|
||||||
|
onKeyUp={updateSelectionState}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
</ContextMenuTrigger>
|
||||||
|
<ContextMenuContent className="w-48">
|
||||||
|
<ContextMenuItem
|
||||||
|
onSelect={handleCut}
|
||||||
|
disabled={!hasSelection || props.disabled || props.readOnly}
|
||||||
|
>
|
||||||
|
<Scissors className="mr-2 h-4 w-4" />
|
||||||
|
Cut
|
||||||
|
<span className="ml-auto text-xs text-muted-foreground">Ctrl+X</span>
|
||||||
|
</ContextMenuItem>
|
||||||
|
<ContextMenuItem
|
||||||
|
onSelect={handleCopy}
|
||||||
|
disabled={!hasSelection || props.disabled}
|
||||||
|
>
|
||||||
|
<Copy className="mr-2 h-4 w-4" />
|
||||||
|
Copy
|
||||||
|
<span className="ml-auto text-xs text-muted-foreground">Ctrl+C</span>
|
||||||
|
</ContextMenuItem>
|
||||||
|
<ContextMenuItem
|
||||||
|
onSelect={handlePaste}
|
||||||
|
disabled={!canPaste || props.disabled || props.readOnly}
|
||||||
|
>
|
||||||
|
<Clipboard className="mr-2 h-4 w-4" />
|
||||||
|
Paste
|
||||||
|
<span className="ml-auto text-xs text-muted-foreground">Ctrl+V</span>
|
||||||
|
</ContextMenuItem>
|
||||||
|
<ContextMenuSeparator />
|
||||||
|
<ContextMenuItem
|
||||||
|
onSelect={handleSelectAll}
|
||||||
|
disabled={!inputRef.current?.value || props.disabled}
|
||||||
|
>
|
||||||
|
<Type className="mr-2 h-4 w-4" />
|
||||||
|
Select All
|
||||||
|
<span className="ml-auto text-xs text-muted-foreground">Ctrl+A</span>
|
||||||
|
</ContextMenuItem>
|
||||||
|
</ContextMenuContent>
|
||||||
|
</ContextMenu>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
InputWithContext.displayName = "InputWithContext";
|
||||||
|
|
||||||
|
export { InputWithContext };
|
||||||
@@ -11,6 +11,7 @@ export function useDownload() {
|
|||||||
const [downloadingTrack, setDownloadingTrack] = useState<string | null>(null);
|
const [downloadingTrack, setDownloadingTrack] = useState<string | null>(null);
|
||||||
const [bulkDownloadType, setBulkDownloadType] = useState<"all" | "selected" | null>(null);
|
const [bulkDownloadType, setBulkDownloadType] = useState<"all" | "selected" | null>(null);
|
||||||
const [downloadedTracks, setDownloadedTracks] = useState<Set<string>>(new Set());
|
const [downloadedTracks, setDownloadedTracks] = useState<Set<string>>(new Set());
|
||||||
|
const [failedTracks, setFailedTracks] = useState<Set<string>>(new Set());
|
||||||
const [currentDownloadInfo, setCurrentDownloadInfo] = useState<{
|
const [currentDownloadInfo, setCurrentDownloadInfo] = useState<{
|
||||||
name: string;
|
name: string;
|
||||||
artists: string;
|
artists: string;
|
||||||
@@ -24,7 +25,9 @@ export function useDownload() {
|
|||||||
artistName?: string,
|
artistName?: string,
|
||||||
albumName?: string,
|
albumName?: string,
|
||||||
playlistName?: string,
|
playlistName?: string,
|
||||||
isArtistDiscography?: boolean
|
isArtistDiscography?: boolean,
|
||||||
|
position?: number,
|
||||||
|
spotifyId?: string
|
||||||
) => {
|
) => {
|
||||||
let service = settings.downloader;
|
let service = settings.downloader;
|
||||||
|
|
||||||
@@ -32,6 +35,7 @@ export function useDownload() {
|
|||||||
const os = settings.operatingSystem;
|
const os = settings.operatingSystem;
|
||||||
|
|
||||||
let outputDir = settings.downloadPath;
|
let outputDir = settings.downloadPath;
|
||||||
|
let useAlbumTrackNumber = false;
|
||||||
|
|
||||||
if (playlistName) {
|
if (playlistName) {
|
||||||
outputDir = joinPath(os, outputDir, sanitizePath(playlistName, os));
|
outputDir = joinPath(os, outputDir, sanitizePath(playlistName, os));
|
||||||
@@ -39,6 +43,7 @@ export function useDownload() {
|
|||||||
if (isArtistDiscography) {
|
if (isArtistDiscography) {
|
||||||
if (settings.albumSubfolder && albumName) {
|
if (settings.albumSubfolder && albumName) {
|
||||||
outputDir = joinPath(os, outputDir, sanitizePath(albumName, os));
|
outputDir = joinPath(os, outputDir, sanitizePath(albumName, os));
|
||||||
|
useAlbumTrackNumber = true; // Use album track number for discography with album subfolder
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (settings.artistSubfolder && artistName) {
|
if (settings.artistSubfolder && artistName) {
|
||||||
@@ -47,51 +52,106 @@ export function useDownload() {
|
|||||||
|
|
||||||
if (settings.albumSubfolder && albumName) {
|
if (settings.albumSubfolder && albumName) {
|
||||||
outputDir = joinPath(os, outputDir, sanitizePath(albumName, os));
|
outputDir = joinPath(os, outputDir, sanitizePath(albumName, os));
|
||||||
|
useAlbumTrackNumber = true; // Use album track number when both artist and album subfolders are used
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (service === "auto") {
|
if (service === "auto") {
|
||||||
// Try Tidal first
|
// Get all streaming URLs once from song.link API
|
||||||
try {
|
let streamingURLs: any = null;
|
||||||
const tidalResponse = await downloadTrack({
|
if (spotifyId) {
|
||||||
isrc,
|
try {
|
||||||
service: "tidal",
|
const { GetStreamingURLs } = await import("../../wailsjs/go/main/App");
|
||||||
query,
|
const urlsJson = await GetStreamingURLs(spotifyId);
|
||||||
track_name: trackName,
|
streamingURLs = JSON.parse(urlsJson);
|
||||||
artist_name: artistName,
|
} catch (err) {
|
||||||
album_name: albumName,
|
console.error("Failed to get streaming URLs:", err);
|
||||||
output_dir: outputDir,
|
}
|
||||||
filename_format: settings.filenameFormat,
|
}
|
||||||
track_number: settings.trackNumber,
|
|
||||||
});
|
// Try Tidal first
|
||||||
|
if (streamingURLs?.tidal_url) {
|
||||||
if (tidalResponse.success) {
|
try {
|
||||||
return tidalResponse;
|
const tidalResponse = await downloadTrack({
|
||||||
|
isrc,
|
||||||
|
service: "tidal",
|
||||||
|
query,
|
||||||
|
track_name: trackName,
|
||||||
|
artist_name: artistName,
|
||||||
|
album_name: albumName,
|
||||||
|
output_dir: outputDir,
|
||||||
|
filename_format: settings.filenameFormat,
|
||||||
|
track_number: settings.trackNumber,
|
||||||
|
position,
|
||||||
|
use_album_track_number: useAlbumTrackNumber,
|
||||||
|
spotify_id: spotifyId,
|
||||||
|
service_url: streamingURLs.tidal_url,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (tidalResponse.success) {
|
||||||
|
return tidalResponse;
|
||||||
|
}
|
||||||
|
console.log("Tidal failed, trying Deezer...");
|
||||||
|
} catch (tidalErr) {
|
||||||
|
console.log("Tidal error:", tidalErr);
|
||||||
}
|
}
|
||||||
} catch (tidalErr) {
|
|
||||||
// Tidal failed, continue to Deezer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try Deezer second
|
// Try Deezer second
|
||||||
try {
|
if (streamingURLs?.deezer_url) {
|
||||||
const deezerResponse = await downloadTrack({
|
try {
|
||||||
isrc,
|
const deezerResponse = await downloadTrack({
|
||||||
service: "deezer",
|
isrc,
|
||||||
query,
|
service: "deezer",
|
||||||
track_name: trackName,
|
query,
|
||||||
artist_name: artistName,
|
track_name: trackName,
|
||||||
album_name: albumName,
|
artist_name: artistName,
|
||||||
output_dir: outputDir,
|
album_name: albumName,
|
||||||
filename_format: settings.filenameFormat,
|
output_dir: outputDir,
|
||||||
track_number: settings.trackNumber,
|
filename_format: settings.filenameFormat,
|
||||||
});
|
track_number: settings.trackNumber,
|
||||||
|
position,
|
||||||
|
use_album_track_number: useAlbumTrackNumber,
|
||||||
|
spotify_id: spotifyId,
|
||||||
|
service_url: streamingURLs.deezer_url,
|
||||||
|
});
|
||||||
|
|
||||||
if (deezerResponse.success) {
|
if (deezerResponse.success) {
|
||||||
return deezerResponse;
|
return deezerResponse;
|
||||||
|
}
|
||||||
|
console.log("Deezer failed, trying Amazon...");
|
||||||
|
} catch (deezerErr) {
|
||||||
|
console.log("Deezer error:", deezerErr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try Amazon third
|
||||||
|
if (streamingURLs?.amazon_url) {
|
||||||
|
try {
|
||||||
|
const amazonResponse = await downloadTrack({
|
||||||
|
isrc,
|
||||||
|
service: "amazon",
|
||||||
|
query,
|
||||||
|
track_name: trackName,
|
||||||
|
artist_name: artistName,
|
||||||
|
album_name: albumName,
|
||||||
|
output_dir: outputDir,
|
||||||
|
filename_format: settings.filenameFormat,
|
||||||
|
track_number: settings.trackNumber,
|
||||||
|
position,
|
||||||
|
use_album_track_number: useAlbumTrackNumber,
|
||||||
|
spotify_id: spotifyId,
|
||||||
|
service_url: streamingURLs.amazon_url,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (amazonResponse.success) {
|
||||||
|
return amazonResponse;
|
||||||
|
}
|
||||||
|
console.log("Amazon failed, trying Qobuz...");
|
||||||
|
} catch (amazonErr) {
|
||||||
|
console.log("Amazon error:", amazonErr);
|
||||||
}
|
}
|
||||||
} catch (deezerErr) {
|
|
||||||
// Deezer failed, continue to Qobuz
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try Qobuz as last fallback
|
// Try Qobuz as last fallback
|
||||||
@@ -100,7 +160,7 @@ export function useDownload() {
|
|||||||
|
|
||||||
return await downloadTrack({
|
return await downloadTrack({
|
||||||
isrc,
|
isrc,
|
||||||
service: service as "deezer" | "tidal" | "qobuz",
|
service: service as "deezer" | "tidal" | "qobuz" | "amazon",
|
||||||
query,
|
query,
|
||||||
track_name: trackName,
|
track_name: trackName,
|
||||||
artist_name: artistName,
|
artist_name: artistName,
|
||||||
@@ -108,6 +168,9 @@ export function useDownload() {
|
|||||||
output_dir: outputDir,
|
output_dir: outputDir,
|
||||||
filename_format: settings.filenameFormat,
|
filename_format: settings.filenameFormat,
|
||||||
track_number: settings.trackNumber,
|
track_number: settings.trackNumber,
|
||||||
|
position,
|
||||||
|
use_album_track_number: useAlbumTrackNumber,
|
||||||
|
spotify_id: spotifyId,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -115,7 +178,8 @@ export function useDownload() {
|
|||||||
isrc: string,
|
isrc: string,
|
||||||
trackName?: string,
|
trackName?: string,
|
||||||
artistName?: string,
|
artistName?: string,
|
||||||
albumName?: string
|
albumName?: string,
|
||||||
|
spotifyId?: string
|
||||||
) => {
|
) => {
|
||||||
if (!isrc) {
|
if (!isrc) {
|
||||||
toast.error("No ISRC found for this track");
|
toast.error("No ISRC found for this track");
|
||||||
@@ -126,6 +190,7 @@ export function useDownload() {
|
|||||||
setDownloadingTrack(isrc);
|
setDownloadingTrack(isrc);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Single track download - no position parameter
|
||||||
const response = await downloadWithAutoFallback(
|
const response = await downloadWithAutoFallback(
|
||||||
isrc,
|
isrc,
|
||||||
settings,
|
settings,
|
||||||
@@ -133,11 +198,17 @@ export function useDownload() {
|
|||||||
artistName,
|
artistName,
|
||||||
albumName,
|
albumName,
|
||||||
undefined,
|
undefined,
|
||||||
false
|
false,
|
||||||
|
undefined, // Don't pass position for single track
|
||||||
|
spotifyId
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
toast.success(response.message);
|
if (response.already_exists) {
|
||||||
|
toast.info(response.message);
|
||||||
|
} else {
|
||||||
|
toast.success(response.message);
|
||||||
|
}
|
||||||
setDownloadedTracks((prev) => new Set(prev).add(isrc));
|
setDownloadedTracks((prev) => new Set(prev).add(isrc));
|
||||||
} else {
|
} else {
|
||||||
toast.error(response.error || "Download failed");
|
toast.error(response.error || "Download failed");
|
||||||
@@ -167,6 +238,7 @@ export function useDownload() {
|
|||||||
|
|
||||||
let successCount = 0;
|
let successCount = 0;
|
||||||
let errorCount = 0;
|
let errorCount = 0;
|
||||||
|
let skippedCount = 0;
|
||||||
const total = selectedTracks.length;
|
const total = selectedTracks.length;
|
||||||
|
|
||||||
for (let i = 0; i < selectedTracks.length; i++) {
|
for (let i = 0; i < selectedTracks.length; i++) {
|
||||||
@@ -187,6 +259,7 @@ export function useDownload() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Use sequential numbering (1, 2, 3...) for selected tracks
|
||||||
const response = await downloadWithAutoFallback(
|
const response = await downloadWithAutoFallback(
|
||||||
isrc,
|
isrc,
|
||||||
settings,
|
settings,
|
||||||
@@ -194,17 +267,31 @@ export function useDownload() {
|
|||||||
track?.artists,
|
track?.artists,
|
||||||
track?.album_name,
|
track?.album_name,
|
||||||
playlistName,
|
playlistName,
|
||||||
isArtistDiscography
|
isArtistDiscography,
|
||||||
|
i + 1, // Sequential position based on selection order
|
||||||
|
track?.spotify_id
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
successCount++;
|
if (response.already_exists) {
|
||||||
|
skippedCount++;
|
||||||
|
console.log(`Skipped: ${track?.name} - ${track?.artists} (already exists)`);
|
||||||
|
} else {
|
||||||
|
successCount++;
|
||||||
|
}
|
||||||
setDownloadedTracks((prev) => new Set(prev).add(isrc));
|
setDownloadedTracks((prev) => new Set(prev).add(isrc));
|
||||||
|
setFailedTracks((prev) => {
|
||||||
|
const newSet = new Set(prev);
|
||||||
|
newSet.delete(isrc); // Remove from failed if it was there
|
||||||
|
return newSet;
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
errorCount++;
|
errorCount++;
|
||||||
|
setFailedTracks((prev) => new Set(prev).add(isrc));
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
errorCount++;
|
errorCount++;
|
||||||
|
setFailedTracks((prev) => new Set(prev).add(isrc));
|
||||||
}
|
}
|
||||||
|
|
||||||
setDownloadProgress(Math.round(((i + 1) / total) * 100));
|
setDownloadProgress(Math.round(((i + 1) / total) * 100));
|
||||||
@@ -216,10 +303,22 @@ export function useDownload() {
|
|||||||
setBulkDownloadType(null);
|
setBulkDownloadType(null);
|
||||||
shouldStopDownloadRef.current = false;
|
shouldStopDownloadRef.current = false;
|
||||||
|
|
||||||
if (errorCount === 0) {
|
// Build summary message
|
||||||
|
if (errorCount === 0 && skippedCount === 0) {
|
||||||
toast.success(`Downloaded ${successCount} tracks successfully`);
|
toast.success(`Downloaded ${successCount} tracks successfully`);
|
||||||
|
} else if (errorCount === 0 && successCount === 0) {
|
||||||
|
// All skipped
|
||||||
|
toast.info(`${skippedCount} tracks already exist`);
|
||||||
|
} else if (errorCount === 0) {
|
||||||
|
// Mix of downloaded and skipped
|
||||||
|
toast.info(`${successCount} downloaded, ${skippedCount} skipped`);
|
||||||
} else {
|
} else {
|
||||||
toast.warning(`Downloaded ${successCount} tracks, ${errorCount} failed`);
|
// Has errors
|
||||||
|
const parts = [];
|
||||||
|
if (successCount > 0) parts.push(`${successCount} downloaded`);
|
||||||
|
if (skippedCount > 0) parts.push(`${skippedCount} skipped`);
|
||||||
|
parts.push(`${errorCount} failed`);
|
||||||
|
toast.warning(parts.join(", "));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -242,6 +341,7 @@ export function useDownload() {
|
|||||||
|
|
||||||
let successCount = 0;
|
let successCount = 0;
|
||||||
let errorCount = 0;
|
let errorCount = 0;
|
||||||
|
let skippedCount = 0;
|
||||||
const total = tracksWithIsrc.length;
|
const total = tracksWithIsrc.length;
|
||||||
|
|
||||||
for (let i = 0; i < tracksWithIsrc.length; i++) {
|
for (let i = 0; i < tracksWithIsrc.length; i++) {
|
||||||
@@ -265,17 +365,31 @@ export function useDownload() {
|
|||||||
track.artists,
|
track.artists,
|
||||||
track.album_name,
|
track.album_name,
|
||||||
playlistName,
|
playlistName,
|
||||||
isArtistDiscography
|
isArtistDiscography,
|
||||||
|
i + 1,
|
||||||
|
track.spotify_id
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
successCount++;
|
if (response.already_exists) {
|
||||||
|
skippedCount++;
|
||||||
|
console.log(`Skipped: ${track.name} - ${track.artists} (already exists)`);
|
||||||
|
} else {
|
||||||
|
successCount++;
|
||||||
|
}
|
||||||
setDownloadedTracks((prev) => new Set(prev).add(track.isrc));
|
setDownloadedTracks((prev) => new Set(prev).add(track.isrc));
|
||||||
|
setFailedTracks((prev) => {
|
||||||
|
const newSet = new Set(prev);
|
||||||
|
newSet.delete(track.isrc); // Remove from failed if it was there
|
||||||
|
return newSet;
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
errorCount++;
|
errorCount++;
|
||||||
|
setFailedTracks((prev) => new Set(prev).add(track.isrc));
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
errorCount++;
|
errorCount++;
|
||||||
|
setFailedTracks((prev) => new Set(prev).add(track.isrc));
|
||||||
}
|
}
|
||||||
|
|
||||||
setDownloadProgress(Math.round(((i + 1) / total) * 100));
|
setDownloadProgress(Math.round(((i + 1) / total) * 100));
|
||||||
@@ -287,10 +401,22 @@ export function useDownload() {
|
|||||||
setBulkDownloadType(null);
|
setBulkDownloadType(null);
|
||||||
shouldStopDownloadRef.current = false;
|
shouldStopDownloadRef.current = false;
|
||||||
|
|
||||||
if (errorCount === 0) {
|
// Build summary message
|
||||||
|
if (errorCount === 0 && skippedCount === 0) {
|
||||||
toast.success(`Downloaded ${successCount} tracks successfully`);
|
toast.success(`Downloaded ${successCount} tracks successfully`);
|
||||||
|
} else if (errorCount === 0 && successCount === 0) {
|
||||||
|
// All skipped
|
||||||
|
toast.info(`${skippedCount} tracks already exist`);
|
||||||
|
} else if (errorCount === 0) {
|
||||||
|
// Mix of downloaded and skipped
|
||||||
|
toast.info(`${successCount} downloaded, ${skippedCount} skipped`);
|
||||||
} else {
|
} else {
|
||||||
toast.warning(`Downloaded ${successCount} tracks, ${errorCount} failed`);
|
// Has errors
|
||||||
|
const parts = [];
|
||||||
|
if (successCount > 0) parts.push(`${successCount} downloaded`);
|
||||||
|
if (skippedCount > 0) parts.push(`${skippedCount} skipped`);
|
||||||
|
parts.push(`${errorCount} failed`);
|
||||||
|
toast.warning(parts.join(", "));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -301,6 +427,7 @@ export function useDownload() {
|
|||||||
|
|
||||||
const resetDownloadedTracks = () => {
|
const resetDownloadedTracks = () => {
|
||||||
setDownloadedTracks(new Set());
|
setDownloadedTracks(new Set());
|
||||||
|
setFailedTracks(new Set());
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -309,6 +436,7 @@ export function useDownload() {
|
|||||||
downloadingTrack,
|
downloadingTrack,
|
||||||
bulkDownloadType,
|
bulkDownloadType,
|
||||||
downloadedTracks,
|
downloadedTracks,
|
||||||
|
failedTracks,
|
||||||
currentDownloadInfo,
|
currentDownloadInfo,
|
||||||
handleDownloadTrack,
|
handleDownloadTrack,
|
||||||
handleDownloadSelected,
|
handleDownloadSelected,
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { useState, useEffect, useRef } from "react";
|
||||||
|
import { GetDownloadProgress } from "../../wailsjs/go/main/App";
|
||||||
|
|
||||||
|
export interface DownloadProgressInfo {
|
||||||
|
is_downloading: boolean;
|
||||||
|
mb_downloaded: number;
|
||||||
|
speed_mbps: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDownloadProgress() {
|
||||||
|
const [progress, setProgress] = useState<DownloadProgressInfo>({
|
||||||
|
is_downloading: false,
|
||||||
|
mb_downloaded: 0,
|
||||||
|
speed_mbps: 0,
|
||||||
|
});
|
||||||
|
const intervalRef = useRef<number | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// Poll progress every 200ms for smooth updates
|
||||||
|
const pollProgress = async () => {
|
||||||
|
try {
|
||||||
|
const progressInfo = await GetDownloadProgress();
|
||||||
|
setProgress(progressInfo);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to get download progress:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Start polling
|
||||||
|
intervalRef.current = window.setInterval(pollProgress, 200);
|
||||||
|
|
||||||
|
// Initial fetch
|
||||||
|
pollProgress();
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
return () => {
|
||||||
|
if (intervalRef.current) {
|
||||||
|
clearInterval(intervalRef.current);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return progress;
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ import { GetDefaults } from "../../wailsjs/go/main/App";
|
|||||||
|
|
||||||
export interface Settings {
|
export interface Settings {
|
||||||
downloadPath: string;
|
downloadPath: string;
|
||||||
downloader: "auto" | "deezer" | "tidal" | "qobuz";
|
downloader: "auto" | "deezer" | "tidal" | "qobuz" | "amazon";
|
||||||
theme: string;
|
theme: string;
|
||||||
themeMode: "auto" | "light" | "dark";
|
themeMode: "auto" | "light" | "dark";
|
||||||
filenameFormat: "title-artist" | "artist-title" | "title";
|
filenameFormat: "title-artist" | "artist-title" | "title";
|
||||||
@@ -12,6 +12,15 @@ export interface Settings {
|
|||||||
operatingSystem: "Windows" | "linux/MacOS"
|
operatingSystem: "Windows" | "linux/MacOS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auto-detect operating system
|
||||||
|
function detectOS(): "Windows" | "linux/MacOS" {
|
||||||
|
const platform = window.navigator.platform.toLowerCase();
|
||||||
|
if (platform.includes('win')) {
|
||||||
|
return "Windows";
|
||||||
|
}
|
||||||
|
return "linux/MacOS";
|
||||||
|
}
|
||||||
|
|
||||||
export const DEFAULT_SETTINGS: Settings = {
|
export const DEFAULT_SETTINGS: Settings = {
|
||||||
downloadPath: "",
|
downloadPath: "",
|
||||||
downloader: "auto",
|
downloader: "auto",
|
||||||
@@ -21,7 +30,7 @@ export const DEFAULT_SETTINGS: Settings = {
|
|||||||
artistSubfolder: false,
|
artistSubfolder: false,
|
||||||
albumSubfolder: false,
|
albumSubfolder: false,
|
||||||
trackNumber: false,
|
trackNumber: false,
|
||||||
operatingSystem: "Windows"
|
operatingSystem: detectOS()
|
||||||
};
|
};
|
||||||
|
|
||||||
async function fetchDefaultPath(): Promise<string> {
|
async function fetchDefaultPath(): Promise<string> {
|
||||||
@@ -46,6 +55,8 @@ export function getSettings(): Settings {
|
|||||||
parsed.themeMode = parsed.darkMode ? 'dark' : 'light';
|
parsed.themeMode = parsed.darkMode ? 'dark' : 'light';
|
||||||
delete parsed.darkMode;
|
delete parsed.darkMode;
|
||||||
}
|
}
|
||||||
|
// Always use detected OS (don't persist it)
|
||||||
|
parsed.operatingSystem = detectOS();
|
||||||
return { ...DEFAULT_SETTINGS, ...parsed };
|
return { ...DEFAULT_SETTINGS, ...parsed };
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -18,11 +18,23 @@ export function sanitizePath(input: string, os: string): string {
|
|||||||
|
|
||||||
export function joinPath(os: string, ...parts: string[]): string {
|
export function joinPath(os: string, ...parts: string[]): string {
|
||||||
const sep = os === "Windows" ? "\\" : "/";
|
const sep = os === "Windows" ? "\\" : "/";
|
||||||
|
|
||||||
return parts
|
const filtered = parts.filter(Boolean);
|
||||||
.filter(Boolean)
|
if (filtered.length === 0) return "";
|
||||||
.map(p => p.replace(/^[/\\]+|[/\\]+$/g, ""))
|
|
||||||
|
const joined = filtered
|
||||||
|
.map((p, i) => {
|
||||||
|
// For first part, only remove trailing slashes (preserve leading slash for absolute paths)
|
||||||
|
if (i === 0) {
|
||||||
|
return p.replace(/[/\\]+$/g, "");
|
||||||
|
}
|
||||||
|
// For other parts, remove both leading and trailing slashes
|
||||||
|
return p.replace(/^[/\\]+|[/\\]+$/g, "");
|
||||||
|
})
|
||||||
|
.filter(Boolean) // Remove empty strings after trimming
|
||||||
.join(sep);
|
.join(sep);
|
||||||
|
|
||||||
|
return joined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildOutputPath(settings: Settings, folder?: string) {
|
export function buildOutputPath(settings: Settings, folder?: string) {
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ import { Toaster } from '@/components/ui/sonner'
|
|||||||
createRoot(document.getElementById('root')!).render(
|
createRoot(document.getElementById('root')!).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<App />
|
<App />
|
||||||
<Toaster />
|
<Toaster position="bottom-left" duration={1000} />
|
||||||
</StrictMode>,
|
</StrictMode>,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export interface TrackMetadata {
|
|||||||
external_urls: string;
|
external_urls: string;
|
||||||
isrc: string;
|
isrc: string;
|
||||||
album_type?: string;
|
album_type?: string;
|
||||||
|
spotify_id?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TrackResponse {
|
export interface TrackResponse {
|
||||||
@@ -97,7 +98,7 @@ export type SpotifyMetadataResponse =
|
|||||||
|
|
||||||
export interface DownloadRequest {
|
export interface DownloadRequest {
|
||||||
isrc: string;
|
isrc: string;
|
||||||
service: "deezer" | "tidal" | "qobuz";
|
service: "deezer" | "tidal" | "qobuz" | "amazon";
|
||||||
query?: string;
|
query?: string;
|
||||||
track_name?: string;
|
track_name?: string;
|
||||||
artist_name?: string;
|
artist_name?: string;
|
||||||
@@ -108,6 +109,10 @@ export interface DownloadRequest {
|
|||||||
folder_name?: string;
|
folder_name?: string;
|
||||||
filename_format?: string;
|
filename_format?: string;
|
||||||
track_number?: boolean;
|
track_number?: boolean;
|
||||||
|
position?: number;
|
||||||
|
use_album_track_number?: boolean;
|
||||||
|
spotify_id?: string;
|
||||||
|
service_url?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DownloadResponse {
|
export interface DownloadResponse {
|
||||||
@@ -115,6 +120,7 @@ export interface DownloadResponse {
|
|||||||
message: string;
|
message: string;
|
||||||
file?: string;
|
file?: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
|
already_exists?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HealthResponse {
|
export interface HealthResponse {
|
||||||
|
|||||||
@@ -12,29 +12,29 @@ require (
|
|||||||
require (
|
require (
|
||||||
github.com/bep/debounce v1.2.1 // indirect
|
github.com/bep/debounce v1.2.1 // indirect
|
||||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
github.com/godbus/dbus/v5 v5.2.0 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/gorilla/websocket v1.5.3 // indirect
|
github.com/gorilla/websocket v1.5.3 // indirect
|
||||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
|
github.com/jchv/go-winloader v0.0.0-20250406163304-c1995be93bd1 // indirect
|
||||||
github.com/labstack/echo/v4 v4.13.3 // indirect
|
github.com/labstack/echo/v4 v4.13.4 // indirect
|
||||||
github.com/labstack/gommon v0.4.2 // indirect
|
github.com/labstack/gommon v0.4.2 // indirect
|
||||||
github.com/leaanthony/go-ansi-parser v1.6.1 // indirect
|
github.com/leaanthony/go-ansi-parser v1.6.1 // indirect
|
||||||
github.com/leaanthony/gosod v1.0.4 // indirect
|
github.com/leaanthony/gosod v1.0.4 // indirect
|
||||||
github.com/leaanthony/slicer v1.6.0 // indirect
|
github.com/leaanthony/slicer v1.6.0 // indirect
|
||||||
github.com/leaanthony/u v1.1.1 // indirect
|
github.com/leaanthony/u v1.1.1 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/rivo/uniseg v0.4.7 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/samber/lo v1.49.1 // indirect
|
github.com/samber/lo v1.52.0 // indirect
|
||||||
github.com/tkrajina/go-reflector v0.5.8 // indirect
|
github.com/tkrajina/go-reflector v0.5.8 // indirect
|
||||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||||
github.com/wailsapp/go-webview2 v1.0.22 // indirect
|
github.com/wailsapp/go-webview2 v1.0.23 // indirect
|
||||||
github.com/wailsapp/mimetype v1.4.1 // indirect
|
github.com/wailsapp/mimetype v1.4.1 // indirect
|
||||||
golang.org/x/crypto v0.33.0 // indirect
|
golang.org/x/crypto v0.45.0 // indirect
|
||||||
golang.org/x/net v0.35.0 // indirect
|
golang.org/x/net v0.47.0 // indirect
|
||||||
golang.org/x/sys v0.30.0 // indirect
|
golang.org/x/sys v0.38.0 // indirect
|
||||||
golang.org/x/text v0.22.0 // indirect
|
golang.org/x/text v0.31.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -10,16 +10,16 @@ github.com/go-flac/go-flac v1.0.0 h1:6qI9XOVLcO50xpzm3nXvO31BgDgHhnr/p/rER/K/doY
|
|||||||
github.com/go-flac/go-flac v1.0.0/go.mod h1:WnZhcpmq4u1UdZMNn9LYSoASpWOCMOoxXxcWEHSzkW8=
|
github.com/go-flac/go-flac v1.0.0/go.mod h1:WnZhcpmq4u1UdZMNn9LYSoASpWOCMOoxXxcWEHSzkW8=
|
||||||
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
|
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
|
||||||
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
|
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
|
||||||
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
|
github.com/godbus/dbus/v5 v5.2.0 h1:3WexO+U+yg9T70v9FdHr9kCxYlazaAXUhx2VMkbfax8=
|
||||||
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
github.com/godbus/dbus/v5 v5.2.0/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
|
github.com/jchv/go-winloader v0.0.0-20250406163304-c1995be93bd1 h1:njuLRcjAuMKr7kI3D85AXWkw6/+v9PwtV6M6o11sWHQ=
|
||||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
|
github.com/jchv/go-winloader v0.0.0-20250406163304-c1995be93bd1/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
|
||||||
github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY=
|
github.com/labstack/echo/v4 v4.13.4 h1:oTZZW+T3s9gAu5L8vmzihV7/lkXGZuITzTQkTEhcXEA=
|
||||||
github.com/labstack/echo/v4 v4.13.3/go.mod h1:o90YNEeQWjDozo584l7AwhJMHN0bOC4tAfg+Xox9q5g=
|
github.com/labstack/echo/v4 v4.13.4/go.mod h1:g63b33BZ5vZzcIUF8AtRH40DrTlXnx4UMC8rBdndmjQ=
|
||||||
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
||||||
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
|
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
|
||||||
github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oOc=
|
github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oOc=
|
||||||
@@ -35,9 +35,8 @@ github.com/leaanthony/u v1.1.1/go.mod h1:9+o6hejoRljvZ3BzdYlVL0JYCwtnAsVuN9pVTQc
|
|||||||
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||||
github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ=
|
github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ=
|
||||||
github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||||
@@ -49,8 +48,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
|||||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew=
|
github.com/samber/lo v1.52.0 h1:Rvi+3BFHES3A8meP33VPAxiBZX/Aws5RxrschYGjomw=
|
||||||
github.com/samber/lo v1.49.1/go.mod h1:dO6KHFzUKXgP8LDhU0oI8d2hekjXnGOu0DB8Jecxd6o=
|
github.com/samber/lo v1.52.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/tkrajina/go-reflector v0.5.8 h1:yPADHrwmUbMq4RGEyaOUpz2H90sRsETNVpjzo3DLVQQ=
|
github.com/tkrajina/go-reflector v0.5.8 h1:yPADHrwmUbMq4RGEyaOUpz2H90sRsETNVpjzo3DLVQQ=
|
||||||
@@ -59,29 +58,28 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw
|
|||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
||||||
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||||
github.com/wailsapp/go-webview2 v1.0.22 h1:YT61F5lj+GGaat5OB96Aa3b4QA+mybD0Ggq6NZijQ58=
|
github.com/wailsapp/go-webview2 v1.0.23 h1:jmv8qhz1lHibCc79bMM/a/FqOnnzOGEisLav+a0b9P0=
|
||||||
github.com/wailsapp/go-webview2 v1.0.22/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc=
|
github.com/wailsapp/go-webview2 v1.0.23/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc=
|
||||||
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
||||||
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
||||||
github.com/wailsapp/wails/v2 v2.11.0 h1:seLacV8pqupq32IjS4Y7V8ucab0WZwtK6VvUVxSBtqQ=
|
github.com/wailsapp/wails/v2 v2.11.0 h1:seLacV8pqupq32IjS4Y7V8ucab0WZwtK6VvUVxSBtqQ=
|
||||||
github.com/wailsapp/wails/v2 v2.11.0/go.mod h1:jrf0ZaM6+GBc1wRmXsM8cIvzlg0karYin3erahI4+0k=
|
github.com/wailsapp/wails/v2 v2.11.0/go.mod h1:jrf0ZaM6+GBc1wRmXsM8cIvzlg0karYin3erahI4+0k=
|
||||||
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
|
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
|
||||||
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
|
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
|
||||||
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
|
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
|
||||||
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
|
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
|
||||||
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
||||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
|
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
|
||||||
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
|
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
@@ -19,9 +19,12 @@ func main() {
|
|||||||
|
|
||||||
// Create application with options
|
// Create application with options
|
||||||
err := wails.Run(&options.App{
|
err := wails.Run(&options.App{
|
||||||
Title: "SpotiFLAC",
|
Title: "SpotiFLAC",
|
||||||
Width: 1024,
|
Width: 1024,
|
||||||
Height: 600,
|
Height: 600,
|
||||||
|
MinWidth: 1024,
|
||||||
|
MinHeight: 600,
|
||||||
|
Frameless: true,
|
||||||
AssetServer: &assetserver.Options{
|
AssetServer: &assetserver.Options{
|
||||||
Assets: assets,
|
Assets: assets,
|
||||||
},
|
},
|
||||||
@@ -31,9 +34,10 @@ func main() {
|
|||||||
app,
|
app,
|
||||||
},
|
},
|
||||||
Windows: &windows.Options{
|
Windows: &windows.Options{
|
||||||
WebviewIsTransparent: false,
|
WebviewIsTransparent: false,
|
||||||
WindowIsTranslucent: false,
|
WindowIsTranslucent: false,
|
||||||
DisableWindowIcon: false,
|
DisableWindowIcon: false,
|
||||||
|
DisableFramelessWindowDecorations: false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -7,4 +7,4 @@
|
|||||||
"katze.qqdl.site",
|
"katze.qqdl.site",
|
||||||
"wolf.qqdl.site",
|
"wolf.qqdl.site",
|
||||||
"tidal.kinoplus.online"
|
"tidal.kinoplus.online"
|
||||||
]
|
]
|
||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"version": "5.6"
|
"version": "6.0"
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-7
@@ -7,17 +7,13 @@
|
|||||||
"frontend:dev:watcher": "pnpm run dev",
|
"frontend:dev:watcher": "pnpm run dev",
|
||||||
"frontend:dev:serverUrl": "auto",
|
"frontend:dev:serverUrl": "auto",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "afkarxyz",
|
"name": "afkarxyz"
|
||||||
"email": "hi@afkarxyz.fun"
|
|
||||||
},
|
},
|
||||||
"info": {
|
"info": {
|
||||||
"companyName": "afkarxyz",
|
|
||||||
"productName": "SpotiFLAC",
|
"productName": "SpotiFLAC",
|
||||||
"productVersion": "5.7",
|
"productVersion": "6.1"
|
||||||
"copyright": "Copyright © 2025",
|
|
||||||
"comments": "Get Spotify tracks in true FLAC from Tidal/Deezer — no account required."
|
|
||||||
},
|
},
|
||||||
"wailsjsdir": "./frontend",
|
"wailsjsdir": "./frontend",
|
||||||
"assetdir": "./frontend/dist",
|
"assetdir": "./frontend/dist",
|
||||||
"reloaddirs": "./frontend/src"
|
"reloaddirs": "./frontend/src"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user