-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6cf7f08
commit 862d8d4
Showing
33 changed files
with
6,231 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from core.control import run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from core.api.aplm import AppleMusic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import m3u8 | ||
from core import parse | ||
|
||
from . import lyrics | ||
|
||
def parse_data(data): | ||
media = {} | ||
media_list = [] | ||
|
||
attr = data["attributes"] | ||
|
||
media["coverUrl"] = attr["artwork"]["url"].format( | ||
w=attr["artwork"].get("width"), | ||
h=attr["artwork"].get("height") | ||
) | ||
|
||
if "editorialVideo" in attr: | ||
if "motionDetailSquare" in attr["editorialVideo"]: | ||
__data = m3u8.load( | ||
attr["editorialVideo"]["motionDetailSquare"].get("video") | ||
) | ||
|
||
streamList = [] | ||
|
||
for i, variants in enumerate(__data.playlists): | ||
streamList.append( | ||
{ | ||
"id": i, | ||
"fps": variants.stream_info.frame_rate, | ||
"codec": "AVC" if "avc" in variants.stream_info.codecs else "HEVC", | ||
"range": variants.stream_info.video_range, | ||
"bitrate": f'{round((variants.stream_info.average_bandwidth)/1000000, 2)} Mb/s', | ||
"resolution": f'{variants.stream_info.resolution[0]}x{variants.stream_info.resolution[1]}', | ||
"uri": variants.uri | ||
} | ||
) | ||
|
||
media["animartwork"] = streamList | ||
|
||
dirname = parse.sanitize( | ||
"{} - {} [{}]{}{}{}".format( | ||
attr.get("artistName"), | ||
attr.get("name"), | ||
data["id"], | ||
" [S]" if "Single" in attr.get("name") else "", | ||
" [EP]" if "EP" in attr.get("name") else "", | ||
" [E]" if attr.get("contentRating") == "explicit" else "" | ||
) | ||
) | ||
|
||
media["dir"] = dirname.replace(' - Single', '').replace(' - EP', '') | ||
|
||
a = { | ||
"copyright": attr.get("copyright"), | ||
"upc": attr.get("upc"), | ||
"recordlabel": attr.get("recordLabel"), | ||
"trackcount": attr.get("trackCount"), | ||
"album": attr.get("name"), | ||
"albumartist": attr.get("artistName") | ||
} | ||
|
||
for item in data["relationships"]["tracks"]["data"]: | ||
attr = item.get("attributes") | ||
|
||
filename = parse.sanitize( | ||
"{} - {}{}".format( | ||
str(attr.get("trackNumber")).zfill(2), | ||
attr.get("name"), | ||
" [E]" if attr.get("contentRating") == "explicit" else "" | ||
) | ||
) | ||
|
||
s = { | ||
"id": item.get("id"), | ||
"genre": attr.get("genreNames"), | ||
"releasedate": attr.get("releaseDate"), | ||
"trackno": attr.get("trackNumber"), | ||
"isrc": attr.get("isrc"), | ||
"composer": attr.get("composerName"), | ||
"discno": attr.get("discNumber"), | ||
"song": attr.get("name"), | ||
"songartist": attr.get("artistName"), | ||
"rating": 4 if attr.get("contentRating") == "explicit" else 0, | ||
"file": filename | ||
} | ||
|
||
rela = item.get("relationships") | ||
if not rela: rela = {} | ||
|
||
if "credits" in rela: | ||
credits = rela["credits"].get("data") | ||
if credits: | ||
|
||
roles = [] | ||
creds = {} | ||
|
||
for catagory in credits: | ||
for credit in catagory["relationships"]["credit-artists"]["data"]: | ||
for role in credit["attributes"]["roleNames"]: | ||
if not role in roles: | ||
roles.append(role) | ||
creds[role] = [credit["attributes"]["name"]] | ||
else: | ||
roleArtist: list = creds[role] | ||
roleArtist.append(credit["attributes"]["name"]) | ||
creds[role] = roleArtist | ||
|
||
s["credits"] = creds | ||
|
||
if "lyrics" in rela: | ||
if rela["lyrics"].get("data"): | ||
if rela["lyrics"]["data"][0].get("attributes"): | ||
s.update( | ||
lyrics.parse( | ||
rela["lyrics"]["data"][0]["attributes"]["ttml"] | ||
) | ||
) | ||
|
||
if item.get("type") == "songs": | ||
s["type"] = 1 | ||
elif item.get("type") == "music-videos": | ||
s["type"] = 6 | ||
|
||
s.update(a) | ||
media_list.append( | ||
parse.opt(s) | ||
) | ||
|
||
media["tracks"] = media_list | ||
return media |
Oops, something went wrong.