upadted to 1.24.0; fixed stb and spiddped doubles in precene
This commit is contained in:
26
pkg/handler/console.go
Normal file
26
pkg/handler/console.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"github.com/logrusorgru/aurora/v4"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func (h *Handler) Console() string {
|
||||
viper.SetDefault("env", "devel")
|
||||
cmd := viper.GetString("create")
|
||||
cmdList := viper.Sub("console.cmd")
|
||||
allowCreate := cmdList.GetStringSlice("create")
|
||||
|
||||
if !slices.Contains(allowCreate, cmd) {
|
||||
fmt.Printf("%s Not allowed command %s used\n", aurora.BgMagenta("[WARN]"), aurora.Magenta(cmd))
|
||||
return ""
|
||||
}
|
||||
|
||||
fmt.Printf("%v\n", slices.Contains(allowCreate, cmd))
|
||||
|
||||
return viper.GetString("env")
|
||||
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/iancoleman/strcase"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"git.amok.space/yevhen/resource-scraper/pkg/service"
|
||||
@@ -16,14 +19,13 @@ func New(services *service.Service) *Handler {
|
||||
}
|
||||
|
||||
func (h *Handler) InitConsole() string {
|
||||
switch viper.GetString(constant.CfgKeyScopeEnable) {
|
||||
case constant.ScopeRuTracker:
|
||||
return h.rutracker()
|
||||
case constant.ScopePrescene:
|
||||
return h.prescene()
|
||||
}
|
||||
methodName := strcase.ToCamel(viper.GetString(constant.FlagScopeEnable))
|
||||
|
||||
return "no scope chosen"
|
||||
immutable := reflect.ValueOf(h)
|
||||
method := immutable.MethodByName(methodName)
|
||||
v := method.Call(nil)
|
||||
|
||||
return methodName + " launched, " + v[0].String() + "\n"
|
||||
}
|
||||
|
||||
func (h *Handler) InitRoutes() string {
|
||||
|
||||
36
pkg/handler/info.go
Normal file
36
pkg/handler/info.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/logrusorgru/aurora/v4"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/mewkiz/flac"
|
||||
|
||||
"git.amok.space/yevhen/resource-scraper/types/constant"
|
||||
)
|
||||
|
||||
func (h *Handler) Info() string {
|
||||
md5()
|
||||
|
||||
fmt.Printf("%s: %s; %s: %s\n",
|
||||
aurora.Cyan("ENV"),
|
||||
viper.GetString(constant.FlagEnv), aurora.Cyan("SCOPE"), viper.GetString(constant.FlagScopeEnable))
|
||||
return "info"
|
||||
}
|
||||
|
||||
func md5() {
|
||||
stream, err := flac.ParseFile("C:\\arm.amok.space\\.incoming\\Ancient Storm\\Forever and Never (2024)\\06 Old Mountain.flac")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer stream.Close()
|
||||
|
||||
fmt.Printf("unencoded audio md5sum: %032x\n", stream.Info.MD5sum[:])
|
||||
fmt.Printf("Total number of inter-channel samples in the stream: %+v\n", stream.Info.NSamples)
|
||||
for i, block := range stream.Blocks {
|
||||
fmt.Printf("block %d: %v\n", i, block.Type)
|
||||
}
|
||||
}
|
||||
5
pkg/handler/metal-archives.go
Normal file
5
pkg/handler/metal-archives.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package handler
|
||||
|
||||
func (h *Handler) MetalArchives() string {
|
||||
return "MetalArchives................."
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"git.amok.space/yevhen/resource-scraper/types/constant"
|
||||
)
|
||||
|
||||
func (h *Handler) prescene() string {
|
||||
func (h *Handler) Prescene() string {
|
||||
pagesToScrape := []string{"1"}
|
||||
levels := viper.GetInt(constant.CfgKeyLevelsToScrape)
|
||||
if levels > 1 {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func (h *Handler) rutracker() string {
|
||||
func (h *Handler) Rutracker() string {
|
||||
key := fmt.Sprintf("topic.%v", time.Now().Hour())
|
||||
topics := viper.GetStringSlice(key)
|
||||
|
||||
|
||||
36
pkg/handler/stb.go
Normal file
36
pkg/handler/stb.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"git.amok.space/yevhen/resource-scraper/types/constant"
|
||||
)
|
||||
|
||||
func (h *Handler) STB() string {
|
||||
endpoint := fmt.Sprintf("%s.%s", constant.ScopeShareTheBrutality, constant.CfgKeyEndpoint)
|
||||
endpoint = viper.GetString(endpoint)
|
||||
|
||||
if endpoint == "" {
|
||||
slog.Error("getting endpoint from config", "err", errors.New("no endpoint provided"))
|
||||
return "stb"
|
||||
}
|
||||
|
||||
es, ms := h.services.ShareTheBrutality.GetMail(endpoint)
|
||||
|
||||
//fmt.Printf("%+v\n", es)
|
||||
ms.LogOut()
|
||||
|
||||
for _, record := range es {
|
||||
fmt.Printf("%s %d: %s [#%s]\n", record.Created, record.Id, record.Title, record.Releaser)
|
||||
}
|
||||
|
||||
/*if err != nil {
|
||||
slog.Error("error occurred while getting topic: ", "err", err)
|
||||
}*/
|
||||
|
||||
return fmt.Sprintf("Added %d records\n", len(es))
|
||||
}
|
||||
Reference in New Issue
Block a user