refactored source
This commit is contained in:
parent
66fb904f95
commit
54e24df0d1
@ -52,7 +52,7 @@ def real_download():
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
music_kraken.cli(genre="test", command_list=[
|
music_kraken.cli(genre="test", command_list=[
|
||||||
"#a Ghost Bath",
|
"#a Molchat Doma",
|
||||||
"1",
|
"0",
|
||||||
"ok"
|
"ok"
|
||||||
])
|
])
|
||||||
|
@ -3,55 +3,12 @@ from enum import Enum
|
|||||||
from typing import List, Dict, Tuple, Optional
|
from typing import List, Dict, Tuple, Optional
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
from ..utils.enums.source import SourcePages, SourceTypes
|
||||||
from .metadata import Mapping, Metadata
|
from .metadata import Mapping, Metadata
|
||||||
from .parents import DatabaseObject
|
from .parents import DatabaseObject
|
||||||
from .collection import Collection
|
from .collection import Collection
|
||||||
|
|
||||||
|
|
||||||
class SourceTypes(Enum):
|
|
||||||
SONG = "song"
|
|
||||||
ALBUM = "album"
|
|
||||||
ARTIST = "artist"
|
|
||||||
LYRICS = "lyrics"
|
|
||||||
|
|
||||||
|
|
||||||
class SourcePages(Enum):
|
|
||||||
YOUTUBE = "youtube"
|
|
||||||
MUSIFY = "musify"
|
|
||||||
GENIUS = "genius"
|
|
||||||
MUSICBRAINZ = "musicbrainz"
|
|
||||||
ENCYCLOPAEDIA_METALLUM = "encyclopaedia metallum"
|
|
||||||
BANDCAMP = "bandcamp"
|
|
||||||
DEEZER = "deezer"
|
|
||||||
SPOTIFY = "spotify"
|
|
||||||
|
|
||||||
# This has nothing to do with audio, but bands can be here
|
|
||||||
WIKIPEDIA = "wikipedia"
|
|
||||||
INSTAGRAM = "instagram"
|
|
||||||
FACEBOOK = "facebook"
|
|
||||||
TWITTER = "twitter" # I will use nitter though lol
|
|
||||||
MYSPACE = "myspace" # Yes somehow this ancient site is linked EVERYWHERE
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_homepage(cls, attribute) -> str:
|
|
||||||
homepage_map = {
|
|
||||||
cls.YOUTUBE: "https://www.youtube.com/",
|
|
||||||
cls.MUSIFY: "https://musify.club/",
|
|
||||||
cls.MUSICBRAINZ: "https://musicbrainz.org/",
|
|
||||||
cls.ENCYCLOPAEDIA_METALLUM: "https://www.metal-archives.com/",
|
|
||||||
cls.GENIUS: "https://genius.com/",
|
|
||||||
cls.BANDCAMP: "https://bandcamp.com/",
|
|
||||||
cls.DEEZER: "https://www.deezer.com/",
|
|
||||||
cls.INSTAGRAM: "https://www.instagram.com/",
|
|
||||||
cls.FACEBOOK: "https://www.facebook.com/",
|
|
||||||
cls.SPOTIFY: "https://open.spotify.com/",
|
|
||||||
cls.TWITTER: "https://twitter.com/",
|
|
||||||
cls.MYSPACE: "https://myspace.com/",
|
|
||||||
cls.WIKIPEDIA: "https://en.wikipedia.org/wiki/Main_Page"
|
|
||||||
}
|
|
||||||
return homepage_map[attribute]
|
|
||||||
|
|
||||||
|
|
||||||
class Source(DatabaseObject):
|
class Source(DatabaseObject):
|
||||||
"""
|
"""
|
||||||
create somehow like that
|
create somehow like that
|
||||||
@ -62,18 +19,27 @@ class Source(DatabaseObject):
|
|||||||
"""
|
"""
|
||||||
COLLECTION_ATTRIBUTES = tuple()
|
COLLECTION_ATTRIBUTES = tuple()
|
||||||
SIMPLE_ATTRIBUTES = {
|
SIMPLE_ATTRIBUTES = {
|
||||||
"type_enum": None,
|
|
||||||
"page_enum": None,
|
"page_enum": None,
|
||||||
"url": None
|
"url": None,
|
||||||
|
"referer_page": None,
|
||||||
|
"audio_url": None
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, page_enum: SourcePages, url: str, id_: str = None, type_enum=None) -> None:
|
def __init__(
|
||||||
|
self,
|
||||||
|
page_enum: SourcePages,
|
||||||
|
url: str,
|
||||||
|
id_: str = None,
|
||||||
|
referer_page: SourceTypes = None,
|
||||||
|
adio_url: str = None
|
||||||
|
) -> None:
|
||||||
DatabaseObject.__init__(self, id_=id_)
|
DatabaseObject.__init__(self, id_=id_)
|
||||||
|
|
||||||
self.type_enum = type_enum
|
|
||||||
self.page_enum = page_enum
|
self.page_enum = page_enum
|
||||||
|
self.referer_page = page_enum if referer_page is None else referer_page
|
||||||
|
|
||||||
self.url = url
|
self.url = url
|
||||||
|
self.audio_url = adio_url
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def match_url(cls, url: str) -> Optional["Source"]:
|
def match_url(cls, url: str) -> Optional["Source"]:
|
||||||
|
0
src/music_kraken/utils/enums/__init__.py
Normal file
0
src/music_kraken/utils/enums/__init__.py
Normal file
45
src/music_kraken/utils/enums/source.py
Normal file
45
src/music_kraken/utils/enums/source.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class SourceTypes(Enum):
|
||||||
|
SONG = "song"
|
||||||
|
ALBUM = "album"
|
||||||
|
ARTIST = "artist"
|
||||||
|
LYRICS = "lyrics"
|
||||||
|
|
||||||
|
|
||||||
|
class SourcePages(Enum):
|
||||||
|
YOUTUBE = "youtube"
|
||||||
|
MUSIFY = "musify"
|
||||||
|
GENIUS = "genius"
|
||||||
|
MUSICBRAINZ = "musicbrainz"
|
||||||
|
ENCYCLOPAEDIA_METALLUM = "encyclopaedia metallum"
|
||||||
|
BANDCAMP = "bandcamp"
|
||||||
|
DEEZER = "deezer"
|
||||||
|
SPOTIFY = "spotify"
|
||||||
|
|
||||||
|
# This has nothing to do with audio, but bands can be here
|
||||||
|
WIKIPEDIA = "wikipedia"
|
||||||
|
INSTAGRAM = "instagram"
|
||||||
|
FACEBOOK = "facebook"
|
||||||
|
TWITTER = "twitter" # I will use nitter though lol
|
||||||
|
MYSPACE = "myspace" # Yes somehow this ancient site is linked EVERYWHERE
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_homepage(cls, attribute) -> str:
|
||||||
|
homepage_map = {
|
||||||
|
cls.YOUTUBE: "https://www.youtube.com/",
|
||||||
|
cls.MUSIFY: "https://musify.club/",
|
||||||
|
cls.MUSICBRAINZ: "https://musicbrainz.org/",
|
||||||
|
cls.ENCYCLOPAEDIA_METALLUM: "https://www.metal-archives.com/",
|
||||||
|
cls.GENIUS: "https://genius.com/",
|
||||||
|
cls.BANDCAMP: "https://bandcamp.com/",
|
||||||
|
cls.DEEZER: "https://www.deezer.com/",
|
||||||
|
cls.INSTAGRAM: "https://www.instagram.com/",
|
||||||
|
cls.FACEBOOK: "https://www.facebook.com/",
|
||||||
|
cls.SPOTIFY: "https://open.spotify.com/",
|
||||||
|
cls.TWITTER: "https://twitter.com/",
|
||||||
|
cls.MYSPACE: "https://myspace.com/",
|
||||||
|
cls.WIKIPEDIA: "https://en.wikipedia.org/wiki/Main_Page"
|
||||||
|
}
|
||||||
|
return homepage_map[attribute]
|
Loading…
Reference in New Issue
Block a user