Skip to content

Commit

Permalink
refactor: project structure & func/var naming (#170)
Browse files Browse the repository at this point in the history
* refactor: project structure & func/var naming

* chore: update header year

* ci(goreleaser): fix deprecation

* ci(goreleaser): fix typo and version
  • Loading branch information
nuxencs authored Mar 1, 2025
1 parent 4d8959f commit cb759bd
Show file tree
Hide file tree
Showing 33 changed files with 427 additions and 406 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
version: "~> v2"
args: release --clean --skip=validate,publish --parallelism 5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -83,7 +83,7 @@ jobs:
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*.dll
*.so
*.dylib
.DS_Store*

# Test binary, built with `go test -c`
*.test
Expand Down
12 changes: 7 additions & 5 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
version: 2

before:
hooks:
- go mod tidy
Expand Down Expand Up @@ -39,7 +41,7 @@ archives:
- seasonpackarr
format_overrides:
- goos: windows
format: zip
formats: [ "zip" ]
files:
- none*
name_template: >-
Expand All @@ -59,11 +61,11 @@ release:
- `docker pull ghcr.io/nuxencs/seasonpackarr:{{ .Tag }}`
## What to do next?
- Read the [documentation](https://github.com/nuxencs/seasonpackarr#readme)
checksum:
name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt'
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"

changelog:
sort: asc
Expand All @@ -74,10 +76,10 @@ changelog:
- Merge remote-tracking branch
- Merge branch
groups:
- title: 'New Features'
- title: "New Features"
regexp: "^.*feat[(\\w)]*:+.*$"
order: 0
- title: 'Bug fixes'
- title: "Bug fixes"
regexp: "^.*fix[(\\w)]*:+.*$"
order: 10
- title: Other work
Expand Down
2 changes: 1 addition & 1 deletion cmd/genToken.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 - 2024, nuxen and the seasonpackarr contributors.
// Copyright (c) 2023 - 2025, nuxen and the seasonpackarr contributors.
// SPDX-License-Identifier: GPL-2.0-or-later

package cmd
Expand Down
6 changes: 3 additions & 3 deletions cmd/pack.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 - 2024, nuxen and the seasonpackarr contributors.
// Copyright (c) 2023 - 2025, nuxen and the seasonpackarr contributors.
// SPDX-License-Identifier: GPL-2.0-or-later

package cmd
Expand All @@ -24,13 +24,13 @@ var packCmd = &cobra.Command{

rlsName = args[0]

body, err := payload.CompilePackPayload(rlsName, clientName)
body, err := payload.CompilePack(rlsName, clientName)
if err != nil {
fmt.Println(err.Error())
return
}

err = payload.ExecRequest(fmt.Sprintf("http://%s:%d/api/pack", host, port), body, apiKey)
err = payload.Exec(fmt.Sprintf("http://%s:%d/api/pack", host, port), body, apiKey)
if err != nil {
fmt.Println(err.Error())
return
Expand Down
6 changes: 3 additions & 3 deletions cmd/parse.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 - 2024, nuxen and the seasonpackarr contributors.
// Copyright (c) 2023 - 2025, nuxen and the seasonpackarr contributors.
// SPDX-License-Identifier: GPL-2.0-or-later

package cmd
Expand Down Expand Up @@ -62,13 +62,13 @@ var parseCmd = &cobra.Command{
}
}

body, err = payload.CompileParsePayload(rlsName, torrentBytes, clientName)
body, err = payload.CompileParse(rlsName, torrentBytes, clientName)
if err != nil {
fmt.Println(err.Error())
return
}

err = payload.ExecRequest(fmt.Sprintf("http://%s:%d/api/parse", host, port), body, apiKey)
err = payload.Exec(fmt.Sprintf("http://%s:%d/api/parse", host, port), body, apiKey)
if err != nil {
fmt.Println(err.Error())
return
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 - 2024, nuxen and the seasonpackarr contributors.
// Copyright (c) 2023 - 2025, nuxen and the seasonpackarr contributors.
// SPDX-License-Identifier: GPL-2.0-or-later

package cmd
Expand Down
4 changes: 2 additions & 2 deletions cmd/start.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 - 2024, nuxen and the seasonpackarr contributors.
// Copyright (c) 2023 - 2025, nuxen and the seasonpackarr contributors.
// SPDX-License-Identifier: GPL-2.0-or-later

package cmd
Expand Down Expand Up @@ -63,7 +63,7 @@ var startCmd = &cobra.Command{

select {
case sig := <-sigCh:
log.Info().Msgf("received signal: %q, shutting down server.", sig.String())
log.Info().Msgf("received signal: %q, shutting down server.", sig)
os.Exit(0)

case err := <-errorChannel:
Expand Down
2 changes: 1 addition & 1 deletion cmd/test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 - 2024, nuxen and the seasonpackarr contributors.
// Copyright (c) 2023 - 2025, nuxen and the seasonpackarr contributors.
// SPDX-License-Identifier: GPL-2.0-or-later

package cmd
Expand Down
10 changes: 5 additions & 5 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (c) 2023 - 2024, nuxen and the seasonpackarr contributors.
// Copyright (c) 2023 - 2025, nuxen and the seasonpackarr contributors.
// SPDX-License-Identifier: GPL-2.0-or-later

package cmd

import (
"encoding/json"
"fmt"
netHTTP "net/http"
"net/http"
"os"
"time"

Expand All @@ -24,13 +24,13 @@ var versionCmd = &cobra.Command{
fmt.Printf("Version: %v\nCommit: %v\nBuild date: %v\n", buildinfo.Version, buildinfo.Commit, buildinfo.Date)

// get the latest release tag from api
client := netHTTP.Client{
client := http.Client{
Timeout: 10 * time.Second,
}

resp, err := client.Get("https://api.github.com/repos/nuxencs/seasonpackarr/releases/latest")
if err != nil {
if errors.Is(err, netHTTP.ErrHandlerTimeout) {
if errors.Is(err, http.ErrHandlerTimeout) {
fmt.Println("Server timed out while fetching latest release from api")
} else {
fmt.Printf("Failed to fetch latest release from api: %v\n", err)
Expand All @@ -40,7 +40,7 @@ var versionCmd = &cobra.Command{
defer resp.Body.Close()

// api returns 500 instead of 404 here
if resp.StatusCode == netHTTP.StatusNotFound || resp.StatusCode == netHTTP.StatusInternalServerError {
if resp.StatusCode == http.StatusNotFound || resp.StatusCode == http.StatusInternalServerError {
fmt.Print("No release found")
os.Exit(1)
}
Expand Down
69 changes: 34 additions & 35 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,82 +3,81 @@ module github.com/nuxencs/seasonpackarr
go 1.23.0

require (
github.com/anacrolix/torrent v1.57.1
github.com/anacrolix/torrent v1.58.1
github.com/autobrr/go-qbittorrent v1.11.0
github.com/dlclark/regexp2 v1.11.4
github.com/dlclark/regexp2 v1.11.5
github.com/fsnotify/fsnotify v1.8.0
github.com/gin-contrib/cors v1.7.2
github.com/gin-contrib/requestid v1.0.3
github.com/gin-contrib/cors v1.7.3
github.com/gin-contrib/requestid v1.0.4
github.com/gin-gonic/gin v1.10.0
github.com/google/uuid v1.6.0
github.com/moistari/rls v0.5.12
github.com/mrobinsn/go-tvmaze v1.2.1
github.com/pkg/errors v0.9.1
github.com/puzpuzpuz/xsync/v3 v3.4.0
github.com/puzpuzpuz/xsync/v3 v3.5.1
github.com/rs/zerolog v1.33.0
github.com/spf13/cobra v1.8.1
github.com/spf13/cobra v1.9.1
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
)

require (
github.com/Masterminds/semver v1.5.0 // indirect
github.com/anacrolix/generics v0.0.3-0.20240902042256-7fb2702ef0ca // indirect
github.com/anacrolix/missinggo v1.3.0 // indirect
github.com/anacrolix/missinggo/v2 v2.7.4 // indirect
github.com/anacrolix/missinggo/v2 v2.8.0 // indirect
github.com/avast/retry-go v3.0.0+incompatible // indirect
github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect
github.com/bytedance/sonic v1.12.2 // indirect
github.com/bytedance/sonic/loader v0.2.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/bytedance/sonic v1.12.9 // indirect
github.com/bytedance/sonic/loader v0.2.3 // indirect
github.com/cloudwego/base64x v0.1.5 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
github.com/gin-contrib/sse v1.0.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.22.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/go-playground/validator/v10 v10.25.0 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-multihash v0.2.3 // indirect
github.com/multiformats/go-varint v0.0.6 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/locafero v0.7.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/afero v1.12.0 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.9.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
golang.org/x/arch v0.14.0 // indirect
golang.org/x/crypto v0.35.0 // indirect
golang.org/x/exp v0.0.0-20250228200357-dead58393ab7 // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/text v0.22.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.1.6 // indirect
lukechampine.com/blake3 v1.4.0 // indirect
)
Loading

0 comments on commit cb759bd

Please sign in to comment.