mirror of
https://github.com/packwiz/packwiz.git
synced 2025-05-01 18:26:31 +02:00
Filter curseforge slug -> ID conversion for only mods
This commit is contained in:
parent
920f95ed53
commit
8325f07f18
@ -27,6 +27,9 @@ type addonSlugResponse struct {
|
|||||||
Data struct {
|
Data struct {
|
||||||
Addons []struct {
|
Addons []struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
|
CategorySection struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
} `json:"categorySection"`
|
||||||
} `json:"addons"`
|
} `json:"addons"`
|
||||||
} `json:"data"`
|
} `json:"data"`
|
||||||
Exception string `json:"exception"`
|
Exception string `json:"exception"`
|
||||||
@ -42,6 +45,9 @@ func modIDFromSlug(slug string) (int, error) {
|
|||||||
query getIDFromSlug($slug: String) {
|
query getIDFromSlug($slug: String) {
|
||||||
addons(slug: $slug) {
|
addons(slug: $slug) {
|
||||||
id
|
id
|
||||||
|
categorySection {
|
||||||
|
id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
@ -82,11 +88,13 @@ func modIDFromSlug(slug string) (int, error) {
|
|||||||
return 0, fmt.Errorf("error requesting id for slug: %s", response.Message)
|
return 0, fmt.Errorf("error requesting id for slug: %s", response.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(response.Data.Addons) < 1 {
|
for _, addonData := range response.Data.Addons {
|
||||||
return 0, errors.New("addon not found")
|
// Only use mods, not resource packs/modpacks
|
||||||
|
if addonData.CategorySection.ID == 8 {
|
||||||
|
return addonData.ID, nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return response.Data.Addons[0].ID, nil
|
return 0, errors.New("addon not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
//noinspection GoUnusedConst
|
//noinspection GoUnusedConst
|
||||||
|
Loading…
x
Reference in New Issue
Block a user