diff --git a/internal/assets/css/screen.css b/internal/assets/css/screen.css index b598944..3f8ccda 100644 --- a/internal/assets/css/screen.css +++ b/internal/assets/css/screen.css @@ -1386,6 +1386,22 @@ body { padding: 0 !important; } +/* SoundCloud embed styles */ +[data-embed-type="soundcloud"] iframe { + max-width: 800px !important; + width: 100% !important; + height: 400px !important; + border-radius: var(--radius-lg); + display: block; + border: 1px solid var(--card-border); + box-shadow: var(--shadow-sm); +} + +.item [data-embed-type="soundcloud"] iframe { + margin: var(--space-2) 0 !important; + padding: 0 !important; +} + /* TikTok embeds */ blockquote[class*="tiktok"], .tiktok-embed { diff --git a/internal/handler/preview.go b/internal/handler/preview.go index 656d9b1..3199d65 100644 --- a/internal/handler/preview.go +++ b/internal/handler/preview.go @@ -29,6 +29,7 @@ var oembedProviders = []struct { }{ {`^https?://(www\.)?(youtube\.com|youtu\.be)/.+`, "https://www.youtube.com/oembed", ""}, {`^https?://(open\.)?spotify\.com/.+`, "https://open.spotify.com/oembed", ""}, + {`^https?://(www\.)?soundcloud\.com/.+`, "https://soundcloud.com/oembed", ""}, {`^https?://(www\.)?tiktok\.com/.+`, "https://www.tiktok.com/oembed", ""}, // {`^https?://(www\.)?reddit\.com/.+`, "https://www.reddit.com/oembed", ""}, // Use scraping for better metadata {`^https?://(www\.)?flickr\.com/.+`, "https://www.flickr.com/services/oembed", ""}, @@ -44,7 +45,7 @@ var oembedProviders = []struct { // OEmbedResponse represents standard OEmbed keys type OEmbedResponse struct { Type string `json:"type"` - Version string `json:"version"` + Version interface{} `json:"version"` Title string `json:"title"` AuthorName string `json:"author_name"` AuthorURL string `json:"author_url"` diff --git a/internal/templates/views/index.html b/internal/templates/views/index.html index ffcaec4..adc078b 100644 --- a/internal/templates/views/index.html +++ b/internal/templates/views/index.html @@ -108,6 +108,7 @@ defaultIcon: "https://www.redditstatic.com/desktop2x/img/favicon/favicon-32x32.png" }, "Spotify": { showTitle: false, showDescription: false, autoExpand: true }, + "SoundCloud": { showTitle: false, showDescription: false, autoExpand: true }, "GIPHY": { showTitle: false, showDescription: false }, "Flickr": { clickableImage: true, forceAspect: "photo" }, "_default": { @@ -430,6 +431,7 @@ // Determine appropriate height based on embed type var isReddit = embedHtml.indexOf('reddit') !== -1; var isSpotify = embedHtml.indexOf('spotify') !== -1; + var isSoundCloud = embedHtml.indexOf('soundcloud') !== -1; var isTikTok = embedHtml.indexOf('tiktok') !== -1; // Auto-resize script for embeds that need dynamic height @@ -462,6 +464,9 @@ if (isSpotify) { iframe.style.height = '152px'; container.setAttribute('data-embed-type', 'spotify'); + } else if (isSoundCloud) { + iframe.style.height = '400px'; + container.setAttribute('data-embed-type', 'soundcloud'); } else if (isReddit) { // Start with reasonable height, will auto-resize iframe.style.height = '300px'; diff --git a/tests/load_fixtures.sh b/tests/load_fixtures.sh index b94df31..e885eae 100755 --- a/tests/load_fixtures.sh +++ b/tests/load_fixtures.sh @@ -53,7 +53,7 @@ if [ "$DRIVER" == "sqlite" ] || [ -z "$DRIVER" ]; then fi fi -TOTAL_FIXTURES=26 +TOTAL_FIXTURES=27 CURRENT=0 load_link() { @@ -116,6 +116,9 @@ load_quote "Simba" "Everything the light touches is our kingdom." # Spotify load_link "music_lover" "https://open.spotify.com/episode/7makk4oTQel546B0PZlDM5" +# SoundCloud +load_link "dj_mix" "https://soundcloud.com/majorlazer/major-lazer-dj-snake-lean-on-feat-mo" + # TikTok load_link "tiktok_star" "https://www.tiktok.com/@tiagogreis/video/6830059644233223429" diff --git a/tests/preview_test.sh b/tests/preview_test.sh index 5a32e05..3a46f43 100755 --- a/tests/preview_test.sh +++ b/tests/preview_test.sh @@ -111,6 +111,17 @@ test_preview "Flickr Single Photo" \ # "https://www.flickr.com/photos/username/albums/123456/" \ # '.provider_name == "Flickr" and .render_inline != "true"' +# --- SOUNDCLOUD --- +# Valid +test_preview "SoundCloud Valid" \ + "https://soundcloud.com/majorlazer/major-lazer-dj-snake-lean-on-feat-mo" \ + '.provider_name == "SoundCloud" or .type == "rich"' + +# Invalid +test_preview "SoundCloud Invalid" \ + "https://soundcloud.com/nonexistent-user-xyz/nonexistent-track-abc-123" \ + '.error != null or .title != null' + # --- TIKTOK --- # Valid test_preview "TikTok Valid" \