11local FILE_NAME = ' dailyprogrammer.txt'
2- local T_MODES = {" easy" , " intermediate" , " difficult" , " hard" }
2+ local T_MODES = {' easy' , ' intermediate' , ' difficult' , ' hard' }
33local t_links = {}
44
55function download ()
66 io.write (' download ... ' )
77 io.flush ()
88 local http = require (' socket.http' )
9- local ltn12 = require (' ltn12' )
109
1110 local pat_entry = ' <a class="title " href="([^"]+)"'
1211 local pat_next = ' <a href="([^"]+)"[^>]+>next'
@@ -17,10 +16,7 @@ function download()
1716 assert (code == 200 )
1817
1918 for x in html :gmatch (pat_entry ) do
20- -- if x:match("_challenge_") then
2119 table.insert (t_links , x )
22- -- end
23- -- print(x)
2420 end
2521
2622 next_link = html :match (pat_next )
@@ -43,7 +39,6 @@ local update = (arg[1] == 'update')
4339local file = io.open (FILE_NAME ,' r' )
4440if not file or update then download ()
4541else
46- print (' using local copy.' )
4742 for link in file :lines () do
4843 table.insert (t_links , link )
4944 end
5247
5348local t_mode = {}
5449for _ ,x in pairs (t_links ) do
55- local mode = x :match (" (difficult)" ) or x :match (" (intermediate)" ) or x :match (" (easy)" ) or x :match (" (hard)" )
50+ local mode = x :match (' (difficult)' ) or x :match (' (intermediate)' ) or x :match (' (easy)' ) or x :match (' (hard)' )
5651
5752 if mode then
5853 if not t_mode [mode ] then t_mode [mode ] = {} end
0 commit comments