Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cld9x committed May 9, 2019
0 parents commit 5e60bfe
Show file tree
Hide file tree
Showing 78 changed files with 11,818 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .assets.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pkg = "assets"
dest = "./xbase/assets/"
fmt = false

[compression]
compress = true
method = "DefaultCompression"
keep = false

clean = false
output = "ab0x.go"
unexporTed = false
spread = false
debug = true

[[custom]]
files = ["./ui/public/"]
base = "./ui/public/"
exclude = [".DS_Store"]
37 changes: 37 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
kind: pipeline
name: default

workspace:
base: /go
path: appsrc/

steps:
- name: fetch
image: docker:git
when:
event:
- tag
commands:
- git fetch --tags

- name: ui
image: node
when:
event:
- tag
commands:
- cd ui
- yarn install
- yarn build

- name: build
image: mailchain/goreleaser-xcgo:latest
environment:
GITHUB_TOKEN:
from_secret: GITHUB_TOKEN
when:
event:
- tag
commands:
- apt-get update && apt-get install -y gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
- goreleaser --skip-validate --rm-dist
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/.idea
.DS_Store

npm-debug.log
yarn-error.log
go.sum
test.db

/dist/
/node_modules/
/xbase/assets/
/ui/public/static/bundle.*
66 changes: 66 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
before:
hooks:
- go mod download
- go get github.com/UnnoTed/fileb0x
- go get github.com/go-bindata/go-bindata
- go generate ./...
builds:
- id: xbvr-mac
binary: xbvr
env:
- CGO_ENABLED=1
- CC=o64-clang
- CXX=o64-clang++
goos:
- darwin
goarch:
- amd64
- id: xbvr-windows
binary: xbvr
env:
- CGO_ENABLED=1
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
goos:
- windows
goarch:
- amd64
- id: xbvr-linux-amd64
binary: xbvr
env:
- CGO_ENABLED=1
goos:
- linux
goarch:
- amd64
- id: xbvr-linux-arm
binary: xbvr
env:
- CGO_ENABLED=1
- CC=arm-linux-gnueabi-gcc
goos:
- linux
goarch:
- arm
goarm:
- 6
- 7
archives:
- replacements:
darwin: macOS
linux: Linux
windows: Windows
amd64: x86_64
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
release:
disable: false
github:
owner: cld9x
name: test
32 changes: 32 additions & 0 deletions .realize.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
settings:
legacy:
force: false
interval: 0s
server:
status: true
open: false
host: localhost
port: 5001
schema:
- name: xbvr
env:
DEBUG: 1
path: .
commands:
generate:
status: true
run:
status: true
args:
- run
watcher:
extensions:
- go
paths:
- /
ignore:
paths:
- .git
- .realize
- node_modules/
- ui/
19 changes: 19 additions & 0 deletions command/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package command

import (
"gopkg.in/urfave/cli.v1"
)

var commands []cli.Command

type Commander interface {
Execute(c *cli.Context)
}

func RegisterCommand(command cli.Command) {
commands = append(commands, command)
}

func GetCommands() []cli.Command {
return commands
}
23 changes: 23 additions & 0 deletions command/log.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package command

import (
"github.com/sirupsen/logrus"
"github.com/x-cray/logrus-prefixed-formatter"
"os"
"runtime"
)

var log = logrus.New()

func init() {
log.Out = os.Stdout
log.SetLevel(logrus.InfoLevel)

if runtime.GOOS == "windows" {
log.Formatter = &prefixed.TextFormatter{
DisableColors: true,
}
} else {
log.Formatter = &prefixed.TextFormatter{}
}
}
18 changes: 18 additions & 0 deletions command/run.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package command

import (
"github.com/cld9x/xbvr/xbase"
"gopkg.in/urfave/cli.v1"
)

func ActionRun(c *cli.Context) {
xbase.StartServer()
}

func init() {
RegisterCommand(cli.Command{
Name: "run",
Usage: "run xbvr",
Action: ActionRun,
})
}
42 changes: 42 additions & 0 deletions command/task.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package command

import (
"github.com/cld9x/xbvr/xbase"
"github.com/cld9x/xbvr/xbase/scrape"
"gopkg.in/urfave/cli.v1"
)

func ActionCleanTags(c *cli.Context) {
xbase.RenameTags()
xbase.CountTags()
}

func ActionScrape(c *cli.Context) {
scrape.ScrapeNA()
scrape.ScrapeBadoink()
scrape.ScrapeMilfVR()
scrape.ScrapeVRB()
scrape.ScrapeWankz()
scrape.ScrapeVirtualTaboo()
}

func init() {
RegisterCommand(cli.Command{
Name: "task",
Usage: "run various tasks",
Subcommands: []cli.Command{
{
Name: "clean-tags",
Category: "tasks",
Usage: "clean tags",
Action: ActionCleanTags,
},
{
Name: "scrape",
Category: "tasks",
Usage: "run scrapers",
Action: ActionScrape,
},
},
})
}
78 changes: 78 additions & 0 deletions command/volume.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package command

import (
"os"
"path/filepath"

"github.com/cld9x/xbvr/xbase"
"gopkg.in/urfave/cli.v1"
)

func ActionAddVolume(c *cli.Context) {
if len(c.Args()) == 1 {
path := c.Args()[0]
if fi, err := os.Stat(path); os.IsNotExist(err) || !fi.IsDir() {
log.Fatal("Path does not exist or is not a directory")
}

path, _ = filepath.Abs(path)

db, _ := xbase.GetDB()
defer db.Close()

var vol []xbase.Volume
db.Where(&xbase.Volume{Path: path}).Find(&vol)

if len(vol) > 0 {
log.Fatal("Volume already exists")
}

nv := xbase.Volume{Path: path, IsEnabled: true, IsAvailable: true}
nv.Save()

log.Info("Added new volume", path)
}
}

func ActionRescanVolumes(c *cli.Context) {
xbase.RescanVolumes()
}

func ActionSaveLocalInfo(c *cli.Context) {
db, _ := xbase.GetDB()
defer db.Close()

var vol []xbase.Volume
db.Find(&vol)

for i := range vol {
vol[i].SaveLocalInfo()
}
}

func init() {
RegisterCommand(cli.Command{
Name: "volume",
Usage: "manage Volumes",
Subcommands: []cli.Command{
{
Name: "add",
Category: "volume",
Usage: "add new volume",
Action: ActionAddVolume,
},
{
Name: "rescan",
Category: "volume",
Usage: "rescan Volumes",
Action: ActionRescanVolumes,
},
{
Name: "localinfo",
Category: "volume",
Usage: "save File info",
Action: ActionSaveLocalInfo,
},
},
})
}
Loading

0 comments on commit 5e60bfe

Please sign in to comment.