From d74a3249995a5e2f0d98f82b9be3d0d999a0a3d2 Mon Sep 17 00:00:00 2001 From: Hazel Noack Date: Thu, 9 Oct 2025 13:40:40 +0200 Subject: [PATCH] ability to reference source type --- internal/plugin/interface.go | 4 ++-- internal/plugin/musify.go | 6 ++++-- internal/plugin/plugin_test.go | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/plugin/interface.go b/internal/plugin/interface.go index 02f389a..f5effd7 100644 --- a/internal/plugin/interface.go +++ b/internal/plugin/interface.go @@ -15,7 +15,7 @@ type Plugin interface { RegexAlbum() *regexp.Regexp RegexSong() *regexp.Regexp - Init() + Init(data.SourceType) Search(query common.Query) ([]data.MusicObject, error) @@ -44,7 +44,7 @@ func RegisterPlugin(plugin Plugin) error { namePlugins[name] = plugin - plugin.Init() + plugin.Init(NameSourceType[name]) return nil } diff --git a/internal/plugin/musify.go b/internal/plugin/musify.go index 27163a1..3941f77 100644 --- a/internal/plugin/musify.go +++ b/internal/plugin/musify.go @@ -22,7 +22,8 @@ func extractName(s string) string { const musifyHost = "https://musify.club" type Musify struct { - session *scraper.Session + session *scraper.Session + sourceType data.SourceType } func (m Musify) Name() string { @@ -41,8 +42,9 @@ func (m Musify) RegexAlbum() *regexp.Regexp { return regexp.MustCompile(`(?i)https?://musify\.club/release/[a-z\-0-9]+`) } -func (m *Musify) Init() { +func (m *Musify) Init(sourceType data.SourceType) { m.session = scraper.NewSession() + m.sourceType = sourceType } func (m Musify) RegexSong() *regexp.Regexp { diff --git a/internal/plugin/plugin_test.go b/internal/plugin/plugin_test.go index 2850db1..1b2bb63 100644 --- a/internal/plugin/plugin_test.go +++ b/internal/plugin/plugin_test.go @@ -40,7 +40,7 @@ func (m MusifyTest) RegexSong() *regexp.Regexp { return regexp.MustCompile(`(?i)https?://musify\.club/track/[a-z\-0-9]+`) } -func (m *MusifyTest) Init() { +func (m *MusifyTest) Init(sourceType data.SourceType) { }