mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-06 05:16:38 +08:00
fix: stabilize library paths and subscription matching
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/ShukeBta/MediaStationGo/internal/model"
|
||||
)
|
||||
|
||||
func subscriptionRunLogFields(sub *model.Subscription) []zap.Field {
|
||||
fields := []zap.Field{}
|
||||
if sub == nil {
|
||||
return fields
|
||||
}
|
||||
return append(fields,
|
||||
zap.String("subscription_id", sub.ID),
|
||||
zap.String("subscription", sub.Name),
|
||||
zap.String("feed_kind", subscriptionFeedKind(sub.FeedURL)),
|
||||
zap.String("filter", sub.Filter),
|
||||
zap.String("media_type", sub.MediaType),
|
||||
zap.String("media_category", sub.MediaCategory),
|
||||
zap.String("search_mode", sub.SearchMode),
|
||||
zap.Bool("enabled", sub.Enabled),
|
||||
zap.Bool("wash_enabled", sub.WashEnabled),
|
||||
zap.String("wash_priority", sub.WashPriority),
|
||||
zap.Int("total_episodes", sub.TotalEpisodes),
|
||||
)
|
||||
}
|
||||
|
||||
func appendSubscriptionRunResultFields(fields []zap.Field, queued int, started time.Time) []zap.Field {
|
||||
return append(fields,
|
||||
zap.Int("queued", queued),
|
||||
zap.Int64("duration_ms", time.Since(started).Milliseconds()),
|
||||
)
|
||||
}
|
||||
|
||||
func subscriptionFeedKind(feedURL string) string {
|
||||
raw := strings.TrimSpace(feedURL)
|
||||
if raw == "" {
|
||||
return "empty"
|
||||
}
|
||||
lower := strings.ToLower(raw)
|
||||
if strings.HasPrefix(lower, "site-search://") {
|
||||
return "site-search"
|
||||
}
|
||||
parsed, err := url.Parse(raw)
|
||||
if err == nil && parsed.Scheme != "" {
|
||||
return parsed.Scheme
|
||||
}
|
||||
return "unknown"
|
||||
}
|
||||
Reference in New Issue
Block a user