~hristoast/mousikofidi

e5b6739a178b332dad45e38eb04fdc23b81fe708 — Hristos N. Triantafillou 9 months ago 007c00d
Recognize video track number data and display it (#65)
3 files changed, 16 insertions(+), 4 deletions(-)

M mousikofidi/mousikofidi.py
M mousikofidi/templates/item_table.html
M test_mousikofidi.py
M mousikofidi/mousikofidi.py => mousikofidi/mousikofidi.py +9 -0
@@ 507,6 507,15 @@ def get_metadata_dict(file_path: str) -> dict:
                elif "nam" in k:
                    d.update({"title": v})

                elif "trkn" in k:
                    track_list = v.strip("(").strip(")").split(",")

                    if track_list[0] != "0":
                        d.update({"track": track_list[0].strip(" ")})

                    if track_list[1] != "0":
                        d.update({"tracktotal": track_list[1].strip(" ")})

    return d



M mousikofidi/templates/item_table.html => mousikofidi/templates/item_table.html +2 -1
@@ 103,9 103,10 @@
            <td class="center mobile-hide"> {# TRACK #}
              {% if page_name != "Playlist" %}
                <div class="anchor" id="{{ item.slug }}">
                  {#{ item.slug }#}
                </div>
              {% endif %}
              {% if item.track and not item.tracktotal %}{{ item.track }}{% endif %}
              {% if item.track and item.tracktotal %}{{ item.track }}/{{ item.tracktotal }}{% endif %}
            </td>

            {% if playlist_add %}

M test_mousikofidi.py => test_mousikofidi.py +5 -3
@@ 423,8 423,8 @@ def test_browse_dir():
                "genre": "MousikóFídi Test Genre",
                "title": "MousikóFídi Test MP4",
                "title_mobile": "MousikóFídi Test MP4",
                "track": None,
                "tracktotal": None,
                "track": "34",
                "tracktotal": "100",
                "file_name": "real.mp4",
                "file_name_mobile": "real.mp4",
                "escaped_path": "{}%2Fexample%2Freal.mp4".format(escaped_sourcedir),


@@ 1756,7 1756,8 @@ def test_dir_detail_found(client):
    assert bytes("MousikóFídi Test MP3", "utf8") in rv.data
    assert bytes("MousikóFídi Test MP4", "utf8") in rv.data
    assert bytes("MousikóFídi Test OGG", "utf8") in rv.data
    assert b"34" in rv.data
    assert bytes("MousikóFídi Test MP4", "utf8") in rv.data
    assert b"34/100" in rv.data
    assert (
        bytes(
            '<title id="title" data-sitename="{n}">{d} | {n}</title>'.format(


@@ 2116,6 2117,7 @@ def test_file_detail_real_mp4(client):
    assert bytes("MousikóFídi Test Artist", "utf8") in rv.data
    assert bytes("MousikóFídi Test MP4", "utf8") in rv.data
    assert bytes('<video id="single" controls>', "utf8") in rv.data
    assert b"Track: 34/100" in rv.data
    assert (
        bytes(
            '<source src="/serve/{}" type="video/mp4">'.format(