~hristoast/mousikofidi

00265fa1e61489fb90816f25b460cdc8520ccebb — Hristos N. Triantafillou a month ago 8c98a49 dev
Use the right method to provide track metadata via the API (#138)

Also ensure some classes are present for mobile views.
3 files changed, 14 insertions(+), 1 deletions(-)

M mousikofidi/mousikofidi.py
M mousikofidi/static/js/queue.js
M test_mousikofidi.py
M mousikofidi/mousikofidi.py => mousikofidi/mousikofidi.py +7 -1
@@ 831,11 831,13 @@ def get_metadata_dict(file_path: str) -> dict:
        "title": None,
        "title_mobile": None,
        "track": None,
        "track_type": None,
        "tracktotal": None,
    }
    metadata = file_metadata(file_path)

    if is_audio_file(file_path):
        d.update({"track_type": "audio"})
        d.update(
            {
                "album": get_metadata_value(


@@ 933,6 935,7 @@ def get_metadata_dict(file_path: str) -> dict:
        d.update({"lyrics": get_metadata_value(["LYRICS", "USLT"], metadata)})

    elif is_video_file(file_path):
        d.update({"track_type": "video"})
        if file_path.endswith(".mp4"):
            if metadata:
                d.update({"cover_art": metadata["cover_art"]})


@@ 1648,7 1651,10 @@ def metadata_for_path(path):
    if not is_valid_path(c, full_path):
        return jsonify({"error": "404: Not Found"}), 404

    return jsonify(get_metadata_dict(full_path))
    metadata = get_metadata_dict(full_path)
    fd = file_dict(full_path, metadata, metadata["track_type"])

    return jsonify(fd)


@app.route("/api/v1/playlist/<name>")

M mousikofidi/static/js/queue.js => mousikofidi/static/js/queue.js +5 -0
@@ 704,6 704,9 @@ function renderQueueRow(tableBody, count, data, clickListener, arrowClass, title
    rowTdTitle.classList.toggle("title-regular");
    rowTdTitle.appendChild(document.createElement("a"));
    var titleLink = rowTdTitle.lastElementChild;
    titleLink.classList.toggle("mobile-big");
    if (data.trackType === "video")
        titleLink.classList.toggle("video-title");
    titleLink.href = getUrl(data.path, typeBrowse);
    titleLink.textContent = data.title;
    titleLink.title = "This track's title";


@@ 714,6 717,8 @@ function renderQueueRow(tableBody, count, data, clickListener, arrowClass, title
    rowTdMobileTitle.classList.toggle("title-mobile");
    rowTdMobileTitle.appendChild(document.createElement("a"));
    var mobileTitleLink = rowTdMobileTitle.lastElementChild;
    if (data.trackType === "video")
        mobileTitleLink.classList.toggle("video-title");
    mobileTitleLink.classList.toggle("mobile-big");
    mobileTitleLink.href = getUrl(data.path, typeBrowse);
    mobileTitleLink.textContent = data.title_mobile;

M test_mousikofidi.py => test_mousikofidi.py +2 -0
@@ 1011,6 1011,7 @@ def test_get_metadata_dict_real_audio():
        "title": "MousikóFídi Test FLAC",
        "title_mobile": "MousikóFídi Test FLAC",
        "track": "34",
        "track_type": "audio",
        "tracktotal": "0",
    }



@@ 1027,6 1028,7 @@ def test_get_metadata_dict_fake_video():
        "title": "fake.webm",
        "title_mobile": "fake.webm",
        "track": None,
        "track_type": "video",
        "tracktotal": None,
    }