Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
point to new rss server and add bbc world feed
Browse files Browse the repository at this point in the history
  • Loading branch information
playsamay4 committed Feb 25, 2024
1 parent f547c3d commit 2a19fcc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
2 changes: 1 addition & 1 deletion main.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local inspect = require "lib.inspect"

Version = "1.2.0"
Version = "1.2.2"

--Set Identity
love.filesystem.setIdentity("VizHelper")
Expand Down
24 changes: 23 additions & 1 deletion modules/ticker_control.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
local tickerControl = {}

local timer = require "lib.timer"

--Check if ticker.txt exists
local tickerExists = love.filesystem.read("ticker.txt")
if tickerExists == nil then
Expand All @@ -16,6 +18,8 @@ tickerControl.tickerUsingRSS = ffi.new("bool[1]", false)

tickerControl.tickerLimit = ffi.new("int[1]", 0)

tickerControl.rssFeedBox = ffi.new("int[1]", 0)

local wires = require "wires"

--Load ticker text
Expand Down Expand Up @@ -49,7 +53,7 @@ tickerControl.draw = function()
imgui.Text("Default ticker text") imgui.SameLine()
imgui.InputText("###defaultTickerText", tickerControl.defaultTickerText, 1024)

if imgui.Checkbox("Use BBC News UK RSS Feed", tickerControl.tickerUsingRSS) then
if imgui.Checkbox("Use BBC RSS Feeds", tickerControl.tickerUsingRSS) then
if tickerControl.tickerUsingRSS[0] == true then
GFX:send("headline", {Type = "GetTickerTextTable", Limit = tickerControl.tickerLimit[0], Text = wires.wireData, DefaultText = ffi.string(tickerControl.defaultTickerText)})
else
Expand Down Expand Up @@ -87,6 +91,24 @@ tickerControl.draw = function()

imgui.Separator()
else
imgui.SameLine()
if imgui.Combo_Str("###rssFeedList", tickerControl.rssFeedBox, "BBC News UK\0BBC World\0") then
if tickerControl.rssFeedBox[0] == 0 then
fillWithUKWires()

timer.after(1.5, function()
GFX:send("headline", {Type = "GetTickerTextTable", Limit = tickerControl.tickerLimit[0], Text = wires.wireData, DefaultText = ffi.string(tickerControl.defaultTickerText)})
end)
elseif tickerControl.rssFeedBox[0] == 1 then
fillWithWorldWires()

timer.after(1.5, function()
GFX:send("headline", {Type = "GetTickerTextTable", Limit = tickerControl.tickerLimit[0], Text = wires.wireData, DefaultText = ffi.string(tickerControl.defaultTickerText)})
end)
end
end


imgui.Text("Limit ticker to ") imgui.SameLine()
if imgui.InputInt(" headlines (0 = no limit) ###tickerLimit", tickerControl.tickerLimit, 1, 2) then
GFX:send("headline", {Type = "GetTickerTextTable", Limit = tickerControl.tickerLimit[0], Text = wires.wireData, DefaultText = ffi.string(tickerControl.defaultTickerText)})
Expand Down
18 changes: 15 additions & 3 deletions wires.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local BBCWorldSCR = [[
local socket = require("socket.http")
local parser = xml2lua.parser(handler)
local wireGatherData = ""
local wireGatherURLS = {"https://rss.playsamay4.com/bbcworld"}
local wireGatherURLS = {"http://rss.playsamay4.com:2082/bbcworld"}
local inspect = require "lib.inspect"
for i = 1, #wireGatherURLS do
Expand All @@ -37,7 +37,7 @@ local BBCUKSCR = [[
local socket = require("socket.http")
local parser = xml2lua.parser(handler)
local wireGatherData = ""
local wireGatherURLS = {"https://rss.playsamay4.com/bbcuk"}
local wireGatherURLS = {"http://rss.playsamay4.com:2082/bbcuk"}
local inspect = require "lib.inspect"
for i = 1, #wireGatherURLS do
Expand All @@ -59,7 +59,7 @@ local BBCUKSCR = [[

wires.wireData = {}

--local BBCWorldThread = love.thread.newThread(BBCWorldSCR)
local BBCWorldThread = love.thread.newThread(BBCWorldSCR)
--BBCWorldThread:start()

local BBCUKThread = love.thread.newThread(BBCUKSCR)
Expand All @@ -84,7 +84,19 @@ function wires.Update(dt)
if wireGatherData[i].title ~= nil then table.insert(wires.wireData, wireGatherData[i].title) end
end



end
end

function fillWithWorldWires()
wires.wireData = {}
BBCWorldThread:start()
end

function fillWithUKWires()
wires.wireData = {}
BBCUKThread:start()
end

return wires

0 comments on commit 2a19fcc

Please sign in to comment.