v5.7-patch1
This commit is contained in:
+50
-35
@@ -233,22 +233,17 @@ jobs:
|
|||||||
- name: Build application
|
- name: Build application
|
||||||
run: wails build -platform linux/amd64
|
run: wails build -platform linux/amd64
|
||||||
|
|
||||||
- name: Download appimagetool
|
- name: Download linuxdeploy and appimagetool
|
||||||
run: |
|
run: |
|
||||||
wget -O appimagetool https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
|
wget -O linuxdeploy https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
|
||||||
chmod +x appimagetool
|
chmod +x linuxdeploy
|
||||||
|
|
||||||
- name: Create AppImage
|
- name: Create AppImage
|
||||||
run: |
|
run: |
|
||||||
mkdir -p AppDir/usr/bin
|
mkdir -p AppDir
|
||||||
mkdir -p AppDir/usr/share/applications
|
|
||||||
mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps
|
|
||||||
|
|
||||||
# Copy binary
|
|
||||||
cp build/bin/SpotiFLAC AppDir/usr/bin/spotiflac
|
|
||||||
|
|
||||||
# Create desktop file
|
# Create desktop file
|
||||||
cat > AppDir/spotiflac.desktop << 'EOF'
|
cat > spotiflac.desktop << 'EOF'
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Name=SpotiFLAC
|
Name=SpotiFLAC
|
||||||
Exec=spotiflac
|
Exec=spotiflac
|
||||||
@@ -258,38 +253,58 @@ jobs:
|
|||||||
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
|
# Create icon in multiple sizes for better compatibility
|
||||||
cp AppDir/spotiflac.desktop AppDir/usr/share/applications/
|
|
||||||
|
|
||||||
# Use existing icon from build or convert SVG to PNG
|
|
||||||
if [ -f "build/appicon.png" ]; then
|
if [ -f "build/appicon.png" ]; then
|
||||||
# Resize to 256x256 if needed
|
cp build/appicon.png spotiflac-256.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 spotiflac-256.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
|
touch spotiflac-256.png # Create empty file to prevent errors
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp AppDir/spotiflac.png AppDir/usr/share/icons/hicolor/256x256/apps/
|
# Create additional icon sizes only if icon exists
|
||||||
cp AppDir/spotiflac.png AppDir/.DirIcon
|
if [ -s spotiflac-256.png ]; then
|
||||||
|
convert spotiflac-256.png -resize 128x128 spotiflac-128.png
|
||||||
|
convert spotiflac-256.png -resize 64x64 spotiflac-64.png
|
||||||
|
convert spotiflac-256.png -resize 48x48 spotiflac-48.png
|
||||||
|
convert spotiflac-256.png -resize 32x32 spotiflac-32.png
|
||||||
|
convert spotiflac-256.png -resize 16x16 spotiflac-16.png
|
||||||
|
fi
|
||||||
|
|
||||||
# Create AppRun
|
# Use linuxdeploy to create AppImage
|
||||||
cat > AppDir/AppRun << 'EOF'
|
# Bundle only uncommon libraries (webkit2gtk), exclude common ones (GTK, glib)
|
||||||
#!/bin/sh
|
|
||||||
SELF=$(readlink -f "$0")
|
|
||||||
HERE=${SELF%/*}
|
|
||||||
export PATH="${HERE}/usr/bin/:${PATH}"
|
|
||||||
export LD_LIBRARY_PATH="${HERE}/usr/lib/:${LD_LIBRARY_PATH}"
|
|
||||||
exec "${HERE}/usr/bin/spotiflac" "$@"
|
|
||||||
EOF
|
|
||||||
chmod +x AppDir/AppRun
|
|
||||||
|
|
||||||
# Create AppImage
|
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
ARCH=x86_64 ./appimagetool --no-appstream AppDir dist/SpotiFLAC-${{ steps.version.outputs.version }}.AppImage
|
./linuxdeploy \
|
||||||
|
--appdir AppDir \
|
||||||
|
--executable build/bin/SpotiFLAC \
|
||||||
|
--desktop-file spotiflac.desktop \
|
||||||
|
--icon-file spotiflac-256.png \
|
||||||
|
--icon-file spotiflac-128.png \
|
||||||
|
--icon-file spotiflac-64.png \
|
||||||
|
--icon-file spotiflac-48.png \
|
||||||
|
--icon-file spotiflac-32.png \
|
||||||
|
--icon-file spotiflac-16.png \
|
||||||
|
--exclude-library "libgtk-3.so*" \
|
||||||
|
--exclude-library "libgdk-3.so*" \
|
||||||
|
--exclude-library "libglib-2.0.so*" \
|
||||||
|
--exclude-library "libgobject-2.0.so*" \
|
||||||
|
--exclude-library "libgio-2.0.so*" \
|
||||||
|
--exclude-library "libpango-1.0.so*" \
|
||||||
|
--exclude-library "libcairo.so*" \
|
||||||
|
--exclude-library "libX11.so*" \
|
||||||
|
--exclude-library "libXext.so*" \
|
||||||
|
--exclude-library "libXrender.so*" \
|
||||||
|
--exclude-library "libfontconfig.so*" \
|
||||||
|
--exclude-library "libfreetype.so*" \
|
||||||
|
--exclude-library "libpthread.so*" \
|
||||||
|
--exclude-library "libdl.so*" \
|
||||||
|
--exclude-library "libm.so*" \
|
||||||
|
--exclude-library "libc.so*" \
|
||||||
|
--output appimage
|
||||||
|
|
||||||
|
# Rename to match version
|
||||||
|
mv SpotiFLAC*.AppImage dist/SpotiFLAC-${{ steps.version.outputs.version }}.AppImage
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ type DownloadRequest struct {
|
|||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DownloadResponse represents the response structure for download operations
|
// DownloadResponse represents the response structure for download operations
|
||||||
@@ -125,20 +126,20 @@ func (a *App) DownloadTrack(req DownloadRequest) (DownloadResponse, error) {
|
|||||||
|
|
||||||
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)
|
filename, err = downloader.DownloadWithFallback(searchQuery, req.ISRC, req.OutputDir, req.AudioFormat, req.FilenameFormat, req.TrackNumber, req.Position, req.TrackName, req.ArtistName, req.AlbumName)
|
||||||
} 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)
|
filename, err = downloader.Download(searchQuery, req.ISRC, req.OutputDir, req.AudioFormat, req.FilenameFormat, req.TrackNumber, req.Position, req.TrackName, req.ArtistName, req.AlbumName)
|
||||||
}
|
}
|
||||||
} else if req.Service == "qobuz" {
|
} else if req.Service == "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)
|
err = downloader.DownloadByISRC(req.ISRC, req.OutputDir, req.AudioFormat, req.FilenameFormat, req.TrackNumber, req.Position, req.TrackName, req.ArtistName, req.AlbumName)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
filename = "Downloaded via Qobuz"
|
filename = "Downloaded via Qobuz"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
downloader := backend.NewDeezerDownloader()
|
downloader := backend.NewDeezerDownloader()
|
||||||
err = downloader.DownloadByISRC(req.ISRC, req.OutputDir, req.FilenameFormat, req.TrackNumber, req.TrackName, req.ArtistName, req.AlbumName)
|
err = downloader.DownloadByISRC(req.ISRC, req.OutputDir, req.FilenameFormat, req.TrackNumber, req.Position, req.TrackName, req.ArtistName, req.AlbumName)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
filename = "Downloaded via Deezer"
|
filename = "Downloaded via Deezer"
|
||||||
}
|
}
|
||||||
@@ -188,3 +189,9 @@ func (a *App) GetDefaults() map[string]string {
|
|||||||
func (a *App) GetDownloadProgress() backend.ProgressInfo {
|
func (a *App) GetDownloadProgress() backend.ProgressInfo {
|
||||||
return backend.GetDownloadProgress()
|
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
|
||||||
|
}
|
||||||
|
|||||||
+13
-6
@@ -172,7 +172,7 @@ func sanitizeFilename(name string) string {
|
|||||||
return sanitized
|
return sanitized
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildFilename(title, artist string, trackNumber int, format string, includeTrackNumber bool) string {
|
func buildFilename(title, artist string, trackNumber int, format string, includeTrackNumber bool, position int) string {
|
||||||
var filename string
|
var filename string
|
||||||
|
|
||||||
// Build base filename based on format
|
// Build base filename based on format
|
||||||
@@ -186,14 +186,15 @@ 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 {
|
// Only use track number for bulk downloads (when position > 0)
|
||||||
filename = fmt.Sprintf("%02d. %s", trackNumber, filename)
|
if includeTrackNumber && position > 0 {
|
||||||
|
filename = fmt.Sprintf("%02d. %s", position, 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) DownloadByISRC(isrc, outputDir, filenameFormat string, includeTrackNumber bool, position int, spotifyTrackName, spotifyArtistName, spotifyAlbumName string) error {
|
||||||
fmt.Printf("Fetching track info for ISRC: %s\n", isrc)
|
fmt.Printf("Fetching track info for ISRC: %s\n", isrc)
|
||||||
|
|
||||||
track, err := d.GetTrackByISRC(isrc)
|
track, err := d.GetTrackByISRC(isrc)
|
||||||
@@ -241,7 +242,7 @@ func (d *DeezerDownloader) DownloadByISRC(isrc, outputDir, filenameFormat string
|
|||||||
safeTitle := sanitizeFilename(trackTitle)
|
safeTitle := sanitizeFilename(trackTitle)
|
||||||
|
|
||||||
// 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)
|
||||||
filepath := filepath.Join(outputDir, filename)
|
filepath := filepath.Join(outputDir, filename)
|
||||||
|
|
||||||
fmt.Println("Downloading FLAC file...")
|
fmt.Println("Downloading FLAC file...")
|
||||||
@@ -263,12 +264,18 @@ func (d *DeezerDownloader) DownloadByISRC(isrc, outputDir, filenameFormat string
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Embedding metadata and cover art...")
|
fmt.Println("Embedding metadata and cover art...")
|
||||||
|
// Only use track number for bulk downloads (when position > 0)
|
||||||
|
trackNumberToEmbed := 0
|
||||||
|
if position > 0 {
|
||||||
|
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,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Global progress tracker
|
// Global progress tracker
|
||||||
@@ -12,12 +13,15 @@ var (
|
|||||||
currentProgressLock sync.RWMutex
|
currentProgressLock sync.RWMutex
|
||||||
isDownloading bool
|
isDownloading bool
|
||||||
downloadingLock sync.RWMutex
|
downloadingLock sync.RWMutex
|
||||||
|
currentSpeed float64
|
||||||
|
speedLock sync.RWMutex
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProgressInfo represents download progress information
|
// ProgressInfo represents download progress information
|
||||||
type ProgressInfo struct {
|
type ProgressInfo struct {
|
||||||
IsDownloading bool `json:"is_downloading"`
|
IsDownloading bool `json:"is_downloading"`
|
||||||
MBDownloaded float64 `json:"mb_downloaded"`
|
MBDownloaded float64 `json:"mb_downloaded"`
|
||||||
|
SpeedMBps float64 `json:"speed_mbps"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDownloadProgress returns current download progress
|
// GetDownloadProgress returns current download progress
|
||||||
@@ -30,12 +34,24 @@ func GetDownloadProgress() ProgressInfo {
|
|||||||
progress := currentProgress
|
progress := currentProgress
|
||||||
currentProgressLock.RUnlock()
|
currentProgressLock.RUnlock()
|
||||||
|
|
||||||
|
speedLock.RLock()
|
||||||
|
speed := currentSpeed
|
||||||
|
speedLock.RUnlock()
|
||||||
|
|
||||||
return ProgressInfo{
|
return ProgressInfo{
|
||||||
IsDownloading: downloading,
|
IsDownloading: downloading,
|
||||||
MBDownloaded: progress,
|
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
|
// SetDownloadProgress updates the current download progress
|
||||||
func SetDownloadProgress(mbDownloaded float64) {
|
func SetDownloadProgress(mbDownloaded float64) {
|
||||||
currentProgressLock.Lock()
|
currentProgressLock.Lock()
|
||||||
@@ -52,6 +68,7 @@ func SetDownloading(downloading bool) {
|
|||||||
if !downloading {
|
if !downloading {
|
||||||
// Reset progress when download completes
|
// Reset progress when download completes
|
||||||
SetDownloadProgress(0)
|
SetDownloadProgress(0)
|
||||||
|
SetDownloadSpeed(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,16 +77,27 @@ type ProgressWriter struct {
|
|||||||
writer io.Writer
|
writer io.Writer
|
||||||
total int64
|
total int64
|
||||||
lastPrinted int64
|
lastPrinted int64
|
||||||
|
startTime int64
|
||||||
|
lastTime int64
|
||||||
|
lastBytes int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewProgressWriter(writer io.Writer) *ProgressWriter {
|
func NewProgressWriter(writer io.Writer) *ProgressWriter {
|
||||||
|
now := getCurrentTimeMillis()
|
||||||
return &ProgressWriter{
|
return &ProgressWriter{
|
||||||
writer: writer,
|
writer: writer,
|
||||||
total: 0,
|
total: 0,
|
||||||
lastPrinted: 0,
|
lastPrinted: 0,
|
||||||
|
startTime: now,
|
||||||
|
lastTime: now,
|
||||||
|
lastBytes: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getCurrentTimeMillis() int64 {
|
||||||
|
return time.Now().UnixMilli()
|
||||||
|
}
|
||||||
|
|
||||||
func (pw *ProgressWriter) Write(p []byte) (int, error) {
|
func (pw *ProgressWriter) Write(p []byte) (int, error) {
|
||||||
n, err := pw.writer.Write(p)
|
n, err := pw.writer.Write(p)
|
||||||
pw.total += int64(n)
|
pw.total += int64(n)
|
||||||
@@ -77,12 +105,26 @@ func (pw *ProgressWriter) Write(p []byte) (int, error) {
|
|||||||
// Report progress every 256KB for smoother updates
|
// Report progress every 256KB for smoother updates
|
||||||
if pw.total-pw.lastPrinted >= 256*1024 {
|
if pw.total-pw.lastPrinted >= 256*1024 {
|
||||||
mbDownloaded := float64(pw.total) / (1024 * 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)
|
fmt.Printf("\rDownloaded: %.2f MB", mbDownloaded)
|
||||||
|
}
|
||||||
|
|
||||||
// Update global progress
|
// Update global progress
|
||||||
SetDownloadProgress(mbDownloaded)
|
SetDownloadProgress(mbDownloaded)
|
||||||
|
|
||||||
pw.lastPrinted = pw.total
|
pw.lastPrinted = pw.total
|
||||||
|
pw.lastTime = now
|
||||||
|
pw.lastBytes = pw.total
|
||||||
}
|
}
|
||||||
|
|
||||||
return n, err
|
return n, err
|
||||||
|
|||||||
+13
-6
@@ -222,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) string {
|
||||||
var filename string
|
var filename string
|
||||||
|
|
||||||
// Build base filename based on format
|
// Build base filename based on format
|
||||||
@@ -236,14 +236,15 @@ 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 {
|
// Only use track number for bulk downloads (when position > 0)
|
||||||
filename = fmt.Sprintf("%02d. %s", trackNumber, filename)
|
if includeTrackNumber && position > 0 {
|
||||||
|
filename = fmt.Sprintf("%02d. %s", position, 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) 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
|
||||||
@@ -311,7 +312,7 @@ func (q *QobuzDownloader) DownloadByISRC(isrc, outputDir, quality, filenameForma
|
|||||||
safeTitle := sanitizeFilename(trackTitle)
|
safeTitle := sanitizeFilename(trackTitle)
|
||||||
|
|
||||||
// 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)
|
||||||
filepath := filepath.Join(outputDir, filename)
|
filepath := filepath.Join(outputDir, filename)
|
||||||
|
|
||||||
fmt.Printf("Downloading FLAC file to: %s\n", filepath)
|
fmt.Printf("Downloading FLAC file to: %s\n", filepath)
|
||||||
@@ -339,12 +340,18 @@ func (q *QobuzDownloader) DownloadByISRC(isrc, outputDir, quality, filenameForma
|
|||||||
releaseYear = track.ReleaseDateOriginal[:4]
|
releaseYear = track.ReleaseDateOriginal[:4]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only use track number for bulk downloads (when position > 0)
|
||||||
|
trackNumberToEmbed := 0
|
||||||
|
if position > 0 {
|
||||||
|
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,
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-8
@@ -333,7 +333,7 @@ func (t *TidalDownloader) DownloadFile(url, filepath string) error {
|
|||||||
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) Download(query, isrc, outputDir, quality, filenameFormat string, includeTrackNumber bool, position int, spotifyTrackName, spotifyArtistName, spotifyAlbumName string) (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)
|
||||||
@@ -386,7 +386,7 @@ func (t *TidalDownloader) Download(query, isrc, outputDir, quality, filenameForm
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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)
|
||||||
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 {
|
||||||
@@ -427,12 +427,18 @@ func (t *TidalDownloader) Download(query, isrc, outputDir, quality, filenameForm
|
|||||||
releaseYear = trackInfo.Album.ReleaseDate[:4]
|
releaseYear = trackInfo.Album.ReleaseDate[:4]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only use track number for bulk downloads (when position > 0)
|
||||||
|
trackNumberToEmbed := 0
|
||||||
|
if position > 0 {
|
||||||
|
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,
|
||||||
}
|
}
|
||||||
@@ -447,7 +453,7 @@ func (t *TidalDownloader) Download(query, isrc, outputDir, quality, filenameForm
|
|||||||
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) DownloadWithFallback(query, isrc, outputDir, quality, filenameFormat string, includeTrackNumber bool, position int, spotifyTrackName, spotifyArtistName, spotifyAlbumName string) (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)
|
||||||
@@ -459,7 +465,7 @@ func (t *TidalDownloader) DownloadWithFallback(query, isrc, outputDir, quality,
|
|||||||
|
|
||||||
fallbackDownloader := NewTidalDownloader(apiURL)
|
fallbackDownloader := NewTidalDownloader(apiURL)
|
||||||
|
|
||||||
result, err := fallbackDownloader.Download(query, isrc, outputDir, quality, filenameFormat, includeTrackNumber, spotifyTrackName, spotifyArtistName, spotifyAlbumName)
|
result, err := fallbackDownloader.Download(query, isrc, outputDir, quality, filenameFormat, includeTrackNumber, position, spotifyTrackName, spotifyArtistName, spotifyAlbumName)
|
||||||
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
|
||||||
@@ -476,7 +482,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) string {
|
||||||
var filename string
|
var filename string
|
||||||
|
|
||||||
// Build base filename based on format
|
// Build base filename based on format
|
||||||
@@ -490,8 +496,9 @@ 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 {
|
// Only use track number for bulk downloads (when position > 0)
|
||||||
filename = fmt.Sprintf("%02d. %s", trackNumber, filename)
|
if includeTrackNumber && position > 0 {
|
||||||
|
filename = fmt.Sprintf("%02d. %s", position, filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
return filename + ".flac"
|
return filename + ".flac"
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ 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";
|
||||||
@@ -259,7 +260,9 @@ 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">
|
||||||
|
<TitleBar />
|
||||||
|
<div className="flex-1 p-4 md:p-8">
|
||||||
<div className="max-w-4xl mx-auto space-y-6">
|
<div className="max-w-4xl mx-auto space-y-6">
|
||||||
<Header version={CURRENT_VERSION} hasUpdate={hasUpdate} />
|
<Header version={CURRENT_VERSION} hasUpdate={hasUpdate} />
|
||||||
|
|
||||||
@@ -347,6 +350,7 @@ function App() {
|
|||||||
{metadata.metadata && renderMetadata()}
|
{metadata.metadata && renderMetadata()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</TooltipProvider>
|
</TooltipProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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" className="gap-1.5">
|
||||||
<FolderOpen className="h-4 w-4" />
|
<FolderOpen className="h-4 w-4" />
|
||||||
Open Folder
|
Open Folder
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -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" className="gap-1.5">
|
||||||
<FolderOpen className="h-4 w-4" />
|
<FolderOpen className="h-4 w-4" />
|
||||||
Open Folder
|
Open Folder
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -9,13 +9,20 @@ export function DownloadProgressToast() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fixed top-4 left-4 z-50 animate-in slide-in-from-left-5 data-[state=closed]:animate-out data-[state=closed]:slide-out-to-left-5">
|
<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="bg-background border rounded-lg shadow-lg p-3">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-3">
|
||||||
<Download className="h-4 w-4 text-primary animate-bounce" />
|
<Download className="h-4 w-4 text-primary animate-bounce" />
|
||||||
|
<div className="flex flex-col">
|
||||||
<p className="text-sm font-medium">
|
<p className="text-sm font-medium">
|
||||||
{progress.mb_downloaded.toFixed(2)} MB
|
{progress.mb_downloaded.toFixed(2)} MB
|
||||||
</p>
|
</p>
|
||||||
|
{progress.speed_mbps > 0 && (
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
{progress.speed_mbps.toFixed(2)} MB/s
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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" className="gap-1.5">
|
||||||
<FolderOpen className="h-4 w-4" />
|
<FolderOpen className="h-4 w-4" />
|
||||||
Open Folder
|
Open Folder
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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";
|
||||||
@@ -191,11 +192,13 @@ 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">
|
||||||
|
{/* Left Column */}
|
||||||
|
<div className="space-y-4">
|
||||||
{/* Download Path */}
|
{/* Download Path */}
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label htmlFor="download-path">Download Path</Label>
|
<Label htmlFor="download-path">Download Path</Label>
|
||||||
@@ -206,8 +209,8 @@ export function Settings() {
|
|||||||
onChange={(e) => handleDownloadPathChange(e.target.value)}
|
onChange={(e) => handleDownloadPathChange(e.target.value)}
|
||||||
placeholder="C:\Users\YourUsername\Music"
|
placeholder="C:\Users\YourUsername\Music"
|
||||||
/>
|
/>
|
||||||
<Button type="button" onClick={handleBrowseFolder}>
|
<Button type="button" onClick={handleBrowseFolder} className="gap-1.5">
|
||||||
<FolderOpen className="h-4 w-4 mr-2" />
|
<FolderOpen className="h-4 w-4" />
|
||||||
Browse
|
Browse
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -224,14 +227,7 @@ export function Settings() {
|
|||||||
<SelectValue placeholder="Select a source" />
|
<SelectValue placeholder="Select a source" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="auto">
|
<SelectItem value="auto">Auto</SelectItem>
|
||||||
<span className="flex items-center">
|
|
||||||
<TidalIcon />
|
|
||||||
<DeezerIcon />
|
|
||||||
<QobuzIcon />
|
|
||||||
Auto (Tidal → Deezer → Qobuz)
|
|
||||||
</span>
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem value="tidal">
|
<SelectItem value="tidal">
|
||||||
<span className="flex items-center">
|
<span className="flex items-center">
|
||||||
<TidalIcon />
|
<TidalIcon />
|
||||||
@@ -254,35 +250,74 @@ export function Settings() {
|
|||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* File Settings */}
|
{/* Theme Mode Selection */}
|
||||||
<div className="space-y-3 pt-3 border-t">
|
<div className="space-y-2">
|
||||||
<h3 className="font-medium text-sm">File Settings</h3>
|
<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>
|
||||||
|
|
||||||
|
{/* Right Column */}
|
||||||
|
<div className="space-y-4">
|
||||||
{/* 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 +325,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">
|
||||||
|
<p className="text-xs whitespace-nowrap">Adds track numbers based on the order in the album, playlist, or discography list</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
@@ -309,38 +352,6 @@ export function Settings() {
|
|||||||
</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,60 @@
|
|||||||
|
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 (
|
||||||
|
<div className="absolute 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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -51,19 +51,20 @@ export function TrackInfo({
|
|||||||
<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)}
|
||||||
|
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
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
{isDownloaded && (
|
{isDownloaded && (
|
||||||
<Button onClick={onOpenFolder} variant="outline" className="gap-2">
|
<Button onClick={onOpenFolder} variant="outline" className="gap-1.5">
|
||||||
<FolderOpen className="h-4 w-4" />
|
<FolderOpen className="h-4 w-4" />
|
||||||
Open Folder
|
Open Folder
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -187,13 +187,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
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ export function useDownload() {
|
|||||||
artistName?: string,
|
artistName?: string,
|
||||||
albumName?: string,
|
albumName?: string,
|
||||||
playlistName?: string,
|
playlistName?: string,
|
||||||
isArtistDiscography?: boolean
|
isArtistDiscography?: boolean,
|
||||||
|
position?: number
|
||||||
) => {
|
) => {
|
||||||
let service = settings.downloader;
|
let service = settings.downloader;
|
||||||
|
|
||||||
@@ -64,6 +65,7 @@ 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,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (tidalResponse.success) {
|
if (tidalResponse.success) {
|
||||||
@@ -85,6 +87,7 @@ 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,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (deezerResponse.success) {
|
if (deezerResponse.success) {
|
||||||
@@ -108,6 +111,7 @@ 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,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -126,6 +130,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,7 +138,8 @@ export function useDownload() {
|
|||||||
artistName,
|
artistName,
|
||||||
albumName,
|
albumName,
|
||||||
undefined,
|
undefined,
|
||||||
false
|
false,
|
||||||
|
undefined // Don't pass position for single track
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
@@ -187,6 +193,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,7 +201,8 @@ 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
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
@@ -265,7 +273,8 @@ export function useDownload() {
|
|||||||
track.artists,
|
track.artists,
|
||||||
track.album_name,
|
track.album_name,
|
||||||
playlistName,
|
playlistName,
|
||||||
isArtistDiscography
|
isArtistDiscography,
|
||||||
|
i + 1
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ import { GetDownloadProgress } from "../../wailsjs/go/main/App";
|
|||||||
export interface DownloadProgressInfo {
|
export interface DownloadProgressInfo {
|
||||||
is_downloading: boolean;
|
is_downloading: boolean;
|
||||||
mb_downloaded: number;
|
mb_downloaded: number;
|
||||||
|
speed_mbps: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useDownloadProgress() {
|
export function useDownloadProgress() {
|
||||||
const [progress, setProgress] = useState<DownloadProgressInfo>({
|
const [progress, setProgress] = useState<DownloadProgressInfo>({
|
||||||
is_downloading: false,
|
is_downloading: false,
|
||||||
mb_downloaded: 0,
|
mb_downloaded: 0,
|
||||||
|
speed_mbps: 0,
|
||||||
});
|
});
|
||||||
const intervalRef = useRef<number | null>(null);
|
const intervalRef = useRef<number | null>(null);
|
||||||
|
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -19,10 +19,22 @@ 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" />
|
||||||
</StrictMode>,
|
</StrictMode>,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ export interface DownloadRequest {
|
|||||||
folder_name?: string;
|
folder_name?: string;
|
||||||
filename_format?: string;
|
filename_format?: string;
|
||||||
track_number?: boolean;
|
track_number?: boolean;
|
||||||
|
position?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DownloadResponse {
|
export interface DownloadResponse {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ func main() {
|
|||||||
Title: "SpotiFLAC",
|
Title: "SpotiFLAC",
|
||||||
Width: 1024,
|
Width: 1024,
|
||||||
Height: 600,
|
Height: 600,
|
||||||
|
Frameless: true,
|
||||||
AssetServer: &assetserver.Options{
|
AssetServer: &assetserver.Options{
|
||||||
Assets: assets,
|
Assets: assets,
|
||||||
},
|
},
|
||||||
@@ -34,6 +35,7 @@ func main() {
|
|||||||
WebviewIsTransparent: false,
|
WebviewIsTransparent: false,
|
||||||
WindowIsTranslucent: false,
|
WindowIsTranslucent: false,
|
||||||
DisableWindowIcon: false,
|
DisableWindowIcon: false,
|
||||||
|
DisableFramelessWindowDecorations: false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user