1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-08 23:02:05 -04:00

track art: use URLs directly

This commit is contained in:
bbedward
2026-02-13 17:31:51 -05:00
parent b8d40761ff
commit ce75dac81b
2 changed files with 21 additions and 25 deletions

View File

@@ -11,7 +11,6 @@ Singleton {
property string _lastArtUrl: ""
property string _bgArtSource: ""
property string activeTrackArtFile: ""
property bool loading: false
function loadArtwork(url) {
@@ -24,30 +23,20 @@ Singleton {
if (url === _lastArtUrl)
return;
_lastArtUrl = url;
loading = true;
if (!url.startsWith("http://") && !url.startsWith("https://")) {
const localUrl = url;
const filePath = url.startsWith("file://") ? url.substring(7) : url;
Proc.runCommand("trackart", ["test", "-f", filePath], (output, exitCode) => {
if (_lastArtUrl !== localUrl)
return;
_bgArtSource = exitCode === 0 ? localUrl : "";
loading = false;
}, 200);
if (url.startsWith("http://") || url.startsWith("https://")) {
_bgArtSource = url;
loading = false;
return;
}
const filename = "/tmp/.dankshell/trackart_" + Date.now() + ".jpg";
activeTrackArtFile = filename;
Proc.runCommand("trackart_cleanup", ["sh", "-c", "mkdir -p /tmp/.dankshell && find /tmp/.dankshell -name 'trackart_*' ! -name '" + filename.split('/').pop() + "' -delete"], null, 0);
Proc.runCommand("trackart", ["dms", "dl", "-o", filename, "--user-agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36", url], (output, exitCode) => {
const resultPath = output.trim();
if (resultPath !== filename)
loading = true;
const localUrl = url;
const filePath = url.startsWith("file://") ? url.substring(7) : url;
Proc.runCommand("trackart", ["test", "-f", filePath], (output, exitCode) => {
if (_lastArtUrl !== localUrl)
return;
_bgArtSource = exitCode === 0 ? "file://" + resultPath : "";
_bgArtSource = exitCode === 0 ? localUrl : "";
loading = false;
}, 200);
}