Skip to content

Commit e370039

Browse files
erinxoconJohnnyCrazy
authored andcommitted
GetAlbumArtUrl() fix
Fixed GetAlbumArtUrl
1 parent ca4bd1e commit e370039

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

SpotifyAPI/Local/Models/Track.cs

100644100755
+10-2
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,20 @@ public string GetAlbumArtUrl(AlbumArtSize size)
7070
raw = wc.DownloadString("http://open.spotify.com/album/" + AlbumResource.Uri.Split(new[] { ":" }, StringSplitOptions.None)[2]);
7171
}
7272
raw = raw.Replace("\t", "");
73+
74+
// < meta property = "og:image" content = "http://o.scdn.co/cover/12b318ffe0e4c92f9b4e1486e4726a57e6437ca7" >
75+
// Spotify changed the response so I am now getting the substring from the first line that parses out the above tag.
7376
string[] lines = raw.Split(new[] { "\n" }, StringSplitOptions.None);
77+
string startString = "<meta property=\"og:image\"";
78+
string endString = "\">";
7479
foreach (string line in lines)
7580
{
76-
if (line.Trim().StartsWith("<meta property=\"og:image\""))
81+
if (line.Trim().Contains("<meta property=\"og:image\""))
7782
{
78-
string[] l = line.Split(new[] { "/" }, StringSplitOptions.None);
83+
int start = line.IndexOf(startString, 0) + startString.Length;
84+
int end = line.IndexOf(endString, start);
85+
string content = line.Substring(start, end - start);
86+
string[] l = content.Split(new[] { "/" }, StringSplitOptions.None);
7987
return "http://o.scdn.co/" + albumsize + @"/" + l[4].Replace("\"", "").Replace(">", "");
8088
}
8189
}

0 commit comments

Comments
 (0)