--[[ ARD Nachrichten-App Vers.: 0.5 Copyright (C) 2016, bazi98 with many hints and code snippets from SatBaby, big thanks from my to him App Description: There the player links are respectively read about the recent news reports of the First German Television "ARD Tagesschau" from the ARD library, displays and allows them to play with the neutrino-movie player. License: GPL This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. Copyright (C) for the linked videos and for the ARD-Logo by the ARD or the respective owners! ]] local json = require "json" time = (os.date ("%H%M")) -- aktuelle Uhrzeit im Format Stunden:Minuten = z.B. 1530 heute=(os.date ("%d.%m.%Y")) heute2=(os.date ("%y/%m/%y%m%d")) gestern = (os.date("%d.%m.%Y", os.time() - 3600*24)) gestern2 = (os.date ("%y/%m/%y%m%d", os.time() - 3600*24)) --Objekte function script_path() local str = debug.getinfo(2, "S").source:sub(2) return str:match("(.*/)") end function init() n = neutrino(); p = {} func = {} pmid = 0 stream = 1 tmpPath = "/tmp" ard_news = decodeImage("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC45bDN+TgAACSFJREFUSEtdVmlUlNcZnuWbAdTTo2hcYrTHti4xp6kLMIBsgoDDMKwamxhrPe4mJ5qm0ahBQFBEIIiJuwJaU6Px2JgaowICwzosbmCMVUGlqK3IvsPM0+d+A9r2x3Pu98039z73fd/nXRQpp10dZnxybPq4+XHHR8/d0WrvFA317BgZkoATn522EVHQ8Jt2dizsZkdDM3s7wXXW5/yf+J3P/C45x3AVe7fBnvvG+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xsUVyD7amEFaa8PxuOK5kZ6F1at+v5U6hJKHcLWRCjhdKdmglrVTrv5fjpw4shDaERfvQE4SbehBRIsC8Yn0MK+1jjbTKyR1eKpqujUwgsrAPU2OrZaFo530P5Zw0udeKzi8JlwqVKtgkxVghzyAeHIgCvmOwbYVcY+Qo8U42XltZiokbKzFj3334ZzWyMLMbkFDUSuMgSOx6tI6jxxVI/ueh9EzjmQkkG+j4LmzA9jrR8QfHAAE2Y68D0AR+R/fmkJSuEcHnKgnLg3MxLe4OjGywRnM3gtkLjWYr3UrLqc7p229h0kpqwHMvzxqYk2QkwV63CYrX/RI7xMvgBxXnEBVHAqXbl5CoLknP2zJdVHJ/LKKCi6AOz+Ecc59ELGEkMpRzgGLe/S75Jka88zW0Xl/IZ6jEIDVwrtDISK+YNsX4sKQMlVuCdfCDMF9WLedTlY4jn1CY70mqTcRWFIerrB7Z8DhYh4j8HoRebIZfRi2mbeDFvFNJIsIjzhAhGhiiKBrJfZdlckTaPsWCT9Kmv6HfXivN2WmVRw0hnoFNr8B3NypZiIruFgOxvf9+DDUcgt08esIzlfs4NYgLCgzsV9NKNVc7z53WifodZs8VeycpVq1apfH9ONtlyoK0c44+W7scdFGwY24KaAfWwWeNy44BxBN818VSeeLbNoL7XMTe6Jd7HIixPnF9v124P92w+uxkb29v6T8BazNrlxUAaQAAAABJRU5ErkJggg==") end function add_stream(t,u) p[#p+1]={title=t,url=u,access=stream} end function getdata(Url,outputfile) if Url == nil then return nil end if Curl == nil then Curl = curl.new() end local ret, data = Curl:download{url=Url,A="Mozilla/5.0;",followRedir=true,o=outputfile } if ret == CURL.OK then return data else return nil end end -- function from http://lua-users.org/wiki/BaseSixtyFour -- character table string local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -- decode function dec(data) data = string.gsub(data, '[^'..b..'=]', '') return (data:gsub('.', function(x) if (x == '=') then return '' end local r,f='',(b:find(x)-1) for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end return r; end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x) if (#x ~= 8) then return '' end local c=0 for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end return string.char(c) end)) end function decodeImage(b64Image) local imgTyp = b64Image:match("data:image/(.-);base64,") local repData = "data:image/" .. imgTyp .. ";base64," local b64Data = string.gsub(b64Image, repData, ""); local tmpImg = os.tmpname() local retImg = tmpImg .. "." .. imgTyp local f = io.open(retImg, "w+") f:write(dec(b64Data)) f:close() os.remove(tmpImg) return retImg end function fill_playlist() --- > begin playlist --- Tagesschau in 100 Sekunden, multiple daily new at different times local data = getdata('http://www.tagesschau.de/export/video-podcast/webxl/tagesschau-in-100-sekunden',nil) if data then local tagesschau100 = data:match('enclosure url="(.-mp4)"') if tagesschau100 then local H,M= tagesschau100:match(".-(%d%d)(%d%d).web-.") -- only time the show when it was included in the ARD Mediathek local Y,m,d= tagesschau100:match(".-100s/(%d%d%d%d)/(%d%d)(%d%d)/TV-.") -- nur Datum add_stream("Tagesschau in 100 Sek. vom "..d.."."..m.."."..Y.."-"..H..":"..M.." Uhr","" .. tagesschau100 .. "") end end --- end Tagesschau in 100 Sekunden --- Tagesschau, multiple daily new at different times if (( time >= "0630") and ( time <= "2030")) then local data = getdata('http://www.tagesschau.de/sendung/letzte-sendung/index.html',nil) if data then local tagesschau_current= data:match('1280x720px.-href="(.-)">HD %(h264%)= "06") and ( H < "20") then add_stream("Tagesschau vom "..d.."."..m.."."..Y.."-"..H..":00 Uhr","" .. tagesschau_current .. "") -- original time of transmission end end end end --- end Tagesschau --- Tageschau von 20:00 Uhr, daily local data = getdata('http://www.tagesschau.de/export/video-podcast/webxl/tagesschau',nil) if data then local tagesschau = data:match('enclosure url="(.-mp4)"') if tagesschau then local Y,m,d= tagesschau:match(".-(%d%d%d%d)(%d%d)(%d%d) - -.") -- only date add_stream("Tagesschau vom "..d.."."..m.."."..Y.."-20:00 Uhr","" .. tagesschau .. "") end end --- end tagesschau von 20:00 Uhr --- Tagesthemen,daily, beginning btw. ca. 22:30 and 23:30 Uhr local data = getdata('http://www.tagesschau.de/export/video-podcast/webxl/tagesthemen',nil) if data then local tagesthemen = data:match('enclosure url="(.-mp4)"') if tagesthemen then local Y,m,d,H,M= tagesthemen:match(".-(%d%d%d%d)(%d%d)(%d%d)-(%d%d)(%d%d)- -.") -- date and time of transmission when it was included in the ARD Mediathek add_stream("Tagesthemen vom "..d.."."..m.."."..Y.."-"..H..":"..M.." Uhr","" .. tagesthemen .. "") end end --- end Tagesthemen --- Nachtmagazin, only Monday through Friday, beginning btw. ca. 00:00 and 01:00 Uhr local data = getdata('http://www.tagesschau.de/export/video-podcast/webxl/nachtmagazin',nil) if data then local nachtmagazin = data:match('enclosure url="(.-mp4)"') if nachtmagazin then local Y,m,d,H,M= nachtmagazin:match(".-(%d%d%d%d)(%d%d)(%d%d)-(%d%d)(%d%d)- -.") -- date and time of transmission when it was included in the ARD Mediathek add_stream("Nachtmagazin vom "..d.."."..m.."."..Y.."-"..H..":"..M.." Uhr","" .. nachtmagazin .. "") end end --- hessenschau local data = getdata('http://www.ardmediathek.de/tv/hessenschau/Sendung?documentId=3301950&bcastId=3301950&rss=true',nil) if data then local hessen_seite = data:match('hessenschau %- ganze.-documentId=(.-)') data = getdata('http://www.ardmediathek.de/play/media/'..hessen_seite,nil) if data then local hessen = data:match('quality":3.-stream":"(.-)"') --- SD = 960x540, kein HD-Stream local y,M,d,h,m,s= hessen:match(".-(%d%d)(%d%d)(%d%d)(%d%d)(%d%d)(%d%d)_ganze-.") add_stream("hessenschau vom "..d.."."..M..".20"..y.."-19:30 Uhr",hessen) end end --- ende hessenschau --- Lokalzeit local data = getdata('http://www1.wdr.de/mediathek/video/sendungen/lokalzeit/',nil) if data then for lokalzeit_seite in data:gmatch(' end of playlist function set_pmid(id) pmid=tonumber(id); return MENU_RETURN["EXIT_ALL"]; end function select_playitem() local m=menu.new{name="ARD News App.", icon=ard_news} for i,r in ipairs(p) do m:addItem{type="forwarder", action="set_pmid", id=i, icon="streaming", name=r.title, hint=r.title, hint_icon="hint_reload"} end repeat pmid=0 m:exec() if pmid==0 then return end local vPlay = nil local url=func[p[pmid].access](p[pmid].url) if url~=nil then if vPlay == nil then vPlay = video.new() end vPlay:PlayFile("Das Erste",url,p[pmid].title,url); end until false end --Main init() func={ [stream]=function (x) return x end, } fill_playlist() select_playitem() os.execute("rm /tmp/lua*.png");