fossasia/loklak_webclient

View on GitHub
iframely/plugins/domains/youtube.com/youtube.playlist.js

Summary

Maintainability
A
0 mins
Test Coverage
module.exports = {

    re: [
        /^https?:\/\/www\.youtube\.com\/playlist\?list=([\-_a-zA-Z0-9]+)$/i
    ],

    mixins: [
        "oembed-thumbnail",
        "oembed-author",
        "oembed-site",
        "oembed-title",
        "domain-icon"
    ],    

    getLinks: function(urlMatch, options) {

        var params = options.getProviderOptions('youtube.get_params', '');

        params = params.replace(/^\?/, '&');

        var autoplay = params + "&autoplay=1";

        var links = [{
            href: 'https://www.youtube.com/embed/videoseries?list=' + urlMatch[1] + params,
            rel: [CONFIG.R.player, CONFIG.R.html5],
            type: CONFIG.T.text_html,
            "aspect-ratio": 560/315
        }, {
            href: 'https://www.youtube.com/embed/videoseries?list=' + urlMatch[1] + autoplay,
            rel: [CONFIG.R.player, CONFIG.R.html5, CONFIG.R.autoplay],
            type: CONFIG.T.text_html,
            "aspect-ratio": 560/315
        }];

        return links;
    },

    tests: [{
        noFeeds: true
    },
        "https://www.youtube.com/playlist?list=PLWYwsGgIRwA9y49l1bwvcAF0Dj-Ac-5kh"
    ]
};