Youtube Playlist 2 mp3

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Youtube Playlist 2 mp3
// @description  Makes script to download playlist and convert it to mp3 with number.
// @namespace    https://greasyfork.org/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);
})();