Last active
January 3, 2025 22:29
-
-
Save abler98/2fbeee9f7bd056bbe6c485041370c556 to your computer and use it in GitHub Desktop.
Скрипт для скачивания музыки VK
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
/* | |
Инструкция по использованию: | |
- заходим в раздел с аудиозаписями | |
- листаем в самый низ (чтобы прогрузились все аудиозаписи) | |
- открываем консоль браузера (F12 -> Консоль) | |
- вставляем код и нажимаем ENTER | |
- скачивание началось... | |
- браузер может потребовать разрешение на сохранение файлов, необходимо подтвердить действие | |
Важно! С открытой вкладкой ничего не делаем! | |
Проверено в Google Chrome | |
*/ | |
var script = document.createElement('script'); | |
script.src = "https://code.jquery.com/jquery-3.2.1.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(script); | |
script = document.createElement('script'); | |
script.src = "https://cdnjs.cloudflare.com/ajax/libs/downloadjs/1.4.7/download.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(script); | |
// Количество одновременных загрузок | |
const DOWNLOAD_COUNT = 5; | |
function download_file(url, name, type, callback) { | |
var xhr = new XMLHttpRequest(); | |
xhr.open("GET", url, true); | |
xhr.responseType = "blob"; | |
xhr.onload = function () { | |
download(xhr.response, name + ".mp3", type); | |
callback(); | |
}; | |
/*xhr.onprogress = function (e) { | |
var progress = e.loaded * 100 / e.total; | |
console.log( name, Math.round(progress, 2) + "%" ); | |
};*/ | |
xhr.send(); | |
} | |
setTimeout(function () { | |
var ids = $('._audio_row').map(function () { | |
return $(this).data('full-id'); | |
}).get(); | |
var progress = 0; | |
window.download_audio = function () { | |
if (progress > (ids.length - 1)) { | |
console.log("Все аудиозаписи скачаны!"); | |
return; | |
} | |
$.post("al_audio.php", { | |
act: "reload_audio", | |
al: 1, | |
ids: ids[progress++] | |
}, function (data) { | |
var matches = data.match(/<!json>\[(.+)\]<!>/); | |
if (matches == null || matches[1] == null) { | |
download_audio(); | |
console.log("Не удалось скачать аудиозапись, идём дальше..."); | |
return; | |
} | |
data = JSON.parse(matches[1]); | |
var name = data[4] + " - " + data[3]; | |
name = $('<textarea/>').html(name).text(); | |
download_file(data[2], name, "audio/mp3", window.download_audio); | |
console.log("Скачиваем...", name); | |
}); | |
} | |
for (var i = 0; i < DOWNLOAD_COUNT; i++) { | |
download_audio(); | |
} | |
}, 2000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ссылка не доступна