Add AMAZON_AFFILIATE_ENABLED flag, disabled by default
All checks were successful
Build and push Docker image / build (push) Successful in 11s
Test / test (push) Successful in 12s

This commit is contained in:
marwin 2026-03-16 20:47:02 +01:00
parent 0f4a7e96d3
commit 945da36c95
4 changed files with 7 additions and 1 deletions

View file

@ -98,3 +98,4 @@ LASTFM_API_SECRET = os.environ.get('LASTFM_API_SECRET', '')
# Amazon affiliate
AMAZON_AFFILIATE_TAG = os.environ.get('AMAZON_AFFILIATE_TAG', 'diora-20')
AMAZON_AFFILIATE_ENABLED = os.environ.get('AMAZON_AFFILIATE_ENABLED', 'True') == 'True'

View file

@ -47,6 +47,7 @@ def index(request):
context = {
'saved_stations': saved_stations,
'history': history,
'amazon_enabled': settings.AMAZON_AFFILIATE_ENABLED,
}
return render(request, 'radio/player.html', context)
@ -144,6 +145,9 @@ def record_track(request):
# ---------------------------------------------------------------------------
def affiliate_links(request):
if not settings.AMAZON_AFFILIATE_ENABLED:
return JsonResponse({'amazon_url': None, 'itunes_data': {}})
track = request.GET.get('track', '').strip()
if not track:
return JsonResponse({'error': 'track parameter required'}, status=400)

View file

@ -282,6 +282,7 @@ async function deleteHistoryEntry(id, btn) {
async function fetchAffiliateLinks(track) {
const section = $('affiliate-section');
if (section && section.dataset.disabled) return;
try {
const res = await fetch('/radio/affiliate/?track=' + encodeURIComponent(track));
if (!res.ok) return;

View file

@ -29,7 +29,7 @@
</section>
<!-- ===== AFFILIATE / TRACK INFO ===== -->
<section class="affiliate-section" id="affiliate-section" style="display:none;">
<section class="affiliate-section" id="affiliate-section" style="display:none;"{% if not amazon_enabled %} data-disabled="true"{% endif %}>
<img class="affiliate-artwork" id="affiliate-artwork" src="" alt="Album art">
<div class="affiliate-info">
<div class="affiliate-track" id="affiliate-track-name"></div>