@tyleretters/discography 2.0.32 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/discography.d.ts +180 -0
- package/dist/discography.yml +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +2 -2
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/types.d.ts +35 -0
- package/package.json +28 -4
- package/src/convert.py +0 -136
- package/src/discography.yml +0 -3287
- package/src/index.ts +0 -5
- package/src/requirements.txt +0 -1
- package/src/types.ts +0 -37
- package/tsconfig.json +0 -16
- package/vite.config.js +0 -21
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface Release {
|
|
2
|
+
title: string;
|
|
3
|
+
project: string;
|
|
4
|
+
released: string;
|
|
5
|
+
type: string;
|
|
6
|
+
format: string;
|
|
7
|
+
role: string;
|
|
8
|
+
label: string;
|
|
9
|
+
mp3: boolean;
|
|
10
|
+
mp3_url?: string;
|
|
11
|
+
wav: boolean;
|
|
12
|
+
wav_url?: string;
|
|
13
|
+
tracks: Array<Track>;
|
|
14
|
+
streams?: Array<Stream>;
|
|
15
|
+
monospaceNotes?: boolean;
|
|
16
|
+
notes: string;
|
|
17
|
+
credits: string;
|
|
18
|
+
release_slug: string;
|
|
19
|
+
project_slug: string;
|
|
20
|
+
cover_url: string;
|
|
21
|
+
id: string;
|
|
22
|
+
}
|
|
23
|
+
export interface Track {
|
|
24
|
+
number: number;
|
|
25
|
+
title: string;
|
|
26
|
+
length: string;
|
|
27
|
+
mp3_url?: string;
|
|
28
|
+
wav_url?: string;
|
|
29
|
+
id: string;
|
|
30
|
+
}
|
|
31
|
+
export interface Stream {
|
|
32
|
+
platform: string;
|
|
33
|
+
url: string;
|
|
34
|
+
id: string;
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,24 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tyleretters/discography",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"description": "A canonical discography of the music of Tyler Etters.",
|
|
6
6
|
"main": "dist/index.es.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.es.js",
|
|
12
|
+
"require": "./dist/index.umd.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
7
18
|
"scripts": {
|
|
8
19
|
"convert": "./src/convert.py",
|
|
9
|
-
"build": "npm run convert &&
|
|
20
|
+
"build": "npm run convert && vite build && tsc && cp ./src/discography.yml ./dist/discography.yml",
|
|
21
|
+
"lint": "eslint . && ruff check src/",
|
|
22
|
+
"lint:fix": "eslint --fix . && ruff check --fix src/"
|
|
10
23
|
},
|
|
11
24
|
"repository": {
|
|
12
25
|
"type": "git",
|
|
13
26
|
"url": "git+https://github.com/tyleretters/discography.git"
|
|
14
27
|
},
|
|
15
|
-
"
|
|
16
|
-
|
|
28
|
+
"homepage": "https://github.com/tyleretters/discography#readme",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/tyleretters/discography/issues"
|
|
17
31
|
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"discography",
|
|
34
|
+
"music",
|
|
35
|
+
"tyler-etters",
|
|
36
|
+
"catalog"
|
|
37
|
+
],
|
|
38
|
+
"license": "CC BY-SA",
|
|
18
39
|
"author": "Tyler Etters",
|
|
19
40
|
"devDependencies": {
|
|
41
|
+
"@eslint/js": "^9.18.0",
|
|
20
42
|
"@types/node": "^20.10.6",
|
|
43
|
+
"eslint": "^9.18.0",
|
|
21
44
|
"typescript": "^5.3.3",
|
|
45
|
+
"typescript-eslint": "^8.21.0",
|
|
22
46
|
"vite": "^6.0.11"
|
|
23
47
|
}
|
|
24
48
|
}
|
package/src/convert.py
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
'''
|
|
4
|
-
convert the yml to json.
|
|
5
|
-
|
|
6
|
-
see README.md for more information.
|
|
7
|
-
'''
|
|
8
|
-
|
|
9
|
-
import os
|
|
10
|
-
import yaml
|
|
11
|
-
import json
|
|
12
|
-
import re
|
|
13
|
-
import hashlib
|
|
14
|
-
from datetime import datetime
|
|
15
|
-
|
|
16
|
-
cdn_base_url = "https://d107e1o0dn11sc.cloudfront.net/"
|
|
17
|
-
dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
18
|
-
yml_path = dir_path + "/" + "discography.yml"
|
|
19
|
-
ts_path = dir_path + "/" + "discography.ts"
|
|
20
|
-
|
|
21
|
-
special_slug_maps = {
|
|
22
|
-
"ΑΙΓΑΙΙΣ": "AIGAIIS",
|
|
23
|
-
"nausicaä": "nausicaa"
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
# there are some encoding issues with the # character
|
|
27
|
-
special_title_maps = {
|
|
28
|
-
'A White USB Drive With "HEXAGON" iStock Logo #1135496271': 'A White USB Drive With "HEXAGON" iStock Logo #1135496271'
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
def make_id(str):
|
|
32
|
-
md5_hash = hashlib.md5()
|
|
33
|
-
md5_hash.update(str.encode("utf-8"))
|
|
34
|
-
return md5_hash.hexdigest()
|
|
35
|
-
|
|
36
|
-
def make_slug(str):
|
|
37
|
-
if str in special_slug_maps:
|
|
38
|
-
str = special_slug_maps[str]
|
|
39
|
-
str = str.lower()
|
|
40
|
-
# convert & to and
|
|
41
|
-
str = re.sub(r'&', 'and', str)
|
|
42
|
-
# only alphanumeric characters, spaces, and hyphens
|
|
43
|
-
str = re.sub(r'[^a-zA-Z0-9\s-]', '', str)
|
|
44
|
-
# replace spaces with hyphens
|
|
45
|
-
str = re.sub(r'\s+', '-', str)
|
|
46
|
-
# replace multiple hyphens with single hyphen
|
|
47
|
-
str = re.sub(r'--+', '-', str)
|
|
48
|
-
return str
|
|
49
|
-
|
|
50
|
-
def make_track_title(str):
|
|
51
|
-
if str in special_title_maps:
|
|
52
|
-
return special_title_maps[str]
|
|
53
|
-
return str
|
|
54
|
-
|
|
55
|
-
def make_html_paragraphs(str):
|
|
56
|
-
str = str.rstrip("\n")
|
|
57
|
-
str = "<p>" + str + "</p>"
|
|
58
|
-
str = str.replace("\n", "</p><p>")
|
|
59
|
-
return str
|
|
60
|
-
|
|
61
|
-
# load data
|
|
62
|
-
with open(yml_path, "r") as yml_file:
|
|
63
|
-
data = yaml.safe_load(yml_file)
|
|
64
|
-
|
|
65
|
-
# enrich data
|
|
66
|
-
for release in data:
|
|
67
|
-
# generate a project slug
|
|
68
|
-
release["project_slug"] = make_slug(release["project"])
|
|
69
|
-
|
|
70
|
-
# generate a release slug
|
|
71
|
-
release["release_slug"] = make_slug(release["title"])
|
|
72
|
-
|
|
73
|
-
# generate a cover
|
|
74
|
-
release["cover_url"] = cdn_base_url + release["project_slug"] + "/" + release["release_slug"] + "/" + release["release_slug"] + ".jpg"
|
|
75
|
-
|
|
76
|
-
# generate an mp3 and wav download links
|
|
77
|
-
zip_slug = cdn_base_url + release["project_slug"] + "/" + release["release_slug"] + "/" + release["release_slug"]
|
|
78
|
-
|
|
79
|
-
if (release["mp3"]):
|
|
80
|
-
release["mp3_url"] = zip_slug + "-mp3.zip"
|
|
81
|
-
|
|
82
|
-
# generate a wave download link
|
|
83
|
-
if (release["wav"]):
|
|
84
|
-
release["wav_url"] = zip_slug + "-wav.zip"
|
|
85
|
-
|
|
86
|
-
# generate an id
|
|
87
|
-
release["id"] = make_id(release["project"] + release["title"])
|
|
88
|
-
|
|
89
|
-
# handle monospaced notes if monospaceNotes is present
|
|
90
|
-
if "monospaceNotes" in release:
|
|
91
|
-
# preserve \n for monospace
|
|
92
|
-
release["notes"] = "<pre>" + release["notes"] + "</pre>"
|
|
93
|
-
else:
|
|
94
|
-
release["notes"] = make_html_paragraphs(release["notes"])
|
|
95
|
-
|
|
96
|
-
# always turn turn \n into paragraphs on the credits
|
|
97
|
-
release["credits"] = make_html_paragraphs(release["credits"])
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
# generate a slug for each track
|
|
101
|
-
if "tracks" in release:
|
|
102
|
-
for track in release["tracks"]:
|
|
103
|
-
|
|
104
|
-
# generate a track slugs for available formats
|
|
105
|
-
# outcome example: project-title/release-title/01-track-title.mp3
|
|
106
|
-
slug = make_slug(str(track["number"]).zfill(2) + "-" + track["title"]) # zero pad track number
|
|
107
|
-
track_slug = release["project_slug"] + "/" + release["release_slug"] + "/" + slug
|
|
108
|
-
if (release["mp3"]):
|
|
109
|
-
track["mp3_url"] = cdn_base_url + track_slug + ".mp3"
|
|
110
|
-
|
|
111
|
-
if (release["wav"]):
|
|
112
|
-
track["wav_url"] = cdn_base_url + track_slug + ".wav"
|
|
113
|
-
|
|
114
|
-
# generate an id (ARTIST + RELEASE + NUMBER + TITLE + LENGTH)
|
|
115
|
-
track["id"] = make_id(release["project"] + release["title"] + str(track["number"]) + track["title"] + track["length"])
|
|
116
|
-
|
|
117
|
-
# generate a track title
|
|
118
|
-
track["title"] = make_track_title(track["title"])
|
|
119
|
-
|
|
120
|
-
# generate an id for each stream
|
|
121
|
-
if "streams" in release:
|
|
122
|
-
for stream in release["streams"]:
|
|
123
|
-
stream["id"] = make_id(release["project"] + release["title"] + stream["platform"])
|
|
124
|
-
|
|
125
|
-
# write discography data
|
|
126
|
-
with open(ts_path, "w") as json_file:
|
|
127
|
-
json.dump(data, json_file, indent=2)
|
|
128
|
-
|
|
129
|
-
# make it a js export
|
|
130
|
-
with open(ts_path, "r") as file:
|
|
131
|
-
existing_contents = file.read()
|
|
132
|
-
|
|
133
|
-
with open(ts_path, "w") as file:
|
|
134
|
-
new_string = "export const discography = "
|
|
135
|
-
file.write(new_string)
|
|
136
|
-
file.write(existing_contents)
|