added artist notes

This commit is contained in:
Hellow2 2023-02-06 09:16:28 +01:00
parent 7d570038b3
commit bbf7181b13
7 changed files with 43 additions and 90 deletions

View File

@ -58,10 +58,10 @@ print_song(song)
artist = song.main_artist_list[0]
print_artist(artist)
# print_artist(artist)
artist = EncyclopaediaMetallum.fetch_artist_details(artist)
# print_artist(artist)
print_artist(artist)
# print(only_smile)

View File

@ -10,7 +10,7 @@ from . import (
not_used_anymore,
target
)
from .not_used_anymore import metadata
from .utils.shared import (
MUSIC_DIR,
@ -49,20 +49,9 @@ Album = database.Album
ID3Timestamp = database.ID3Timestamp
MetadataSearch = metadata.MetadataSearch
MetadataDownload = metadata.MetadataDownload
cache = database.cache
Database = database.Database
def fetch_metadata(type_: str, id_: str):
metadata_downloader = MetadataDownload()
metadata_downloader.download({'type': type_, 'id': id_})
def fetch_metadata_from_search(search_instance: MetadataSearch):
current_option = search_instance.current_option
fetch_metadata(type_=current_option.type, id_=current_option.id)
def set_targets(genre: str):
@ -112,42 +101,6 @@ searches for the track <any track> from the release <any relaese>
print(msg)
def execute_input(_input: str, search: MetadataSearch) -> bool:
"""
:returns: True if it should break out of the loop else False
"""
query_input = _input.strip()
_input = _input.strip().lower()
if _input in ("d", "ok", "dl", "download"):
return True
if _input in ("q", "quit", "exit"):
exit()
if _input in ("h", "help"):
help_search_metadata()
return False
if _input.isdigit():
print()
print(search.choose(int(_input)))
return False
if _input == "..":
print()
print(search.get_previous_options())
return False
print()
print(search.search_from_query(query_input))
def search_for_metadata():
search = MetadataSearch()
while True:
_input = input("\"help\" for an overview of commands: ")
if execute_input(_input=_input, search=search):
break
print(f"downloading: {search.current_option}")
return search
def get_genre():
@ -166,36 +119,3 @@ def get_genre():
return existing_genres[genre_id]
return genre
def cli(start_at: int = 0, only_lyrics: bool = False):
if start_at <= 2 and not only_lyrics:
genre = get_genre()
logging.info(f"{genre} has been set as genre.")
if start_at <= 0:
search = search_for_metadata()
logging.info("Starting Downloading of metadata")
fetch_metadata_from_search(search)
if start_at <= 1 and not only_lyrics:
logging.info("creating Paths")
set_targets(genre=genre)
if start_at <= 2 and not only_lyrics:
logging.info("Fetching Download Links")
fetch_sources(cache.get_tracks_without_src())
if start_at <= 3 and not only_lyrics:
logging.info("starting to download the mp3's")
fetch_audios(cache.get_tracks_to_download())
if start_at <= 4:
logging.info("starting to fetch the lyrics")
lyrics.fetch_lyrics(cache.get_tracks_for_lyrics())
def gtk_gui():
# please maximaly a minimal gui, the fully fleshed out gui should be made externally
# to avoid ending up with a huge monolyth
pass

View File

@ -16,5 +16,7 @@ Lyrics = objects.Lyrics
Album = objects.Album
Artist = objects.Artist
FormattedText = objects.FormattedText
Database = database.Database
cache = temp_database.TempDatabase()

View File

@ -2,7 +2,8 @@ from . import (
song,
metadata,
source,
parents
parents,
formatted_text
)
MusicObject = parents.DatabaseObject
@ -21,3 +22,5 @@ Target = song.Target
Lyrics = song.Lyrics
Album = song.Album
FormattedText = formatted_text.FormattedText

View File

@ -51,6 +51,10 @@ class FormattedText:
return None
return pandoc.write(self.doc, format="plain").strip()
plaintext = property(fget=get_plaintext, fset=set_plaintext)
markdown = property(fget=get_markdown, fset=set_markdown)
html = property(fget=get_html, fset=set_html)
class NotesAttributes:
def __init__(self) -> None:

View File

@ -23,6 +23,7 @@ from .source import (
SourcePages,
SourceAttribute
)
from .formatted_text import FormattedText
"""
All Objects dependent
@ -363,7 +364,7 @@ class Artist(DatabaseObject, SourceAttribute, MetadataAttribute):
feature_songs: List[Song] = None,
main_albums: List[Album] = None,
album_type: str = None,
notes: str = None,
notes: FormattedText = None,
lyrical_themes: List[str] = None,
general_genre: str = "",
country=None,
@ -382,7 +383,9 @@ class Artist(DatabaseObject, SourceAttribute, MetadataAttribute):
which are meant to only use in outputs to describe the object
i mean do as you want but there aint no strict rule about em so good luck
"""
self.notes = notes
self.notes: FormattedText = notes
if self.notes is None:
self.notes = FormattedText()
self.lyrical_themes: List[str] = lyrical_themes
if self.lyrical_themes is None:
self.lyrical_themes = []
@ -406,7 +409,11 @@ class Artist(DatabaseObject, SourceAttribute, MetadataAttribute):
self.source_list = source_list
def __str__(self):
return self.name or ""
string = self.name or ""
plaintext_notes = self.notes.get_plaintext()
if plaintext_notes is not None:
string += "\n" + plaintext_notes
return string
def __repr__(self):
return self.__str__()

View File

@ -15,7 +15,8 @@ from ..database import (
SourcePages,
Song,
Album,
ID3Timestamp
ID3Timestamp,
FormattedText
)
from ..utils import (
string_processing
@ -383,6 +384,19 @@ class EncyclopaediaMetallum(Page):
return artist
@classmethod
def fetch_band_notes(cls, artist: Artist, ma_artist_id: str) -> Artist:
endpoint = "https://www.metal-archives.com/band/read-more/id/{}"
# make the request
r = cls.API_SESSION.get(endpoint.format(ma_artist_id))
if r.status_code != 200:
LOGGER.warning(f"code {r.status_code} at {endpoint.format(ma_artist_id)}")
return artist
artist.notes.html = r.text
return artist
@classmethod
def fetch_artist_details(cls, artist: Artist) -> Artist:
source_list = artist.get_sources_from_page(cls.SOURCE_TYPE)
@ -397,12 +411,12 @@ class EncyclopaediaMetallum(Page):
"""
TODO
[] https://www.metal-archives.com/bands/Ghost_Bath/3540372489
[x] https://www.metal-archives.com/bands/Ghost_Bath/3540372489
[x] https://www.metal-archives.com/band/discography/id/3540372489/tab/all
[] reviews: https://www.metal-archives.com/review/ajax-list-band/id/3540372489/json/1?sEcho=1&iColumns=4&sColumns=&iDisplayStart=0&iDisplayLength=200&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&mDataProp_3=3&iSortCol_0=3&sSortDir_0=desc&iSortingCols=1&bSortable_0=true&bSortable_1=true&bSortable_2=true&bSortable_3=true&_=1675155257133
[] simmilar: https://www.metal-archives.com/band/ajax-recommendations/id/3540372489
[x] sources: https://www.metal-archives.com/link/ajax-list/type/band/id/3540372489
[] band notes: https://www.metal-archives.com/band/read-more/id/3540372489
[x] band notes: https://www.metal-archives.com/band/read-more/id/3540372489
"""
# SIMPLE METADATA
@ -414,4 +428,7 @@ class EncyclopaediaMetallum(Page):
# EXTERNAL SOURCES
artist = cls.fetch_artist_sources(artist, artist_id)
# ARTIST NOTES
artist = cls.fetch_band_notes(artist, artist_id)
return artist