Compare commits
2 Commits
b5a78eb5b9
...
d74a324999
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d74a324999 | ||
|
|
184ffdf2b8 |
@@ -2,7 +2,6 @@ package plugin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"gitea.elara.ws/Hazel/music-kraken/internal/common"
|
||||
@@ -16,7 +15,7 @@ type Plugin interface {
|
||||
RegexAlbum() *regexp.Regexp
|
||||
RegexSong() *regexp.Regexp
|
||||
|
||||
Init()
|
||||
Init(data.SourceType)
|
||||
|
||||
Search(query common.Query) ([]data.MusicObject, error)
|
||||
|
||||
@@ -45,7 +44,7 @@ func RegisterPlugin(plugin Plugin) error {
|
||||
|
||||
namePlugins[name] = plugin
|
||||
|
||||
plugin.Init()
|
||||
plugin.Init(NameSourceType[name])
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -102,8 +101,6 @@ func compileSource(source data.Source) (data.Source, error) {
|
||||
|
||||
func FetchSource(source data.Source) (data.MusicObject, error) {
|
||||
// the fetch function without the post processing of the music objects
|
||||
fmt.Println("call")
|
||||
|
||||
source, err := compileSource(source)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -114,8 +111,6 @@ func FetchSource(source data.Source) (data.MusicObject, error) {
|
||||
return nil, errors.New("didn't find plugin of the name " + source.SourceType.Name)
|
||||
}
|
||||
|
||||
fmt.Println("call2", source)
|
||||
|
||||
if source.ObjectType == data.SongSource {
|
||||
song, err := plugin.FetchSong(source)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package plugin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
@@ -23,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 {
|
||||
@@ -42,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 {
|
||||
@@ -568,8 +569,6 @@ func parseAlbum(doc *goquery.Document) data.Album {
|
||||
}
|
||||
|
||||
func (m Musify) FetchAlbum(source data.Source) (data.Album, error) {
|
||||
fmt.Println("meow")
|
||||
|
||||
album := data.Album{
|
||||
Sources: []data.Source{source},
|
||||
Artists: []data.Artist{},
|
||||
|
||||
@@ -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) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user