cav2

package module
v0.0.0-...-eb5632f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2021 License: MIT Imports: 10 Imported by: 1 module, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

CAV2

Curse Api Version 2 - in go Fork-mirror from Modmuss50/cav2 Extended and cleaned by me (Mini) Use the Twitch OAuth Generator to get your oauth token

Documentation

Index

Constants

View Source
const (
	//APIEndpoint URL of API
	APIEndpoint = "https://addons-ecs.forgesvc.net/api/v2/"
)

Variables

View Source
var (
	//OAuthToken - Twitch oauth's token
	OAuthToken string
	//WriteSession - Unknown
	WriteSession = false
)
View Source
var (
	//EMPTY Empty req data
	EMPTY []byte
)

Functions

func DoHTTPRequest

func DoHTTPRequest(url string) (*http.Response, error)

DoHTTPRequest does a basic http request

func GetAddonDatabaseTimestamp

func GetAddonDatabaseTimestamp() (string, error)

GetAddonDatabaseTimestamp Gets last update of addon DB

func GetAuthenticatedReponse

func GetAuthenticatedReponse(method, token, url string, b []byte) (*http.Response, error)

GetAuthenticatedReponse wraps an http client with an authenication token

func GetByteArrayHash

func GetByteArrayHash(bytes []byte) int

GetByteArrayHash Computes a murmur2 byte array hash

func GetFileHash

func GetFileHash(file string) (int, error)

GetFileHash Computes a murmur2 hash of a file

func GetHTTPResponse

func GetHTTPResponse(method, url string, b []byte) (*http.Response, error)

GetHTTPResponse gets response from URL (Wraps GetAuthenicatedResponse)

func ReadTokenFromDisk

func ReadTokenFromDisk()

ReadTokenFromDisk Reads the auth token from a file

func ResponseToBytes

func ResponseToBytes(response *http.Response) []byte

ResponseToBytes Converts an http.Response to bytes

func ResponseToString

func ResponseToString(response *http.Response) string

ResponseToString Converts an http.Response to a string

func SetOAuth

func SetOAuth(token string)

SetOAuth Takes in a twitch oauth code generated with OAuth.html

func WriteBytesToFile

func WriteBytesToFile(data []byte, file string) error

WriteBytesToFile Generic Write file bytes

Types

type Addon

type Addon struct {
	Attachments              []AddonAttachments   `json:"attachments"`
	Authors                  []AddonAuthors       `json:"authors"`
	AvatarURL                interface{}          `json:"avatarUrl"`
	Categories               []AddonCategories    `json:"categories"`
	CategoryList             string               `json:"categoryList"`
	CategorySection          AddonCategorySection `json:"categorySection"`
	ClientURL                string               `json:"clientUrl"`
	CommentCount             int                  `json:"commentCount"`
	DateCreated              string               `json:"dateCreated"`
	DateModified             string               `json:"dateModified"`
	DateReleased             string               `json:"dateReleased"`
	DefaultFileID            int                  `json:"defaultFileId"`
	DonationURL              interface{}          `json:"donationUrl"`
	DownloadCount            float64              `json:"downloadCount"`
	ExternalURL              interface{}          `json:"externalUrl"`
	FullDescription          string               `json:"fullDescription"`
	GameID                   int                  `json:"gameId"`
	GameName                 string               `json:"gameName"`
	GamePopularityRank       int                  `json:"gamePopularityRank"`
	GameVersionLatestFiles   []AddonGameVersion   `json:"gameVersionLatestFiles"`
	ID                       int                  `json:"id"`
	InstallCount             int                  `json:"installCount"`
	IsAvailable              bool                 `json:"isAvailable"`
	IsFeatured               bool                 `json:"isFeatured"`
	LatestFiles              []AddonLatestFile    `json:"latestFiles"`
	Likes                    int                  `json:"likes"`
	Name                     string               `json:"name"`
	PackageType              int                  `json:"packageType"`
	PopularityScore          float64              `json:"popularityScore"`
	PortalName               string               `json:"portalName"`
	PrimaryAuthorName        string               `json:"primaryAuthorName"`
	PrimaryCategoryAvatarURL string               `json:"primaryCategoryAvatarUrl"`
	PrimaryCategoryName      string               `json:"primaryCategoryName"`
	Rating                   int                  `json:"rating"`
	SectionName              string               `json:"sectionName"`
	Slug                     string               `json:"slug"`
	Stage                    int                  `json:"stage"`
	Status                   int                  `json:"status"`
	Summary                  string               `json:"summary"`
	WebsiteURL               string               `json:"websiteUrl"`
}

Addon of curseforge

func GetAddon

func GetAddon(addonID string) (*Addon, error)

GetAddon gets Addon with addonID

func GetAddons

func GetAddons(addons []int) ([]*Addon, error)

GetAddons Gets addons with []AddonID

func GetAllAddons

func GetAllAddons() ([]*Addon, error)

GetAllAddons Uses the search to find as many addons as possible, not perfect but should get most of them. This is a very expensive call, takes a while and uses a lot of api requests

func Search(query string) ([]*Addon, error)

Search searches for addons with query

type AddonAttachments

type AddonAttachments struct {
	Description  string `json:"description"`
	ID           int    `json:"id"`
	IsDefault    bool   `json:"isDefault"`
	ProjectID    int    `json:"projectID"`
	ThumbnailURL string `json:"thumbnailUrl"`
	Title        string `json:"title"`
	URL          string `json:"url"`
}

AddonAttachments embedded attachments on the curseforge page (images,etc)

type AddonAuthors

type AddonAuthors struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

AddonAuthors Represents an author of an addon

type AddonCategories

type AddonCategories struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	URL  string `json:"url"`
}

AddonCategories represents the category or an addon

type AddonCategorySection

type AddonCategorySection struct {
	ID                      int         `json:"Id"`
	ExtraIncludePattern     interface{} `json:"extraIncludePattern"`
	GameID                  int         `json:"gameId"`
	InitialInclusionPattern string      `json:"initialInclusionPattern"`
	Name                    string      `json:"name"`
	PackageType             int         `json:"packageType"`
	Path                    string      `json:"path"`
}

AddonCategorySection Section of addon

type AddonDependency

type AddonDependency struct {
	AddonID int `json:"addonId"`
	Type    int `json:"type"`
}

AddonDependency a dependency of an addon

type AddonGameVersion

type AddonGameVersion struct {
	FileType        int    `json:"fileType"`
	GameVersion     string `json:"gameVersion"`
	ProjectFileID   int    `json:"projectFileId"`
	ProjectFileName string `json:"projectFileName"`
}

AddonGameVersion AddonGameVersion

type AddonLatestFile

type AddonLatestFile struct {
	AlternateFileID    int               `json:"alternateFileId"`
	Dependencies       []AddonDependency `json:"dependencies"`
	DownloadURL        string            `json:"downloadUrl"`
	FileDate           string            `json:"fileDate"`
	FileName           string            `json:"fileName"`
	FileNameOnDisk     string            `json:"fileNameOnDisk"`
	FileStatus         int               `json:"fileStatus"`
	GameVersion        []string          `json:"gameVersion"`
	ID                 int               `json:"id"`
	IsAlternate        bool              `json:"isAlternate"`
	IsAvailable        bool              `json:"isAvailable"`
	Modules            []AddonModules    `json:"modules"`
	PackageFingerprint int               `json:"packageFingerprint"`
	ReleaseType        int               `json:"releaseType"`
}

AddonLatestFile Latest file uploads

type AddonModules

type AddonModules struct {
	Fingerprint int    `json:"fingerprint"`
	FolderName  string `json:"folderName"`
}

AddonModules Folders in addon File

type AuthSession

type AuthSession struct {
	UserID                 int    `json:"UserID"`
	Username               string `json:"Username"`
	DisplayName            string `json:"DisplayName"`
	SessionID              string `json:"SessionID"`
	Token                  string `json:"Token"`
	EmailAddress           string `json:"EmailAddress"`
	EffectivePremiumStatus bool   `json:"EffectivePremiumStatus"`
	ActualPremiumStatus    bool   `json:"ActualPremiumStatus"`
	SubscriptionToken      int    `json:"SubscriptionToken"`
	Expires                int    `json:"Expires"`
	RenewAfter             int    `json:"RenewAfter"`
	IsTemporaryAccount     bool   `json:"IsTemporaryAccount"`
	IsMerged               bool   `json:"IsMerged"`
	Bans                   int    `json:"Bans"`
}

AuthSession Session of auth

type AuthenticationResponse

type AuthenticationResponse struct {
	Status        int         `json:"Status"`
	StatusMessage string      `json:"StatusMessage"`
	Session       AuthSession `json:"Session"`
}

AuthenticationResponse Response of auth

type File

type File struct {
	ID                 int               `json:"id"`
	FileName           string            `json:"fileName"`
	FileNameOnDisk     string            `json:"fileNameOnDisk"`
	FileDate           string            `json:"fileDate"`
	ReleaseType        int               `json:"releaseType"`
	FileStatus         int               `json:"fileStatus"`
	DownloadURL        string            `json:"downloadUrl"`
	IsAlternate        bool              `json:"isAlternate"`
	AlternateFileID    int               `json:"alternateFileId"`
	Dependencies       []AddonDependency `json:"dependencies"`
	IsAvailable        bool              `json:"isAvailable"`
	Modules            []AddonModules    `json:"modules"`
	PackageFingerprint int64             `json:"packageFingerprint"`
	GameVersion        []string          `json:"gameVersion"`
}

File a single file

func GetAddonFile

func GetAddonFile(addon int, fileID int) (*File, error)

GetAddonFile Gets an addons file with AddonID and fileId

func GetAddonFiles

func GetAddonFiles(addonID string) ([]*File, error)

GetAddonFiles Gets files for addonID

type FingerprintList

type FingerprintList struct {
	IsCacheBuilt          bool               `json:"isCacheBuilt"`
	ExactMatches          []FingerprintMatch `json:"exactMatches"`
	ExactFingerprints     []int              `json:"exactFingerprints"`
	InstalledFingerprints []int              `json:"installedFingerprints"`
}

FingerprintList List of fingerprint matches

func GetHashMatches

func GetHashMatches(addons []int) (*FingerprintList, error)

GetHashMatches Gets addon Fingerprints

type FingerprintMatch

type FingerprintMatch struct {
	AddonID int  `json:"id"`
	File    File `json:"file"`
}

FingerprintMatch match of addon fingerprint

type Login

type Login struct {
	Username string `json:"Username"`
	Password string `json:"Password"`
}

Login user/pass

type Register

type Register struct {
	Username   string `json:"Username"`
	Password   string `json:"Password"`
	Email      string `json:"Email"`
	Newsletter bool   `json:"Newsletter"`
}

Register user/pass object

type RenewTokenResponseContract

type RenewTokenResponseContract struct {
	Token      string `json:"Token"`
	Expires    int    `json:"Expires"`
	RenewAfter int    `json:"RenewAfter"`
}

RenewTokenResponseContract OAuth stuffs

type TwitchOAuthRequest

type TwitchOAuthRequest struct {
	ClientID    string `json:"ClientID"`
	Code        string `json:"Code"`
	RedirectURI string `json:"RedirectUri"`
	State       string `json:"State"`
}

TwitchOAuthRequest https://logins-v1.curseapp.net/Help/Api/POST-login-twitch-oauth

type TwitchOAuthResponse

type TwitchOAuthResponse struct {
	Status            int         `json:"Status"`
	Session           AuthSession `json:"Session"`
	TwitchUsername    string      `json:"TwitchUsername"`
	TwitchDisplayName string      `json:"TwitchDisplayName"`
	TwitchAvatar      string      `json:"TwitchAvatar"`
	TwitchUserID      string      `json:"TwitchUserID"`
}

TwitchOAuthResponse Response from above

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址