Compare commits
No commits in common. "fefa69e92af13b3b996c3b01d7691c64a61308e6" and "c43a7cb154f9854dbd739646cffad51bda3fe8ab" have entirely different histories.
fefa69e92a
...
c43a7cb154
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"cSpell.words": [
|
|
||||||
"musify",
|
|
||||||
"Musify"
|
|
||||||
]
|
|
||||||
}
|
|
1
internal/data/album.go
Normal file
1
internal/data/album.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package data
|
@ -1,39 +1,15 @@
|
|||||||
package data
|
package data
|
||||||
|
|
||||||
type MusicObject interface {
|
|
||||||
}
|
|
||||||
|
|
||||||
type Song struct {
|
type Song struct {
|
||||||
Id int
|
Id int
|
||||||
|
|
||||||
Name string
|
Name string
|
||||||
UnifiedName string
|
UnifiedName string
|
||||||
|
Isrc string
|
||||||
Album Album
|
Genre string
|
||||||
Artists []Artist
|
Note string
|
||||||
|
Tracksort int
|
||||||
Sources []Source
|
Artwork string
|
||||||
}
|
|
||||||
|
|
||||||
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
|
Sources []Source
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ type SourceType struct {
|
|||||||
|
|
||||||
var SourceTypes = []SourceType{
|
var SourceTypes = []SourceType{
|
||||||
{Name: "Youtube", Regex: *regexp.MustCompile(`(?i)\b(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})\b`)},
|
{Name: "Youtube", Regex: *regexp.MustCompile(`(?i)\b(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})\b`)},
|
||||||
{Name: "Musify", Regex: *regexp.MustCompile(`(?i)https?://musify\.club/(artist|track|release)/[a-z\-0-9]+`)},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetSourceType(name string) *SourceType {
|
func GetSourceType(name string) *SourceType {
|
||||||
|
@ -38,33 +38,3 @@ func TestYouTube(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMusify(t *testing.T) {
|
|
||||||
validUrls := []string{
|
|
||||||
"https://musify.club/artist/plohoyparen-645023",
|
|
||||||
"https://musify.club/track/plohoyparen-obgon-dve-sploshnie-poh-voobshe-9769231",
|
|
||||||
"https://musify.club/release/plohoyparen-hello-my-name-2018-1029885",
|
|
||||||
"https://musify.clUb/Release/plohoyParen-hello-my-name-2018-1029885",
|
|
||||||
}
|
|
||||||
invalidUrls := []string{
|
|
||||||
"https://musify.club/",
|
|
||||||
"https://musify.club/not-data-type",
|
|
||||||
"https://m.youtube.com/watch?v=dQw4w9WgXcQ",
|
|
||||||
}
|
|
||||||
|
|
||||||
st := GetSourceType("Musify")
|
|
||||||
|
|
||||||
for _, u := range validUrls {
|
|
||||||
_, err := st.NewSource(u)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf(`%q is a valid musify url`, u)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, u := range invalidUrls {
|
|
||||||
_, err := st.NewSource(u)
|
|
||||||
if err == nil {
|
|
||||||
t.Errorf(`%q is an invalid musify url`, u)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
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")
|
|
||||||
}
|
|
4
main.go
4
main.go
@ -4,13 +4,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"gitea.elara.ws/Hazel/music-kraken/internal/data"
|
"gitea.elara.ws/Hazel/music-kraken/internal/data"
|
||||||
"gitea.elara.ws/Hazel/music-kraken/internal/plugin"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
plugins := []plugin.Plugin{
|
|
||||||
&plugin.Musify{},
|
|
||||||
}
|
|
||||||
fmt.Println("music kraken")
|
fmt.Println("music kraken")
|
||||||
data.GetSourceType("Youtube")
|
data.GetSourceType("Youtube")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user