So you know what’s really annoying? How many downloaders people are trying to sell! I love DownThemAll for firefox, its a great plug-in that i highly recommend. Unfortunately you can’t just add a list of links. You have to have “clickable” links for it to work. Well that sucks, I guess you have to get one of those 20 dollar apps, right? WRONG! Ruby saves the day! I might make a gui for this script at some point but until then it works flawlessly in terminal.
Just add all the links you want to download to a text file and save it with .txt extension. Now run this script and input the .txt file as the parameter, i.e:
./txttohtml links.txt
Now you should find an html file in the same folder with the text file, the filename is the, but with an .html extension. Anyway, here’s the script:
#!/usr/bin/ruby
# Dmitry Nedospasov
# Text to HTML
# This script converts a .txt file to an html file with each
# line of the file as a link
#
# I wanted this so that i could use rapidshare with DTA
# Script needs one argument, the .txt file
require 'ftools'
def parseargs(arguments, stdin)
# puts arguments
txtFile = arguments[0]
if txtFile == nil
puts 'Please enter a filename'
elsif txtFile =~ /.txt$/
puts 'Checking the following file: ' + txtFile
convertFromTxtToHtml(txtFile)
else
puts 'Please enter a file that ends with .txt'
end
end
def convertFromTxtToHtml(txtFile)
htmlFile = txtFile.sub(/.txt$/, " .html" )
puts 'Writing results to: ' + htmlFile
myHtmlFile = File.new(htmlFile, " w+" )
myTxtFile = File.open(txtFile, " r" )
if File.zero?(myTxtFile)
puts 'the .txt file is empty'
elsif File.exist?(myTxtFile)
myHtmlFile.puts(" <html>" )
counter = 1
myTxtFile.readlines.each { |curLine|
newLine = '<a href=" '
newLine += curLine
newLine += '" >'
newLine += " #{counter}"
newLine += ' - '
newLine += curLine
newLine += '</a>'
myHtmlFile.puts(newLine)
myHtmlFile.puts(" <br />" )
counter += 1
}
myHtmlFile.puts(" </html>" )
else
puts 'File not found'
end
end
parseargs(ARGV, STDIN)
Now you can fire up firefox and open the html file and start dta, however the “cool” way to create the html files and launch firefox from terminal is, in Mac OS:
./txttohtml.rb *.txt && open -a Firefox *.html
And in linux:
./txttohtml.rb *.txt && firefox *.html
Have fun and here is the file for download