Accept direct Soundcloud URL instead of data from API to share Soundcloud tracks

This commit is contained in:
Nicolas Rosset 2021-04-02 18:11:06 +02:00
parent 586ad0e722
commit fdd2ad61c3
1 changed files with 36 additions and 31 deletions

View File

@ -1235,7 +1235,7 @@ tarteaucitron.services.stonly = {
window.StonlyWidget || ((window.w = window.StonlyWidget = function() { window.StonlyWidget || ((window.w = window.StonlyWidget = function() {
window.w._api ? window.w._api.apply(window.w, arguments) : window.w.queue.push(arguments) window.w._api ? window.w._api.apply(window.w, arguments) : window.w.queue.push(arguments)
}).queue = []); }).queue = []);
tarteaucitron.addScript('https://stonly.com/js/widget/v2/stonly-widget.js?v=' + Date.now()); tarteaucitron.addScript('https://stonly.com/js/widget/v2/stonly-widget.js?v=' + Date.now());
} }
}; };
@ -1885,7 +1885,7 @@ tarteaucitron.services.recaptcha = {
} else { } else {
tarteaucitron.addScript('https://www.google.com/recaptcha/api.js?onload=tacRecaptchaOnLoad&render=' + tarteaucitron.user.recaptchaapi); tarteaucitron.addScript('https://www.google.com/recaptcha/api.js?onload=tacRecaptchaOnLoad&render=' + tarteaucitron.user.recaptchaapi);
} }
}, },
"fallback": function () { "fallback": function () {
"use strict"; "use strict";
@ -2312,37 +2312,42 @@ tarteaucitron.services.soundcloud = {
js: function () { js: function () {
"use strict"; "use strict";
tarteaucitron.fallback(['soundcloud_player'], function (x) { tarteaucitron.fallback(['soundcloud_player'], function (x) {
var player_height = x.getAttribute('data-height'), var player_height = x.getAttribute('data-height'),
frame_height = 'height="' + player_height + '" ', frame_height = 'height="' + player_height + '" ',
playable_id = x.getAttribute('data-playable-id'), playable_id = x.getAttribute('data-playable-id'),
playable_type = x.getAttribute('data-playable-type'), playable_type = x.getAttribute('data-playable-type'),
color = x.getAttribute('data-color'), data_playable_url = x.getAttribute('data-playable-url'),
autoplay = x.getAttribute('data-auto-play'), color = x.getAttribute('data-color'),
hideRelated = x.getAttribute('data-hide-related'), autoplay = x.getAttribute('data-auto-play'),
showComments = x.getAttribute('data-show-comments'), hideRelated = x.getAttribute('data-hide-related'),
showUser = x.getAttribute('data-show-user'), showComments = x.getAttribute('data-show-comments'),
showReposts = x.getAttribute('data-show-reposts'), showUser = x.getAttribute('data-show-user'),
showTeaser = x.getAttribute('data-show-teaser'), showReposts = x.getAttribute('data-show-reposts'),
visual = x.getAttribute('data-visual'), showTeaser = x.getAttribute('data-show-teaser'),
artwork = x.getAttribute('data-artwork'); visual = x.getAttribute('data-visual'),
artwork = x.getAttribute('data-artwork');
var allowAutoplay = autoplay === 'true' ? 'allow="autoplay"' : ''; var allowAutoplay = autoplay === 'true' ? 'allow="autoplay"' : '';
if (playable_id === undefined) { if (playable_id === undefined && data_playable_url === undefined) {
return ""; return "";
} }
// Allow to embed from API results (playable_type + playable_id)
var qs = '?url=https%3A//api.soundcloud.com/' + playable_type + '/' + playable_id; var qs = '?url=https%3A//api.soundcloud.com/' + playable_type + '/' + playable_id;
if (hideRelated && hideRelated.length > 0) qs += '&hide_related=' + hideRelated; // Or from raw URL from Soundcloud website
if (color && color.length > 0) qs += '&color=' + color.replace('#', '%23'); if (data_playable_url && data_playable_url.length >0) qs = '?url=' + escape(data_playable_url);
if (autoplay && autoplay.length > 0) qs += '&auto_play=' + autoplay;
if (showComments && showComments.length > 0) qs += '&show_comments=' + showComments; if (hideRelated && hideRelated.length > 0) qs += '&hide_related=' + hideRelated;
if (hideRelated && hideRelated.length > 0) qs += '&hide_related=' + hideRelated; if (color && color.length > 0) qs += '&color=' + color.replace('#', '%23');
if (showUser && showUser.length > 0) qs += '&show_user=' + showUser; if (autoplay && autoplay.length > 0) qs += '&auto_play=' + autoplay;
if (showReposts && showReposts.length > 0) qs += '&show_reposts=' + showReposts; if (showComments && showComments.length > 0) qs += '&show_comments=' + showComments;
if (showTeaser && showTeaser.length > 0) qs += '&show_teaser=' + showTeaser; if (hideRelated && hideRelated.length > 0) qs += '&hide_related=' + hideRelated;
if (visual && visual.length > 0) qs += '&visual=' + visual; if (showUser && showUser.length > 0) qs += '&show_user=' + showUser;
if (artwork && artwork.length > 0) qs += '&show_artwork=' + artwork; if (showReposts && showReposts.length > 0) qs += '&show_reposts=' + showReposts;
if (showTeaser && showTeaser.length > 0) qs += '&show_teaser=' + showTeaser;
if (visual && visual.length > 0) qs += '&visual=' + visual;
if (artwork && artwork.length > 0) qs += '&show_artwork=' + artwork;
return '<iframe title="Soundcloud iframe" width="100%" ' + frame_height + ' scrolling="no" ' + allowAutoplay + ' src="https://w.soundcloud.com/player/' + qs + '"></iframe>'; return '<iframe title="Soundcloud iframe" width="100%" ' + frame_height + ' scrolling="no" ' + allowAutoplay + ' src="https://w.soundcloud.com/player/' + qs + '"></iframe>';
}); });
@ -3039,7 +3044,7 @@ tarteaucitron.services.atinternetoptin = {
"js": function () { "js": function () {
"use strict"; "use strict";
tarteaucitron.launch['atinternetoptout'] = false; tarteaucitron.launch['atinternetoptout'] = false;
setTimeout(function() { setTimeout(function() {
tarteaucitron.userInterface.respond(document.getElementById('atinternetAllowed'), true); tarteaucitron.userInterface.respond(document.getElementById('atinternetAllowed'), true);
tarteaucitron.userInterface.respond(document.getElementById('atinternetoptoutDenied'), false); tarteaucitron.userInterface.respond(document.getElementById('atinternetoptoutDenied'), false);
@ -3256,7 +3261,7 @@ tarteaucitron.services.linkedininsighttag = {
window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || []; window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];
window._linkedin_data_partner_ids.push(tarteaucitron.user.linkedininsighttag); window._linkedin_data_partner_ids.push(tarteaucitron.user.linkedininsighttag);
} }
tarteaucitron.addScript('https://snap.licdn.com/li.lms-analytics/insight.min.js'); tarteaucitron.addScript('https://snap.licdn.com/li.lms-analytics/insight.min.js');
} }
}; };
@ -3529,8 +3534,8 @@ tarteaucitron.services.matomo = {
}, 100) }, 100)
} }
}; };
tarteaucitron.services.matomohightrack = { tarteaucitron.services.matomohightrack = {
"key": "matomohightrack", "key": "matomohightrack",
"type": "analytic", "type": "analytic",
@ -3851,7 +3856,7 @@ tarteaucitron.services.userlike = {
tarteaucitron.addScript('//userlike-cdn-widgets.s3-eu-west-1.amazonaws.com/' + tarteaucitron.user.userlikeKey); tarteaucitron.addScript('//userlike-cdn-widgets.s3-eu-west-1.amazonaws.com/' + tarteaucitron.user.userlikeKey);
} }
}; };
// adobeanalytics // adobeanalytics
tarteaucitron.services.adobeanalytics = { tarteaucitron.services.adobeanalytics = {
"key": "adobeanalytics", "key": "adobeanalytics",