draft
This commit is contained in:
parent
b1cc6506d0
commit
fefa69e92a
6
.vscode/settings.json
vendored
Normal file
6
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"musify",
|
||||
"Musify"
|
||||
]
|
||||
}
|
@ -1 +0,0 @@
|
||||
package data
|
@ -1,15 +1,39 @@
|
||||
package data
|
||||
|
||||
type MusicObject interface {
|
||||
}
|
||||
|
||||
type Song struct {
|
||||
Id int
|
||||
|
||||
Name string
|
||||
UnifiedName string
|
||||
Isrc string
|
||||
Genre string
|
||||
Note string
|
||||
Tracksort int
|
||||
Artwork string
|
||||
|
||||
Album Album
|
||||
Artists []Artist
|
||||
|
||||
Sources []Source
|
||||
}
|
||||
|
||||
type Album struct {
|
||||
Id int
|
||||
|
||||
Name string
|
||||
UnifiedName string
|
||||
|
||||
Songs []Song
|
||||
Artists []Artist
|
||||
|
||||
Sources []Source
|
||||
}
|
||||
|
||||
type Artist struct {
|
||||
Id int
|
||||
|
||||
Name string
|
||||
UnifiedName string
|
||||
|
||||
Albums []Album
|
||||
|
||||
Sources []Source
|
||||
}
|
||||
|
37
internal/plugin/interface.go
Normal file
37
internal/plugin/interface.go
Normal file
@ -0,0 +1,37 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"regexp"
|
||||
|
||||
"gitea.elara.ws/Hazel/music-kraken/internal/data"
|
||||
)
|
||||
|
||||
type Plugin interface {
|
||||
GetRegex() regexp.Regexp
|
||||
|
||||
Search(query string) []data.MusicObject
|
||||
|
||||
Fetch(source data.Source) data.MusicObject
|
||||
FetchSong(source data.Source) data.Song
|
||||
FetchAlbum(source data.Source) data.Album
|
||||
FetchArtist(source data.Source) data.Artist
|
||||
}
|
||||
|
||||
var plugins map[string]Plugin = make(map[string]Plugin)
|
||||
|
||||
func AddPlugin(plugin Plugin) {
|
||||
name := reflect.TypeOf(plugin).Name()
|
||||
|
||||
sourceType := data.SourceType{
|
||||
Name: reflect.TypeOf(plugin).Name(),
|
||||
Regex: plugin.GetRegex(),
|
||||
}
|
||||
|
||||
plugins[name] = pluginStorage{
|
||||
plugin: plugin,
|
||||
sourceType: sourceType,
|
||||
}
|
||||
|
||||
data.SourceTypes = append(data.SourceTypes, &sourceType)
|
||||
}
|
34
internal/plugin/musify.go
Normal file
34
internal/plugin/musify.go
Normal file
@ -0,0 +1,34 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
|
||||
"gitea.elara.ws/Hazel/music-kraken/internal/data"
|
||||
)
|
||||
|
||||
type Musify struct {
|
||||
}
|
||||
|
||||
func (m *Musify) GetRegex() regexp.Regexp {
|
||||
return *regexp.MustCompile(`(?i)https?://musify\.club/(artist|track|release)/[a-z\-0-9]+`)
|
||||
}
|
||||
|
||||
func (m *Musify) Fetch(source data.Source) data.MusicObject {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (m *Musify) FetchAlbum(source data.Source) data.Album {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (m *Musify) FetchArtist(source data.Source) data.Artist {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (m *Musify) FetchSong(source data.Source) data.Song {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (m *Musify) Search(query string) []data.MusicObject {
|
||||
panic("unimplemented")
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user