This commit is contained in:
Gregory Salaun 2024-11-25 17:38:16 +07:00
parent b031b9d09b
commit e2282af31c
7 changed files with 123 additions and 0 deletions

3
.gitignore vendored
View File

@ -21,3 +21,6 @@
# Go workspace file
go.work
*.log
.vscode
bin

7
Makefile Normal file
View File

@ -0,0 +1,7 @@
BINARY_NAME=GoUploadAssistant
build:
go build -o ./bin/${BINARY_NAME}.exe .\cmd\GoUploadAssistant\main.go
run:
go run .\cmd\GoUploadAssistant\main.go -p "C:\\Perso\\Seafile\\Programmation\\Golang\\GoUploadAssistant\\Dune.Prophecy.S01E01.MULTi.1080p.AMZN.WEB.DDP5.1.H.265-TFA"

View File

@ -0,0 +1,20 @@
package main
import (
"flag"
"fmt"
"git.rouggy.com/rouggy/GoUploadAssistant/internal/release"
)
func main() {
var cfgPath, path string
flag.StringVar(&cfgPath, "cfg", "./config.yml", "path to a valid config file")
flag.StringVar(&path, "p", "", "Path to the release to upload")
flag.Parse()
r := release.Parse(path)
fmt.Println(r)
}

9
go.mod Normal file
View File

@ -0,0 +1,9 @@
module git.rouggy.com/rouggy/GoUploadAssistant
go 1.23.1
require (
github.com/moistari/rls v0.5.12 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/text v0.14.0 // indirect
)

6
go.sum Normal file
View File

@ -0,0 +1,6 @@
github.com/moistari/rls v0.5.12 h1:PPtKMAkUT926vYiGCBmZWiU0iMMTcPmo08v28C2Sq9E=
github.com/moistari/rls v0.5.12/go.mod h1:+imnKzXNKNrbnDMppQH28S1y8ayitmniumqquzj229A=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=

View File

@ -0,0 +1,59 @@
package release
import (
"path/filepath"
"strings"
"git.rouggy.com/rouggy/GoUploadAssistant/internal/utils"
"github.com/moistari/rls"
)
type Release struct {
TorrentName string
Title string
Season int
Episode int
Year int
Resolution string
Source string
HDR string
Audio string
AudioChannels string
Group string
Language string
}
func Parse(path string) *Release {
var title string
if utils.IsFolderRelease(path) {
title = filepath.Base(path)
} else {
title = strings.Replace(filepath.Base(path), ".mkv", "", 1)
}
rel := rls.ParseString(title)
r := Release{}
r.TorrentName = title
r.Title = rel.Title
r.Season = rel.Series
r.Episode = rel.Episode
r.Source = rel.Source
r.Resolution = rel.Resolution
r.Year = rel.Year
if len(rel.HDR) > 0 {
r.HDR = rel.HDR[0]
}
if len(rel.Audio) > 0 {
r.Audio = rel.Audio[0]
}
r.AudioChannels = rel.Channels
r.Group = rel.Group
return &r
}

19
internal/utils/utils.go Normal file
View File

@ -0,0 +1,19 @@
package utils
import (
"fmt"
"os"
)
func IsFolderRelease(path string) bool {
info, err := os.Stat(path)
if err != nil {
fmt.Println(err)
}
if info.IsDir() {
return true
} else {
return false
}
}