コード例 #1
0
        public YRequest Create()
        {
            var query = new Dictionary <string, string> {
                { "lang", storage.User.Lang },
                { "external-domain", "music.yandex.ru" },
                { "overembed", "no" },
                { "ncrnd", "0.1822837925478349" }
            };

            var headers = new List <KeyValuePair <string, string> > {
                YRequestHeaders.Get(YHeader.Accept, storage),
                YRequestHeaders.Get(YHeader.AcceptEncoding, storage),
                YRequestHeaders.Get(YHeader.AcceptLanguage, storage),
                YRequestHeaders.Get(YHeader.AccessControlAllowMethods, storage),
                YRequestHeaders.Get(YHeader.Origin, storage),
                YRequestHeaders.Get(YHeader.Referer, storage),
                YRequestHeaders.Get(YHeader.SecFetchMode, storage),
                YRequestHeaders.Get(YHeader.SecFetchSite, storage),
                YRequestHeaders.Get(YHeader.XCurrentUID, storage),
                YRequestHeaders.Get(YHeader.XRequestedWith, storage),
                YRequestHeaders.Get(YHeader.XRetpathY, storage)
            };

            FormRequest(YEndpoints.Auth, query: query, headers: headers);

            return(this);
        }
コード例 #2
0
        public YRequest Create(YStationDescription station, YStationSettings2 settings2)
        {
            var headers = new List <KeyValuePair <string, string> > {
                YRequestHeaders.Get(YHeader.ContentType, storage)
            };

            string body = JsonConvert.SerializeObject(settings2, settings);

            FormRequest($"{YEndpoints.API}/rotor/station/{station.Id.Type}:{station.Id.Tag}/settings2", WebRequestMethods.Http.Post,
                        headers: headers, body: body);

            return(this);
        }
コード例 #3
0
        public YRequest Create(string kinds, string name)
        {
            Dictionary <string, string> query = new Dictionary <string, string> {
                { "value", name },
            };

            var headers = new List <KeyValuePair <string, string> > {
                YRequestHeaders.Get(YHeader.ContentType, "application/x-www-form-urlencoded")
            };

            FormRequest($"{YEndpoints.API}/users/{storage.User.Uid}/playlists/{kinds}/name", body: GetQueryString(query), headers: headers, method: WebRequestMethods.Http.Post);

            return(this);
        }
コード例 #4
0
        public YRequest Create(string id, YLibrarySection section, YLibrarySectionType type = YLibrarySectionType.Likes)
        {
            Dictionary <string, string> body = new Dictionary <string, string> {
                { $"{section.ToString().ToLower().TrimEnd('s')}-ids", id }
            };

            List <KeyValuePair <string, string> > headers = new List <KeyValuePair <string, string> > {
                YRequestHeaders.Get(YHeader.ContentType, "application/x-www-form-urlencoded")
            };

            FormRequest($"{YEndpoints.API}/users/{storage.User.Uid}/{type.ToString().ToLower()}/{section.ToString().ToLower()}/remove",
                        WebRequestMethods.Http.Post, body: GetQueryString(body), headers: headers);

            return(this);
        }
コード例 #5
0
        public YRequest Create(YPlaylist playlist, List <YPlaylistChange> changes)
        {
            Dictionary <string, string> query = new Dictionary <string, string> {
                { "kind", playlist.Kind },
                { "revision", playlist.Revision.ToString() },
                { "diff", JsonConvert.SerializeObject(changes, settings) }
            };

            var headers = new List <KeyValuePair <string, string> > {
                YRequestHeaders.Get(YHeader.ContentType, "application/x-www-form-urlencoded")
            };

            FormRequest($"{YEndpoints.API}/users/{storage.User.Uid}/playlists/{playlist.Kind}/change",
                        body: GetQueryString(query), headers: headers, method: WebRequestMethods.Http.Post);

            return(this);
        }
コード例 #6
0
        public YRequest Create(string login, string password)
        {
            var headers = new List <KeyValuePair <string, string> > {
                YRequestHeaders.Get(YHeader.ContentType, "application/x-www-form-urlencoded")
            };

            var body = new Dictionary <string, string> {
                { "grant_type", "password" },
                { "client_id", CLIENT_ID },
                { "client_secret", CLIENT_SECRET },
                { "username", login },
                { "password", password },
            };

            FormRequest($"{YEndpoints.OAuth}/token", WebRequestMethods.Http.Post, headers: headers, body: GetQueryString(body));

            return(this);
        }