Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"path/filepath"
"strings"

syncpkg "plex-language-sync/internal/sync"
"plex-language-sync/internal/timeutil"
syncpkg "github.com/cplieger/plex-language-sync/internal/sync"
"github.com/cplieger/plex-language-sync/internal/timeutil"
)

// ---------------------------------------------------------------------------
Expand All @@ -42,19 +42,19 @@ const (
// ---------------------------------------------------------------------------

type config struct {
plexURL string
plexToken string
updateLevel string // "show" or "season"
updateStrategy string // "all" or "next"
schedulerTime string // "HH:MM"
caCertPath string
ignoreLabels []string
ignoreLibraries []string
triggerOnPlay bool
triggerOnScan bool
schedulerEnable bool
languageProfiles bool
debug bool
plexURL string
plexToken string
updateLevel string // "show" or "season"
updateStrategy string // "all" or "next"
schedulerTime string // "HH:MM"
caCertPath string
ignoreLabels []string
ignoreLibraries []string
triggerOnPlay bool
triggerOnScan bool
schedulerEnable bool
languageProfiles bool
debug bool
}

// loadConfig reads environment variables into a config value, applying
Expand All @@ -71,17 +71,17 @@ func loadConfig() config {
&slog.HandlerOptions{Level: level})))

cfg := config{
plexURL: requireEnv("PLEX_URL"),
plexToken: requireEnv("PLEX_TOKEN"),
updateLevel: envOr("UPDATE_LEVEL", defaultUpdateLevel),
updateStrategy: envOr("UPDATE_STRATEGY", defaultUpdateStrategy),
triggerOnPlay: envBool("TRIGGER_ON_PLAY", true),
triggerOnScan: envBool("TRIGGER_ON_SCAN", true),
schedulerEnable: envBool("SCHEDULER_ENABLE", true),
languageProfiles: envBool("LANGUAGE_PROFILES", true),
schedulerTime: envOr("SCHEDULER_SCHEDULE_TIME", defaultScheduleTime),
debug: debug,
caCertPath: envOr("PLEX_CA_CERT_PATH", ""),
plexURL: requireEnv("PLEX_URL"),
plexToken: requireEnv("PLEX_TOKEN"),
updateLevel: envOr("UPDATE_LEVEL", defaultUpdateLevel),
updateStrategy: envOr("UPDATE_STRATEGY", defaultUpdateStrategy),
triggerOnPlay: envBool("TRIGGER_ON_PLAY", true),
triggerOnScan: envBool("TRIGGER_ON_SCAN", true),
schedulerEnable: envBool("SCHEDULER_ENABLE", true),
languageProfiles: envBool("LANGUAGE_PROFILES", true),
schedulerTime: envOr("SCHEDULER_SCHEDULE_TIME", defaultScheduleTime),
debug: debug,
caCertPath: envOr("PLEX_CA_CERT_PATH", ""),
}

if v := os.Getenv("IGNORE_LABELS"); v != "" {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module plex-language-sync
module github.com/cplieger/plex-language-sync

go 1.26.4

Expand Down
8 changes: 3 additions & 5 deletions health.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package main

import "github.com/cplieger/health"

// healthMarkerPath is the default marker location. Docker healthchecks
// stat this path; the app creates and removes it at lifecycle points.
// /tmp is conventional because strict-tier compose services mount
// /tmp as tmpfs (see base.yaml -strict templates).
const healthMarkerPath = "/tmp/.healthy"
// healthMarkerPath is the marker location, sourced from the library so
// the literal lives in exactly one place.
const healthMarkerPath = health.DefaultPath

// healthMarker wraps *health.Marker for backward-compatible usage in main.
type healthMarker = health.Marker
Expand Down
4 changes: 2 additions & 2 deletions internal/api/plex.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ package api
import (
"context"

"plex-language-sync/internal/plex"
"plex-language-sync/internal/streams"
"github.com/cplieger/plex-language-sync/internal/plex"
"github.com/cplieger/plex-language-sync/internal/streams"
)

// PlexReader is the read side of the Plex HTTP client as consumed by the
Expand Down
2 changes: 1 addition & 1 deletion internal/api/users.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package api

import "plex-language-sync/internal/plex"
import "github.com/cplieger/plex-language-sync/internal/plex"

// UserInfo is the minimal user record consumers pass across the api
// spine. Mirrors internal/users.Info but uses primitive string IDs so
Expand Down
3 changes: 1 addition & 2 deletions internal/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import (
"sync"

"github.com/cplieger/atomicfile"

"plex-language-sync/internal/api"
"github.com/cplieger/plex-language-sync/internal/api"
)

// Compile-time interface satisfaction assertion.
Expand Down
3 changes: 1 addition & 2 deletions internal/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import (
"testing"
"time"

"plex-language-sync/internal/testsupport/fakeapi"

"github.com/cplieger/plex-language-sync/internal/testsupport/fakeapi"
"pgregory.net/rapid"
)

Expand Down
6 changes: 3 additions & 3 deletions internal/ignore/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
"log/slog"
"slices"

"plex-language-sync/internal/api"
"plex-language-sync/internal/plex"
"plex-language-sync/internal/streams"
"github.com/cplieger/plex-language-sync/internal/api"
"github.com/cplieger/plex-language-sync/internal/plex"
"github.com/cplieger/plex-language-sync/internal/streams"
)

// Compile-time interface satisfaction assertion.
Expand Down
13 changes: 10 additions & 3 deletions internal/ignore/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"errors"
"testing"

"plex-language-sync/internal/api"
"plex-language-sync/internal/plex"
"plex-language-sync/internal/streams"
"github.com/cplieger/plex-language-sync/internal/api"
"github.com/cplieger/plex-language-sync/internal/plex"
"github.com/cplieger/plex-language-sync/internal/streams"
)

func TestPolicyIgnoreLibrary(t *testing.T) {
Expand Down Expand Up @@ -72,24 +72,31 @@ type stubReader struct {
func (r *stubReader) Episode(context.Context, plex.RatingKey) (*streams.Episode, error) {
panic("Episode: not used")
}

func (r *stubReader) ShowEpisodes(context.Context, plex.RatingKey) ([]streams.Episode, error) {
panic("ShowEpisodes: not used")
}

func (r *stubReader) SeasonEpisodes(context.Context, plex.RatingKey) ([]streams.Episode, error) {
panic("SeasonEpisodes: not used")
}

func (r *stubReader) ShowMetadata(_ context.Context, _ plex.RatingKey) (*plex.Show, error) {
return r.show, r.err
}

func (r *stubReader) RecentlyAdded(context.Context, plex.RatingKey, int64) ([]streams.Episode, error) {
panic("RecentlyAdded: not used")
}

func (r *stubReader) History(context.Context, int64) ([]plex.HistoryItem, error) {
panic("History: not used")
}

func (r *stubReader) ShowSections(context.Context) ([]plex.Section, error) {
panic("ShowSections: not used")
}

func (r *stubReader) UserFromSession(context.Context, string) (string, string, error) {
panic("UserFromSession: not used")
}
Expand Down
3 changes: 1 addition & 2 deletions internal/notify/classify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
"testing"

"github.com/coder/websocket"

"plex-language-sync/internal/plex"
"github.com/cplieger/plex-language-sync/internal/plex"
)

// TestClassifyError covers the substring-free, typed-sentinel
Expand Down
2 changes: 1 addition & 1 deletion internal/notify/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
// nopHandler is a no-op Handler for fuzz dispatch safety.
type nopHandler struct{}

func (nopHandler) OnPlay(_ context.Context, _ PlayEvent) {}
func (nopHandler) OnPlay(_ context.Context, _ PlayEvent) {}
func (nopHandler) OnTimeline(_ context.Context, _ []TimelineEntry) {}

func FuzzNotificationUnmarshal(f *testing.F) {
Expand Down
3 changes: 1 addition & 2 deletions internal/notify/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import (
"time"

"github.com/coder/websocket"
"github.com/cplieger/plex-language-sync/internal/plex"
"pgregory.net/rapid"

"plex-language-sync/internal/plex"
)

// fakeHandler records the events delivered by dispatch / Listen so
Expand Down
4 changes: 2 additions & 2 deletions internal/notify/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package notify
import (
"fmt"

"plex-language-sync/internal/cache"
"plex-language-sync/internal/plex"
"github.com/cplieger/plex-language-sync/internal/cache"
"github.com/cplieger/plex-language-sync/internal/plex"
)

// Plex wire-format constants used by the event predicates. These mirror
Expand Down
2 changes: 1 addition & 1 deletion internal/plex/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"
"testing"

"plex-language-sync/internal/streams"
"github.com/cplieger/plex-language-sync/internal/streams"
)

func FuzzSharedServersXMLUnmarshal(f *testing.F) {
Expand Down
2 changes: 1 addition & 1 deletion internal/plex/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"plex-language-sync/internal/streams"
"github.com/cplieger/plex-language-sync/internal/streams"
)

// ShowSections returns the TV-show library sections.
Expand Down
2 changes: 1 addition & 1 deletion internal/plex/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"fmt"
"strconv"

"plex-language-sync/internal/streams"
"github.com/cplieger/plex-language-sync/internal/streams"
)

// Plex wire-protocol constants. These strings/numbers appear in the
Expand Down
11 changes: 5 additions & 6 deletions internal/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ import (
"sync/atomic"
"time"

"github.com/cplieger/plex-language-sync/internal/api"
"github.com/cplieger/plex-language-sync/internal/cache"
"github.com/cplieger/plex-language-sync/internal/plex"
"github.com/cplieger/plex-language-sync/internal/streams"
"github.com/cplieger/plex-language-sync/internal/timeutil"
"golang.org/x/sync/singleflight"

"plex-language-sync/internal/api"
"plex-language-sync/internal/cache"
"plex-language-sync/internal/plex"
"plex-language-sync/internal/streams"
"plex-language-sync/internal/timeutil"
)

// deepAnalysisConcurrency is the upper bound on in-flight per-item work
Expand Down
11 changes: 6 additions & 5 deletions internal/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"testing"
"time"

"plex-language-sync/internal/api"
"plex-language-sync/internal/ignore"
"plex-language-sync/internal/plex"
"plex-language-sync/internal/streams"
"plex-language-sync/internal/testsupport/fakeapi"
"github.com/cplieger/plex-language-sync/internal/api"
"github.com/cplieger/plex-language-sync/internal/ignore"
"github.com/cplieger/plex-language-sync/internal/plex"
"github.com/cplieger/plex-language-sync/internal/streams"
"github.com/cplieger/plex-language-sync/internal/testsupport/fakeapi"
)

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -72,6 +72,7 @@ type fakeSyncer struct {
func (s *fakeSyncer) ChangeTracksForEpisode(_ context.Context, _ api.PlexReadWriter, _ string, _ *streams.Episode, _ string) {
s.changeCalls.Add(1)
}

func (s *fakeSyncer) ProcessNewOrUpdatedEpisodeAllUsers(_ context.Context, _ *streams.Episode, _ string) {
s.processCalls.Add(1)
}
Expand Down
19 changes: 14 additions & 5 deletions internal/streams/score_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,20 @@ func TestSubtitleCodecScore(t *testing.T) {
codec string
want int
}{
{"ass", 3}, {"ssa", 3}, {"ASS", 3},
{"pgs", 2}, {"vobsub", 2}, {"dvdsub", 2},
{"dvb_subtitle", 2}, {"hdmv_pgs_subtitle", 2},
{"srt", 1}, {"subrip", 1}, {"mov_text", 1}, {"webvtt", 1},
{"", 0}, {"unknown", 0},
{"ass", 3},
{"ssa", 3},
{"ASS", 3},
{"pgs", 2},
{"vobsub", 2},
{"dvdsub", 2},
{"dvb_subtitle", 2},
{"hdmv_pgs_subtitle", 2},
{"srt", 1},
{"subrip", 1},
{"mov_text", 1},
{"webvtt", 1},
{"", 0},
{"unknown", 0},
}
for _, tt := range tests {
t.Run(tt.codec, func(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions internal/sync/episode.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"log/slog"
"slices"

"plex-language-sync/internal/api"
"plex-language-sync/internal/plex"
"plex-language-sync/internal/streams"
"github.com/cplieger/plex-language-sync/internal/api"
"github.com/cplieger/plex-language-sync/internal/plex"
"github.com/cplieger/plex-language-sync/internal/streams"
)

// EpisodeRef bundles a shared reference episode and its selected
Expand Down
4 changes: 2 additions & 2 deletions internal/sync/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"log/slog"

"plex-language-sync/internal/api"
"plex-language-sync/internal/streams"
"github.com/cplieger/plex-language-sync/internal/api"
"github.com/cplieger/plex-language-sync/internal/streams"
)

// ApplyLanguageProfile applies a learned language profile to a new
Expand Down
6 changes: 3 additions & 3 deletions internal/sync/tracks.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
"log/slog"
"strings"

"plex-language-sync/internal/api"
"plex-language-sync/internal/plex"
"plex-language-sync/internal/streams"
"github.com/cplieger/plex-language-sync/internal/api"
"github.com/cplieger/plex-language-sync/internal/plex"
"github.com/cplieger/plex-language-sync/internal/streams"
)

// Config captures the subset of application configuration the Syncer
Expand Down
10 changes: 5 additions & 5 deletions internal/sync/tracks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"errors"
"testing"

"plex-language-sync/internal/api"
"plex-language-sync/internal/ignore"
"plex-language-sync/internal/plex"
"plex-language-sync/internal/streams"
"plex-language-sync/internal/testsupport/fakeapi"
"github.com/cplieger/plex-language-sync/internal/api"
"github.com/cplieger/plex-language-sync/internal/ignore"
"github.com/cplieger/plex-language-sync/internal/plex"
"github.com/cplieger/plex-language-sync/internal/streams"
"github.com/cplieger/plex-language-sync/internal/testsupport/fakeapi"
)

// ---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion internal/testsupport/fakeapi/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"sync"
"time"

"plex-language-sync/internal/api"
"github.com/cplieger/plex-language-sync/internal/api"
)

// Cache is a concurrency-safe in-memory implementation of api.Cache.
Expand Down
Loading