Compare commits
3 Commits
20f4fdbd39
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 7c7bc48d09 | |||
| e7af7f471f | |||
| eb13944e46 |
@@ -68,18 +68,18 @@
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"options": {
|
||||
"browserTarget": "dashboard:build"
|
||||
"buildTarget": "dashboard:build"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"browserTarget": "dashboard:build:production"
|
||||
"buildTarget": "dashboard:build:production"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"browserTarget": "dashboard:build"
|
||||
"buildTarget": "dashboard:build"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
|
||||
18132
dashboard/package-lock.json
generated
18132
dashboard/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,38 +11,38 @@
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^15.1.3",
|
||||
"@angular/common": "^15.1.3",
|
||||
"@angular/compiler": "^15.1.3",
|
||||
"@angular/core": "^15.1.3",
|
||||
"@angular/forms": "^15.1.3",
|
||||
"@angular/localize": "^15.1.3",
|
||||
"@angular/platform-browser": "^15.1.3",
|
||||
"@angular/platform-browser-dynamic": "^15.1.3",
|
||||
"@angular/router": "^15.1.3",
|
||||
"@ng-bootstrap/ng-bootstrap": "^14.0.0",
|
||||
"bootstrap": "^3.3.7",
|
||||
"rxjs": "~6.6.0",
|
||||
"tslib": "^2.0.0",
|
||||
"zone.js": "~0.11.4"
|
||||
"@angular/animations": "^17.1.0",
|
||||
"@angular/common": "^17.1.0",
|
||||
"@angular/compiler": "^17.1.0",
|
||||
"@angular/core": "^17.1.0",
|
||||
"@angular/forms": "^17.1.0",
|
||||
"@angular/localize": "^17.1.0",
|
||||
"@angular/platform-browser": "^17.1.0",
|
||||
"@angular/platform-browser-dynamic": "^17.1.0",
|
||||
"@angular/router": "^17.1.0",
|
||||
"@ng-bootstrap/ng-bootstrap": "^16.0.0",
|
||||
"bootstrap": "^3.4.1",
|
||||
"rxjs": "~7.8.1",
|
||||
"tslib": "^2.6.2",
|
||||
"zone.js": "^0.14.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^15.1.4",
|
||||
"@angular/cli": "^15.1.4",
|
||||
"@angular/compiler-cli": "^15.1.3",
|
||||
"@types/jasmine": "~3.6.0",
|
||||
"@types/node": "^12.11.1",
|
||||
"codelyzer": "^6.0.0",
|
||||
"jasmine-core": "~3.6.0",
|
||||
"jasmine-spec-reporter": "~5.0.0",
|
||||
"karma": "~6.3.4",
|
||||
"karma-chrome-launcher": "~3.1.0",
|
||||
"karma-coverage": "~2.0.3",
|
||||
"karma-jasmine": "~4.0.0",
|
||||
"karma-jasmine-html-reporter": "^1.5.0",
|
||||
"@angular-devkit/build-angular": "^17.1.0",
|
||||
"@angular/cli": "^17.1.0",
|
||||
"@angular/compiler-cli": "^17.1.0",
|
||||
"@types/jasmine": "~5.1.4",
|
||||
"@types/node": "^20.11.5",
|
||||
"codelyzer": "^6.0.2",
|
||||
"jasmine-core": "~5.1.1",
|
||||
"jasmine-spec-reporter": "~7.0.0",
|
||||
"karma": "~6.4.2",
|
||||
"karma-chrome-launcher": "~3.2.0",
|
||||
"karma-coverage": "~2.2.1",
|
||||
"karma-jasmine": "~5.1.0",
|
||||
"karma-jasmine-html-reporter": "^2.1.0",
|
||||
"protractor": "~7.0.0",
|
||||
"ts-node": "~8.3.0",
|
||||
"ts-node": "~10.9.2",
|
||||
"tslint": "~6.1.0",
|
||||
"typescript": "~4.9.5"
|
||||
"typescript": "~5.3.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
</div>
|
||||
|
||||
<div class="alert alert-warning">
|
||||
<img class="images" src="data:image/png;base64, {{album.Cover}}" height="500"/>
|
||||
<h3>Debug Zone</h3>
|
||||
ID: {{album.id}}<br />
|
||||
Returned song: {{songs.length}}<br />
|
||||
Theorical number song: {{ album ? album['Track Count'] : "" }}
|
||||
<span *ngIf="album && (songs.length == album['Track Count'])" class="glyphicon glyphicon-ok" style="color:green"></span>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
export class Album {
|
||||
id: number;
|
||||
Name: string;
|
||||
Cover: string;
|
||||
Album: string;
|
||||
Artist: Array<string>;
|
||||
Rating: number;
|
||||
|
||||
95
ingest_cover.py
Normal file
95
ingest_cover.py
Normal file
@@ -0,0 +1,95 @@
|
||||
import base64
|
||||
import os
|
||||
from typing import List, Optional
|
||||
import requests
|
||||
import json
|
||||
import re
|
||||
|
||||
from urllib import parse
|
||||
|
||||
|
||||
TYPESENSE_URL = "http://localhost:8108"
|
||||
COLLECTION = "albums"
|
||||
HEADERS = {"X-TYPESENSE-API-KEY": "toto", "Content-Type": "application/json"}
|
||||
|
||||
def get_albums(offset = 0) -> List[tuple[str, str, str]]:
|
||||
params = {"q": "*", "per_page": 250, "offset": offset}
|
||||
q_url = f"{TYPESENSE_URL}/collections/{COLLECTION}/documents/search"
|
||||
# print(q_url)
|
||||
req = requests.get(q_url, params=params, headers=HEADERS)
|
||||
|
||||
ret = [ (hit['document']['id'], hit['document']['Album'], hit['document']['Artist']) for hit in req.json()['hits']]
|
||||
return ret
|
||||
|
||||
def get_album_location(id: int) -> str:
|
||||
q_url = f"{TYPESENSE_URL}/collections/{COLLECTION}/documents/{id}"
|
||||
# print(q_url)
|
||||
req = requests.get(q_url, headers=HEADERS)
|
||||
|
||||
if "Cover" in req.json():
|
||||
return
|
||||
|
||||
return req.json()["Location"]
|
||||
|
||||
|
||||
def patch_album(id: int, cover: bytes) -> bool:
|
||||
q_url = f"{TYPESENSE_URL}/collections/{COLLECTION}/documents/{id}"
|
||||
# print(q_url)
|
||||
payload = {"Cover": cover.decode()}
|
||||
payload = json.dumps(payload)
|
||||
req = requests.patch(q_url, headers=HEADERS, data=payload)
|
||||
|
||||
return req.status_code == 200
|
||||
|
||||
|
||||
def sanitize_location(location: str) -> Optional[str]:
|
||||
result = parse.unquote(location, encoding='utf-8', errors='replace')
|
||||
result = result.replace("file://localhost/", "")
|
||||
result = result.replace(":", "")
|
||||
result = re.sub("^([A-Z])", lambda m: m.group(0).lower(), result)
|
||||
result = result.replace("%20", " ")
|
||||
result = "/mnt/" + result
|
||||
result = re.sub('/Disc [0-9]*$', "", result)
|
||||
|
||||
for file in ["/Pochette.jpg", "/cover.jpg", "/Pochette.png"]:
|
||||
if os.path.isfile(result + file):
|
||||
result = result + file
|
||||
return result
|
||||
return None
|
||||
|
||||
|
||||
def get_base64(location: str) -> bytes:
|
||||
with open(location, "rb") as image_file:
|
||||
encoded_cover = base64.b64encode(image_file.read())
|
||||
return encoded_cover
|
||||
|
||||
def process_one_album(id: int) -> bool:
|
||||
raw_loc = get_album_location(id)
|
||||
if not raw_loc:
|
||||
return False
|
||||
loc = sanitize_location(raw_loc)
|
||||
if not loc:
|
||||
return False
|
||||
cover = get_base64(loc)
|
||||
if patch_album(id, cover):
|
||||
return True
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
# process_one_album(2151)
|
||||
elements = get_albums()
|
||||
processed = 0
|
||||
while len(elements) == 250:
|
||||
for id, name, artist in elements:
|
||||
processed += 1
|
||||
raw_loc = get_album_location(id)
|
||||
if not raw_loc:
|
||||
continue
|
||||
loc = sanitize_location(raw_loc)
|
||||
if not loc:
|
||||
continue
|
||||
print(f"Try {id} - {name} ({artist})")
|
||||
cover = get_base64(loc)
|
||||
if patch_album(id, cover):
|
||||
print(f"Album {id} - {name} ({artist}) patched successfully")
|
||||
elements = get_albums(offset = processed)
|
||||
Reference in New Issue
Block a user