Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- created by /u/revereddesecration on 2014/09/09
- -- tested on Win7
- -- you will need luarocks - see here: http://luarocks.org/en/Download
- -- xml module can be installed using "luarocks install xml"
- -- more info on the xml module: https://rocks.moonscript.org/modules/gaspard/xml
- -- you will also need curl - see here: http://curl.haxx.se/dlwiz/?type=bin
- -- tprint not required, it just prints tables nicely
- assert(require "tprint", "tprint not found - no biggie smalls")
- xml = require "xml"
- -- begin user input section
- -- channel names must match youtube URL e.g. www.youtube.com/user/GuudeBoulderfist
- channels = {
- GuudeBoulderfist = {
- patterns = {"Space", "crack"}
- },
- Pyropuncher = {
- patterns = {"Civilization 5"}
- },
- DocM77 = {
- patterns = {"Civilization V"}
- },
- VintageBeef = {
- patterns = {"The Forest"} -- lol
- },
- SuperMCGamer = {
- patterns = {"Zelda: Oracle of Seasons"}
- },
- MillBeeful = {
- patterns = {"Mario Kart 8 :: The Road To 10,000"}
- }
- }
- -- end user input section
- for channel,tableChannel in pairs(channels) do
- os.execute("curl http://gdata.youtube.com/feeds/api/users/"..channel.."/uploads -o feeds/"..channel..".xml")
- channels[channel].xml = xml.loadpath("feeds/"..channel..".xml")
- channels[channel].videos = {}
- for k,v in pairs(channels[channel].xml) do
- if (tonumber(k) or 1) > 16 then
- n = tonumber(k)
- channels[channel].videos[n] = {}
- channels[channel].videos[n].title = v[6][1]
- channels[channel].videos[n].time = v[2][1]
- channels[channel].videos[n].url = string.sub(v[8].href, 1, 42)
- channels[channel].videos[n].thumb = v[15][8].url
- end
- end
- channels[channel].xml = nil
- end
- videos = {}
- function parseTime(s)
- year = s:sub(1,4)
- month = s:sub(6,7)
- day = s:sub(9,10)
- hour = s:sub(12,13)
- minute = s:sub(15,16)
- second = s:sub(18,19)
- return tonumber(year..month..day..hour..minute..second)
- end
- for channel,tableChannel in pairs(channels) do
- for video,tableVideo in pairs(tableChannel.videos) do
- for _,pattern in pairs(tableChannel.patterns) do
- if string.find(tableVideo.title, pattern) then
- videos[parseTime(tableVideo.time)] = {
- channel = channel,
- title = tableVideo.title,
- url = tableVideo.url,
- thumb = tableVideo.thumb
- }
- end
- end
- end
- end
- html = [[<head>
- <style>
- .thumbnail {
- width: 200px;
- height: 120px;
- }
- /* resize images */
- .thumbnail img {
- width: 100%;
- height: auto;
- }
- </style>
- </head>
- <body>
- <table>
- <tr>
- <th>Thumbnail</th>
- <th>Information</th>
- </tr>
- ]]
- a = {}
- for n in pairs(videos) do table.insert(a, n) end
- table.sort(a, function(a,b) return a>b end)
- for i,n in ipairs(a) do
- html = html..[[<tr>
- <td class="thumbnail">]].."<a href=\""..videos[n].url.."\"><img src=\""..videos[n].thumb.."\" />"..[[</td>
- <td>]]..videos[n].channel.."<br/><a href=\""..videos[n].url.."\">"..videos[n].title.."<a/>"..[[</td>
- </tr>
- ]]
- end
- html = html..[[
- </table>
- </body>]]
- --print(html)
- file = io.open("subs.html","w")
- file:write(html)
- file:close()
- os.execute("subs.html")
- print("success!")
Advertisement
Add Comment
Please, Sign In to add comment