Created
October 10, 2014 15:41
-
-
Save MohamedBassem/4d02873058f7c3232ad5 to your computer and use it in GitHub Desktop.
Nogomi Downloader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
require 'open-uri' | |
require 'net/http' | |
require 'uri' | |
artist_link = ARGV[0] | |
folder_name = ARGV[1] | |
if artist_link.nil? or folder_name.nil? | |
puts "You must specify the artist link and folder name" | |
end | |
albums = Nokogiri::HTML(open(artist_link)).css("#IndDivmainbox_m_left_Top_Albums_thumb_Title > font > a") | |
albums = albums.map { |link| [link.text.strip.gsub(/ /,"").gsub(/\n/,"") , link["href"].gsub(/album.asp\?ID=/,"")] } | |
puts "Will Download : " | |
albums.each do |album| | |
puts album[1] + ": " + album[0] | |
end | |
album_download_links = albums.map { |album| "http://www.nogomistars.com/zip.asp?type=mp3&ID=" + album[1] } | |
direct_download_links = [] | |
puts "\nAlbum Download Links : " | |
album_download_links.each_with_index do |line,idx| | |
doc = Nokogiri::HTML(open(line)) | |
x = doc.css("a:contains('Download From Mirror')").first | |
if x.nil? | |
puts "Album " + line.chomp + " " + "doesn't have an mp3 version" | |
else | |
puts x["href"].gsub(/\?/,"links.asp?") | |
direct_download_links << [ albums[idx][0] , x["href"].gsub(/\?/,"links.asp?") ] | |
end | |
end | |
direct_download_links.each do |link| | |
puts "\n\n\n\nDownloading " + link[0] | |
`wget -P "#{folder_name}" --content-disposition "#{link[1]}"` | |
puts "Downloaded ..\n\n\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment