Exemplo n.º 1
0
        internal static IEnumerable<Album> getListOfAlbums(GrooveSharp grooveSharp, string json)
        {
            List<Album> _retVal = new List<Album>();
            var _data = Snippet.ToXElementCollection(json);

            _data.Where(e => e.Name == "albums").Select(e => e).ToList().ForEach(e =>
                {
                    Artist _artist = new Artist()
                    {
                        ID = Convert.ToInt32(e.Elements().Where(i => i.Name == "ArtistID").First().Value),
                        Name = e.Elements().Where(i => i.Name == "ArtistName").First().Value
                    };

                    Album _album = new Album()
                    {
                        ID = Convert.ToInt32(e.Elements().Where(i => i.Name == "AlbumID").First().Value),
                        Name = e.Elements().Where(i => i.Name == "AlbumName").First().Value,
                        CoverArtFileName = e.Elements().Where(i => i.Name == "CoverArtFilename").First().Value,
                        IsVerified = Convert.ToBoolean(e.Elements().Where(i => i.Name == "IsVerified").First().Value),
                        Artist = _artist,
                        grooveSharp = grooveSharp
                    };

                    _retVal.Add(_album);
                });

            return _retVal;
        }
Exemplo n.º 2
0
        internal static List<Artist> parseToList(GrooveSharp grooveSharp, string jsonData)
        {
            List<Artist> _artists = new List<Artist>();
            var _data = Snippet.ToXElementCollection(jsonData);

            _data.Where(e => e.Name == "artists").Select(e => e).ToList().ForEach(e =>
            {
                Artist _artist = new Artist()
                {
                    ID = Convert.ToInt32(e.Elements().Where(i => i.Name == "ArtistID").First().Value),
                    Name = e.Elements().Where(i => i.Name == "ArtistName").First().Value,
                    IsVerified = Convert.ToBoolean(e.Elements().Where(i => i.Name == "IsVerified").First().Value)
                };

                _artists.Add(_artist);
            });

            return _artists;
        }
Exemplo n.º 3
0
        internal static SubStream parse(string data, GrooveSharp grooveSharp)
        {
            IEnumerable<XElement> _elems = Snippet.ToXElementCollection(data);

            SubStream _stream = new SubStream()
            {
                Key = _elems.Where(e => e.Name == "StreamKey").First().Value,
                Url = new Uri(_elems.Where(e => e.Name == "url").First().Value),
                Time = TimeSpan.FromTicks(Convert.ToInt64(_elems.Where(e => e.Name == "uSecs").First().Value + "0")),
                ServerID = Convert.ToInt32(_elems.Where(e => e.Name == "StreamServerID").First().Value)
            };

            _stream.grooveSharp = grooveSharp;

            if (_stream.Url == null)
                return null;

            return _stream;
        }
Exemplo n.º 4
0
        internal static List<Playlist> parseToList(GrooveSharp grooveSharp, string jsonData)
        {
            List<Playlist> _playlist = new List<Playlist>();
            var _data = Snippet.ToXElementCollection(jsonData);

            _data.Where(e => e.Name == "playlists").Select(e => e).ToList().ForEach(e =>
                {
                    User _user = new User();

                    try
                    {
                        _user.ID = Convert.ToInt32(e.Elements().Where(i => i.Name == "UserID").First().Value);
                        _user.FirstName = e.Elements().Where(i => i.Name == "FName").First().Value;
                        _user.LastName = e.Elements().Where(i => i.Name == "LName").First().Value;
                    }
                    catch { }

                    DateTime _dateTime = DateTime.Now;

                    try
                    {
                        _dateTime = DateTime.Parse(e.Elements().Where(i => i.Name == "TSAdded").First().Value);
                    }
                    catch { }

                    Playlist _p = new Playlist()
                    {
                        ID = Convert.ToInt32(e.Elements().Where(i => i.Name == "PlaylistID").First().Value),
                        Name = e.Elements().Where(i => i.Name == "PlaylistName").First().Value,
                        Added = _dateTime,
                        User = _user,
                        grooveSharp = grooveSharp
                    };

                    _playlist.Add(_p);
                });

            return _playlist;
        }
Exemplo n.º 5
0
        internal static IEnumerable<Song> parseToList(GrooveSharp grooveSharp, string json)
        {
            List<Song> _retVal = new List<Song>();
            var _el = Snippet.ToXElementCollection(json);

            _el.Where(e => e.Name == "songs").ToList().ForEach(e =>
            {
                var _inner = e.Elements();
                Artist _artist = new Artist()
                {
                    ID = Convert.ToInt32(_inner.Where(i => i.Name == "ArtistID").First().Value),
                    Name = _inner.Where(i => i.Name == "ArtistName").First().Value
                };

                Album _album = new Album()
                {
                    ID = Convert.ToInt32(_inner.Where(i => i.Name == "AlbumID").First().Value),
                    Name = _inner.Where(i => i.Name == "AlbumName").First().Value,
                    CoverArtFileName = _inner.Where(i => i.Name == "CoverArtFilename").First().Value,
                    Artist = _artist
                };

                var _ver = _inner.Where(i => i.Name == "IsVerified").First().Value;
                var _lowB = _inner.Where(i => i.Name == "IsLowBitrateAvailable").First().Value;

                if (_ver == "1")
                    _ver = "True";
                else if (_ver == "0")
                    _ver = "False";

                if (_lowB == "1")
                    _lowB = "True";
                else if (_lowB == "0")
                    _lowB = "False";

                bool _isVerified = Convert.ToBoolean(_ver);
                bool _isLowBitRate = Convert.ToBoolean(_lowB);

                Song _song = new Song()
                {
                    Album = _album,
                    ID = Convert.ToInt32(_inner.Where(i => i.Name == "SongID").First().Value),
                    Title = _inner.Where(i => i.Name == "SongName").First().Value,
                    Artist = _artist,
                    Popularity = Convert.ToInt64(_inner.Where(i => i.Name == "Popularity").First().Value),
                    IsLowBitrateAvailable = _isLowBitRate,
                    IsVerified = _isVerified,
                    Flags = Convert.ToInt32(_inner.Where(i => i.Name == "Flags").First().Value)
                };

                _song.grooveSharp = grooveSharp;

                _retVal.Add(_song);
            });

            return _retVal.AsEnumerable();
        }
Exemplo n.º 6
0
        internal static User Parse(GrooveSharp grooveSharp, string jsonData)
        {
            var _el = Snippet.ToXElementCollection(jsonData);

            string _email = (_el.Where(e => e.Name == "Email").FirstOrDefault() == null) ?
                "" : _el.Where(e => e.Name == "Email").FirstOrDefault().Value;

            User _user = new User()
            {
                ID = Convert.ToInt32(_el.Where(e => e.Name == "UserID").First().Value),
                LastName = _el.Where(e => e.Name == "LName").First().Value,
                FirstName = _el.Where(e => e.Name == "FName").First().Value,
                IsPlus = Convert.ToBoolean(_el.Where(e => e.Name == "IsPlus").First().Value),
                IsPremium = Convert.ToBoolean(_el.Where(e => e.Name == "IsPremium").First().Value),
                IsAnywhere = Convert.ToBoolean(_el.Where(e => e.Name == "IsAnywhere").First().Value),
                Email = _email
            };

            _user.grooveSharp = grooveSharp;

            return _user;
        }
Exemplo n.º 7
0
        public static IGrooveSharp Init(string key, string secret)
        {
            GrooveSharp _gSharp = new GrooveSharp(key, secret);
            _gSharp.isHTTPS = true;

            return _gSharp;
        }