Documentation
¶
Index ¶
- Constants
- Variables
- func AvatarPrimaryStyle(av map[string]any) string
- func ClearClientBuildIfBelowMin(b *steam.ClientBuild, min int) bool
- func ClientConfigPlatform(clientName string) string
- func CompactCountWikitext(n int64) string
- func DisplayShelfTitle(raw string) string
- func FileIDFromURL(rawURL string) string
- func FlattenWorld(world map[string]any) map[string]string
- func FormatCompactCount(n int64) (coeff string, unit string)
- func GenerateTOTP(secret string) (string, error)
- func ImageExtensionFromBytes(data []byte) string
- func IsCompactCountPage(subpath string) bool
- func IsExcludedWorldKey(key string) bool
- func ListingImageFilename(displayName, ext string) string
- func ListingProducts(listing map[string]any) []map[string]any
- func ListingTypeLabel(listing map[string]any) string
- func LoadNetscapeJar(jar http.CookieJar, path string) error
- func MinBuildForClient(mins map[string]int, clientName string) (int, error)
- func NewCookieJar() (http.CookieJar, error)
- func NormalizeImageExt(ext string) string
- func ProductImageFilename(productTypeLabel, displayName, ext string) string
- func RenderAvatarAuthorsIndexWikitext(year int, authors []string) string
- func RenderAvatarStylesIndexWikitext(year int, styles []string) string
- func RenderCurrentOffersWikitext(year int, shelves []struct{ ... }) string
- func RenderInventoryContentDisplay(d InventoryContentDisplay) string
- func RenderShelfWikitext(shelfTitle string, shelfIconFile string, cards []InventoryContentDisplay) string
- func ReplaceImageExt(filename, ext string) string
- func ResolveImageExt(data []byte, fallback string) string
- func SafeFilename(name string) string
- func SaveNetscapeJar(jar http.CookieJar, path string) error
- func ShelfIconFilename(shelfTitle, ext string) string
- func ShelfListings(shelf map[string]any) []map[string]any
- func StoreShelves(store map[string]any) []map[string]any
- type AuthConfig
- type AvatarMarketplaceListing
- type Client
- func (c *Client) AuthedGet(rawURL string) ([]byte, error)
- func (c *Client) AuthedGetJSON(rawURL string, dest any) error
- func (c *Client) DownloadFileBytes(fileID string) ([]byte, string, error)
- func (c *Client) DownloadImage(rawURL string) ([]byte, string, error)
- func (c *Client) DownloadYouTubeThumbnail(videoID string) ([]byte, string, error)
- func (c *Client) EnsureAuth(cfg AuthConfig, logger *slog.Logger) error
- func (c *Client) FetchListingGallery(listingID string) ([]map[string]any, error)
- func (c *Client) FetchPaidMarketplaceAvatars(snapshotDir string, limit int) ([]map[string]any, error)
- func (c *Client) FetchStoreCatalog(snapshotDir string, avatarLimit int, logger *slog.Logger) (*StoreSnapshot, error)
- func (c *Client) GetClientBuildConfig() (mins map[string]int, sdkUnity string, err error)
- func (c *Client) GetFileDownload(fileID string) (*FileDownloadInfo, error)
- func (c *Client) GetMinSupportedClientBuildNumbers() (map[string]int, error)
- func (c *Client) GetSdkUnityVersion() (string, error)
- func (c *Client) GetWorld(worldID string) (map[string]any, error)
- func (c *Client) PersistSession() error
- type FileDownloadInfo
- type InventoryContentDisplay
- type StoreSnapshot
Constants ¶
const (
OfficialStoreID = "esto_00000000-0000-0000-0000-000000000000"
)
const UnitySDKClientName = "unity-sdk"
Variables ¶
var CompactCountPageKeys = []string{"visits", "favorites"}
CompactCountPageKeys are FlattenWorld subpaths stored as Compact number template calls. Their page bodies must not run through |/= sanitization.
var ErrNotFound = errors.New("image not found")
ErrNotFound is returned by DownloadImage when the server answers 404.
Functions ¶
func AvatarPrimaryStyle ¶
func ClearClientBuildIfBelowMin ¶
func ClearClientBuildIfBelowMin(b *steam.ClientBuild, min int) bool
func ClientConfigPlatform ¶
func CompactCountWikitext ¶
CompactCountWikitext returns a Compact number template call for n.
func DisplayShelfTitle ¶
func FileIDFromURL ¶
FileIDFromURL extracts a VRChat file_… UUID from an API or CDN URL.
func FormatCompactCount ¶
FormatCompactCount returns a coefficient string and unit for n using ~3 significant figures (e.g. 28817 → "28.8","k"; 1413125 → "1.41","M"). For n < 1000 the coefficient is the full integer and unit is empty.
func GenerateTOTP ¶
GenerateTOTP returns a 6-digit TOTP code for the given base32 secret (RFC 6238).
func ImageExtensionFromBytes ¶
ImageExtensionFromBytes returns png/jpg/webp/gif based on magic bytes, or "" when the payload is not a recognized image. Prefer this over API metadata or Content-Type: MediaWiki verifies uploads the same way.
func IsCompactCountPage ¶
IsCompactCountPage reports whether subpath is written as Compact number wikitext.
func IsExcludedWorldKey ¶
IsExcludedWorldKey reports whether a top-level world JSON key is omitted from sync.
func ListingImageFilename ¶
func ListingTypeLabel ¶
func LoadNetscapeJar ¶
LoadNetscapeJar loads cookies from a Netscape cookie file into jar.
func MinBuildForClient ¶
func NewCookieJar ¶
NewCookieJar returns an empty in-memory cookie jar.
func NormalizeImageExt ¶
NormalizeImageExt lowercases and maps "jpeg" → "jpg". Unknown values are returned unchanged (callers may still reject them).
func ProductImageFilename ¶
func RenderInventoryContentDisplay ¶
func RenderInventoryContentDisplay(d InventoryContentDisplay) string
func RenderShelfWikitext ¶
func RenderShelfWikitext(shelfTitle string, shelfIconFile string, cards []InventoryContentDisplay) string
func ReplaceImageExt ¶
ReplaceImageExt returns filename with its final extension replaced by ext. Prefer this when reusing a wiki filename but the real bytes need a different type (e.g. preferred "ListingImage Foo.png" for JPEG bytes → ".jpg").
func ResolveImageExt ¶
ResolveImageExt prefers magic-byte detection, then fallback (API/header/URL).
func SafeFilename ¶
func SaveNetscapeJar ¶
SaveNetscapeJar writes api.vrchat.cloud cookies (and vrchat.com mirrors) to path.
func ShelfIconFilename ¶
Types ¶
type AuthConfig ¶
func AuthConfigFromEnv ¶
func AuthConfigFromEnv() (AuthConfig, bool)
type AvatarMarketplaceListing ¶
type AvatarMarketplaceListing struct {
ListingID string
Style string
Author string
ImageID string
FallbackAvatar map[string]any
Display InventoryContentDisplay
}
func BuildAvatarMarketplaceListings ¶
func BuildAvatarMarketplaceListings(avatars []map[string]any, now time.Time) []AvatarMarketplaceListing
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) DownloadFileBytes ¶
func (*Client) DownloadImage ¶
DownloadImage fetches image bytes from a VRChat file URL (redirects to the CDN are followed by the HTTP client) and returns the bytes plus the file extension. Magic bytes win over Content-Type and URL path so the wiki filename matches MediaWiki's MIME verification.
func (*Client) DownloadYouTubeThumbnail ¶
DownloadYouTubeThumbnail fetches the thumbnail for a YouTube video id, preferring maxresdefault and using hqdefault when the video has no max-resolution thumbnail (YouTube answers 404 in that case).
func (*Client) EnsureAuth ¶
func (c *Client) EnsureAuth(cfg AuthConfig, logger *slog.Logger) error
func (*Client) FetchListingGallery ¶
func (*Client) FetchPaidMarketplaceAvatars ¶
func (*Client) FetchStoreCatalog ¶
func (*Client) GetClientBuildConfig ¶
func (*Client) GetFileDownload ¶
func (c *Client) GetFileDownload(fileID string) (*FileDownloadInfo, error)
func (*Client) GetMinSupportedClientBuildNumbers ¶
func (*Client) GetSdkUnityVersion ¶
func (*Client) PersistSession ¶
PersistSession writes the in-memory cookie jar to disk so later runs can reuse the VRChat auth cookies without logging in again.
type FileDownloadInfo ¶
type InventoryContentDisplay ¶
type InventoryContentDisplay struct {
Name string
Image string
Seller string
Publisher string
Author string
Type string
Price int
PriceVRCPlus int
PriceText string
AvailabilityDate string
Description string
ProductID string
AvatarID string
}