Skip to content

Commit

Permalink
Do not upload files to anonfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
waybackarchiver committed Aug 3, 2024
1 parent 1585066 commit 7e53347
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 36 deletions.
24 changes: 8 additions & 16 deletions reduxer/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,49 @@ func BundleExample() Reduxer {
Img: Asset{
Local: "/path/to/image",
Remote: Remote{
Anonfile: "https://anonfiles.com/FbZfSa9eu4",
Catbox: "https://files.catbox.moe/9u6yvu.png",
Catbox: "https://files.catbox.moe/9u6yvu.png",
},
},
PDF: Asset{
Local: "/path/to/pdf",
Remote: Remote{
Anonfile: "https://anonfiles.com/r4G8Sb90ud",
Catbox: "https://files.catbox.moe/q73uqh.pdf",
Catbox: "https://files.catbox.moe/q73uqh.pdf",
},
},
Raw: Asset{
Local: "/path/to/htm",
Remote: Remote{
Anonfile: "https://anonfiles.com/pbG4Se94ua",
Catbox: "https://files.catbox.moe/bph1g6.htm",
Catbox: "https://files.catbox.moe/bph1g6.htm",
},
},
Txt: Asset{
Local: "/path/to/txt",
Remote: Remote{
Anonfile: "https://anonfiles.com/naG6S09bu1",
Catbox: "https://files.catbox.moe/wwrby6.txt",
Catbox: "https://files.catbox.moe/wwrby6.txt",
},
},
HAR: Asset{
Local: "/path/to/har",
Remote: Remote{
Anonfile: "https://anonfiles.com/n1paZfB3ub",
Catbox: "https://files.catbox.moe/3agtva.har",
Catbox: "https://files.catbox.moe/3agtva.har",
},
},
HTM: Asset{
Local: "/path/to/single-htm",
Remote: Remote{
Anonfile: "https://anonfiles.com/v4G4S09abc",
Catbox: "",
Catbox: "",
},
},
WARC: Asset{
Local: "/path/to/warc",
Remote: Remote{
Anonfile: "https://anonfiles.com/v4G4S09auc",
Catbox: "invalid-url-moe/kkai0w.warc",
Catbox: "invalid-url-moe/kkai0w.warc",
},
},
Media: Asset{
Local: "",
Remote: Remote{
Anonfile: "",
Catbox: "",
Catbox: "",
},
},
},
Expand Down
27 changes: 7 additions & 20 deletions reduxer/reduxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

"github.com/go-shiori/go-readability"
"github.com/go-shiori/obelisk"
"github.com/wabarc/go-anonfile"
"github.com/wabarc/go-catbox"
"github.com/wabarc/helper"
"github.com/wabarc/logger"
Expand Down Expand Up @@ -73,8 +72,7 @@ type Asset struct {

// Remote represents the file on the remote server.
type Remote struct {
Anonfile string
Catbox string
Catbox string
}

// Src represents the requested url.
Expand Down Expand Up @@ -317,7 +315,6 @@ func remotely(ctx context.Context, artifact *Artifact) (err error) {
}

cat := catbox.New(ingress.Client())
anon := anonfile.NewAnonfile(ingress.Client())
g, _ := errgroup.WithContext(ctx)

var mu sync.RWMutex
Expand All @@ -333,22 +330,12 @@ func remotely(ctx context.Context, artifact *Artifact) (err error) {
g.Go(func() error {
var remote Remote
mu.Lock()
func() {
r, e := anon.Upload(asset.Local)
if e != nil {
err = errors.Wrap(err, fmt.Sprintf("upload %s to anonfiles failed: %v", asset.Local, e))
} else {
remote.Anonfile = r.Short()
}
}()
func() {
c, e := cat.Upload(asset.Local)
if e != nil {
err = errors.Wrap(err, fmt.Sprintf("upload %s to catbox failed: %v", asset.Local, e))
} else {
remote.Catbox = c
}
}()
c, e := cat.Upload(asset.Local)
if e != nil {
err = errors.Wrap(err, fmt.Sprintf("upload %s to catbox failed: %v", asset.Local, e))
} else {
remote.Catbox = c
}
asset.Remote = remote
mu.Unlock()
return nil
Expand Down

0 comments on commit 7e53347

Please sign in to comment.