-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse
More file actions
executable file
·27 lines (23 loc) · 777 Bytes
/
Copy pathparse
File metadata and controls
executable file
·27 lines (23 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/ruby
require './crawler.rb'
def parse_chapters(story)
list = Dir["#{story}/chapter*"].sort_by { |x| x.match(/\d+$/)[0].to_i }
list.each do |chapter|
puts "\n - Re-parsing #{chapter} ... "
if !File.size?("#{chapter}/crawled.html")
raise "ERROR #{chapter}/crawled.html not cached"
next
end
html = File.open("#{chapter}/crawled.html", 'r').read
chapnum = chapter.match(/\d+$/)[0].to_i
nextchap = list.last != chapter
Crawler.parse(html, story.sub(/.*content\//, ''), chapter, chapnum, nextchap)
# raise
end
end
(ARGV.empty? ? Dir["./content/*"] : ARGV).each do |story|
if File.directory? story
puts "\n---", story
parse_chapters(story)
end
end