From: Mike Lowis Date: Thu, 6 Feb 2025 17:41:25 +0000 (-0500) Subject: sort the results and save teh state to web root instead of /tmp X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=6184534e4431e87da651bf943aaa19946fa4ba48;p=proto%2Fatv.git sort the results and save teh state to web root instead of /tmp --- diff --git a/atv/lib/atv/channel.rb b/atv/lib/atv/channel.rb index 68cabd0..9aec110 100644 --- a/atv/lib/atv/channel.rb +++ b/atv/lib/atv/channel.rb @@ -103,7 +103,7 @@ module ATV data["type"] = "dir" end data - end + end.sort {|a,b| a["name"] <=> b["name"] } { "items" => items } end diff --git a/atv/lib/atv/player.rb b/atv/lib/atv/player.rb index 9738974..f672094 100644 --- a/atv/lib/atv/player.rb +++ b/atv/lib/atv/player.rb @@ -5,8 +5,8 @@ module ATV @channel = 0 @channels = channels @playing = true - if File.exist? "/tmp/atv.json" - data = JSON.parse(File.read("/tmp/atv.json")) + if File.exist? "#{ATV_ROOT}/atv.json" + data = JSON.parse(File.read("#{ATV_ROOT}/atv.json")) data.each_with_index {|e, i| channels[i].import_state e } end end @@ -18,7 +18,7 @@ module ATV updated ||= c.update(@playing) export_data << c.export_state end - File.open("/tmp/atv.json", "wb") do |f| + File.open("#{ATV_ROOT}/atv.json", "wb") do |f| f.write JSON.dump(export_data) end updated