adding new doctype
This commit is contained in:
16
poetry.lock
generated
16
poetry.lock
generated
@@ -73,6 +73,17 @@ optional = false
|
|||||||
python-versions = "*"
|
python-versions = "*"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
category = "dev"
|
||||||
|
description = "make your debug printing more friendly"
|
||||||
|
name = "beeprint"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
version = "2.4.10"
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
urwid = "*"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
category = "main"
|
category = "main"
|
||||||
description = "Python package for providing Mozilla's CA Bundle."
|
description = "Python package for providing Mozilla's CA Bundle."
|
||||||
@@ -1066,7 +1077,7 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"]
|
|||||||
testing = ["jaraco.itertools", "func-timeout"]
|
testing = ["jaraco.itertools", "func-timeout"]
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
content-hash = "44fd20a54848c7d35be309d10766f8c4a4f3fdee8d661a1ad5088085ca5aca5e"
|
content-hash = "f2c161c810940af2e52283d3b1f2af77d6673bebe20a2af79cc44a14debb4bf1"
|
||||||
python-versions = "^3.7"
|
python-versions = "^3.7"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
@@ -1098,6 +1109,9 @@ beautifultable = [
|
|||||||
{file = "beautifultable-0.8.0-py2.py3-none-any.whl", hash = "sha256:28e2e93d44a4e84511c4869da4b907345435a06728925e295790f24e1d57300c"},
|
{file = "beautifultable-0.8.0-py2.py3-none-any.whl", hash = "sha256:28e2e93d44a4e84511c4869da4b907345435a06728925e295790f24e1d57300c"},
|
||||||
{file = "beautifultable-0.8.0.tar.gz", hash = "sha256:d44d9551bbed7bfa88675324f84efb9aa857384d44e9fb21eb530f0a0badb815"},
|
{file = "beautifultable-0.8.0.tar.gz", hash = "sha256:d44d9551bbed7bfa88675324f84efb9aa857384d44e9fb21eb530f0a0badb815"},
|
||||||
]
|
]
|
||||||
|
beeprint = [
|
||||||
|
{file = "beeprint-2.4.10.tar.gz", hash = "sha256:b3cbe170718e696bfa05e074789212ba6aef5f096a5fd12717f14d4f1615a440"},
|
||||||
|
]
|
||||||
certifi = [
|
certifi = [
|
||||||
{file = "certifi-2019.11.28-py2.py3-none-any.whl", hash = "sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3"},
|
{file = "certifi-2019.11.28-py2.py3-none-any.whl", hash = "sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3"},
|
||||||
{file = "certifi-2019.11.28.tar.gz", hash = "sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f"},
|
{file = "certifi-2019.11.28.tar.gz", hash = "sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f"},
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ mkdocs = "^1.1"
|
|||||||
mkdocs-material = "^4.6.3"
|
mkdocs-material = "^4.6.3"
|
||||||
pymdown-extensions = "^6.3"
|
pymdown-extensions = "^6.3"
|
||||||
mkdocstrings = "^0.8.0"
|
mkdocstrings = "^0.8.0"
|
||||||
|
beeprint = "^2.4.10"
|
||||||
|
|
||||||
[tool.poetry.plugins."console_scripts"]
|
[tool.poetry.plugins."console_scripts"]
|
||||||
"musicbrainzapi" = "musicbrainzapi.cli.cli:cli"
|
"musicbrainzapi" = "musicbrainzapi.cli.cli:cli"
|
||||||
|
|||||||
@@ -1,53 +1,49 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from collections import Counter
|
|
||||||
import html
|
import html
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
import string
|
import string
|
||||||
from typing import Union, Dict
|
from collections import Counter
|
||||||
|
from typing import Dict, Union
|
||||||
|
|
||||||
import addict
|
import addict
|
||||||
import click
|
import click
|
||||||
import musicbrainzngs
|
import musicbrainzngs
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import requests
|
import requests
|
||||||
|
from beeprint import pp
|
||||||
|
|
||||||
from musicbrainzapi.api.lyrics.concrete_builder import LyricsConcreteBuilder
|
|
||||||
from musicbrainzapi.api.lyrics import Lyrics
|
|
||||||
from musicbrainzapi.api import authenticate
|
from musicbrainzapi.api import authenticate
|
||||||
|
from musicbrainzapi.api.lyrics import Lyrics
|
||||||
|
from musicbrainzapi.api.lyrics.concrete_builder import LyricsConcreteBuilder
|
||||||
|
|
||||||
|
|
||||||
class LyricsBuilder(LyricsConcreteBuilder):
|
class LyricsBuilder(LyricsConcreteBuilder):
|
||||||
"""docstring for LyricsBuilder
|
"""
|
||||||
|
This interface will build a Lyrics object.
|
||||||
|
|
||||||
Attributes
|
!!! info "Attributes"
|
||||||
----------
|
- musicbrainz_artists (addict.Dict): A dict response from the Musicbrainz api for all artists.
|
||||||
album_statistics : addict.Dict
|
- release_group_ids (addict.Dict): : A dict response from the Musicbrainz api for all artists.
|
||||||
Dictionary containing album statistics
|
- all_albums (list): : A dict response from the Musicbrainz api for all artists.
|
||||||
all_albums : list
|
- total_track_count (list): : A dict response from the Musicbrainz api for all artists.
|
||||||
List of all albums + track titles
|
- all_albums_lyrics_url (addict.Dict): : A dict response from the Musicbrainz api for all artists.
|
||||||
all_albums_lyrics : list
|
- all_albums_lyrics (addict.Dict): : A dict response from the Musicbrainz api for all artists.
|
||||||
List of all albums + track lyrics
|
- all_albums_lyrics_count (addict.Dict): : A dict response from the Musicbrainz api for all artists.
|
||||||
all_albums_lyrics_count : list
|
- all_albums_lyrics_sum (addict.Dict): : A dict response from the Musicbrainz api for all artists.
|
||||||
List of all albums + track lyrics counted by each word
|
- album_statistics (addict.Dict): : A dict response from the Musicbrainz api for all artists.
|
||||||
all_albums_lyrics_sum : list
|
- album_statistics (addict.Dict): : A dict response from the Musicbrainz api for all artists.
|
||||||
List of all albums + track lyrics counted and summed up.
|
- year_statistics (addict.Dict): : A dict response from the Musicbrainz api for all artists.
|
||||||
all_albums_lyrics_url : list
|
- year_statistics (addict.Dict): : A dict response from the Musicbrainz api for all artists.
|
||||||
List of all albums + link to lyrics api for each track.
|
|
||||||
musicbrainz_artists : addict.Dict
|
Example:
|
||||||
Dictionary of response from Musicbrainzapi
|
A test example.
|
||||||
release_group_ids : addict.Dict
|
|
||||||
Dictionary of Musicbrainz release-group ids
|
|
||||||
total_track_count : int
|
|
||||||
Total number of tracks across all albums
|
|
||||||
year_statistics : addict.Dict
|
|
||||||
Dictionary containing album statistics
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def product(self) -> Lyrics:
|
def product(self) -> Lyrics:
|
||||||
product = self._product
|
return self._product
|
||||||
return product
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def artist(self) -> str:
|
def artist(self) -> str:
|
||||||
@@ -167,7 +163,7 @@ class LyricsBuilder(LyricsConcreteBuilder):
|
|||||||
Dict[str, int]
|
Dict[str, int]
|
||||||
Dictionary of statistic and value.
|
Dictionary of statistic and value.
|
||||||
"""
|
"""
|
||||||
if len(nums) == 0:
|
if not nums:
|
||||||
return
|
return
|
||||||
avg = math.ceil(np.mean(nums))
|
avg = math.ceil(np.mean(nums))
|
||||||
median = math.ceil(np.median(nums))
|
median = math.ceil(np.median(nums))
|
||||||
@@ -179,22 +175,22 @@ class LyricsBuilder(LyricsConcreteBuilder):
|
|||||||
p_75 = math.ceil(np.percentile(nums, 75))
|
p_75 = math.ceil(np.percentile(nums, 75))
|
||||||
p_90 = math.ceil(np.percentile(nums, 90))
|
p_90 = math.ceil(np.percentile(nums, 90))
|
||||||
count = len(nums)
|
count = len(nums)
|
||||||
_d = addict.Dict(
|
return addict.Dict(
|
||||||
('avg', avg),
|
('avg', avg),
|
||||||
('median', median),
|
('median', median),
|
||||||
('std', std),
|
('std', std),
|
||||||
('max', _max),
|
('max', _max),
|
||||||
('min', _min),
|
('min', _min),
|
||||||
('p_10', p_10),
|
('p_10', p_10),
|
||||||
('p_25', p_25),
|
('p_25', p_25),
|
||||||
('p_75', p_75),
|
('p_75', p_75),
|
||||||
('p_90', p_90),
|
('p_90', p_90),
|
||||||
('count', count),
|
('count', count),
|
||||||
)
|
)
|
||||||
return _d
|
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""Create a builder instance to build a Lyrics object."""
|
"""Create a `LyricsBuilder`.
|
||||||
|
"""
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
def reset(self) -> None:
|
def reset(self) -> None:
|
||||||
@@ -518,3 +514,6 @@ class LyricsBuilder(LyricsConcreteBuilder):
|
|||||||
self.year_statistics = addict.Dict(
|
self.year_statistics = addict.Dict(
|
||||||
**self.year_statistics, **addict.Dict((year, _d))
|
**self.year_statistics, **addict.Dict((year, _d))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
pp(LyricsBuilder)
|
||||||
|
|||||||
Reference in New Issue
Block a user