2024-11-25 17:38:16 +07:00

60 lines
1001 B
Go

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
}