feat: sign in to IMVU for Access Pass products (#4)
CI / build (push) Successful in 16s
Release / release (push) Successful in 3s
CI / image (push) Successful in 12s

Co-authored-by: dhkatz <[email protected]>
This commit was merged in pull request #4.
This commit is contained in:
dhkatz authored and dhkatz committed 2026-11-08 16:15:05 +00:00
1 parent dd8205602c
commit 145ebf25c1
11 files changed
+1001 -24

No files matched your search

+19 -3
View File
@@ -30,6 +30,8 @@ type Importer struct {
UserAgent string
HTTP *http.Client // for uploads to the catalog
Tmp string // a folder for working files
Sessions string // a folder for the IMVU accounts' sessions (their cookies)
APIURL string // IMVU's API (imvu.APIURL, or a test server's)
Logger *log.Logger
ConfigEvery time.Duration // how often the config is fetched (default a minute)
@@ -38,6 +40,7 @@ type Importer struct {
paused bool
concurrency int
signIn signedIn
}
// Run runs until ctx ends. Jobs it's working on then are left claimed; the hub queues them again after 30 minutes.
@@ -195,6 +198,8 @@ func (im *Importer) syncAccounts(ctx context.Context, list []hub.Account) {
} else if n > 0 {
im.Logger.Printf("accounts: forgot %d the hub no longer lists", n)
}
im.forgetSessions(ids)
im.ensureSignedIn(ctx, list)
}
func upperFirst(s string) string {
@@ -211,15 +216,19 @@ func (im *Importer) job(ctx context.Context, j hub.Job) {
if ctx.Err() != nil {
return
}
what := fmt.Sprintf("IMVU product %d", j.IMVUProduct)
if j.Kind == "list" {
what = fmt.Sprintf("IMVU shop %d", j.IMVUCreator)
}
if err != nil {
im.Logger.Printf("job %s (IMVU product %d): failed: %v", j.ID, j.IMVUProduct, err)
im.Logger.Printf("job %s (%s): failed: %v", j.ID, what, err)
out = &hub.Outcome{Status: "failed", Reason: upperFirst(err.Error()) + "."}
}
if out == nil {
return // the catalog's upload registered it: the job is done
}
if out.Status == "unchanged" {
im.Logger.Printf("job %s (IMVU product %d): no revision after %d", j.ID, j.IMVUProduct, out.IMVURevision)
im.Logger.Printf("job %s (%s): no revision after %d", j.ID, what, out.IMVURevision)
}
if err := im.Hub.Report(ctx, j.ID, *out); err != nil && ctx.Err() == nil {
im.Logger.Printf("job %s: reporting: %v", j.ID, err)
@@ -229,8 +238,15 @@ func (im *Importer) job(ctx context.Context, j hub.Job) {
// run imports a job's product: its newest revision after the last one imported. It returns the outcome to report,
// or nil when the upload registered it.
func (im *Importer) run(ctx context.Context, j hub.Job, start time.Time) (*hub.Outcome, error) {
if j.Kind == "list" {
return im.listShop(ctx, j)
}
if j.Rating == "" {
return nil, errors.New("the hub doesn't know this product's rating: IMVU hides it from the signed out (an Access Pass product?), and the importer can't sign in to IMVU yet")
rating, err := im.lookUp(ctx, j)
if err != nil {
return nil, err
}
j.Rating = rating
}
latest, probes, err := im.CDN.Latest(ctx, j.IMVUProduct, j.LastRevision+1)
if err != nil {