public bool Unstar(IEnumerable <int> ids)
        {
            RestCommand command = new RestCommand();

            command.MethodName = "unstar";
            foreach (int id in ids)
            {
                command.AddParameter("id", id);
            }
            return(Client.GetResponseXDocument(command).Root.Attribute("status").Value == "ok");
        }
Example #2
0
        public bool UpdatePlaylist(int playlistId, string name    = null, string comment = null, bool?isPublic = null,
                                   IEnumerable <int> songIdsToAdd = null, IEnumerable <int> songIdsToRemove = null)
        {
            RestCommand command = new RestCommand();

            command.MethodName = "updatePlaylist";
            command.AddParameter("playlistId", playlistId);
            if (!string.IsNullOrEmpty(name))
            {
                command.AddParameter("name", name);
            }
            if (!string.IsNullOrEmpty(comment))
            {
                command.AddParameter("comment", comment);
            }
            if (isPublic.HasValue)
            {
                command.AddParameter("public", isPublic.Value.ToString().ToLower());
            }
            if (songIdsToAdd != null)
            {
                foreach (int song in songIdsToAdd)
                {
                    command.AddParameter("songIdToAdd", song);
                }
            }
            if (songIdsToRemove != null)
            {
                foreach (int song in songIdsToRemove)
                {
                    command.AddParameter("songIdToRemove", song);
                }
            }
            return(Client.GetResponseXDocument(command).Root.Attribute("status").Value == "ok");
        }
Example #3
0
        public string Hls(int id, int bitRate = -1, int height = -1, int width = -1, int audioTrack = -1)
        {
            RestCommand command = new RestCommand();

            command.MethodName = "hls";
            command.AddParameter("id", id);
            if (bitRate != -1)
            {
                if (height != -1 && width != -1)
                {
                    command.AddParameter("bitRate", $"{bitRate}@{width}x{height}");
                }
                else
                {
                    command.AddParameter("bitRate", bitRate);
                }
            }
            if (audioTrack != -1)
            {
                command.AddParameter("audioTrack", audioTrack);
            }
            return(Client.FormatCommand(command));
        }
Example #4
0
        public Dictionary <string, IEnumerable <Artist> > GetArtists(int musicFolderId = -1)
        {
            RestCommand command = new RestCommand
            {
                MethodName = "getArtists"
            };

            if (musicFolderId != -1)
            {
                command.AddParameter("musicFolderId", musicFolderId);
            }
            XDocument document = Client.GetResponseXDocument(command);

            return(GetArtists(document));
        }
Example #5
0
        public Task <byte[]> GetAvatarAsync(string username)
        {
            RestCommand command = new RestCommand();

            command.MethodName = "getAvatar";
            command.AddParameter("username", username);
            return(Task <byte[]> .Factory.StartNew(() =>
            {
                using (HttpClient http = new HttpClient())
                {
                    http.Timeout = TimeSpan.FromDays(1);
                    return http.GetByteArrayAsync(Client.FormatCommand(command)).Result;
                }
            }));
        }