read nomianted maps
This commit is contained in:
parent
b929741599
commit
540505e4bd
3 changed files with 48 additions and 1 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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"`
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue