v6.4
This commit is contained in:
@@ -357,10 +357,14 @@ func (a *App) AnalyzeMultipleTracks(filePaths []string) (string, error) {
|
|||||||
|
|
||||||
// LyricsDownloadRequest represents the request structure for downloading lyrics
|
// LyricsDownloadRequest represents the request structure for downloading lyrics
|
||||||
type LyricsDownloadRequest struct {
|
type LyricsDownloadRequest struct {
|
||||||
SpotifyID string `json:"spotify_id"`
|
SpotifyID string `json:"spotify_id"`
|
||||||
TrackName string `json:"track_name"`
|
TrackName string `json:"track_name"`
|
||||||
ArtistName string `json:"artist_name"`
|
ArtistName string `json:"artist_name"`
|
||||||
OutputDir string `json:"output_dir"`
|
OutputDir string `json:"output_dir"`
|
||||||
|
FilenameFormat string `json:"filename_format"`
|
||||||
|
TrackNumber bool `json:"track_number"`
|
||||||
|
Position int `json:"position"`
|
||||||
|
UseAlbumTrackNumber bool `json:"use_album_track_number"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DownloadLyrics downloads lyrics for a single track
|
// DownloadLyrics downloads lyrics for a single track
|
||||||
@@ -374,10 +378,14 @@ func (a *App) DownloadLyrics(req LyricsDownloadRequest) (backend.LyricsDownloadR
|
|||||||
|
|
||||||
client := backend.NewLyricsClient()
|
client := backend.NewLyricsClient()
|
||||||
backendReq := backend.LyricsDownloadRequest{
|
backendReq := backend.LyricsDownloadRequest{
|
||||||
SpotifyID: req.SpotifyID,
|
SpotifyID: req.SpotifyID,
|
||||||
TrackName: req.TrackName,
|
TrackName: req.TrackName,
|
||||||
ArtistName: req.ArtistName,
|
ArtistName: req.ArtistName,
|
||||||
OutputDir: req.OutputDir,
|
OutputDir: req.OutputDir,
|
||||||
|
FilenameFormat: req.FilenameFormat,
|
||||||
|
TrackNumber: req.TrackNumber,
|
||||||
|
Position: req.Position,
|
||||||
|
UseAlbumTrackNumber: req.UseAlbumTrackNumber,
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := client.DownloadLyrics(backendReq)
|
resp, err := client.DownloadLyrics(backendReq)
|
||||||
@@ -390,3 +398,23 @@ func (a *App) DownloadLyrics(req LyricsDownloadRequest) (backend.LyricsDownloadR
|
|||||||
|
|
||||||
return *resp, nil
|
return *resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckTrackAvailability checks the availability of a track on different streaming platforms
|
||||||
|
func (a *App) CheckTrackAvailability(spotifyTrackID string, isrc string) (string, error) {
|
||||||
|
if spotifyTrackID == "" {
|
||||||
|
return "", fmt.Errorf("spotify track ID is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
client := backend.NewSongLinkClient()
|
||||||
|
availability, err := client.CheckTrackAvailability(spotifyTrackID, isrc)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonData, err := json.Marshal(availability)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to encode response: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(jsonData), nil
|
||||||
|
}
|
||||||
|
|||||||
+39
-6
@@ -28,10 +28,14 @@ type LyricsResponse struct {
|
|||||||
|
|
||||||
// LyricsDownloadRequest represents a request to download lyrics
|
// LyricsDownloadRequest represents a request to download lyrics
|
||||||
type LyricsDownloadRequest struct {
|
type LyricsDownloadRequest struct {
|
||||||
SpotifyID string `json:"spotify_id"`
|
SpotifyID string `json:"spotify_id"`
|
||||||
TrackName string `json:"track_name"`
|
TrackName string `json:"track_name"`
|
||||||
ArtistName string `json:"artist_name"`
|
ArtistName string `json:"artist_name"`
|
||||||
OutputDir string `json:"output_dir"`
|
OutputDir string `json:"output_dir"`
|
||||||
|
FilenameFormat string `json:"filename_format"`
|
||||||
|
TrackNumber bool `json:"track_number"`
|
||||||
|
Position int `json:"position"`
|
||||||
|
UseAlbumTrackNumber bool `json:"use_album_track_number"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LyricsDownloadResponse represents the response from lyrics download
|
// LyricsDownloadResponse represents the response from lyrics download
|
||||||
@@ -121,6 +125,31 @@ func msToLRCTimestamp(msStr string) string {
|
|||||||
return fmt.Sprintf("[%02d:%02d.%02d]", minutes, seconds, centiseconds)
|
return fmt.Sprintf("[%02d:%02d.%02d]", minutes, seconds, centiseconds)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// buildLyricsFilename builds the lyrics filename based on settings (same as track filename)
|
||||||
|
func buildLyricsFilename(trackName, artistName, filenameFormat string, includeTrackNumber bool, position int) string {
|
||||||
|
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
|
||||||
|
if includeTrackNumber && position > 0 {
|
||||||
|
filename = fmt.Sprintf("%02d. %s", position, filename)
|
||||||
|
}
|
||||||
|
|
||||||
|
return filename + ".lrc"
|
||||||
|
}
|
||||||
|
|
||||||
// DownloadLyrics downloads lyrics for a single track
|
// DownloadLyrics downloads lyrics for a single track
|
||||||
func (c *LyricsClient) DownloadLyrics(req LyricsDownloadRequest) (*LyricsDownloadResponse, error) {
|
func (c *LyricsClient) DownloadLyrics(req LyricsDownloadRequest) (*LyricsDownloadResponse, error) {
|
||||||
if req.SpotifyID == "" {
|
if req.SpotifyID == "" {
|
||||||
@@ -143,8 +172,12 @@ func (c *LyricsClient) DownloadLyrics(req LyricsDownloadRequest) (*LyricsDownloa
|
|||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate filename
|
// Generate filename using same format as track
|
||||||
filename := sanitizeFilename(fmt.Sprintf("%s - %s.lrc", req.TrackName, req.ArtistName))
|
filenameFormat := req.FilenameFormat
|
||||||
|
if filenameFormat == "" {
|
||||||
|
filenameFormat = "title-artist" // default
|
||||||
|
}
|
||||||
|
filename := buildLyricsFilename(req.TrackName, req.ArtistName, filenameFormat, req.TrackNumber, req.Position)
|
||||||
filePath := filepath.Join(outputDir, filename)
|
filePath := filepath.Join(outputDir, filename)
|
||||||
|
|
||||||
// Check if file already exists
|
// Check if file already exists
|
||||||
|
|||||||
@@ -22,6 +22,19 @@ type SongLinkURLs struct {
|
|||||||
AmazonURL string `json:"amazon_url"`
|
AmazonURL string `json:"amazon_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TrackAvailability represents the availability of a track on different platforms
|
||||||
|
type TrackAvailability struct {
|
||||||
|
SpotifyID string `json:"spotify_id"`
|
||||||
|
Tidal bool `json:"tidal"`
|
||||||
|
Deezer bool `json:"deezer"`
|
||||||
|
Amazon bool `json:"amazon"`
|
||||||
|
Qobuz bool `json:"qobuz"`
|
||||||
|
TidalURL string `json:"tidal_url,omitempty"`
|
||||||
|
DeezerURL string `json:"deezer_url,omitempty"`
|
||||||
|
AmazonURL string `json:"amazon_url,omitempty"`
|
||||||
|
QobuzURL string `json:"qobuz_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
func NewSongLinkClient() *SongLinkClient {
|
func NewSongLinkClient() *SongLinkClient {
|
||||||
return &SongLinkClient{
|
return &SongLinkClient{
|
||||||
client: &http.Client{
|
client: &http.Client{
|
||||||
@@ -148,3 +161,152 @@ func (s *SongLinkClient) GetAllURLsFromSpotify(spotifyTrackID string) (*SongLink
|
|||||||
|
|
||||||
return urls, nil
|
return urls, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckTrackAvailability checks the availability of a track on different platforms
|
||||||
|
func (s *SongLinkClient) CheckTrackAvailability(spotifyTrackID string, isrc string) (*TrackAvailability, 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.Printf("Checking availability for track: %s\n", spotifyTrackID)
|
||||||
|
|
||||||
|
// 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 check availability: %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)
|
||||||
|
}
|
||||||
|
|
||||||
|
availability := &TrackAvailability{
|
||||||
|
SpotifyID: spotifyTrackID,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check Tidal
|
||||||
|
if tidalLink, ok := songLinkResp.LinksByPlatform["tidal"]; ok && tidalLink.URL != "" {
|
||||||
|
availability.Tidal = true
|
||||||
|
availability.TidalURL = tidalLink.URL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check Deezer
|
||||||
|
if deezerLink, ok := songLinkResp.LinksByPlatform["deezer"]; ok && deezerLink.URL != "" {
|
||||||
|
availability.Deezer = true
|
||||||
|
availability.DeezerURL = deezerLink.URL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check Amazon
|
||||||
|
if amazonLink, ok := songLinkResp.LinksByPlatform["amazonMusic"]; ok && amazonLink.URL != "" {
|
||||||
|
availability.Amazon = true
|
||||||
|
availability.AmazonURL = amazonLink.URL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check Qobuz using ISRC (song.link doesn't support Qobuz)
|
||||||
|
if isrc != "" {
|
||||||
|
qobuzAvailable := checkQobuzAvailability(isrc)
|
||||||
|
availability.Qobuz = qobuzAvailable
|
||||||
|
}
|
||||||
|
|
||||||
|
return availability, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// checkQobuzAvailability checks if a track is available on Qobuz using ISRC
|
||||||
|
func checkQobuzAvailability(isrc string) bool {
|
||||||
|
client := &http.Client{Timeout: 10 * time.Second}
|
||||||
|
appID := "798273057"
|
||||||
|
|
||||||
|
// Decode base64 API URL
|
||||||
|
apiBase, _ := base64.StdEncoding.DecodeString("aHR0cHM6Ly93d3cucW9idXouY29tL2FwaS5qc29uLzAuMi90cmFjay9zZWFyY2g/cXVlcnk9")
|
||||||
|
searchURL := fmt.Sprintf("%s%s&limit=1&app_id=%s", string(apiBase), isrc, appID)
|
||||||
|
|
||||||
|
resp, err := client.Get(searchURL)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var searchResp struct {
|
||||||
|
Tracks struct {
|
||||||
|
Total int `json:"total"`
|
||||||
|
} `json:"tracks"`
|
||||||
|
}
|
||||||
|
if err := json.NewDecoder(resp.Body).Decode(&searchResp); err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return searchResp.Tracks.Total > 0
|
||||||
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
2d92c35b92c8ea713ea561773c5b7b7b
|
e92e100705a0bb90f6783cd4074df1a7
|
||||||
+22
-7
@@ -31,6 +31,7 @@ import type { HistoryItem } from "@/components/FetchHistory";
|
|||||||
import { useDownload } from "@/hooks/useDownload";
|
import { useDownload } from "@/hooks/useDownload";
|
||||||
import { useMetadata } from "@/hooks/useMetadata";
|
import { useMetadata } from "@/hooks/useMetadata";
|
||||||
import { useLyrics } from "@/hooks/useLyrics";
|
import { useLyrics } from "@/hooks/useLyrics";
|
||||||
|
import { useAvailability } from "@/hooks/useAvailability";
|
||||||
|
|
||||||
const HISTORY_KEY = "spotiflac_fetch_history";
|
const HISTORY_KEY = "spotiflac_fetch_history";
|
||||||
const MAX_HISTORY = 5;
|
const MAX_HISTORY = 5;
|
||||||
@@ -45,11 +46,12 @@ function App() {
|
|||||||
const [fetchHistory, setFetchHistory] = useState<HistoryItem[]>([]);
|
const [fetchHistory, setFetchHistory] = useState<HistoryItem[]>([]);
|
||||||
|
|
||||||
const ITEMS_PER_PAGE = 50;
|
const ITEMS_PER_PAGE = 50;
|
||||||
const CURRENT_VERSION = "6.3";
|
const CURRENT_VERSION = "6.4";
|
||||||
|
|
||||||
const download = useDownload();
|
const download = useDownload();
|
||||||
const metadata = useMetadata();
|
const metadata = useMetadata();
|
||||||
const lyrics = useLyrics();
|
const lyrics = useLyrics();
|
||||||
|
const availability = useAvailability();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const settings = getSettings();
|
const settings = getSettings();
|
||||||
@@ -79,6 +81,7 @@ function App() {
|
|||||||
setSearchQuery("");
|
setSearchQuery("");
|
||||||
download.resetDownloadedTracks();
|
download.resetDownloadedTracks();
|
||||||
lyrics.resetLyricsState();
|
lyrics.resetLyricsState();
|
||||||
|
availability.clearAvailability();
|
||||||
setSortBy("default");
|
setSortBy("default");
|
||||||
setCurrentPage(1);
|
setCurrentPage(1);
|
||||||
}, [metadata.metadata]);
|
}, [metadata.metadata]);
|
||||||
@@ -256,8 +259,11 @@ function App() {
|
|||||||
downloadedLyrics={lyrics.downloadedLyrics.has(track.spotify_id || "")}
|
downloadedLyrics={lyrics.downloadedLyrics.has(track.spotify_id || "")}
|
||||||
failedLyrics={lyrics.failedLyrics.has(track.spotify_id || "")}
|
failedLyrics={lyrics.failedLyrics.has(track.spotify_id || "")}
|
||||||
skippedLyrics={lyrics.skippedLyrics.has(track.spotify_id || "")}
|
skippedLyrics={lyrics.skippedLyrics.has(track.spotify_id || "")}
|
||||||
|
checkingAvailability={availability.checkingTrackId === track.spotify_id}
|
||||||
|
availability={availability.getAvailability(track.spotify_id || "")}
|
||||||
onDownload={download.handleDownloadTrack}
|
onDownload={download.handleDownloadTrack}
|
||||||
onDownloadLyrics={lyrics.handleDownloadLyrics}
|
onDownloadLyrics={lyrics.handleDownloadLyrics}
|
||||||
|
onCheckAvailability={availability.checkAvailability}
|
||||||
onOpenFolder={handleOpenFolder}
|
onOpenFolder={handleOpenFolder}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -286,14 +292,17 @@ function App() {
|
|||||||
failedLyrics={lyrics.failedLyrics}
|
failedLyrics={lyrics.failedLyrics}
|
||||||
skippedLyrics={lyrics.skippedLyrics}
|
skippedLyrics={lyrics.skippedLyrics}
|
||||||
downloadingLyricsTrack={lyrics.downloadingLyricsTrack}
|
downloadingLyricsTrack={lyrics.downloadingLyricsTrack}
|
||||||
|
checkingAvailabilityTrack={availability.checkingTrackId}
|
||||||
|
availabilityMap={availability.availabilityMap}
|
||||||
onSearchChange={handleSearchChange}
|
onSearchChange={handleSearchChange}
|
||||||
onSortChange={setSortBy}
|
onSortChange={setSortBy}
|
||||||
onToggleTrack={toggleTrackSelection}
|
onToggleTrack={toggleTrackSelection}
|
||||||
onToggleSelectAll={toggleSelectAll}
|
onToggleSelectAll={toggleSelectAll}
|
||||||
onDownloadTrack={download.handleDownloadTrack}
|
onDownloadTrack={download.handleDownloadTrack}
|
||||||
onDownloadLyrics={(spotifyId, name, artists, albumName) =>
|
onDownloadLyrics={(spotifyId, name, artists, albumName, _folderName, _isArtistDiscography, position) =>
|
||||||
lyrics.handleDownloadLyrics(spotifyId, name, artists, albumName, album_info.name)
|
lyrics.handleDownloadLyrics(spotifyId, name, artists, albumName, album_info.name, false, position)
|
||||||
}
|
}
|
||||||
|
onCheckAvailability={availability.checkAvailability}
|
||||||
onDownloadAll={() => download.handleDownloadAll(track_list, album_info.name)}
|
onDownloadAll={() => download.handleDownloadAll(track_list, album_info.name)}
|
||||||
onDownloadSelected={() =>
|
onDownloadSelected={() =>
|
||||||
download.handleDownloadSelected(selectedTracks, track_list, album_info.name)
|
download.handleDownloadSelected(selectedTracks, track_list, album_info.name)
|
||||||
@@ -340,14 +349,17 @@ function App() {
|
|||||||
failedLyrics={lyrics.failedLyrics}
|
failedLyrics={lyrics.failedLyrics}
|
||||||
skippedLyrics={lyrics.skippedLyrics}
|
skippedLyrics={lyrics.skippedLyrics}
|
||||||
downloadingLyricsTrack={lyrics.downloadingLyricsTrack}
|
downloadingLyricsTrack={lyrics.downloadingLyricsTrack}
|
||||||
|
checkingAvailabilityTrack={availability.checkingTrackId}
|
||||||
|
availabilityMap={availability.availabilityMap}
|
||||||
onSearchChange={handleSearchChange}
|
onSearchChange={handleSearchChange}
|
||||||
onSortChange={setSortBy}
|
onSortChange={setSortBy}
|
||||||
onToggleTrack={toggleTrackSelection}
|
onToggleTrack={toggleTrackSelection}
|
||||||
onToggleSelectAll={toggleSelectAll}
|
onToggleSelectAll={toggleSelectAll}
|
||||||
onDownloadTrack={download.handleDownloadTrack}
|
onDownloadTrack={download.handleDownloadTrack}
|
||||||
onDownloadLyrics={(spotifyId, name, artists, albumName) =>
|
onDownloadLyrics={(spotifyId, name, artists, albumName, _folderName, _isArtistDiscography, position) =>
|
||||||
lyrics.handleDownloadLyrics(spotifyId, name, artists, albumName, playlist_info.owner.name)
|
lyrics.handleDownloadLyrics(spotifyId, name, artists, albumName, playlist_info.owner.name, false, position)
|
||||||
}
|
}
|
||||||
|
onCheckAvailability={availability.checkAvailability}
|
||||||
onDownloadAll={() => download.handleDownloadAll(track_list, playlist_info.owner.name)}
|
onDownloadAll={() => download.handleDownloadAll(track_list, playlist_info.owner.name)}
|
||||||
onDownloadSelected={() =>
|
onDownloadSelected={() =>
|
||||||
download.handleDownloadSelected(
|
download.handleDownloadSelected(
|
||||||
@@ -400,14 +412,17 @@ function App() {
|
|||||||
failedLyrics={lyrics.failedLyrics}
|
failedLyrics={lyrics.failedLyrics}
|
||||||
skippedLyrics={lyrics.skippedLyrics}
|
skippedLyrics={lyrics.skippedLyrics}
|
||||||
downloadingLyricsTrack={lyrics.downloadingLyricsTrack}
|
downloadingLyricsTrack={lyrics.downloadingLyricsTrack}
|
||||||
|
checkingAvailabilityTrack={availability.checkingTrackId}
|
||||||
|
availabilityMap={availability.availabilityMap}
|
||||||
onSearchChange={handleSearchChange}
|
onSearchChange={handleSearchChange}
|
||||||
onSortChange={setSortBy}
|
onSortChange={setSortBy}
|
||||||
onToggleTrack={toggleTrackSelection}
|
onToggleTrack={toggleTrackSelection}
|
||||||
onToggleSelectAll={toggleSelectAll}
|
onToggleSelectAll={toggleSelectAll}
|
||||||
onDownloadTrack={download.handleDownloadTrack}
|
onDownloadTrack={download.handleDownloadTrack}
|
||||||
onDownloadLyrics={(spotifyId, name, artists, albumName, _folderName, isArtistDiscography) =>
|
onDownloadLyrics={(spotifyId, name, artists, albumName, _folderName, isArtistDiscography, position) =>
|
||||||
lyrics.handleDownloadLyrics(spotifyId, name, artists, albumName, artist_info.name, isArtistDiscography)
|
lyrics.handleDownloadLyrics(spotifyId, name, artists, albumName, artist_info.name, isArtistDiscography, position)
|
||||||
}
|
}
|
||||||
|
onCheckAvailability={availability.checkAvailability}
|
||||||
onDownloadAll={() => download.handleDownloadAll(track_list, artist_info.name, true)}
|
onDownloadAll={() => download.handleDownloadAll(track_list, artist_info.name, true)}
|
||||||
onDownloadSelected={() =>
|
onDownloadSelected={() =>
|
||||||
download.handleDownloadSelected(selectedTracks, track_list, artist_info.name, true)
|
download.handleDownloadSelected(selectedTracks, track_list, artist_info.name, true)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Spinner } from "@/components/ui/spinner";
|
|||||||
import { SearchAndSort } from "./SearchAndSort";
|
import { SearchAndSort } from "./SearchAndSort";
|
||||||
import { TrackList } from "./TrackList";
|
import { TrackList } from "./TrackList";
|
||||||
import { DownloadProgress } from "./DownloadProgress";
|
import { DownloadProgress } from "./DownloadProgress";
|
||||||
import type { TrackMetadata } from "@/types/api";
|
import type { TrackMetadata, TrackAvailability } from "@/types/api";
|
||||||
|
|
||||||
interface AlbumInfoProps {
|
interface AlbumInfoProps {
|
||||||
albumInfo: {
|
albumInfo: {
|
||||||
@@ -36,12 +36,16 @@ interface AlbumInfoProps {
|
|||||||
failedLyrics?: Set<string>;
|
failedLyrics?: Set<string>;
|
||||||
skippedLyrics?: Set<string>;
|
skippedLyrics?: Set<string>;
|
||||||
downloadingLyricsTrack?: string | null;
|
downloadingLyricsTrack?: string | null;
|
||||||
|
// Availability props
|
||||||
|
checkingAvailabilityTrack?: string | null;
|
||||||
|
availabilityMap?: Map<string, TrackAvailability>;
|
||||||
onSearchChange: (value: string) => void;
|
onSearchChange: (value: string) => void;
|
||||||
onSortChange: (value: string) => void;
|
onSortChange: (value: string) => void;
|
||||||
onToggleTrack: (isrc: string) => void;
|
onToggleTrack: (isrc: string) => void;
|
||||||
onToggleSelectAll: (tracks: TrackMetadata[]) => void;
|
onToggleSelectAll: (tracks: TrackMetadata[]) => void;
|
||||||
onDownloadTrack: (isrc: string, name: string, artists: string, albumName: string, spotifyId?: string) => void;
|
onDownloadTrack: (isrc: string, name: string, artists: string, albumName: string, spotifyId?: string) => void;
|
||||||
onDownloadLyrics?: (spotifyId: string, name: string, artists: string, albumName: string, folderName?: string, isArtistDiscography?: boolean) => void;
|
onDownloadLyrics?: (spotifyId: string, name: string, artists: string, albumName: string, folderName?: string, isArtistDiscography?: boolean, position?: number) => void;
|
||||||
|
onCheckAvailability?: (spotifyId: string) => void;
|
||||||
onDownloadAll: () => void;
|
onDownloadAll: () => void;
|
||||||
onDownloadSelected: () => void;
|
onDownloadSelected: () => void;
|
||||||
onStopDownload: () => void;
|
onStopDownload: () => void;
|
||||||
@@ -71,12 +75,15 @@ export function AlbumInfo({
|
|||||||
failedLyrics,
|
failedLyrics,
|
||||||
skippedLyrics,
|
skippedLyrics,
|
||||||
downloadingLyricsTrack,
|
downloadingLyricsTrack,
|
||||||
|
checkingAvailabilityTrack,
|
||||||
|
availabilityMap,
|
||||||
onSearchChange,
|
onSearchChange,
|
||||||
onSortChange,
|
onSortChange,
|
||||||
onToggleTrack,
|
onToggleTrack,
|
||||||
onToggleSelectAll,
|
onToggleSelectAll,
|
||||||
onDownloadTrack,
|
onDownloadTrack,
|
||||||
onDownloadLyrics,
|
onDownloadLyrics,
|
||||||
|
onCheckAvailability,
|
||||||
onDownloadAll,
|
onDownloadAll,
|
||||||
onDownloadSelected,
|
onDownloadSelected,
|
||||||
onStopDownload,
|
onStopDownload,
|
||||||
@@ -191,10 +198,13 @@ export function AlbumInfo({
|
|||||||
failedLyrics={failedLyrics}
|
failedLyrics={failedLyrics}
|
||||||
skippedLyrics={skippedLyrics}
|
skippedLyrics={skippedLyrics}
|
||||||
downloadingLyricsTrack={downloadingLyricsTrack}
|
downloadingLyricsTrack={downloadingLyricsTrack}
|
||||||
|
checkingAvailabilityTrack={checkingAvailabilityTrack}
|
||||||
|
availabilityMap={availabilityMap}
|
||||||
onToggleTrack={onToggleTrack}
|
onToggleTrack={onToggleTrack}
|
||||||
onToggleSelectAll={onToggleSelectAll}
|
onToggleSelectAll={onToggleSelectAll}
|
||||||
onDownloadTrack={onDownloadTrack}
|
onDownloadTrack={onDownloadTrack}
|
||||||
onDownloadLyrics={onDownloadLyrics}
|
onDownloadLyrics={onDownloadLyrics}
|
||||||
|
onCheckAvailability={onCheckAvailability}
|
||||||
onPageChange={onPageChange}
|
onPageChange={onPageChange}
|
||||||
onTrackClick={onTrackClick}
|
onTrackClick={onTrackClick}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Spinner } from "@/components/ui/spinner";
|
|||||||
import { SearchAndSort } from "./SearchAndSort";
|
import { SearchAndSort } from "./SearchAndSort";
|
||||||
import { TrackList } from "./TrackList";
|
import { TrackList } from "./TrackList";
|
||||||
import { DownloadProgress } from "./DownloadProgress";
|
import { DownloadProgress } from "./DownloadProgress";
|
||||||
import type { TrackMetadata } from "@/types/api";
|
import type { TrackMetadata, TrackAvailability } from "@/types/api";
|
||||||
|
|
||||||
interface ArtistInfoProps {
|
interface ArtistInfoProps {
|
||||||
artistInfo: {
|
artistInfo: {
|
||||||
@@ -41,12 +41,16 @@ interface ArtistInfoProps {
|
|||||||
failedLyrics?: Set<string>;
|
failedLyrics?: Set<string>;
|
||||||
skippedLyrics?: Set<string>;
|
skippedLyrics?: Set<string>;
|
||||||
downloadingLyricsTrack?: string | null;
|
downloadingLyricsTrack?: string | null;
|
||||||
|
// Availability props
|
||||||
|
checkingAvailabilityTrack?: string | null;
|
||||||
|
availabilityMap?: Map<string, TrackAvailability>;
|
||||||
onSearchChange: (value: string) => void;
|
onSearchChange: (value: string) => void;
|
||||||
onSortChange: (value: string) => void;
|
onSortChange: (value: string) => void;
|
||||||
onToggleTrack: (isrc: string) => void;
|
onToggleTrack: (isrc: string) => void;
|
||||||
onToggleSelectAll: (tracks: TrackMetadata[]) => void;
|
onToggleSelectAll: (tracks: TrackMetadata[]) => void;
|
||||||
onDownloadTrack: (isrc: string, name: string, artists: string, albumName: string, spotifyId?: string) => void;
|
onDownloadTrack: (isrc: string, name: string, artists: string, albumName: string, spotifyId?: string) => void;
|
||||||
onDownloadLyrics?: (spotifyId: string, name: string, artists: string, albumName: string, folderName?: string, isArtistDiscography?: boolean) => void;
|
onDownloadLyrics?: (spotifyId: string, name: string, artists: string, albumName: string, folderName?: string, isArtistDiscography?: boolean, position?: number) => void;
|
||||||
|
onCheckAvailability?: (spotifyId: string) => void;
|
||||||
onDownloadAll: () => void;
|
onDownloadAll: () => void;
|
||||||
onDownloadSelected: () => void;
|
onDownloadSelected: () => void;
|
||||||
onStopDownload: () => void;
|
onStopDownload: () => void;
|
||||||
@@ -78,12 +82,15 @@ export function ArtistInfo({
|
|||||||
failedLyrics,
|
failedLyrics,
|
||||||
skippedLyrics,
|
skippedLyrics,
|
||||||
downloadingLyricsTrack,
|
downloadingLyricsTrack,
|
||||||
|
checkingAvailabilityTrack,
|
||||||
|
availabilityMap,
|
||||||
onSearchChange,
|
onSearchChange,
|
||||||
onSortChange,
|
onSortChange,
|
||||||
onToggleTrack,
|
onToggleTrack,
|
||||||
onToggleSelectAll,
|
onToggleSelectAll,
|
||||||
onDownloadTrack,
|
onDownloadTrack,
|
||||||
onDownloadLyrics,
|
onDownloadLyrics,
|
||||||
|
onCheckAvailability,
|
||||||
onDownloadAll,
|
onDownloadAll,
|
||||||
onDownloadSelected,
|
onDownloadSelected,
|
||||||
onStopDownload,
|
onStopDownload,
|
||||||
@@ -230,10 +237,13 @@ export function ArtistInfo({
|
|||||||
failedLyrics={failedLyrics}
|
failedLyrics={failedLyrics}
|
||||||
skippedLyrics={skippedLyrics}
|
skippedLyrics={skippedLyrics}
|
||||||
downloadingLyricsTrack={downloadingLyricsTrack}
|
downloadingLyricsTrack={downloadingLyricsTrack}
|
||||||
|
checkingAvailabilityTrack={checkingAvailabilityTrack}
|
||||||
|
availabilityMap={availabilityMap}
|
||||||
onToggleTrack={onToggleTrack}
|
onToggleTrack={onToggleTrack}
|
||||||
onToggleSelectAll={onToggleSelectAll}
|
onToggleSelectAll={onToggleSelectAll}
|
||||||
onDownloadTrack={onDownloadTrack}
|
onDownloadTrack={onDownloadTrack}
|
||||||
onDownloadLyrics={onDownloadLyrics}
|
onDownloadLyrics={onDownloadLyrics}
|
||||||
|
onCheckAvailability={onCheckAvailability}
|
||||||
onPageChange={onPageChange}
|
onPageChange={onPageChange}
|
||||||
onAlbumClick={onAlbumClick}
|
onAlbumClick={onAlbumClick}
|
||||||
onArtistClick={onArtistClick}
|
onArtistClick={onArtistClick}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useState } from "react";
|
import { useState, useCallback } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
@@ -17,11 +17,14 @@ import { SpectrumVisualization } from "@/components/SpectrumVisualization";
|
|||||||
import { useAudioAnalysis } from "@/hooks/useAudioAnalysis";
|
import { useAudioAnalysis } from "@/hooks/useAudioAnalysis";
|
||||||
import { SelectFile } from "../../wailsjs/go/main/App";
|
import { SelectFile } from "../../wailsjs/go/main/App";
|
||||||
import { toastWithSound as toast } from "@/lib/toast-with-sound";
|
import { toastWithSound as toast } from "@/lib/toast-with-sound";
|
||||||
|
import { OnFileDrop, OnFileDropOff } from "../../wailsjs/runtime/runtime";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
export function AudioAnalysisDialog() {
|
export function AudioAnalysisDialog() {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const { analyzing, result, analyzeFile, clearResult } = useAudioAnalysis();
|
const { analyzing, result, analyzeFile, clearResult } = useAudioAnalysis();
|
||||||
const [selectedFilePath, setSelectedFilePath] = useState<string>("");
|
const [selectedFilePath, setSelectedFilePath] = useState<string>("");
|
||||||
|
const [isDragging, setIsDragging] = useState(false);
|
||||||
|
|
||||||
const handleSelectFile = async () => {
|
const handleSelectFile = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -37,6 +40,38 @@ export function AudioAnalysisDialog() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleFileDrop = useCallback(async (_x: number, _y: number, paths: string[]) => {
|
||||||
|
setIsDragging(false);
|
||||||
|
|
||||||
|
if (paths.length === 0) return;
|
||||||
|
|
||||||
|
const filePath = paths[0];
|
||||||
|
|
||||||
|
// Check if it's a FLAC file
|
||||||
|
if (!filePath.toLowerCase().endsWith('.flac')) {
|
||||||
|
toast.error("Invalid File Type", {
|
||||||
|
description: "Please drop a FLAC file for analysis",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setSelectedFilePath(filePath);
|
||||||
|
await analyzeFile(filePath);
|
||||||
|
}, [analyzeFile]);
|
||||||
|
|
||||||
|
// Register drag and drop handlers when dialog is open
|
||||||
|
useEffect(() => {
|
||||||
|
if (open) {
|
||||||
|
OnFileDrop((x, y, paths) => {
|
||||||
|
handleFileDrop(x, y, paths);
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
OnFileDropOff();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}, [open, handleFileDrop]);
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -82,11 +117,32 @@ export function AudioAnalysisDialog() {
|
|||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{/* File Selection */}
|
{/* File Selection */}
|
||||||
{!result && !analyzing && (
|
{!result && !analyzing && (
|
||||||
<div className="flex flex-col items-center justify-center py-12 border-2 border-dashed rounded-lg">
|
<div
|
||||||
<Activity className="h-16 w-16 text-muted-foreground/50 mb-4" />
|
className={`flex flex-col items-center justify-center py-12 border-2 border-dashed rounded-lg transition-colors ${
|
||||||
|
isDragging
|
||||||
|
? "border-primary bg-primary/10"
|
||||||
|
: "border-muted-foreground/30 hover:border-muted-foreground/50"
|
||||||
|
}`}
|
||||||
|
onDragOver={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
setIsDragging(true);
|
||||||
|
}}
|
||||||
|
onDragLeave={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
setIsDragging(false);
|
||||||
|
}}
|
||||||
|
onDrop={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
setIsDragging(false);
|
||||||
|
}}
|
||||||
|
style={{ "--wails-drop-target": "drop" } as React.CSSProperties}
|
||||||
|
>
|
||||||
|
<Activity className={`h-16 w-16 mb-4 transition-colors ${isDragging ? "text-primary" : "text-muted-foreground/50"}`} />
|
||||||
<h3 className="text-lg font-medium mb-2">Analyze FLAC Audio Quality</h3>
|
<h3 className="text-lg font-medium mb-2">Analyze FLAC Audio Quality</h3>
|
||||||
<p className="text-sm text-muted-foreground mb-6 text-center max-w-md">
|
<p className="text-sm text-muted-foreground mb-6 text-center max-w-md">
|
||||||
Upload a FLAC file to verify true lossless quality, view detailed technical specifications, and see the frequency spectrum
|
{isDragging
|
||||||
|
? "Drop your FLAC file here"
|
||||||
|
: "Drag and drop a FLAC file here, or click the button below to select"}
|
||||||
</p>
|
</p>
|
||||||
<Button onClick={handleSelectFile} size="lg">
|
<Button onClick={handleSelectFile} size="lg">
|
||||||
<Upload className="h-5 w-5" />
|
<Upload className="h-5 w-5" />
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
// Platform Icons for streaming services
|
||||||
|
|
||||||
|
export const TidalIcon = ({ className = "w-4 h-4" }: { className?: string }) => (
|
||||||
|
<svg viewBox="0 0 24 24" className={`${className} fill-current`}>
|
||||||
|
<path d="M4.022 4.5 0 8.516l3.997 3.99 3.997-3.984L4.022 4.5Zm7.956 0L7.994 8.522l4.003 3.984L16 8.484 11.978 4.5Zm8.007 0L24 8.528l-4.003 3.978L16 8.484 19.985 4.5Z"></path>
|
||||||
|
<path d="m8.012 16.534 3.991 3.966L16 16.49l-4.003-3.984-3.985 4.028Z"></path>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const DeezerIcon = ({ className = "w-4 h-4" }: { className?: string }) => (
|
||||||
|
<svg viewBox="0 0 24 24" className={`${className} fill-current`}>
|
||||||
|
<path d="M18.77 5.55c.19-1.07.46-1.75.76-1.75.56 0 1.02 2.34 1.02 5.23 0 2.89-.46 5.23-1.02 5.23-.23 0-.44-.4-.61-1.06-.27 2.43-.83 4.11-1.48 4.11-.5 0-.96-1-1.26-2.6-.2 3.03-.73 5.17-1.33 5.17-.39 0-.73-.85-.99-2.23-.31 2.85-1.03 4.85-1.86 4.85-.83 0-1.55-2-1.86-4.85-.25 1.38-.6 2.23-.99 2.23-.6 0-1.12-2.14-1.33-5.16-.3 1.58-.75 2.6-1.26 2.6-.65 0-1.2-1.68-1.48-4.12-.17.66-.38 1.06-.61 1.06-.56 0-1.02-2.34-1.02-5.23 0-2.89.46-5.23 1.02-5.23.3 0 .57.68.76 1.75C5.53 3.7 6 2.5 6.56 2.5c.66 0 1.22 1.7 1.49 4.17.26-1.8.66-2.94 1.1-2.94.63 0 1.16 2.25 1.36 5.4.36-1.62.9-2.63 1.5-2.63.58 0 1.12 1.01 1.49 2.62.2-3.14.72-5.4 1.35-5.4.44 0 .84 1.15 1.1 2.95.27-2.47.84-4.17 1.49-4.17.55 0 1.03 1.2 1.33 3.05ZM2 8.52c0-1.3.26-2.34.58-2.34.32 0 .57 1.05.57 2.34 0 1.29-.25 2.34-.57 2.34-.32 0-.58-1.05-.58-2.34Zm18.85 0c0-1.3.25-2.34.57-2.34.32 0 .58 1.05.58 2.34 0 1.29-.26 2.34-.58 2.34-.32 0-.57-1.05-.57-2.34Z"></path>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const QobuzIcon = ({ className = "w-4 h-4" }: { className?: string }) => (
|
||||||
|
<svg viewBox="0 0 24 24" className={`${className} fill-current`}>
|
||||||
|
<path d="M21.744 9.815C19.836 1.261 8.393-1 3.55 6.64-.618 13.214 4 22 11.988 22c2.387 0 4.63-.83 6.394-2.304l2.252 2.252 1.224-1.224-2.252-2.253c1.983-2.407 2.823-5.586 2.138-8.656Zm-3.508 7.297L16.4 15.275c-.786-.787-2.017.432-1.224 1.225L17 18.326C10.29 23.656.5 16 5.16 7.667c3.502-6.264 13.172-4.348 14.707 2.574.529 2.385-.06 4.987-1.63 6.87Z"></path>
|
||||||
|
<path d="M13.4 8.684a3.59 3.59 0 0 0-4.712 1.9 3.59 3.59 0 0 0 1.9 4.712 3.594 3.594 0 0 0 4.711-1.89 3.598 3.598 0 0 0-1.9-4.722Zm-.737 3.591a.727.727 0 0 1-.965.384.727.727 0 0 1-.384-.965.727.727 0 0 1 .965-.384.73.73 0 0 1 .384.965Z"></path>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const AmazonIcon = ({ className = "w-4 h-4" }: { className?: string }) => (
|
||||||
|
<svg viewBox="0 0 24 24" className={`${className} fill-current`}>
|
||||||
|
<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>
|
||||||
|
);
|
||||||
@@ -5,7 +5,7 @@ import { Spinner } from "@/components/ui/spinner";
|
|||||||
import { SearchAndSort } from "./SearchAndSort";
|
import { SearchAndSort } from "./SearchAndSort";
|
||||||
import { TrackList } from "./TrackList";
|
import { TrackList } from "./TrackList";
|
||||||
import { DownloadProgress } from "./DownloadProgress";
|
import { DownloadProgress } from "./DownloadProgress";
|
||||||
import type { TrackMetadata } from "@/types/api";
|
import type { TrackMetadata, TrackAvailability } from "@/types/api";
|
||||||
|
|
||||||
interface PlaylistInfoProps {
|
interface PlaylistInfoProps {
|
||||||
playlistInfo: {
|
playlistInfo: {
|
||||||
@@ -40,12 +40,16 @@ interface PlaylistInfoProps {
|
|||||||
failedLyrics?: Set<string>;
|
failedLyrics?: Set<string>;
|
||||||
skippedLyrics?: Set<string>;
|
skippedLyrics?: Set<string>;
|
||||||
downloadingLyricsTrack?: string | null;
|
downloadingLyricsTrack?: string | null;
|
||||||
|
// Availability props
|
||||||
|
checkingAvailabilityTrack?: string | null;
|
||||||
|
availabilityMap?: Map<string, TrackAvailability>;
|
||||||
onSearchChange: (value: string) => void;
|
onSearchChange: (value: string) => void;
|
||||||
onSortChange: (value: string) => void;
|
onSortChange: (value: string) => void;
|
||||||
onToggleTrack: (isrc: string) => void;
|
onToggleTrack: (isrc: string) => void;
|
||||||
onToggleSelectAll: (tracks: TrackMetadata[]) => void;
|
onToggleSelectAll: (tracks: TrackMetadata[]) => void;
|
||||||
onDownloadTrack: (isrc: string, name: string, artists: string, albumName: string, spotifyId?: string) => void;
|
onDownloadTrack: (isrc: string, name: string, artists: string, albumName: string, spotifyId?: string) => void;
|
||||||
onDownloadLyrics?: (spotifyId: string, name: string, artists: string, albumName: string, folderName?: string, isArtistDiscography?: boolean) => void;
|
onDownloadLyrics?: (spotifyId: string, name: string, artists: string, albumName: string, folderName?: string, isArtistDiscography?: boolean, position?: number) => void;
|
||||||
|
onCheckAvailability?: (spotifyId: string) => void;
|
||||||
onDownloadAll: () => void;
|
onDownloadAll: () => void;
|
||||||
onDownloadSelected: () => void;
|
onDownloadSelected: () => void;
|
||||||
onStopDownload: () => void;
|
onStopDownload: () => void;
|
||||||
@@ -76,12 +80,15 @@ export function PlaylistInfo({
|
|||||||
failedLyrics,
|
failedLyrics,
|
||||||
skippedLyrics,
|
skippedLyrics,
|
||||||
downloadingLyricsTrack,
|
downloadingLyricsTrack,
|
||||||
|
checkingAvailabilityTrack,
|
||||||
|
availabilityMap,
|
||||||
onSearchChange,
|
onSearchChange,
|
||||||
onSortChange,
|
onSortChange,
|
||||||
onToggleTrack,
|
onToggleTrack,
|
||||||
onToggleSelectAll,
|
onToggleSelectAll,
|
||||||
onDownloadTrack,
|
onDownloadTrack,
|
||||||
onDownloadLyrics,
|
onDownloadLyrics,
|
||||||
|
onCheckAvailability,
|
||||||
onDownloadAll,
|
onDownloadAll,
|
||||||
onDownloadSelected,
|
onDownloadSelected,
|
||||||
onStopDownload,
|
onStopDownload,
|
||||||
@@ -182,10 +189,13 @@ export function PlaylistInfo({
|
|||||||
failedLyrics={failedLyrics}
|
failedLyrics={failedLyrics}
|
||||||
skippedLyrics={skippedLyrics}
|
skippedLyrics={skippedLyrics}
|
||||||
downloadingLyricsTrack={downloadingLyricsTrack}
|
downloadingLyricsTrack={downloadingLyricsTrack}
|
||||||
|
checkingAvailabilityTrack={checkingAvailabilityTrack}
|
||||||
|
availabilityMap={availabilityMap}
|
||||||
onToggleTrack={onToggleTrack}
|
onToggleTrack={onToggleTrack}
|
||||||
onToggleSelectAll={onToggleSelectAll}
|
onToggleSelectAll={onToggleSelectAll}
|
||||||
onDownloadTrack={onDownloadTrack}
|
onDownloadTrack={onDownloadTrack}
|
||||||
onDownloadLyrics={onDownloadLyrics}
|
onDownloadLyrics={onDownloadLyrics}
|
||||||
|
onCheckAvailability={onCheckAvailability}
|
||||||
onPageChange={onPageChange}
|
onPageChange={onPageChange}
|
||||||
onAlbumClick={onAlbumClick}
|
onAlbumClick={onAlbumClick}
|
||||||
onArtistClick={onArtistClick}
|
onArtistClick={onArtistClick}
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
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, CheckCircle, XCircle, FileText, SkipForward } from "lucide-react";
|
import { Download, FolderOpen, CheckCircle, XCircle, FileText, SkipForward, Globe } from "lucide-react";
|
||||||
import { Spinner } from "@/components/ui/spinner";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
import type { TrackMetadata } from "@/types/api";
|
import {
|
||||||
|
Tooltip,
|
||||||
|
TooltipContent,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from "@/components/ui/tooltip";
|
||||||
|
import type { TrackMetadata, TrackAvailability } from "@/types/api";
|
||||||
|
import { TidalIcon, DeezerIcon, QobuzIcon, AmazonIcon } from "./PlatformIcons";
|
||||||
|
|
||||||
interface TrackInfoProps {
|
interface TrackInfoProps {
|
||||||
track: TrackMetadata & { album_name: string; release_date: string };
|
track: TrackMetadata & { album_name: string; release_date: string };
|
||||||
@@ -14,8 +20,11 @@ interface TrackInfoProps {
|
|||||||
downloadedLyrics?: boolean;
|
downloadedLyrics?: boolean;
|
||||||
failedLyrics?: boolean;
|
failedLyrics?: boolean;
|
||||||
skippedLyrics?: boolean;
|
skippedLyrics?: boolean;
|
||||||
|
checkingAvailability?: boolean;
|
||||||
|
availability?: TrackAvailability;
|
||||||
onDownload: (isrc: string, name: string, artists: string, albumName?: string, spotifyId?: string) => void;
|
onDownload: (isrc: string, name: string, artists: string, albumName?: string, spotifyId?: string) => void;
|
||||||
onDownloadLyrics?: (spotifyId: string, name: string, artists: string, albumName?: string) => void;
|
onDownloadLyrics?: (spotifyId: string, name: string, artists: string, albumName?: string) => void;
|
||||||
|
onCheckAvailability?: (spotifyId: string, isrc?: string) => void;
|
||||||
onOpenFolder: () => void;
|
onOpenFolder: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,21 +38,71 @@ export function TrackInfo({
|
|||||||
downloadedLyrics,
|
downloadedLyrics,
|
||||||
failedLyrics,
|
failedLyrics,
|
||||||
skippedLyrics,
|
skippedLyrics,
|
||||||
|
checkingAvailability,
|
||||||
|
availability,
|
||||||
onDownload,
|
onDownload,
|
||||||
onDownloadLyrics,
|
onDownloadLyrics,
|
||||||
|
onCheckAvailability,
|
||||||
onOpenFolder,
|
onOpenFolder,
|
||||||
}: TrackInfoProps) {
|
}: TrackInfoProps) {
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent className="px-6">
|
<CardContent className="px-6">
|
||||||
<div className="flex gap-6 items-start">
|
<div className="flex gap-6 items-start">
|
||||||
{track.images && (
|
<div className="shrink-0">
|
||||||
<img
|
{track.images && (
|
||||||
src={track.images}
|
<img
|
||||||
alt={track.name}
|
src={track.images}
|
||||||
className="w-48 h-48 rounded-md shadow-lg object-cover shrink-0"
|
alt={track.name}
|
||||||
/>
|
className="w-48 h-48 rounded-md shadow-lg object-cover"
|
||||||
)}
|
/>
|
||||||
|
)}
|
||||||
|
{/* Availability Icons - below cover art */}
|
||||||
|
{availability && (
|
||||||
|
<div className="flex items-center justify-center gap-2 mt-3">
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger>
|
||||||
|
<div className={`${availability.tidal ? "text-green-500" : "text-red-500"}`}>
|
||||||
|
<TidalIcon className="w-5 h-5" />
|
||||||
|
</div>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>
|
||||||
|
<p>Tidal</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger>
|
||||||
|
<div className={`${availability.deezer ? "text-green-500" : "text-red-500"}`}>
|
||||||
|
<DeezerIcon className="w-5 h-5" />
|
||||||
|
</div>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>
|
||||||
|
<p>Deezer</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger>
|
||||||
|
<div className={`${availability.amazon ? "text-green-500" : "text-red-500"}`}>
|
||||||
|
<AmazonIcon className="w-5 h-5" />
|
||||||
|
</div>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>
|
||||||
|
<p>Amazon Music</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger>
|
||||||
|
<div className={`${availability.qobuz ? "text-green-500" : "text-red-500"}`}>
|
||||||
|
<QobuzIcon className="w-5 h-5" />
|
||||||
|
</div>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>
|
||||||
|
<p>Qobuz</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<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">
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
@@ -68,7 +127,7 @@ export function TrackInfo({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{track.isrc && (
|
{track.isrc && (
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2 flex-wrap">
|
||||||
<Button
|
<Button
|
||||||
onClick={() => onDownload(track.isrc, track.name, track.artists, track.album_name, track.spotify_id)}
|
onClick={() => onDownload(track.isrc, track.name, track.artists, track.album_name, track.spotify_id)}
|
||||||
disabled={isDownloading || downloadingTrack === track.isrc}
|
disabled={isDownloading || downloadingTrack === track.isrc}
|
||||||
@@ -82,30 +141,51 @@ export function TrackInfo({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
|
{track.spotify_id && onCheckAvailability && (
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger asChild>
|
||||||
|
<Button
|
||||||
|
onClick={() => onCheckAvailability(track.spotify_id!, track.isrc)}
|
||||||
|
variant="outline"
|
||||||
|
disabled={checkingAvailability}
|
||||||
|
>
|
||||||
|
{checkingAvailability ? (
|
||||||
|
<Spinner />
|
||||||
|
) : (
|
||||||
|
<Globe className="h-4 w-4" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>
|
||||||
|
<p>Check Availability</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
{track.spotify_id && onDownloadLyrics && (
|
{track.spotify_id && onDownloadLyrics && (
|
||||||
<Button
|
<Tooltip>
|
||||||
onClick={() => onDownloadLyrics(track.spotify_id!, track.name, track.artists, track.album_name)}
|
<TooltipTrigger asChild>
|
||||||
variant="secondary"
|
<Button
|
||||||
disabled={downloadingLyricsTrack === track.spotify_id}
|
onClick={() => onDownloadLyrics(track.spotify_id!, track.name, track.artists, track.album_name)}
|
||||||
>
|
variant="outline"
|
||||||
{downloadingLyricsTrack === track.spotify_id ? (
|
disabled={downloadingLyricsTrack === track.spotify_id}
|
||||||
<Spinner />
|
>
|
||||||
) : (
|
{downloadingLyricsTrack === track.spotify_id ? (
|
||||||
<>
|
<Spinner />
|
||||||
<FileText className="h-4 w-4" />
|
) : skippedLyrics ? (
|
||||||
Download Lyric
|
<SkipForward className="h-4 w-4 text-yellow-500" />
|
||||||
{skippedLyrics && (
|
) : downloadedLyrics ? (
|
||||||
<SkipForward className="h-4 w-4 text-yellow-500 ml-1" />
|
<CheckCircle className="h-4 w-4 text-green-500" />
|
||||||
|
) : failedLyrics ? (
|
||||||
|
<XCircle className="h-4 w-4 text-red-500" />
|
||||||
|
) : (
|
||||||
|
<FileText className="h-4 w-4" />
|
||||||
)}
|
)}
|
||||||
{downloadedLyrics && !skippedLyrics && (
|
</Button>
|
||||||
<CheckCircle className="h-4 w-4 text-green-500 ml-1" />
|
</TooltipTrigger>
|
||||||
)}
|
<TooltipContent>
|
||||||
{failedLyrics && (
|
<p>Download Lyric</p>
|
||||||
<XCircle className="h-4 w-4 text-red-500 ml-1" />
|
</TooltipContent>
|
||||||
)}
|
</Tooltip>
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
{isDownloaded && (
|
{isDownloaded && (
|
||||||
<Button onClick={onOpenFolder} variant="outline">
|
<Button onClick={onOpenFolder} variant="outline">
|
||||||
|
|||||||
@@ -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, XCircle, SkipForward, FileText } from "lucide-react";
|
import { Download, CheckCircle, XCircle, SkipForward, FileText, Globe } from "lucide-react";
|
||||||
import { Spinner } from "@/components/ui/spinner";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
import {
|
import {
|
||||||
Tooltip,
|
Tooltip,
|
||||||
@@ -15,7 +15,8 @@ import {
|
|||||||
PaginationNext,
|
PaginationNext,
|
||||||
PaginationPrevious,
|
PaginationPrevious,
|
||||||
} from "@/components/ui/pagination";
|
} from "@/components/ui/pagination";
|
||||||
import type { TrackMetadata } from "@/types/api";
|
import type { TrackMetadata, TrackAvailability } from "@/types/api";
|
||||||
|
import { TidalIcon, DeezerIcon, QobuzIcon, AmazonIcon } from "./PlatformIcons";
|
||||||
|
|
||||||
interface TrackListProps {
|
interface TrackListProps {
|
||||||
tracks: TrackMetadata[];
|
tracks: TrackMetadata[];
|
||||||
@@ -38,10 +39,14 @@ interface TrackListProps {
|
|||||||
failedLyrics?: Set<string>;
|
failedLyrics?: Set<string>;
|
||||||
skippedLyrics?: Set<string>;
|
skippedLyrics?: Set<string>;
|
||||||
downloadingLyricsTrack?: string | null;
|
downloadingLyricsTrack?: string | null;
|
||||||
|
// Availability props
|
||||||
|
checkingAvailabilityTrack?: string | null;
|
||||||
|
availabilityMap?: Map<string, TrackAvailability>;
|
||||||
onToggleTrack: (isrc: string) => void;
|
onToggleTrack: (isrc: string) => void;
|
||||||
onToggleSelectAll: (tracks: TrackMetadata[]) => void;
|
onToggleSelectAll: (tracks: TrackMetadata[]) => void;
|
||||||
onDownloadTrack: (isrc: string, name: string, artists: string, albumName: string, spotifyId?: string, folderName?: string, isArtistDiscography?: boolean) => void;
|
onDownloadTrack: (isrc: string, name: string, artists: string, albumName: string, spotifyId?: string, folderName?: string, isArtistDiscography?: boolean) => void;
|
||||||
onDownloadLyrics?: (spotifyId: string, name: string, artists: string, albumName: string, folderName?: string, isArtistDiscography?: boolean) => void;
|
onDownloadLyrics?: (spotifyId: string, name: string, artists: string, albumName: string, folderName?: string, isArtistDiscography?: boolean, position?: number) => void;
|
||||||
|
onCheckAvailability?: (spotifyId: string, isrc?: string) => void;
|
||||||
onPageChange: (page: number) => void;
|
onPageChange: (page: number) => void;
|
||||||
onAlbumClick?: (album: { id: string; name: string; external_urls: string }) => void;
|
onAlbumClick?: (album: { id: string; name: string; external_urls: string }) => void;
|
||||||
onArtistClick?: (artist: { id: string; name: string; external_urls: string }) => void;
|
onArtistClick?: (artist: { id: string; name: string; external_urls: string }) => void;
|
||||||
@@ -68,10 +73,13 @@ export function TrackList({
|
|||||||
failedLyrics,
|
failedLyrics,
|
||||||
skippedLyrics,
|
skippedLyrics,
|
||||||
downloadingLyricsTrack,
|
downloadingLyricsTrack,
|
||||||
|
checkingAvailabilityTrack,
|
||||||
|
availabilityMap,
|
||||||
onToggleTrack,
|
onToggleTrack,
|
||||||
onToggleSelectAll,
|
onToggleSelectAll,
|
||||||
onDownloadTrack,
|
onDownloadTrack,
|
||||||
onDownloadLyrics,
|
onDownloadLyrics,
|
||||||
|
onCheckAvailability,
|
||||||
onPageChange,
|
onPageChange,
|
||||||
onAlbumClick,
|
onAlbumClick,
|
||||||
onArtistClick,
|
onArtistClick,
|
||||||
@@ -296,12 +304,44 @@ export function TrackList({
|
|||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
{track.spotify_id && onCheckAvailability && (
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger asChild>
|
||||||
|
<Button
|
||||||
|
onClick={() => onCheckAvailability(track.spotify_id!, track.isrc)}
|
||||||
|
size="sm"
|
||||||
|
variant="outline"
|
||||||
|
disabled={checkingAvailabilityTrack === track.spotify_id}
|
||||||
|
>
|
||||||
|
{checkingAvailabilityTrack === track.spotify_id ? (
|
||||||
|
<Spinner />
|
||||||
|
) : availabilityMap?.has(track.spotify_id) ? (
|
||||||
|
<CheckCircle className="h-4 w-4 text-green-500" />
|
||||||
|
) : (
|
||||||
|
<Globe className="h-4 w-4" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>
|
||||||
|
{availabilityMap?.has(track.spotify_id) ? (
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<TidalIcon className={`w-4 h-4 ${availabilityMap.get(track.spotify_id)?.tidal ? "text-green-500" : "text-red-500"}`} />
|
||||||
|
<DeezerIcon className={`w-4 h-4 ${availabilityMap.get(track.spotify_id)?.deezer ? "text-green-500" : "text-red-500"}`} />
|
||||||
|
<AmazonIcon className={`w-4 h-4 ${availabilityMap.get(track.spotify_id)?.amazon ? "text-green-500" : "text-red-500"}`} />
|
||||||
|
<QobuzIcon className={`w-4 h-4 ${availabilityMap.get(track.spotify_id)?.qobuz ? "text-green-500" : "text-red-500"}`} />
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<p>Check Availability</p>
|
||||||
|
)}
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
{track.spotify_id && onDownloadLyrics && (
|
{track.spotify_id && onDownloadLyrics && (
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
onDownloadLyrics(track.spotify_id!, track.name, track.artists, track.album_name, folderName, isArtistDiscography)
|
onDownloadLyrics(track.spotify_id!, track.name, track.artists, track.album_name, folderName, isArtistDiscography, startIndex + index + 1)
|
||||||
}
|
}
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
import { useState, useCallback } from "react";
|
||||||
|
import { CheckTrackAvailability } from "../../wailsjs/go/main/App";
|
||||||
|
import type { TrackAvailability } from "@/types/api";
|
||||||
|
import { logger } from "@/lib/logger";
|
||||||
|
|
||||||
|
export function useAvailability() {
|
||||||
|
const [checking, setChecking] = useState(false);
|
||||||
|
const [checkingTrackId, setCheckingTrackId] = useState<string | null>(null);
|
||||||
|
const [availabilityMap, setAvailabilityMap] = useState<Map<string, TrackAvailability>>(new Map());
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const checkAvailability = useCallback(async (spotifyId: string, isrc?: string) => {
|
||||||
|
if (!spotifyId) {
|
||||||
|
setError("No Spotify ID provided");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if already cached
|
||||||
|
if (availabilityMap.has(spotifyId)) {
|
||||||
|
return availabilityMap.get(spotifyId)!;
|
||||||
|
}
|
||||||
|
|
||||||
|
setChecking(true);
|
||||||
|
setCheckingTrackId(spotifyId);
|
||||||
|
setError(null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
logger.info(`Checking availability for track: ${spotifyId}`);
|
||||||
|
const response = await CheckTrackAvailability(spotifyId, isrc || "");
|
||||||
|
const availability: TrackAvailability = JSON.parse(response);
|
||||||
|
|
||||||
|
setAvailabilityMap((prev) => {
|
||||||
|
const newMap = new Map(prev);
|
||||||
|
newMap.set(spotifyId, availability);
|
||||||
|
return newMap;
|
||||||
|
});
|
||||||
|
|
||||||
|
logger.success(`Availability check completed for ${spotifyId}`);
|
||||||
|
return availability;
|
||||||
|
} catch (err) {
|
||||||
|
const errorMessage = err instanceof Error ? err.message : "Failed to check availability";
|
||||||
|
logger.error(`Availability check error: ${errorMessage}`);
|
||||||
|
setError(errorMessage);
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
setChecking(false);
|
||||||
|
setCheckingTrackId(null);
|
||||||
|
}
|
||||||
|
}, [availabilityMap]);
|
||||||
|
|
||||||
|
const getAvailability = useCallback((spotifyId: string) => {
|
||||||
|
return availabilityMap.get(spotifyId);
|
||||||
|
}, [availabilityMap]);
|
||||||
|
|
||||||
|
const clearAvailability = useCallback(() => {
|
||||||
|
setAvailabilityMap(new Map());
|
||||||
|
setError(null);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return {
|
||||||
|
checking,
|
||||||
|
checkingTrackId,
|
||||||
|
availabilityMap,
|
||||||
|
error,
|
||||||
|
checkAvailability,
|
||||||
|
getAvailability,
|
||||||
|
clearAvailability,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -17,7 +17,8 @@ export function useLyrics() {
|
|||||||
artistName: string,
|
artistName: string,
|
||||||
albumName?: string,
|
albumName?: string,
|
||||||
playlistName?: string,
|
playlistName?: string,
|
||||||
isArtistDiscography?: boolean
|
isArtistDiscography?: boolean,
|
||||||
|
position?: number
|
||||||
) => {
|
) => {
|
||||||
if (!spotifyId) {
|
if (!spotifyId) {
|
||||||
toast.error("No Spotify ID found for this track");
|
toast.error("No Spotify ID found for this track");
|
||||||
@@ -55,6 +56,10 @@ export function useLyrics() {
|
|||||||
track_name: trackName,
|
track_name: trackName,
|
||||||
artist_name: artistName,
|
artist_name: artistName,
|
||||||
output_dir: outputDir,
|
output_dir: outputDir,
|
||||||
|
filename_format: settings.filenameFormat,
|
||||||
|
track_number: settings.trackNumber,
|
||||||
|
position: position || 0,
|
||||||
|
use_album_track_number: settings.albumSubfolder,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
|
|||||||
@@ -172,6 +172,10 @@ export interface LyricsDownloadRequest {
|
|||||||
track_name: string;
|
track_name: string;
|
||||||
artist_name: string;
|
artist_name: string;
|
||||||
output_dir?: string;
|
output_dir?: string;
|
||||||
|
filename_format?: string;
|
||||||
|
track_number?: boolean;
|
||||||
|
position?: number;
|
||||||
|
use_album_track_number?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LyricsDownloadResponse {
|
export interface LyricsDownloadResponse {
|
||||||
@@ -182,4 +186,16 @@ export interface LyricsDownloadResponse {
|
|||||||
already_exists?: boolean;
|
already_exists?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TrackAvailability {
|
||||||
|
spotify_id: string;
|
||||||
|
tidal: boolean;
|
||||||
|
deezer: boolean;
|
||||||
|
amazon: boolean;
|
||||||
|
qobuz: boolean;
|
||||||
|
tidal_url?: string;
|
||||||
|
deezer_url?: string;
|
||||||
|
amazon_url?: string;
|
||||||
|
qobuz_url?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,12 @@ func main() {
|
|||||||
},
|
},
|
||||||
BackgroundColour: &options.RGBA{R: 0, G: 0, B: 0, A: 255},
|
BackgroundColour: &options.RGBA{R: 0, G: 0, B: 0, A: 255},
|
||||||
OnStartup: app.startup,
|
OnStartup: app.startup,
|
||||||
|
DragAndDrop: &options.DragAndDrop{
|
||||||
|
EnableFileDrop: true,
|
||||||
|
DisableWebViewDrop: false,
|
||||||
|
CSSDropProperty: "--wails-drop-target",
|
||||||
|
CSSDropValue: "drop",
|
||||||
|
},
|
||||||
Bind: []interface{}{
|
Bind: []interface{}{
|
||||||
app,
|
app,
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
"info": {
|
"info": {
|
||||||
"productName": "SpotiFLAC",
|
"productName": "SpotiFLAC",
|
||||||
"productVersion": "6.3"
|
"productVersion": "6.4"
|
||||||
},
|
},
|
||||||
"wailsjsdir": "./frontend",
|
"wailsjsdir": "./frontend",
|
||||||
"assetdir": "./frontend/dist",
|
"assetdir": "./frontend/dist",
|
||||||
|
|||||||
Reference in New Issue
Block a user