• Removes a track from the user's Spotify library

    Parameters

    • trackId: string

      Spotify track ID to remove

    • silent: boolean = false

      Whether to suppress error logs

    Returns Promise<boolean>

    Promise resolving to true if successful

    export async function unlikeTrack(
    trackId: string,
    silent: boolean = false,
    ): Promise<boolean> {
    await ensureValidToken();

    try {
    await retryApiCall(async () => {
    await spotifyAxios.delete(`${API_BASE_URL}/me/tracks?ids=${trackId}`, {
    headers: {
    Authorization: `Bearer ${getAccessToken()}`,
    },
    });
    });

    if (!silent) {
    saveLog(`Track ${trackId} removed from library`, "INFO");
    }
    return true;
    } catch (error: unknown) {
    const err = error as Error & AxiosErrorResponse;
    if (!silent) {
    saveLog(`Failed to remove track from library: ${err.message}`, "ERROR");
    }
    return false;
    }
    }