Process timestamps properly
This commit is contained in:
@@ -6,11 +6,12 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
"github.com/debridmediamanager.com/zurg/internal/config"
|
"github.com/debridmediamanager.com/zurg/internal/config"
|
||||||
"github.com/debridmediamanager.com/zurg/pkg/logutil"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScriptExecutor struct {
|
type ScriptExecutor struct {
|
||||||
Script string
|
Script string
|
||||||
|
Args []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (se *ScriptExecutor) Execute() (string, error) {
|
func (se *ScriptExecutor) Execute() (string, error) {
|
||||||
@@ -29,11 +30,10 @@ func (se *ScriptExecutor) Execute() (string, error) {
|
|||||||
return out.String(), nil
|
return out.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func OnLibraryUpdateHook(config config.ConfigInterface) {
|
func OnLibraryUpdateHook(paths []string, config config.ConfigInterface, log *zap.SugaredLogger) {
|
||||||
log := logutil.NewLogger().Named("hooks")
|
|
||||||
|
|
||||||
executor := &ScriptExecutor{
|
executor := &ScriptExecutor{
|
||||||
Script: config.GetOnLibraryUpdate(),
|
Script: config.GetOnLibraryUpdate(),
|
||||||
|
Args: paths,
|
||||||
}
|
}
|
||||||
output, err := executor.Execute()
|
output, err := executor.Execute()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -329,7 +329,8 @@ func (t *TorrentManager) startRefreshJob() {
|
|||||||
t.repairAll()
|
t.repairAll()
|
||||||
t.log.Info("Finished checking for torrents to repair")
|
t.log.Info("Finished checking for torrents to repair")
|
||||||
}
|
}
|
||||||
go OnLibraryUpdateHook(t.cfg)
|
// TODO: pass the changed directories to the hook
|
||||||
|
go OnLibraryUpdateHook([]string{}, t.cfg, t.log)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,7 +405,7 @@ func hashStringToFh(s string) (fh uint64) {
|
|||||||
|
|
||||||
func (t *TorrentManager) getName(name, originalName string) string {
|
func (t *TorrentManager) getName(name, originalName string) string {
|
||||||
// drop the extension from the name
|
// drop the extension from the name
|
||||||
if t.cfg.EnableRetainFolderNameExtension() && strings.Contains(name, originalName) {
|
if t.cfg.EnableRetainFolderNameExtension() {
|
||||||
return name
|
return name
|
||||||
} else {
|
} else {
|
||||||
ret := strings.TrimSuffix(originalName, ".mp4")
|
ret := strings.TrimSuffix(originalName, ".mp4")
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package realdebrid
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"math"
|
"math"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FileJSON struct {
|
type FileJSON struct {
|
||||||
@@ -22,10 +23,7 @@ type UnrestrictResponse struct {
|
|||||||
type Torrent struct {
|
type Torrent struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"filename"`
|
Name string `json:"filename"`
|
||||||
Hash string `json:"hash"`
|
|
||||||
Progress int `json:"-"`
|
Progress int `json:"-"`
|
||||||
Added string `json:"added"`
|
|
||||||
Bytes int64 `json:"bytes"`
|
|
||||||
Links []string `json:"links"`
|
Links []string `json:"links"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,13 +50,13 @@ type TorrentInfo struct {
|
|||||||
Hash string `json:"hash"`
|
Hash string `json:"hash"`
|
||||||
Progress int `json:"-"`
|
Progress int `json:"-"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Added string `json:"added"`
|
Added string `json:"-"`
|
||||||
Ended string `json:"ended"`
|
Ended string `json:"-"`
|
||||||
Bytes int64 `json:"bytes"`
|
Bytes int64 `json:"bytes"`
|
||||||
Links []string `json:"links"`
|
Links []string `json:"links"`
|
||||||
OriginalName string `json:"original_filename"` // from info
|
OriginalName string `json:"original_filename"`
|
||||||
OriginalBytes int64 `json:"original_bytes"` // from info
|
OriginalBytes int64 `json:"original_bytes"`
|
||||||
Files []File `json:"files"` // from info
|
Files []File `json:"files"`
|
||||||
Version string `json:"-"`
|
Version string `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +64,8 @@ func (i *TorrentInfo) UnmarshalJSON(data []byte) error {
|
|||||||
type Alias TorrentInfo
|
type Alias TorrentInfo
|
||||||
aux := &struct {
|
aux := &struct {
|
||||||
Progress float64 `json:"progress"`
|
Progress float64 `json:"progress"`
|
||||||
|
Added string `json:"added"`
|
||||||
|
Ended string `json:"ended"`
|
||||||
*Alias
|
*Alias
|
||||||
}{
|
}{
|
||||||
Alias: (*Alias)(i),
|
Alias: (*Alias)(i),
|
||||||
@@ -76,6 +76,13 @@ func (i *TorrentInfo) UnmarshalJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
i.Progress = int(math.Round(aux.Progress))
|
i.Progress = int(math.Round(aux.Progress))
|
||||||
|
|
||||||
|
i.Added = strings.Replace(aux.Added, "Z", "+01:00", 1)
|
||||||
|
|
||||||
|
if aux.Ended != "" {
|
||||||
|
i.Ended = strings.Replace(aux.Ended, "Z", "+01:00", 1)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user