finished database integration and simmilar
This commit is contained in:
parent
3ddddf2f5f
commit
06cc826a21
@ -32,6 +32,7 @@ def div(msg: str = ""):
|
|||||||
cache = music_kraken.database.new_database.Database("test.db")
|
cache = music_kraken.database.new_database.Database("test.db")
|
||||||
cache.reset()
|
cache.reset()
|
||||||
|
|
||||||
|
|
||||||
def print_song(song_: Song):
|
def print_song(song_: Song):
|
||||||
print(str(song_.metadata))
|
print(str(song_.metadata))
|
||||||
print("----album--")
|
print("----album--")
|
||||||
@ -65,14 +66,16 @@ song = Song(
|
|||||||
language=pycountry.languages.get(alpha_2="en"),
|
language=pycountry.languages.get(alpha_2="en"),
|
||||||
label="cum productions",
|
label="cum productions",
|
||||||
source_list=[
|
source_list=[
|
||||||
Source(SourcePages.ENCYCLOPAEDIA_METALLUM, "https://www.metal-archives.com/albums/I%27m_in_a_Coffin/One_Final_Action/207614")
|
Source(SourcePages.ENCYCLOPAEDIA_METALLUM,
|
||||||
|
"https://www.metal-archives.com/albums/I%27m_in_a_Coffin/One_Final_Action/207614")
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
main_artist_list=[
|
main_artist_list=[
|
||||||
Artist(
|
Artist(
|
||||||
name="I'm in a coffin",
|
name="I'm in a coffin",
|
||||||
source_list=[
|
source_list=[
|
||||||
Source(SourcePages.ENCYCLOPAEDIA_METALLUM, "https://www.metal-archives.com/bands/I%27m_in_a_Coffin/127727")
|
Source(SourcePages.ENCYCLOPAEDIA_METALLUM,
|
||||||
|
"https://www.metal-archives.com/bands/I%27m_in_a_Coffin/127727")
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
Artist(name="some_split_artist")
|
Artist(name="some_split_artist")
|
||||||
@ -82,8 +85,6 @@ song = Song(
|
|||||||
|
|
||||||
print_song(song)
|
print_song(song)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
div()
|
div()
|
||||||
song_ref = song.reference
|
song_ref = song.reference
|
||||||
cache.push([song])
|
cache.push([song])
|
||||||
@ -97,44 +98,5 @@ print_song(song_from_db)
|
|||||||
# try writing metadata
|
# try writing metadata
|
||||||
write_metadata(song)
|
write_metadata(song)
|
||||||
|
|
||||||
exit()
|
|
||||||
|
|
||||||
# getting song by album ref
|
# getting song by album ref
|
||||||
div()
|
div()
|
||||||
song_output_list = cache.pull_songs(album_ref=album_input.reference)
|
|
||||||
print(len(song_output_list), song_output_list)
|
|
||||||
for song in song_output_list:
|
|
||||||
print(song, song.album)
|
|
||||||
|
|
||||||
# getting album
|
|
||||||
div("album")
|
|
||||||
album_output_list = cache.pull_albums(album_ref=album_input.reference)
|
|
||||||
album_output = album_output_list[0]
|
|
||||||
print(album_output)
|
|
||||||
print(f"--tracklist-{len(album_output)}--")
|
|
||||||
for track in album_output.tracklist:
|
|
||||||
print(track.tracksort, track)
|
|
||||||
print("--artist--")
|
|
||||||
for artist in album_output.artists:
|
|
||||||
print(artist)
|
|
||||||
|
|
||||||
# getting album by song
|
|
||||||
div()
|
|
||||||
album_output_list = cache.pull_albums(song_ref=song_ref)
|
|
||||||
print(album_output_list)
|
|
||||||
print("len of album ->", len(album_output_list[0]), album_output_list[0], sep=" | ")
|
|
||||||
|
|
||||||
# get artist
|
|
||||||
div("artist")
|
|
||||||
artist_output = cache.pull_artists(artist_ref=artist_ref)[0]
|
|
||||||
print(artist_output)
|
|
||||||
|
|
||||||
print("---static---")
|
|
||||||
print("albums", artist_output.main_albums)
|
|
||||||
print("main_s", artist_output.main_songs)
|
|
||||||
print("feat_s", artist_output.feature_songs)
|
|
||||||
|
|
||||||
print("---dynamic---")
|
|
||||||
print("discography", artist_output.discography)
|
|
||||||
print("songs", artist_output.songs, artist_output.songs.tracklist)
|
|
||||||
print("features", artist_output.features, artist_output.features.tracklist)
|
|
@ -161,9 +161,12 @@ class Database:
|
|||||||
|
|
||||||
for source in album.source_list:
|
for source in album.source_list:
|
||||||
source.type_enum = SourceTypes.ALBUM
|
source.type_enum = SourceTypes.ALBUM
|
||||||
|
source.add_song(album)
|
||||||
self.push_source(source=source)
|
self.push_source(source=source)
|
||||||
|
|
||||||
def push_song(self, song: Song):
|
def push_song(self, song: Song):
|
||||||
|
if song.dynamic:
|
||||||
|
return
|
||||||
# ADDING THE DATA FOR THE SONG OBJECT
|
# ADDING THE DATA FOR THE SONG OBJECT
|
||||||
"""
|
"""
|
||||||
db_field - object attribute
|
db_field - object attribute
|
||||||
@ -356,6 +359,7 @@ class Database:
|
|||||||
Gets a list of sources. if source_ref is passed in the List will most likely only
|
Gets a list of sources. if source_ref is passed in the List will most likely only
|
||||||
contain one Element if everything goes accordingly.
|
contain one Element if everything goes accordingly.
|
||||||
**If neither song_ref nor source_ref are passed in it will return ALL sources**
|
**If neither song_ref nor source_ref are passed in it will return ALL sources**
|
||||||
|
:param artist_ref:
|
||||||
:param song_ref:
|
:param song_ref:
|
||||||
:param source_ref:
|
:param source_ref:
|
||||||
:param type_str: the thing the source belongs to like eg. "song" or "album"
|
:param type_str: the thing the source belongs to like eg. "song" or "album"
|
||||||
@ -512,7 +516,6 @@ class Database:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if Album not in exclude_relations and song_result['album_id'] is not None:
|
if Album not in exclude_relations and song_result['album_id'] is not None:
|
||||||
print(dict(song_result))
|
|
||||||
album_obj = self.pull_albums(album_ref=Reference(song_result['album_id']),
|
album_obj = self.pull_albums(album_ref=Reference(song_result['album_id']),
|
||||||
exclude_relations=new_exclude_relations)
|
exclude_relations=new_exclude_relations)
|
||||||
if len(album_obj) > 0:
|
if len(album_obj) > 0:
|
||||||
|
@ -5,10 +5,6 @@ import dateutil.tz
|
|||||||
from mutagen import id3
|
from mutagen import id3
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from .parents import (
|
|
||||||
ID3Metadata
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Mapping(Enum):
|
class Mapping(Enum):
|
||||||
"""
|
"""
|
||||||
@ -253,7 +249,7 @@ class MetadataAttribute:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
class Metadata:
|
class Metadata:
|
||||||
# its a null byte for the later concatenation of text frames
|
# it's a null byte for the later concatenation of text frames
|
||||||
NULL_BYTE: str = "\x00"
|
NULL_BYTE: str = "\x00"
|
||||||
# this is pretty self-explanatory
|
# this is pretty self-explanatory
|
||||||
# the key is an enum from Mapping
|
# the key is an enum from Mapping
|
||||||
|
@ -64,13 +64,3 @@ class SongAttribute:
|
|||||||
self.song_ref = Reference(song_id)
|
self.song_ref = Reference(song_id)
|
||||||
|
|
||||||
song_ref_id = property(fget=get_ref_song_id, fset=set_ref_song_id)
|
song_ref_id = property(fget=get_ref_song_id, fset=set_ref_song_id)
|
||||||
|
|
||||||
|
|
||||||
class ID3Metadata:
|
|
||||||
def get_metadata(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_id3_dict(self) -> dict:
|
|
||||||
return {}
|
|
||||||
|
|
||||||
id3_dict: dict = property(fget=get_id3_dict)
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import os
|
import os
|
||||||
from typing import List, Tuple, Dict
|
from typing import List
|
||||||
import datetime
|
|
||||||
import pycountry
|
import pycountry
|
||||||
|
import copy
|
||||||
|
|
||||||
from .metadata import (
|
from .metadata import (
|
||||||
Mapping as ID3_MAPPING,
|
Mapping as id3Mapping,
|
||||||
ID3Timestamp,
|
ID3Timestamp,
|
||||||
MetadataAttribute
|
MetadataAttribute
|
||||||
)
|
)
|
||||||
@ -15,8 +15,7 @@ from ...utils.shared import (
|
|||||||
from .parents import (
|
from .parents import (
|
||||||
DatabaseObject,
|
DatabaseObject,
|
||||||
Reference,
|
Reference,
|
||||||
SongAttribute,
|
SongAttribute
|
||||||
ID3Metadata
|
|
||||||
)
|
)
|
||||||
from .source import (
|
from .source import (
|
||||||
Source,
|
Source,
|
||||||
@ -83,11 +82,11 @@ class Target(DatabaseObject, SongAttribute):
|
|||||||
class Lyrics(DatabaseObject, SongAttribute, SourceAttribute, MetadataAttribute):
|
class Lyrics(DatabaseObject, SongAttribute, SourceAttribute, MetadataAttribute):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
text: str,
|
text: str,
|
||||||
language: str,
|
language: str,
|
||||||
id_: str = None,
|
id_: str = None,
|
||||||
source_list: List[Source] = None
|
source_list: List[Source] = None
|
||||||
) -> None:
|
) -> None:
|
||||||
DatabaseObject.__init__(self, id_=id_)
|
DatabaseObject.__init__(self, id_=id_)
|
||||||
SongAttribute.__init__(self)
|
SongAttribute.__init__(self)
|
||||||
self.text = text
|
self.text = text
|
||||||
@ -134,7 +133,7 @@ class Song(DatabaseObject, SourceAttribute, MetadataAttribute):
|
|||||||
self.album_name: str | None = album_name
|
self.album_name: str | None = album_name
|
||||||
self.tracksort: int | None = tracksort
|
self.tracksort: int | None = tracksort
|
||||||
self.genre: str = genre
|
self.genre: str = genre
|
||||||
|
|
||||||
if source_list:
|
if source_list:
|
||||||
self.source_list = source_list
|
self.source_list = source_list
|
||||||
|
|
||||||
@ -196,15 +195,14 @@ class Song(DatabaseObject, SourceAttribute, MetadataAttribute):
|
|||||||
return str(self.tracksort)
|
return str(self.tracksort)
|
||||||
|
|
||||||
return f"{self.tracksort}/{len(self.album.tracklist)}"
|
return f"{self.tracksort}/{len(self.album.tracklist)}"
|
||||||
|
|
||||||
|
|
||||||
def get_metadata(self) -> MetadataAttribute.Metadata:
|
def get_metadata(self) -> MetadataAttribute.Metadata:
|
||||||
metadata = MetadataAttribute.Metadata({
|
metadata = MetadataAttribute.Metadata({
|
||||||
ID3_MAPPING.TITLE: [self.title],
|
id3Mapping.TITLE: [self.title],
|
||||||
ID3_MAPPING.ISRC: [self.isrc],
|
id3Mapping.ISRC: [self.isrc],
|
||||||
ID3_MAPPING.LENGTH: [str(self.length)],
|
id3Mapping.LENGTH: [str(self.length)],
|
||||||
ID3_MAPPING.GENRE: [self.genre],
|
id3Mapping.GENRE: [self.genre],
|
||||||
ID3_MAPPING.TRACKNUMBER: [self.tracksort_str]
|
id3Mapping.TRACKNUMBER: [self.tracksort_str]
|
||||||
})
|
})
|
||||||
|
|
||||||
metadata.merge_many([s.get_song_metadata() for s in self.source_list])
|
metadata.merge_many([s.get_song_metadata() for s in self.source_list])
|
||||||
@ -216,15 +214,17 @@ class Song(DatabaseObject, SourceAttribute, MetadataAttribute):
|
|||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
def set_album(self, album):
|
def set_album(self, album):
|
||||||
|
if album is None:
|
||||||
|
return
|
||||||
|
|
||||||
self._album = album
|
self._album = album
|
||||||
if self not in self._album.tracklist:
|
if self not in self._album.tracklist:
|
||||||
self._album.tracklist.append(self)
|
flat_copy = copy.copy(self)
|
||||||
|
flat_copy.dynamic = True
|
||||||
|
self._album.tracklist.append(flat_copy)
|
||||||
|
|
||||||
tracksort_str = property(fget=get_tracksort_str)
|
tracksort_str = property(fget=get_tracksort_str)
|
||||||
album = property(fget=lambda self: self._album, fset=set_album)
|
album = property(fget=lambda self: self._album, fset=set_album)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -313,11 +313,11 @@ class Album(DatabaseObject, SourceAttribute, MetadataAttribute):
|
|||||||
|
|
||||||
def get_metadata(self) -> MetadataAttribute.Metadata:
|
def get_metadata(self) -> MetadataAttribute.Metadata:
|
||||||
return MetadataAttribute.Metadata({
|
return MetadataAttribute.Metadata({
|
||||||
ID3_MAPPING.ALBUM: [self.title],
|
id3Mapping.ALBUM: [self.title],
|
||||||
ID3_MAPPING.COPYRIGHT: [self.copyright],
|
id3Mapping.COPYRIGHT: [self.copyright],
|
||||||
ID3_MAPPING.LANGUAGE: [self.iso_639_2_language],
|
id3Mapping.LANGUAGE: [self.iso_639_2_language],
|
||||||
ID3_MAPPING.ALBUM_ARTIST: [a.name for a in self.artists],
|
id3Mapping.ALBUM_ARTIST: [a.name for a in self.artists],
|
||||||
ID3_MAPPING.DATE: [self.date.timestamp]
|
id3Mapping.DATE: [self.date.timestamp]
|
||||||
})
|
})
|
||||||
|
|
||||||
def get_copyright(self) -> str:
|
def get_copyright(self) -> str:
|
||||||
@ -337,7 +337,6 @@ class Album(DatabaseObject, SourceAttribute, MetadataAttribute):
|
|||||||
tracklist = property(fget=lambda self: self._tracklist, fset=set_tracklist)
|
tracklist = property(fget=lambda self: self._tracklist, fset=set_tracklist)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
All objects dependent on Artist
|
All objects dependent on Artist
|
||||||
"""
|
"""
|
||||||
@ -391,7 +390,6 @@ class Artist(DatabaseObject, SourceAttribute, MetadataAttribute):
|
|||||||
def get_features(self) -> Album:
|
def get_features(self) -> Album:
|
||||||
feature_release = Album(
|
feature_release = Album(
|
||||||
title="features",
|
title="features",
|
||||||
copyright_=self.name,
|
|
||||||
album_status="dynamic",
|
album_status="dynamic",
|
||||||
is_split=True,
|
is_split=True,
|
||||||
albumsort=666,
|
albumsort=666,
|
||||||
@ -405,7 +403,6 @@ class Artist(DatabaseObject, SourceAttribute, MetadataAttribute):
|
|||||||
def get_songs(self) -> Album:
|
def get_songs(self) -> Album:
|
||||||
song_release = Album(
|
song_release = Album(
|
||||||
title="song collection",
|
title="song collection",
|
||||||
copyright_=self.name,
|
|
||||||
album_status="dynamic",
|
album_status="dynamic",
|
||||||
is_split=False,
|
is_split=False,
|
||||||
albumsort=666,
|
albumsort=666,
|
||||||
@ -429,13 +426,12 @@ class Artist(DatabaseObject, SourceAttribute, MetadataAttribute):
|
|||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
metadata = MetadataAttribute.Metadata({
|
metadata = MetadataAttribute.Metadata({
|
||||||
ID3_MAPPING.ARTIST: [self.name]
|
id3Mapping.ARTIST: [self.name]
|
||||||
})
|
})
|
||||||
metadata.merge_many([s.get_artist_metadata() for s in self.source_list])
|
metadata.merge_many([s.get_artist_metadata() for s in self.source_list])
|
||||||
|
|
||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
|
|
||||||
discography: List[Album] = property(fget=get_discography)
|
discography: List[Album] = property(fget=get_discography)
|
||||||
features: Album = property(fget=get_features)
|
features: Album = property(fget=get_features)
|
||||||
songs: Album = property(fget=get_songs)
|
songs: Album = property(fget=get_songs)
|
||||||
|
@ -5,7 +5,6 @@ from .metadata import Mapping, MetadataAttribute
|
|||||||
from .parents import (
|
from .parents import (
|
||||||
DatabaseObject,
|
DatabaseObject,
|
||||||
SongAttribute,
|
SongAttribute,
|
||||||
ID3Metadata
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ class EncyclopaediaMetallum(Page):
|
|||||||
|
|
||||||
SOURCE_TYPE = SourcePages.ENCYCLOPAEDIA_METALLUM
|
SOURCE_TYPE = SourcePages.ENCYCLOPAEDIA_METALLUM
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def search_by_query(cls, query: str) -> List[MusicObject]:
|
def search_by_query(cls, query: str) -> List[MusicObject]:
|
||||||
query_obj = cls.Query(query)
|
query_obj = cls.Query(query)
|
||||||
@ -48,10 +47,11 @@ class EncyclopaediaMetallum(Page):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def search_for_song(cls, query: Page.Query) -> List[Song]:
|
def search_for_song(cls, query: Page.Query) -> List[Song]:
|
||||||
endpoint = "https://www.metal-archives.com/search/ajax-advanced/searching/songs/?songTitle={song}&bandName={artist}&releaseTitle={album}&lyrics=&genre=&sEcho=1&iColumns=5&sColumns=&iDisplayStart=0&iDisplayLength=200&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&mDataProp_3=3&mDataProp_4=4&_=1674550595663"
|
endpoint = "https://www.metal-archives.com/search/ajax-advanced/searching/songs/?songTitle={song}&bandName={artist}&releaseTitle={album}&lyrics=&genre=&sEcho=1&iColumns=5&sColumns=&iDisplayStart=0&iDisplayLength=200&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&mDataProp_3=3&mDataProp_4=4&_=1674550595663"
|
||||||
|
|
||||||
r = cls.API_SESSION.get(endpoint.format(song=query.song_str, artist=query.artist_str, album=query.album_str))
|
r = cls.API_SESSION.get(endpoint.format(song=query.song_str, artist=query.artist_str, album=query.album_str))
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
LOGGER.warning(f"code {r.status_code} at {endpoint.format(song=query.song_str, artist=query.artist_str, album=query.album_str)}")
|
LOGGER.warning(
|
||||||
|
f"code {r.status_code} at {endpoint.format(song=query.song_str, artist=query.artist_str, album=query.album_str)}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
return [cls.get_song_from_json(
|
return [cls.get_song_from_json(
|
||||||
@ -65,10 +65,11 @@ class EncyclopaediaMetallum(Page):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def search_for_album(cls, query: Page.Query) -> List[Album]:
|
def search_for_album(cls, query: Page.Query) -> List[Album]:
|
||||||
endpoint = "https://www.metal-archives.com/search/ajax-advanced/searching/albums/?bandName={artist}&releaseTitle={album}&releaseYearFrom=&releaseMonthFrom=&releaseYearTo=&releaseMonthTo=&country=&location=&releaseLabelName=&releaseCatalogNumber=&releaseIdentifiers=&releaseRecordingInfo=&releaseDescription=&releaseNotes=&genre=&sEcho=1&iColumns=3&sColumns=&iDisplayStart=0&iDisplayLength=200&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&_=1674563943747"
|
endpoint = "https://www.metal-archives.com/search/ajax-advanced/searching/albums/?bandName={artist}&releaseTitle={album}&releaseYearFrom=&releaseMonthFrom=&releaseYearTo=&releaseMonthTo=&country=&location=&releaseLabelName=&releaseCatalogNumber=&releaseIdentifiers=&releaseRecordingInfo=&releaseDescription=&releaseNotes=&genre=&sEcho=1&iColumns=3&sColumns=&iDisplayStart=0&iDisplayLength=200&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&_=1674563943747"
|
||||||
|
|
||||||
r = cls.API_SESSION.get(endpoint.format(artist=query.artist_str, album=query.album_str))
|
r = cls.API_SESSION.get(endpoint.format(artist=query.artist_str, album=query.album_str))
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
LOGGER.warning(f"code {r.status_code} at {endpoint.format(song=query.song_str, artist=query.artist_str, album=query.album_str)}")
|
LOGGER.warning(
|
||||||
|
f"code {r.status_code} at {endpoint.format(song=query.song_str, artist=query.artist_str, album=query.album_str)}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
return [cls.get_album_from_json(
|
return [cls.get_album_from_json(
|
||||||
@ -80,14 +81,14 @@ class EncyclopaediaMetallum(Page):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def search_for_artist(cls, query: Page.Query) -> List[Artist]:
|
def search_for_artist(cls, query: Page.Query) -> List[Artist]:
|
||||||
endpoint = "https://www.metal-archives.com/search/ajax-advanced/searching/bands/?bandName={artist}&genre=&country=&yearCreationFrom=&yearCreationTo=&bandNotes=&status=&themes=&location=&bandLabelName=&sEcho=1&iColumns=3&sColumns=&iDisplayStart=0&iDisplayLength=200&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&_=1674565459976"
|
endpoint = "https://www.metal-archives.com/search/ajax-advanced/searching/bands/?bandName={artist}&genre=&country=&yearCreationFrom=&yearCreationTo=&bandNotes=&status=&themes=&location=&bandLabelName=&sEcho=1&iColumns=3&sColumns=&iDisplayStart=0&iDisplayLength=200&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&_=1674565459976"
|
||||||
|
|
||||||
r = cls.API_SESSION.get(endpoint.format(artist=query.artist))
|
r = cls.API_SESSION.get(endpoint.format(artist=query.artist))
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
LOGGER.warning(f"code {r.status_code} at {endpoint.format(artist=query.artist)}")
|
LOGGER.warning(f"code {r.status_code} at {endpoint.format(artist=query.artist)}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
return [
|
return [
|
||||||
cls.get_artist_from_json(html=raw_artist[0], genre=raw_artist[1], country=raw_artist[2])
|
cls.get_artist_from_json(html=raw_artist[0], genre=raw_artist[1], country=raw_artist[2])
|
||||||
for raw_artist in r.json()['aaData']
|
for raw_artist in r.json()['aaData']
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -105,7 +106,7 @@ class EncyclopaediaMetallum(Page):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
return [
|
return [
|
||||||
cls.get_artist_from_json(html=raw_artist[0], genre=raw_artist[1], country=raw_artist[2])
|
cls.get_artist_from_json(html=raw_artist[0], genre=raw_artist[1], country=raw_artist[2])
|
||||||
for raw_artist in r.json()['aaData']
|
for raw_artist in r.json()['aaData']
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -138,7 +139,7 @@ class EncyclopaediaMetallum(Page):
|
|||||||
sources=[
|
sources=[
|
||||||
Source(SourcePages.ENCYCLOPAEDIA_METALLUM, artist_url)
|
Source(SourcePages.ENCYCLOPAEDIA_METALLUM, artist_url)
|
||||||
],
|
],
|
||||||
notes = notes
|
notes=notes
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -164,7 +165,8 @@ class EncyclopaediaMetallum(Page):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_song_from_json(cls, artist_html=None, album_html=None, release_type=None, title=None, lyrics_html=None) -> Song:
|
def get_song_from_json(cls, artist_html=None, album_html=None, release_type=None, title=None,
|
||||||
|
lyrics_html=None) -> Song:
|
||||||
song_id = None
|
song_id = None
|
||||||
if lyrics_html is not None:
|
if lyrics_html is not None:
|
||||||
# <a href="javascript:;" id="lyricsLink_5948443" title="Toggle lyrics display" class="viewLyrics iconContainer ui-state-default"><span class="ui-icon ui-icon-script">Edit song lyrics</span></a>
|
# <a href="javascript:;" id="lyricsLink_5948443" title="Toggle lyrics display" class="viewLyrics iconContainer ui-state-default"><span class="ui-icon ui-icon-script">Edit song lyrics</span></a>
|
||||||
@ -172,7 +174,7 @@ class EncyclopaediaMetallum(Page):
|
|||||||
anchor = soup.find('a')
|
anchor = soup.find('a')
|
||||||
raw_song_id = anchor.get('id')
|
raw_song_id = anchor.get('id')
|
||||||
song_id = raw_song_id.replace("lyricsLink_", "")
|
song_id = raw_song_id.replace("lyricsLink_", "")
|
||||||
|
|
||||||
return Song(
|
return Song(
|
||||||
id_=song_id,
|
id_=song_id,
|
||||||
title=title,
|
title=title,
|
||||||
@ -191,6 +193,6 @@ class EncyclopaediaMetallum(Page):
|
|||||||
break
|
break
|
||||||
if relevant_source is None:
|
if relevant_source is None:
|
||||||
return artist
|
return artist
|
||||||
|
|
||||||
print(relevant_source.url)
|
print(relevant_source.url)
|
||||||
return artist
|
return artist
|
||||||
|
BIN
src/test.db
BIN
src/test.db
Binary file not shown.
Loading…
Reference in New Issue
Block a user