public bool ProcessAlbum(FullAlbum album, bool downloadCover = true) { String[] parseFecha = album.ReleaseDate.Split('-'); string cover = album.Name + "_" + album.Artists[0].Name + ".jpg"; //Remove Windows forbidden characters so we can save the album cover. foreach (char ch in ForbiddenChars) { if (cover.Contains(ch.ToString())) { cover = cover.Replace(ch.ToString(), string.Empty); } } AlbumData a = new AlbumData(album.Name.Replace(";", ""), album.Artists[0].Name.Replace(";", ""), Convert.ToInt16(parseFecha[0]), Environment.CurrentDirectory + "/covers/" + cover); //creamos A if (Kernel.Collection.IsInCollection(a)) { Log.Instance.PrintMessage("Adding duplicate album", MessageType.Warning); Log.Instance.PrintMessage(a.ToString(), MessageType.Info); return(false); } if (downloadCover) { using (System.Net.WebClient webClient = new System.Net.WebClient()) { try { System.IO.Directory.CreateDirectory(Environment.CurrentDirectory + "/covers"); webClient.DownloadFile(new Uri(album.Images[0].Url), Environment.CurrentDirectory + "/covers/" + cover); } catch (System.Net.WebException e) { Log.Instance.PrintMessage("Exception captured System.Net.WebException", MessageType.Warning); MessageBox.Show(Kernel.LocalTexts.GetString("errorPortada"), "", MessageBoxButtons.OK, MessageBoxIcon.Error); cover = ""; } } } else { a.CoverPath = ""; } a.IdSpotify = album.Id; List <Song> songs = new List <Song>(a.NumberOfSongs); List <SimpleTrack> albumSongs = album.Tracks.Items; for (int i = 0; i < albumSongs.Count; i++) { songs.Add(new Song(albumSongs[i].Name.Replace(";", ""), new TimeSpan(0, 0, 0, 0, albumSongs[i].DurationMs), ref a)); if (songs[i].Length.Milliseconds > 500) { songs[i].Length += new TimeSpan(0, 0, 0, 0, 1000 - songs[i].Length.Milliseconds); } else { songs[i].Length -= new TimeSpan(0, 0, 0, 0, songs[i].Length.Milliseconds); } } a.Songs = songs; a.CanBeRemoved = true; Kernel.Collection.AddAlbum(ref a); Kernel.SetSaveMark(); return(true); }