Created
October 30, 2011 16:39
-
-
Save Sakurina/1326097 to your computer and use it in GitHub Desktop.
a horrific attempt at brute forcing technika 3 album art URLs, could probably be greatly improved, uses repeated_permutation which requires ruby 1.9.x
This file contains hidden or 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 'uri' | |
require 'net/http' | |
def url_for_songname(songname) | |
"http://img3.platinumcrew.co.kr/icon/disc/110/#{songname}_1.png" | |
end | |
def all_possibilities_for_this_many_characters(c) | |
char_seq = [] | |
(97..122).each do |charcode| # letters | |
char_seq << charcode.chr | |
end | |
(48..57).each do |charcode| # numbers | |
char_seq << charcode.chr | |
end | |
return char_seq.repeated_permutation(c).to_a.map { |p| | |
p.join | |
} | |
end | |
def song_validity_test(url) | |
uri = URI.parse(url) | |
result = Net::HTTP.start(uri.host, uri.port) { |http| http.get(uri.path) } | |
puts url if result.code == "200" | |
end | |
(2..25).each do |c| | |
puts ":: trying song name possibilities with #{c} characters..." | |
possibilities = all_possibilities_for_this_many_characters(c) | |
possibilities.each do |songname| | |
song_validity_test(url_for_songname(songname)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment