Esempio n. 1
0
        public static IPlaylistFile ToIPlaylistFile(this PlaylistInfoVkModel playlist, IList <IAudioFile> tracks, string artist)
        {
            string cover       = "no";
            string genre       = "";
            string year        = "";
            string description = "";

            try
            {
                cover = playlist.Photo.Photo600.ToString();
            }
            catch { }

            try
            {
                genre = playlist.Genres[0].Name;
            }catch { }

            try
            {
                year = playlist.Year.ToString();
            }catch { }



            IPlaylistFile playlistFile = new PlaylistFileAnyPlatform()
            {
                Artist      = artist,
                Cover       = cover,
                Id          = playlist.Id,
                OwnerId     = playlist.OwnerId,
                IsLocal     = false,
                Tracks      = tracks,
                AccessKey   = playlist.AccessKey,
                Name        = playlist.Title,
                IsAlbum     = true,
                Genre       = genre,
                OnRequest   = true,
                Year        = year,
                Description = description
            };

            return(playlistFile);
        }
Esempio n. 2
0
        public static IPlaylistFile ToIPlaylistFile(this AudioPlaylist playlist, IList <IAudioFile> tracks)
        {
            bool   isAlbum = playlist.Type == 1;
            string cover;
            string artist      = "";
            string genre       = "";
            string year        = "";
            string description = "";

            try
            {
                artist = playlist.MainArtists.First().Name;
            }
            catch
            {
                artist = "Неизвестный исполнитель";
            }
            try
            {
                cover = playlist.Cover.Photo300;
            }
            catch
            {
                cover = "no";
            }

            if (isAlbum)
            {
                try
                {
                    genre = playlist.Genres.First().Name;
                }
                catch
                {
                    genre = "no";
                }

                try
                {
                    year = playlist.Year.Value.ToString();
                }
                catch
                {
                    year = "no";
                }
            }
            else
            {
                if (playlist.Description != null)
                {
                    description = playlist.Description;
                }
                genre = "no";
                year  = "no";
            }


            IPlaylistFile playlistFile = new PlaylistFileAnyPlatform()
            {
                Artist      = artist,
                Cover       = cover,
                Id          = playlist.Id.Value,
                IsLocal     = false,
                Tracks      = tracks,
                Name        = playlist.Title,
                AccessKey   = playlist.AccessKey,
                IsAlbum     = isAlbum,
                OnRequest   = tracks.Count == 0,
                Plays       = playlist.Plays,
                OwnerId     = playlist.OwnerId.Value,
                Genre       = genre,
                Year        = year,
                Description = description
            };

            return(playlistFile);
        }