tweaked ui - mpv-jellyfin - MPV script for adding an interface for Jellyfin.
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 8bec6ae51093850eb2850c5f1242b77f5d93a74b
 (DIR) parent 6767689fc042bb8ccb56fba8604800418aad770c
 (HTM) Author: EmperorPenguin18 <60635017+EmperorPenguin18@users.noreply.github.com>
       Date:   Thu, 23 May 2024 21:38:52 -0400
       
       tweaked ui
       
       Diffstat:
         A PKGBUILD                            |      18 ++++++++++++++++++
         M README.md                           |       2 --
         M scripts/jellyfin.lua                |      50 ++++++++++++++++++-------------
       
       3 files changed, 47 insertions(+), 23 deletions(-)
       ---
 (DIR) diff --git a/PKGBUILD b/PKGBUILD
       @@ -0,0 +1,18 @@
       +# Maintainer: Sebastien MacDougall-Landry
       +
       +pkgname=mpv-jellyfin
       +pkgver=1.1
       +pkgrel=1
       +pkgdesc='mpv plugin that turns it into a Jellyfin client'
       +url='https://github.com/EmperorPenguin18/mpv-jellyfin/'
       +source=("$pkgname-$pkgver.tar.gz::https://github.com/EmperorPenguin18/mpv-jellyfin/archive/refs/tags/$pkgver.tar.gz")
       +arch=('any')
       +license=('Unlicense')
       +depends=('mpv' 'curl')
       +sha256sums=('')
       +
       +package () {
       +  cd "$srcdir/$pkgname-$pkgver"
       +  install -Dm644 scripts/jellyfin.lua -t "$pkgdir/etc/mpv/scripts"
       +  install -Dm644 script-opts/jellyfin.conf -t "$pkgdir/etc/mpv/script-opts"
       +}
 (DIR) diff --git a/README.md b/README.md
       @@ -29,6 +29,4 @@ When you activate a video in the menu, it will begin to play that file.
        
        In general this is a very minimal script and isn't designed to be a full Jellyfin client. Changing settings or metadata has to be done from a real Jellyfin client.
        
       -Currently navigation is very slow because metadata is pulled in sequentially. You may want to create a playlist with stuff you want to watch to save yourself the time.
       -
        Thumbnails will accumulate if the selected image path isn't tmpfs. In addition thumbnails are raw bgra, which means they are less space efficient than the source images from the Jellyfin server.
 (DIR) diff --git a/scripts/jellyfin.lua b/scripts/jellyfin.lua
       @@ -25,6 +25,7 @@ local items = {}
        local ow, oh, op = 0, 0, 0
        local video_id = ""
        local async = nil
       +local list_start = 1
        
        local toggle_overlay -- function
        
       @@ -59,21 +60,24 @@ end
        
        local function update_list()
                overlay.data = ""
       -        for _, item in ipairs(items) do
       -                if _ > selection[layer] - (53 / op) then
       -                        if _ < selection[layer] + (20 * op) then
       -                                local index
       -                                if item.IndexNumber and item.IsFolder == false then
       -                                        index = item.IndexNumber..". "
       -                                else
       -                                        index = ""
       -                                end
       -                                if _ == selection[layer] then
       -                                        overlay.data = overlay.data.."{\\fs16}{\\c&HFF&}"..index..item.Name.."\n"
       -                                else
       -                                        overlay.data = overlay.data.."{\\fs16}"..index..item.Name.."\n"
       -                                end
       -                        end
       +        local magic_num = 29 -- const
       +        if selection[layer] - list_start > magic_num then
       +                list_start = selection[layer] - magic_num
       +        elseif selection[layer] - list_start < 0 then
       +                list_start = selection[layer]
       +        end
       +        for i=list_start,list_start+magic_num do
       +                if i > #items then break end
       +                local index = ""
       +                if items[i].IndexNumber and items[i].IsFolder == false then
       +                        index = items[i].IndexNumber..". "
       +                else
       +                        -- nothing
       +                end
       +                if i == selection[layer] then
       +                        overlay.data = overlay.data.."{\\fs16}{\\c&HFF&}"..index..items[i].Name.."\n"
       +                else
       +                        overlay.data = overlay.data.."{\\fs16}"..index..items[i].Name.."\n"
                        end
                end
                overlay:update()
       @@ -178,9 +182,11 @@ local function play_video()
        end
        
        local function key_up()
       -        selection[layer] = selection[layer] - 1
       -        if selection[layer] == 0 then selection[layer] = table.getn(items) end
       -        update_data()
       +        if #items > 1 then
       +                selection[layer] = selection[layer] - 1
       +                if selection[layer] == 0 then selection[layer] = table.getn(items) end
       +                update_data()
       +        end
        end
        
        local function key_right()
       @@ -196,9 +202,11 @@ local function key_right()
        end
        
        local function key_down()
       -        selection[layer] = selection[layer] + 1
       -        if selection[layer] > table.getn(items) then selection[layer] = 1 end
       -        update_data()
       +        if #items > 1 then
       +                selection[layer] = selection[layer] + 1
       +                if selection[layer] > table.getn(items) then selection[layer] = 1 end
       +                update_data()
       +        end
        end
        
        local function key_left()