Add initial version of the project
This commit is contained in:
@@ -0,0 +1 @@
|
||||
.DS_Store
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
source .venv/bin/activate
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
source bin/activate.sh
|
||||
python -m tagger.run $*
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
[[ -d .venv ]] && rm -rf .venv
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate
|
||||
pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
source bin/activate.sh
|
||||
pytest tagger -vv $*
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
source bin/activate.sh
|
||||
watch -c "pytest -q --color=yes --tb=short tagger"
|
||||
@@ -0,0 +1 @@
|
||||
mutagen==1.47.0
|
||||
Binary file not shown.
@@ -0,0 +1,69 @@
|
||||
from mutagen import File
|
||||
from pathlib import Path
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
# Constants ########################################################################################
|
||||
|
||||
KEYS = {
|
||||
"GRID": "group-identification",
|
||||
"GRP1": "itunes-group",
|
||||
"MVIN": "itunes-movement-number-count",
|
||||
"MVNM": "itunes-movement-name",
|
||||
"OWNE": "ownership",
|
||||
"PCNT": "play-count",
|
||||
"PRIV": "private",
|
||||
"TALB": "album",
|
||||
"TBPM": "beats-per-minute",
|
||||
"TCMP": "itunes-compilation-flag",
|
||||
"TCOM": "composer",
|
||||
"TCON": "content-type-genre",
|
||||
"TCOP": "copyright",
|
||||
"TDAT": "recording-date", # DDMM format
|
||||
"TEXT": "lyricist",
|
||||
"TIME": "recording-time", # HHMM format
|
||||
"TIPL": "involved-people-list",
|
||||
"TIT1": "content-group-description",
|
||||
"TIT2": "title",
|
||||
"TIT3": "subtitle",
|
||||
"TMCL": "musicians-list",
|
||||
"TMOO": "mood",
|
||||
"TOWN": "owner",
|
||||
"TPE1": "lead-artist-performer-soloist",
|
||||
"TPE2": "band-orchestra-accompanist",
|
||||
"TPE3": "conductor",
|
||||
"TPE4": "iterpreter-remixer",
|
||||
"TPOS": "part-of-set",
|
||||
"TRCK": "track-number", # n/m format
|
||||
"TSO2": "itunes-album-artist-sort-key",
|
||||
"TSOA": "album-sort-key",
|
||||
"TSOC": "itunes-composer-sort-key",
|
||||
"TSOP": "performer-sort-key",
|
||||
"TSOT": "title-sort-key",
|
||||
"TXXX": "user-data",
|
||||
"TYER": "recording-year",
|
||||
}
|
||||
|
||||
# Script ###########################################################################################
|
||||
|
||||
if __name__ == "__main__":
|
||||
results:dict[str, dict[str,str|None]] = {}
|
||||
|
||||
sourcePath = Path(sys.argv[1])
|
||||
for path in sorted(sourcePath.iterdir()):
|
||||
file = File(path)
|
||||
if not file: continue
|
||||
|
||||
pathText = str(path)
|
||||
results[pathText] = {}
|
||||
|
||||
for code, key in KEYS.items():
|
||||
if code in file:
|
||||
results[pathText][key] = file[code].text
|
||||
else:
|
||||
results[pathText][key] = None
|
||||
|
||||
targetFile = sourcePath / "tags.json"
|
||||
with targetFile.open("w") as file:
|
||||
file.write(json.dumps(results, indent=" "))
|
||||
Reference in New Issue
Block a user