vrchat

package
v0.0.0-...-2e21b6e Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OfficialStoreID = "esto_00000000-0000-0000-0000-000000000000"
)
View Source
const UnitySDKClientName = "unity-sdk"

Variables

View Source
var CompactCountPageKeys = []string{"visits", "favorites"}

CompactCountPageKeys are FlattenWorld subpaths stored as Compact number template calls. Their page bodies must not run through |/= sanitization.

View Source
var ErrNotFound = errors.New("image not found")

ErrNotFound is returned by DownloadImage when the server answers 404.

Functions

func AvatarPrimaryStyle

func AvatarPrimaryStyle(av map[string]any) string

func ClearClientBuildIfBelowMin

func ClearClientBuildIfBelowMin(b *steam.ClientBuild, min int) bool

func ClientConfigPlatform

func ClientConfigPlatform(clientName string) string

func CompactCountWikitext

func CompactCountWikitext(n int64) string

CompactCountWikitext returns a Compact number template call for n.

func DisplayShelfTitle

func DisplayShelfTitle(raw string) string

func FileIDFromURL

func FileIDFromURL(rawURL string) string

FileIDFromURL extracts a VRChat file_… UUID from an API or CDN URL.

func FlattenWorld

func FlattenWorld(world map[string]any) map[string]string

func FormatCompactCount

func FormatCompactCount(n int64) (coeff string, unit string)

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

func GenerateTOTP(secret string) (string, error)

GenerateTOTP returns a 6-digit TOTP code for the given base32 secret (RFC 6238).

func ImageExtensionFromBytes

func ImageExtensionFromBytes(data []byte) string

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

func IsCompactCountPage(subpath string) bool

IsCompactCountPage reports whether subpath is written as Compact number wikitext.

func IsExcludedWorldKey

func IsExcludedWorldKey(key string) bool

IsExcludedWorldKey reports whether a top-level world JSON key is omitted from sync.

func ListingImageFilename

func ListingImageFilename(displayName, ext string) string

func ListingProducts

func ListingProducts(listing map[string]any) []map[string]any

func ListingTypeLabel

func ListingTypeLabel(listing map[string]any) string

func LoadNetscapeJar

func LoadNetscapeJar(jar http.CookieJar, path string) error

LoadNetscapeJar loads cookies from a Netscape cookie file into jar.

func MinBuildForClient

func MinBuildForClient(mins map[string]int, clientName string) (int, error)

func NewCookieJar

func NewCookieJar() (http.CookieJar, error)

NewCookieJar returns an empty in-memory cookie jar.

func NormalizeImageExt

func NormalizeImageExt(ext string) string

NormalizeImageExt lowercases and maps "jpeg" → "jpg". Unknown values are returned unchanged (callers may still reject them).

func ProductImageFilename

func ProductImageFilename(productTypeLabel, displayName, ext string) string

func RenderAvatarAuthorsIndexWikitext

func RenderAvatarAuthorsIndexWikitext(year int, authors []string) string

func RenderAvatarStylesIndexWikitext

func RenderAvatarStylesIndexWikitext(year int, styles []string) string

func RenderCurrentOffersWikitext

func RenderCurrentOffersWikitext(year int, shelves []struct{ Title, IconFile string }) string

func RenderInventoryContentDisplay

func RenderInventoryContentDisplay(d InventoryContentDisplay) string

func RenderShelfWikitext

func RenderShelfWikitext(shelfTitle string, shelfIconFile string, cards []InventoryContentDisplay) string

func ReplaceImageExt

func ReplaceImageExt(filename, ext string) string

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

func ResolveImageExt(data []byte, fallback string) string

ResolveImageExt prefers magic-byte detection, then fallback (API/header/URL).

func SafeFilename

func SafeFilename(name string) string

func SaveNetscapeJar

func SaveNetscapeJar(jar http.CookieJar, path string) error

SaveNetscapeJar writes api.vrchat.cloud cookies (and vrchat.com mirrors) to path.

func ShelfIconFilename

func ShelfIconFilename(shelfTitle, ext string) string

func ShelfListings

func ShelfListings(shelf map[string]any) []map[string]any

func StoreShelves

func StoreShelves(store map[string]any) []map[string]any

Types

type AuthConfig

type AuthConfig struct {
	Username   string
	Password   string
	TOTPSecret string
	CookiePath string
}

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 NewClient

func NewClient(httpClient *http.Client) *Client

func (*Client) AuthedGet

func (c *Client) AuthedGet(rawURL string) ([]byte, error)

func (*Client) AuthedGetJSON

func (c *Client) AuthedGetJSON(rawURL string, dest any) error

func (*Client) DownloadFileBytes

func (c *Client) DownloadFileBytes(fileID string) ([]byte, string, error)

func (*Client) DownloadImage

func (c *Client) DownloadImage(rawURL string) ([]byte, string, error)

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

func (c *Client) DownloadYouTubeThumbnail(videoID string) ([]byte, string, error)

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 (c *Client) FetchListingGallery(listingID string) ([]map[string]any, error)

func (*Client) FetchPaidMarketplaceAvatars

func (c *Client) FetchPaidMarketplaceAvatars(snapshotDir string, limit int) ([]map[string]any, error)

func (*Client) FetchStoreCatalog

func (c *Client) FetchStoreCatalog(snapshotDir string, avatarLimit int, logger *slog.Logger) (*StoreSnapshot, error)

func (*Client) GetClientBuildConfig

func (c *Client) GetClientBuildConfig() (mins map[string]int, sdkUnity string, err error)

func (*Client) GetFileDownload

func (c *Client) GetFileDownload(fileID string) (*FileDownloadInfo, error)

func (*Client) GetMinSupportedClientBuildNumbers

func (c *Client) GetMinSupportedClientBuildNumbers() (map[string]int, error)

func (*Client) GetSdkUnityVersion

func (c *Client) GetSdkUnityVersion() (string, error)

func (*Client) GetWorld

func (c *Client) GetWorld(worldID string) (map[string]any, error)

func (*Client) PersistSession

func (c *Client) PersistSession() error

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 FileDownloadInfo struct {
	FileID   string
	Version  int
	URL      string
	FileName string
	Ext      string
}

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
}

func AvatarToDisplay

func AvatarToDisplay(av map[string]any, now time.Time, imageFilename string) InventoryContentDisplay

func ListingToDisplay

func ListingToDisplay(listing map[string]any, now time.Time, imageFilename string) InventoryContentDisplay

type StoreSnapshot

type StoreSnapshot struct {
	FetchedAt   time.Time                 `json:"fetchedAt"`
	Store       map[string]any            `json:"store"`
	Listings    map[string]map[string]any `json:"listings"`
	Avatars     []map[string]any          `json:"avatars"`
	TypeCounts  map[string]int            `json:"typeCounts"`
	SnapshotDir string                    `json:"-"`
}

Jump to

Keyboard shortcuts

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