Youtube Playlist 2 mp3

Makes script to download playlist and convert it to mp3 with number.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Youtube Playlist 2 mp3
// @description  Makes script to download playlist and convert it to mp3 with number.
// @namespace    https://greatest.deepsurf.us/users/3159
// @version      0.3
// @include      http*://www.youtube.com/playlist?list=*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function generateScript(){
        var playlist = document.getElementsByClassName('yt-simple-endpoint style-scope ytd-playlist-video-renderer');
        var allCode = [];

        for (var i = 0; i < playlist.length; i++) {
            if (playlist[i].getAttribute("href")){
                if (playlist[i].children[1].children[0].children[1].title != ("[Deleted video]" || "[Private video]")) {

                    var a=playlist[i].href.split('v=')[1].split('&')[0] // Video ID
                    var b=playlist[i].href.split('index=')[1].split('&')[0].padStart(3, "0") // Number
                    var c=playlist[i].children[1].children[0].children[1].title.replace(/\//g, "\\").replace(/\'/g, '"') // Name and remove '

                 allCode.push("youtube-dl -f 251 'https://www.youtube.com/watch?v=" + a + "' --id && ffmpeg -i '" + a + ".webm' '" + b + "_" + c + ".mp3'");
            }}
        }
        document.body.innerHTML = "select all and copy into terminal, remove webm waste when done<br /><br />";
        document.body.style.fontSize="1.3em"
        for (i = 0; i < allCode.length; i++) {
            document.body.innerHTML += allCode[i] + " && <br />";
        }
        document.body.innerHTML += "echo 'done! Remember to use kid3 to set track number if needed.'";
    }

    var css = 'p:hover{ background-color:red;color:white;border-radius: 3px; }p{ font-size:.75em;float:right;cursor:pointer }';
    var style = document.createElement('style');
    style.innerHTML = css;
    document.head.appendChild(style);

    var button = document.createElement('p');
    button.innerText = " ⇩ ";
    button.onclick = generateScript;
    document.getElementById('text-displayed').appendChild(button);
})();