View Single Post
  #4566  
Old 27.09.2021, 15:31
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,553
Default

Workaround using eventscripter, to get 100+ items from playlist.

Script:
Code:
/*
    Get all YT playlist items (Requires youtube-dl)
    Trigger: Linkgrabber contextmenu button pressed
    Customize linkgrabber context menu > Add a new "Eventscripter Trigger" button > Rename it to "Get all playlist items"
*/

var youtube_dl = "d:/apps/youtube-dl/youtube-dl.exe"; // <- set path to yotuube-dl

if (name == "Get all playlist items") {
    var link, playlistId, playlist, title, url, urls = [];

    try {
        link = lgSelection.contextLink;
        playlistId = link.getProperty("YT_PLAYLIST_ID");

        if (!getProperty(playlistId, false)) {
            try {
                setProperty(playlistId, true, false);
                playlist = callSync(youtube_dl, "-J", "--flat-playlist", playlistId);
                playlist = JSON.parse(playlist);
                len = playlist.entries.length;
                title = playlist.title;

                playlist.entries.forEach(function(entry, index) {
                    url = "https" + "://www.youtube.com/watch?v=";
                    url += entry.id;
                    url += "&playlistTitle=" + title;
                    url += "&playlistPosition=" + getIndex(index, len);

                    urls.push(url);
                })

                callAPI("linkgrabberv2", "addLinks", {
                    links: urls.join("<br>")
                })
            } finally {
                setProperty(playlistId, null, false);
            };
        }
    } catch (e) {};
}

function getIndex(index, len) {
    var len = "" + len;
    var index = "" + (index + 1);

    while (index.length < len.length) {
        index = "0" + index;
    }

    return index;
}

Packagizer rule to set playlist title as packagename and append playlist position to filename (Optional):
Code:
If > sourceurls(s) > contains : &playlistTitle=*&playlistPosition=*

then set > Package Name: <jd:source:1>
then set > Filename: <jd:source:2> <jd:orgfilename>

To get all remaining links of a playlist, in the linkgrabber, select existing link belonging to that playlist and run the scirpt by clicking "Get all playlist items" in the context menu.
Reply With Quote