Documentation ¶
Overview ¶
Package modpacksch implements an API client for downloading modpacks from https://api.modpacks.ch/.
API documentation: https://modpacksch.docs.apiary.io/
Index ¶
- Constants
- Variables
- type CurseForgeFile
- type CurseForgeModpackClient
- type ModpackArt
- type ModpackAuthor
- type ModpackClient
- type ModpackLink
- type ModpackManifest
- type ModpackRating
- type ModpackTag
- type ModpackVersion
- type ModpackVersionFile
- type ModpackVersionManifest
- type ModpackVersionSpecs
- type ModpackVersionTarget
- type PublicModpackClient
- type ResourceBase
- type Time
Constants ¶
const ( // APIBaseURL is the base URL of the API. APIBaseURL = "https://api.modpacks.ch" // APIPublicModpack is the path of the public modpack endpoint. APIPublicModpack = "/public/modpack" // APIPublicCurseForge is the path of the public CurseForge endpoint. APIPublicCurseForge = "/public/curseforge" // APIUserAgent is the user agent used for API requests. // The FTB folks don't like seeing people download their stuff from unofficial clients, // so we pretend to be https://github.com/CreeperHost/modpacksch-serverdownloader. APIUserAgent = "modpackserverdownloader/1.0" )
Variables ¶
var ( ErrPathSanitization = errors.New("path rejected by sanitization") ErrMissingURL = errors.New("missing URL") )
var ( // DefaultPublicModpackClient is the default public modpack client. DefaultPublicModpackClient = NewPublicModpackClient(http.DefaultClient) // DefaultCurseForgeModpackClient is the default CurseForge modpack client. DefaultCurseForgeModpackClient = NewCurseForgeModpackClient(http.DefaultClient) )
Functions ¶
This section is empty.
Types ¶
type CurseForgeFile ¶ added in v1.1.0
CurseForgeFile is a file under a CurseForge project.
func (*CurseForgeFile) DownloadURL ¶ added in v1.1.0
func (f *CurseForgeFile) DownloadURL(name string) string
DownloadURL returns the download URL of the file.
type CurseForgeModpackClient ¶ added in v1.1.0
type CurseForgeModpackClient struct {
// contains filtered or unexported fields
}
CurseForgeModpackClient is a modpack client for the modpacks.ch CurseForge modpack API.
CurseForgeModpackClient implements ModpackClient.
func NewCurseForgeModpackClient ¶ added in v1.1.0
func NewCurseForgeModpackClient(client *http.Client) *CurseForgeModpackClient
NewCurseForgeModpackClient creates a new CurseForgeModpackClient.
func (*CurseForgeModpackClient) GetModpackManifest ¶ added in v1.1.0
func (c *CurseForgeModpackClient) GetModpackManifest(ctx context.Context, modpackID int64) (ModpackManifest, error)
GetModpackManifest gets the manifest of a CurseForge modpack with the given ID.
GetModpackManifest implements [ModpackClient.GetModpackManifest].
func (*CurseForgeModpackClient) GetModpackVersionManifest ¶ added in v1.1.0
func (c *CurseForgeModpackClient) GetModpackVersionManifest(ctx context.Context, modpackID, versionID int64) (ModpackVersionManifest, error)
GetModpackVersionManifest gets the manifest of a CurseForge modpack version with the given modpack ID and version ID.
GetModpackVersionManifest implements [ModpackClient.GetModpackVersionManifest].
type ModpackArt ¶
type ModpackArt struct { Width int `json:"width"` Height int `json:"height"` Compressed bool `json:"compressed"` URL string `json:"url"` Mirrors []string `json:"mirrors"` SHA1 string `json:"sha1"` Size int64 `json:"size"` ID int64 `json:"id"` Type string `json:"type"` Updated Time `json:"updated"` }
ModpackArt is an image of a modpack.
type ModpackAuthor ¶
type ModpackAuthor struct { Website string `json:"website"` ResourceBase }
ModpackAuthor is a modpack's author.
type ModpackClient ¶
type ModpackClient interface { // GetModpackManifest gets the manifest of a modpack with the given ID. GetModpackManifest(ctx context.Context, modpackID int64) (ModpackManifest, error) // GetModpackVersionManifest gets the manifest of a modpack version with the given modpack ID and version ID. GetModpackVersionManifest(ctx context.Context, modpackID, versionID int64) (ModpackVersionManifest, error) }
ModpackClient is a modpack client for the modpacks.ch API.
type ModpackLink ¶
type ModpackLink struct { ID int64 `json:"id"` Name string `json:"name"` Link string `json:"link"` Type string `json:"type"` }
ModpackLink is a modpack's miscellaneous link.
type ModpackManifest ¶
type ModpackManifest struct { Synopsis string `json:"synopsis"` Description string `json:"description"` Art []ModpackArt `json:"art"` Links []ModpackLink `json:"links"` Authors []ModpackAuthor `json:"authors"` Versions []ModpackVersion `json:"versions"` Installs int64 `json:"installs"` Plays int64 `json:"plays"` Tags []ModpackTag `json:"tags"` Featured bool `json:"featured"` Refreshed Time `json:"refreshed"` Notification string `json:"notification"` Rating ModpackRating `json:"rating"` Status string `json:"status"` Released Time `json:"released"` Provider string `json:"provider"` Plays14D int64 `json:"plays_14d"` ResourceBase Private bool `json:"private"` }
ModpackManifest is the manifest of a modpack. This is the response of GET /public/modpack/{modpack_id}.
func GetCurseForgeModpackManifest ¶ added in v1.1.0
func GetCurseForgeModpackManifest(ctx context.Context, modpackID int64) (ModpackManifest, error)
GetCurseForgeModpackManifest gets the manifest of a CurseForge modpack with the given ID.
func GetPublicModpackManifest ¶
func GetPublicModpackManifest(ctx context.Context, modpackID int64) (ModpackManifest, error)
GetPublicModpackManifest gets the manifest of a public modpack with the given ID.
func (*ModpackManifest) LatestVersion ¶
func (m *ModpackManifest) LatestVersion() (ModpackVersion, bool)
LatestVersion returns the latest version of a modpack.
type ModpackRating ¶
type ModpackRating struct { ID int64 `json:"id"` Configured bool `json:"configured"` Verified bool `json:"verified"` Age int `json:"age"` Gambling bool `json:"gambling"` Frightening bool `json:"frightening"` Alcoholdrugs bool `json:"alcoholdrugs"` Nuditysexual bool `json:"nuditysexual"` Sterotypeshate bool `json:"sterotypeshate"` Language bool `json:"language"` Violence bool `json:"violence"` }
ModpackRating is a modpack's rating.
type ModpackTag ¶
ModpackTag is a modpack's tag.
type ModpackVersion ¶
type ModpackVersion struct { Specs ModpackVersionSpecs `json:"specs"` Targets []ModpackVersionTarget `json:"targets"` ResourceBase Private bool `json:"private"` }
ModpackVersion is a modpack's version.
type ModpackVersionFile ¶
type ModpackVersionFile struct { Path string `json:"path"` URL string `json:"url"` Mirrors []string `json:"mirrors"` SHA1 string `json:"sha1"` Size int64 `json:"size"` ClientOnly bool `json:"clientonly"` ServerOnly bool `json:"serveronly"` Optional bool `json:"optional"` ResourceBase CurseForge *CurseForgeFile `json:"curseforge,omitempty"` }
ModpackVersionFile is a file in a modpack version's file list.
func (*ModpackVersionFile) PrecheckJob ¶
func (f *ModpackVersionFile) PrecheckJob( migrateFromPath, clientPath, serverPath string, preserveMigrationSource bool, ) (precheck.Job, bool, error)
PrecheckJob returns a precheck job for the file.
type ModpackVersionManifest ¶
type ModpackVersionManifest struct { Files []ModpackVersionFile `json:"files"` Specs ModpackVersionSpecs `json:"specs"` Targets []ModpackVersionTarget `json:"targets"` Installs int64 `json:"installs"` Plays int64 `json:"plays"` Refreshed Time `json:"refreshed"` Changelog string `json:"changelog"` Parent int64 `json:"parent"` Notification string `json:"notification"` Status string `json:"status"` ResourceBase Private bool `json:"private"` }
ModpackVersionManifest is the manifest of a modpack version. This is the response of GET /public/modpack/{modpack_id}/{version_id}.
func GetCurseForgeModpackVersionManifest ¶ added in v1.1.0
func GetCurseForgeModpackVersionManifest(ctx context.Context, modpackID, versionID int64) (ModpackVersionManifest, error)
GetCurseForgeModpackVersionManifest gets the manifest of a CurseForge modpack version with the given modpack ID and version ID.
func GetPublicModpackVersionManifest ¶
func GetPublicModpackVersionManifest(ctx context.Context, modpackID, versionID int64) (ModpackVersionManifest, error)
GetPublicModpackVersionManifest gets the manifest of a public modpack version with the given modpack ID and version ID.
type ModpackVersionSpecs ¶
type ModpackVersionSpecs struct { ID int64 `json:"id"` Minimum int `json:"minimum"` Recommended int `json:"recommended"` }
ModpackVersionSpecs is a modpack's version specifications.
type ModpackVersionTarget ¶
type ModpackVersionTarget struct { Version string `json:"version"` ResourceBase }
ModpackVersionTarget is a modpack's version target.
type PublicModpackClient ¶ added in v1.1.0
type PublicModpackClient struct {
// contains filtered or unexported fields
}
PublicModpackClient is a modpack client for the modpacks.ch public modpack API.
PublicModpackClient implements ModpackClient.
func NewPublicModpackClient ¶ added in v1.1.0
func NewPublicModpackClient(client *http.Client) *PublicModpackClient
NewPublicModpackClient creates a new PublicModpackClient.
func (*PublicModpackClient) GetModpackManifest ¶ added in v1.1.0
func (c *PublicModpackClient) GetModpackManifest(ctx context.Context, modpackID int64) (ModpackManifest, error)
GetModpackManifest gets the manifest of a public modpack with the given ID.
GetModpackManifest implements [ModpackClient.GetModpackManifest].
func (*PublicModpackClient) GetModpackVersionManifest ¶ added in v1.1.0
func (c *PublicModpackClient) GetModpackVersionManifest(ctx context.Context, modpackID, versionID int64) (ModpackVersionManifest, error)
GetModpackVersionManifest gets the manifest of a public modpack version with the given modpack ID and version ID.
GetModpackVersionManifest implements [ModpackClient.GetModpackVersionManifest].
type ResourceBase ¶
type ResourceBase struct { ID int64 `json:"id"` Name string `json:"name"` Type string `json:"type"` Updated Time `json:"updated"` }
ResourceBase contains basic information about a remote resource.
type Time ¶
Time marshals into and unmarshals from a Unix timestamp in seconds.
func (Time) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.