read nomianted maps

This commit is contained in:
Michael Zhang 2020-10-15 12:37:21 -05:00
parent b929741599
commit 540505e4bd
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
3 changed files with 48 additions and 1 deletions

View file

@ -68,3 +68,28 @@ func (api *Osuapi) BeatmapsetDownload(beatmapSetId int) (path string, err error)
path = file.Name()
return
}
type GetBeatmapsetEventsOptions struct {
User string
Types []string
}
func (api *Osuapi) GetBeatmapsetEvents(opts *GetBeatmapsetEventsOptions) (events []BeatmapsetEvent, err error) {
values := url.Values{}
values.Set("user", opts.User)
query := values.Encode()
for _, t := range opts.Types {
query += "&types[]=" + t
}
url := "/beatmapsets/events?" + query
fmt.Println("URL IS", url)
var reply BeatmapsetEvents
err = api.Request("GET", url, &reply)
if err != nil {
return
}
events = reply.Events
return
}

View file

@ -63,3 +63,14 @@ type EventUser struct {
type BeatmapSearch struct {
Beatmapsets []Beatmapset `json:"beatmapsets"`
}
type BeatmapsetEvents struct {
Events []BeatmapsetEvent `json:"events"`
}
type BeatmapsetEvent struct {
ID int `json:"id"`
Type string `json:"type"`
Beatmapset Beatmapset `json:"beatmapset"`
UserID int `json:"user_id"`
}

View file

@ -1,5 +1,16 @@
package scrape
func (s *Scraper) scrapeNominatedMaps() {
import (
"fmt"
"subscribe-bot/osuapi"
)
func (s *Scraper) scrapeNominatedMaps() {
events, _ := s.api.GetBeatmapsetEvents(&osuapi.GetBeatmapsetEventsOptions{
Types: []string{"nominate", "qualify"},
})
for _, event := range events {
fmt.Println(event)
}
}