Compare commits

..

2 Commits

Author SHA1 Message Date
Hazel Noack
d74a324999 ability to reference source type 2025-10-09 13:40:40 +02:00
Hazel Noack
184ffdf2b8 removed prints 2025-10-09 13:36:42 +02:00
3 changed files with 7 additions and 13 deletions

View File

@@ -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)

View File

@@ -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{},

View File

@@ -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) {
}