ability to reference source type
This commit is contained in:
@@ -15,7 +15,7 @@ type Plugin interface {
|
|||||||
RegexAlbum() *regexp.Regexp
|
RegexAlbum() *regexp.Regexp
|
||||||
RegexSong() *regexp.Regexp
|
RegexSong() *regexp.Regexp
|
||||||
|
|
||||||
Init()
|
Init(data.SourceType)
|
||||||
|
|
||||||
Search(query common.Query) ([]data.MusicObject, error)
|
Search(query common.Query) ([]data.MusicObject, error)
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ func RegisterPlugin(plugin Plugin) error {
|
|||||||
|
|
||||||
namePlugins[name] = plugin
|
namePlugins[name] = plugin
|
||||||
|
|
||||||
plugin.Init()
|
plugin.Init(NameSourceType[name])
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ func extractName(s string) string {
|
|||||||
const musifyHost = "https://musify.club"
|
const musifyHost = "https://musify.club"
|
||||||
|
|
||||||
type Musify struct {
|
type Musify struct {
|
||||||
session *scraper.Session
|
session *scraper.Session
|
||||||
|
sourceType data.SourceType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m Musify) Name() string {
|
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]+`)
|
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.session = scraper.NewSession()
|
||||||
|
m.sourceType = sourceType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m Musify) RegexSong() *regexp.Regexp {
|
func (m Musify) RegexSong() *regexp.Regexp {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ func (m MusifyTest) RegexSong() *regexp.Regexp {
|
|||||||
return regexp.MustCompile(`(?i)https?://musify\.club/track/[a-z\-0-9]+`)
|
return regexp.MustCompile(`(?i)https?://musify\.club/track/[a-z\-0-9]+`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MusifyTest) Init() {
|
func (m *MusifyTest) Init(sourceType data.SourceType) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user