From 674648d63759dbec8faeab2c3858ac1781f53ea4 Mon Sep 17 00:00:00 2001 From: nstCactus Date: Fri, 20 Nov 2020 10:04:43 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20SouncCloud=20service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tarteaucitron.services.js | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 37950bf..3d91d1f 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -1906,6 +1906,58 @@ tarteaucitron.services.slideshare = { } }; +// soundcloud +tarteaucitron.services.soundcloud = { + key: 'soundcloud', + type: 'video', + name: 'SoundCloud', + needConsent: true, + cookies: ['sc_anonymous_id'], + js: function () { + "use strict"; + tarteaucitron.fallback(['soundcloud_player'], function (x) { + var player_height = x.getAttribute('data-height'), + frame_height = 'height="' + player_height + '" ', + playable_id = x.getAttribute('data-playable-id'), + playable_type = x.getAttribute('data-playable-type'), + color = x.getAttribute('data-color'), + autoplay = x.getAttribute('data-auto-play'), + hideRelated = x.getAttribute('data-hide-related'), + showComments = x.getAttribute('data-show-comments'), + showUser = x.getAttribute('data-show-user'), + showReposts = x.getAttribute('data-show-reposts'), + showTeaser = x.getAttribute('data-show-teaser'), + visual = x.getAttribute('data-visual'); + + var allowAutoplay = autoplay === 'true' ? 'allow="autoplay"' : ''; + + if (playable_id === undefined) { + return ""; + } + + var qs = '?url=https%3A//api.soundcloud.com/' + playable_type + '/' + playable_id; + if (hideRelated.length > 0) qs += '&hide_related=' + hideRelated; + if (color.length > 0) qs += '&color=' + color.replace('#', '%23'); + if (autoplay.length > 0) qs += '&auto_play=' + autoplay; + if (showComments.length > 0) qs += '&show_comments=' + showComments; + if (hideRelated.length > 0) qs += '&hide_related=' + hideRelated; + if (showUser.length > 0) qs += '&show_user=' + showUser; + if (showReposts.length > 0) qs += '&show_reposts=' + showReposts; + if (showTeaser.length > 0) qs += '&show_teaser=' + showTeaser; + if (visual.length > 0) qs += '&visual=' + visual; + + return ''; + }); + }, + fallback: function () { + "use strict"; + tarteaucitron.fallback(['soundcloud_player'], function (elem) { + elem.style.height = elem.getAttribute('data-height') + 'px'; + return tarteaucitron.engage('soundcloud'); + }); + } +}; + // statcounter tarteaucitron.services.statcounter = { "key": "statcounter",