diff --git a/EspionSpotify/API/SpotifyAPI.cs b/EspionSpotify/API/SpotifyAPI.cs
index f3fbb091..64bed626 100644
--- a/EspionSpotify/API/SpotifyAPI.cs
+++ b/EspionSpotify/API/SpotifyAPI.cs
@@ -1,4 +1,5 @@
using EspionSpotify.Enums;
+using EspionSpotify.Extensions;
using EspionSpotify.Models;
using EspionSpotify.Properties;
using EspionSpotify.Spotify;
@@ -59,7 +60,7 @@ public SpotifyAPI(string clientId, string secretId, string redirectUrl = SPOTIFY
if (_api != null)
{
- var playback = await _api.GetPlaybackAsync();
+ var playback = await _api.GetPlaybackWithoutExceptionAsync();
if (playback != null && !playback.HasError())
{
playing = playback.IsPlaying;
@@ -129,7 +130,7 @@ private async Task UpdateTrack(Track track, bool retry = false)
if (_api == null) return;
- var playback = await _api.GetPlaybackAsync();
+ var playback = await _api.GetPlaybackWithoutExceptionAsync();
var hasNoPlayback = playback == null || playback.Item == null;
if (!retry && hasNoPlayback)
@@ -167,7 +168,7 @@ private async Task UpdateTrack(Track track, bool retry = false)
if (playback.Item.Album?.Id == null) return;
- var album = await _api.GetAlbumAsync(playback.Item.Album.Id);
+ var album = await _api.GetAlbumWithoutExceptionAsync(playback.Item.Album.Id);
if (album.HasError()) return;
diff --git a/EspionSpotify/EspionSpotify.csproj b/EspionSpotify/EspionSpotify.csproj
index daec98a8..36f2140c 100644
--- a/EspionSpotify/EspionSpotify.csproj
+++ b/EspionSpotify/EspionSpotify.csproj
@@ -204,6 +204,7 @@
+
diff --git a/EspionSpotify/Extensions/SpotifyWebAPIExtensions.cs b/EspionSpotify/Extensions/SpotifyWebAPIExtensions.cs
new file mode 100644
index 00000000..09849aae
--- /dev/null
+++ b/EspionSpotify/Extensions/SpotifyWebAPIExtensions.cs
@@ -0,0 +1,35 @@
+using SpotifyAPI.Web;
+using SpotifyAPI.Web.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EspionSpotify.Extensions
+{
+ public static class SpotifyWebAPIExtensions
+ {
+ public static async Task GetPlaybackWithoutExceptionAsync(this SpotifyWebAPI api)
+ {
+ PlaybackContext playback = null;
+ try
+ {
+ playback = await api.GetPlaybackAsync();
+ }
+ catch { }
+ return playback;
+ }
+
+ public static async Task GetAlbumWithoutExceptionAsync(this SpotifyWebAPI api, string id)
+ {
+ FullAlbum album = null;
+ try
+ {
+ album = await api.GetAlbumAsync(id);
+ }
+ catch { }
+ return album;
+ }
+ }
+}