0x1eef
2d9a22ea8f
The project's directory structure has been changed to be similar to how FreeBSD organizes its filesystem. The english, portuguese, and farsi translations are now sourced from https://quran.com. The original Arabic is still sourced from searchtruth.com. Files have been removed, and / or replaced. The SQL-related files have been removed, with the intention to separate them into a new project in the future (quran-sql). The lessons learnt from the development of quran-audio were an inspiration for this change.
32 lines
752 B
Text
Executable file
32 lines
752 B
Text
Executable file
#!/usr/bin/env ruby
|
|
lib_dir = File.realpath File.join(__dir__, "..", "..", "lib", "quran-pull")
|
|
require File.join(lib_dir, "pull")
|
|
require "optparse"
|
|
require "nokogiri"
|
|
|
|
def grep(res)
|
|
html = Nokogiri::HTML(res.body)
|
|
el = html.css("div[class^='TranslationText']").last
|
|
el.text.gsub(/[0-9]/, "")
|
|
end
|
|
|
|
##
|
|
# main
|
|
def main(argv)
|
|
cmd = Pull.new(Pull.cli(argv))
|
|
cmd.http.start
|
|
1.upto(114) do |surah_no|
|
|
rows = []
|
|
1.upto(cmd.count[surah_no]) do |ayah_no|
|
|
cmd.pull_ayah(surah_no, ayah_no) do |res|
|
|
rows.concat([ayah_no, grep(res)])
|
|
end
|
|
cmd.line.rewind.print "Surah #{surah_no} [#{ayah_no}/#{cmd.count[surah_no]}]"
|
|
end
|
|
cmd.write(surah_no, rows)
|
|
cmd.line.end
|
|
end
|
|
ensure
|
|
cmd.http.finish
|
|
end
|
|
main(ARGV)
|