Created
May 13, 2013 15:13
-
-
Save SergXIIIth/5569057 to your computer and use it in GitHub Desktop.
Download music from vk.com. 1. Run vk_download.js inside your music
2. Save result json to file "tracks.json"
3. Run "ruby vk_download.rb" Music will be in "./tracks"
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
function async_init() { | |
var element, type, src; | |
var parent = document.getElementsByTagName('body'); | |
var cdn = new Array; | |
cdn[0] = '//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js'; | |
for (var i in cdn) { | |
element = document.createElement('script'); | |
type = document.createAttribute('type'); | |
src = document.createAttribute('src'); | |
type.nodeValue = 'text/javascript'; | |
src.nodeValue = cdn[i]; | |
element.setAttributeNode(type); | |
element.setAttributeNode(src); | |
document.body.insertBefore(element, parent); | |
} | |
} | |
async_init() | |
function p(mes){ console.log(mes); } | |
var tracks = []; | |
$(".audio").each(function(){ | |
var audio = {} | |
audio.url = $(".play_btn input", this).val(); | |
audio.url = audio.url.split(',')[0]; | |
audio.name = $(".title a", this).text(); | |
tracks.push(audio); | |
}); | |
$('body').html(JSON.stringify(tracks)); |
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 'json' | |
require 'open-uri' | |
Dir.mkdir('tracks') unless Dir.exists?('tracks') | |
tracks = JSON.parse(File.read('tracks.json')) | |
tracks.each do |track| | |
next if File.exists?("tracks/#{track['name']}") | |
open("tracks/#{track['name']}", 'wb') do |file| | |
file << open(track['url']).read | |
end | |
puts "#{track['name']} - downloaded" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment