From 1be543b00a73f2c23ad040827ee29d570c432199 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Thu, 3 Apr 2014 20:44:36 +0200 Subject: [PATCH] Only cache available Spotify tracks --- src/spotify.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/spotify.c b/src/spotify.c index 4c25861b..2770efbc 100644 --- a/src/spotify.c +++ b/src/spotify.c @@ -195,6 +195,7 @@ typedef int (*fptr_sp_track_duration_t)(sp_track *track); typedef int (*fptr_sp_track_index_t)(sp_track *track); typedef int (*fptr_sp_track_disc_t)(sp_track *track); typedef sp_album* (*fptr_sp_track_album_t)(sp_track *track); +typedef sp_track_availability (*fptr_sp_track_get_availability_t)(sp_session *session, sp_track *track); typedef sp_link* (*fptr_sp_link_create_from_playlist_t)(sp_playlist *playlist); typedef sp_link* (*fptr_sp_link_create_from_track_t)(sp_track *track, int offset); @@ -245,6 +246,7 @@ fptr_sp_track_duration_t fptr_sp_track_duration; fptr_sp_track_index_t fptr_sp_track_index; fptr_sp_track_disc_t fptr_sp_track_disc; fptr_sp_track_album_t fptr_sp_track_album; +fptr_sp_track_get_availability_t fptr_sp_track_get_availability; fptr_sp_link_create_from_playlist_t fptr_sp_link_create_from_playlist; fptr_sp_link_create_from_track_t fptr_sp_link_create_from_track; @@ -301,6 +303,7 @@ fptr_assign_all() && (fptr_sp_track_index = dlsym(h, "sp_track_index")) && (fptr_sp_track_disc = dlsym(h, "sp_track_disc")) && (fptr_sp_track_album = dlsym(h, "sp_track_album")) + && (fptr_sp_track_get_availability = dlsym(h, "sp_track_get_availability")) && (fptr_sp_link_create_from_playlist = dlsym(h, "sp_link_create_from_playlist")) && (fptr_sp_link_create_from_track = dlsym(h, "sp_link_create_from_track")) && (fptr_sp_link_create_from_string = dlsym(h, "sp_link_create_from_string")) @@ -464,6 +467,12 @@ spotify_track_save(int plid, sp_track *track) return 0; } + if (fptr_sp_track_get_availability(g_sess, track) != SP_TRACK_AVAILABILITY_AVAILABLE) + { + DPRINTF(E_INFO, L_SPOTIFY, "Track not available for playback\n"); + return 0; + } + link = fptr_sp_link_create_from_track(track, 0); if (!link) {