Introduction
Introduction Statistics Contact Development Disclaimer Help
better performance - mpv-jellyfin - MPV script for adding an interface for Jell…
Log
Files
Refs
README
LICENSE
---
commit 6767689fc042bb8ccb56fba8604800418aad770c
parent afadb0cc8bc8a0222580fe00b0ba1e5d8ceb4b37
Author: EmperorPenguin18 <[email protected]>
Date: Thu, 23 May 2024 20:07:32 -0400
better performance
Diffstat:
M scripts/jellyfin.lua | 85 +++++++++++++++++++++--------…
1 file changed, 58 insertions(+), 27 deletions(-)
---
diff --git a/scripts/jellyfin.lua b/scripts/jellyfin.lua
@@ -24,6 +24,7 @@ local layer = 1
local items = {}
local ow, oh, op = 0, 0, 0
local video_id = ""
+local async = nil
local toggle_overlay -- function
@@ -56,7 +57,7 @@ local function line_break(str, flags, space)
return text
end
-local function update_data()
+local function update_list()
overlay.data = ""
for _, item in ipairs(items) do
if _ > selection[layer] - (53 / op) then
@@ -76,62 +77,92 @@ local function update_data()
end
end
overlay:update()
+end
+
+local scale = 2 -- const
- local id = items[selection[layer]].Id
- local width = math.floor(ow/3)
+local function show_image(success, result, error, userdata)
+ if success == true then
+ mp.command_native({
+ name = "overlay-add",
+ id = 0,
+ x = math.floor(ow/2.5),
+ y = 10,
+ file = userdata[3],
+ offset = 0,
+ fmt = "bgra",
+ w = userdata[1],
+ h = userdata[2],
+ stride = userdata[1]*4,
+ dw = userdata[1]*scale,
+ dh = userdata[2]*scale
+ })
+ end
+end
+
+local function update_image(item)
+ local width = math.floor(ow/(3*scale))
local height = 0
local filepath = ""
- for _, image in ipairs(send_request("GET", options.url.."/Items/"..id.…
- if image.ImageType == "Primary" then
- height = math.floor( width*(image.Height / image.Width…
- filepath = options.image_path.."/"..id.."_"..width.."_…
- mp.command_native({
- name = "subprocess",
- playback_only = false,
- args = { "mpv", options.url.."/Items/"..id.."/…
- })
- break
- end
- end
mp.commandv("overlay-remove", "0")
- mp.commandv("overlay-add", "0", tostring(math.floor(ow/2.5)), tostring…
+ if item.ImageTags.Primary ~= nil then
+ height = math.floor(width/item.PrimaryImageAspectRatio)
+ filepath = options.image_path.."/"..item.Id.."_"..width.."_"..…
+ if async ~= nil then mp.abort_async_command(async) end
+ async = mp.command_native_async({
+ name = "subprocess",
+ playback_only = false,
+ args = { "mpv", options.url.."/Items/"..item.Id.."/Ima…
+ }, function(success, result, error) show_image(success, result…
+ end
+end
+
+local function update_metadata(item)
meta_overlay.data = ""
- local metadata = send_request("GET", options.url.."/Users/"..user_id..…
- local name = line_break(metadata.Name, "{\\a7}{\\fs24}", 30)
+ local name = line_break(item.Name, "{\\a7}{\\fs24}", 30)
meta_overlay.data = meta_overlay.data..name.."\n"
local year = ""
- if metadata.ProductionYear then year = metadata.ProductionYear end
+ if item.ProductionYear then year = item.ProductionYear end
local time = ""
- if metadata.RunTimeTicks then time = " "..math.floor(metadata.RunTim…
+ if item.RunTimeTicks then time = " "..math.floor(item.RunTimeTicks/6…
local rating = ""
- if metadata.CommunityRating then rating = " "..metadata.CommunityRat…
+ if item.CommunityRating then rating = " "..item.CommunityRating end
local hidden = ""
local watched = ""
- if metadata.UserData.Played == false then
+ if item.UserData.Played == false then
if options.hide_spoilers ~= "off" then hidden = "{\\bord0}{\\1…
else
watched = " Watched"
end
local favourite = ""
- if metadata.UserData.IsFavorite == true then
+ if item.UserData.IsFavorite == true then
favourite = " Favorite"
end
meta_overlay.data = meta_overlay.data.."{\\a7}{\\fs16}"..year..time..r…
- local tagline = line_break(metadata.Taglines[1], "{\\a7}{\\fs20}", 35)
+ local tagline = line_break(item.Taglines[1], "{\\a7}{\\fs20}", 35)
meta_overlay.data = meta_overlay.data..tagline.."\n"
- local description = line_break(metadata.Overview, "{\\a7}{\\fs16}"..hi…
+ local description = line_break(item.Overview, "{\\a7}{\\fs16}"..hidden…
meta_overlay.data = meta_overlay.data..description
meta_overlay:update()
end
+local function update_data()
+ update_list()
+ local item = items[selection[layer]]
+ update_image(item)
+ update_metadata(item)
+end
+
local function update_overlay()
overlay.data = "{\\fs16}Loading..."
overlay:update()
+ local url = options.url.."/Items?api_key="..api_key.."&userID="..user_…
if layer == 2 then
- items = send_request("GET", options.url.."/Items?api_key="..ap…
+ url = url.."&sortBy=SortName"
else
- items = send_request("GET", options.url.."/Items?api_key="..ap…
+ -- nothing
end
+ items = send_request("GET", url).Items
ow, oh, op = mp.get_osd_size()
update_data()
end
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.