commit
This commit is contained in:
59
internal/release/release.go
Normal file
59
internal/release/release.go
Normal 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
19
internal/utils/utils.go
Normal 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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user