Bad inline onebox title for Spotify album shares

AI-generated summary

The issue concerns a bad inline onebox title for Spotify album links, where the title displays as ‘Unsupported browser’ instead of the album name. supermathie identifies that the discrepancy arises because the full onebox uses a custom user agent (‘Discourse Forum Onebox v3.5.0.beta9-dev’) that receives the correct page, while the inline onebox uses an outdated Safari 14 user agent, causing Spotify to return an unsupported browser page. awesomerobot questions whether updating the user agent would help. supermathie confirms the inconsistency and notes that despite Spotify serving Open Graph metadata, the system prioritizes the <title> tag, which shows ‘Unsupported browser’. sam explains that the current code prioritizes the <title> over Open Graph properties and references a pull request that should fix it. sam adds that Spotify now returns a generic title ‘spotify’, suggesting custom Spotify-specific handling may be needed.

The title for an inline onebox is bad (not that I’m saying it’s our fault):

Inline: Spotify

source:

https://open.spotify.com/album/1nrWysWdrgPR0kBJ45z2aS?si=FurcwGpfSrWJBPGwKeCvDQ

Inline: https://open.spotify.com/album/1nrWysWdrgPR0kBJ45z2aS?si=FurcwGpfSrWJBPGwKeCvDQ

image (preview):

image (baked):

4 Likes

Do we need to update the browser version in the user agent our crawler is using? looks like we’re using Safari 14?

Visiting the URL manually in that Safari version:

We’re not consistent with user agents.

For the full onebox we use:

Discourse Forum Onebox v3.5.0.beta9-dev

and Spotify is fine with this and serves the full page:

○ → curl -s --user-agent 'Discourse Forum Onebox v3.5.0.beta9-dev' 'https://open.spotify.com/album/1nrWysWdrgPR0kBJ45z2aS?si=FurcwGpfSrWJBPGwKeCvDQ' | htmlq 'meta[property^="og:description"], meta[property^="og:site_name"], title'
<title>The First Symphony - Album by Indecent | Spotify</title>
<meta content="Spotify" property="og:site_name">
<meta content="Indecent · Album · 2024 · 12 songs" property="og:description">
<meta content="Spotify" property="og:site_name">

but for the inline onebox we use:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15

So that’s ultimately why we’re getting different behaviour, though I would still ask why we don’t use the opengraph properties here? Spotify is still serving those up despite being an unsupported browser:

○ → curl -s --user-agent 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15' 'https://open.spotify.com/album/1nrWysWdrgPR0kBJ45z2aS?si=FurcwGpfSrWJBPGwKeCvDQ' | htmlq 'meta[property^="og:description"], meta[property^="og:site_name"], title'
<title>Unsupported browser</title>
<meta content="Spotify" property="og:site_name">
<meta content="Indecent · Album · 2024 · 12 songs" property="og:description">
<meta content="Spotify" property="og:site_name">
all properties
○ → curl -s --user-agent 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15' 'https://open.spotify.com/album/1nrWysWdrgPR0kBJ45z2aS?si=FurcwGpfSrWJBPGwKeCvDQ' | htmlq 'meta[property^="og:"]'
<meta content="Spotify" property="og:site_name">
<meta content="The First Symphony" property="og:title">
<meta content="Indecent · Album · 2024 · 12 songs" property="og:description">
<meta content="https://open.spotify.com/album/1nrWysWdrgPR0kBJ45z2aS" property="og:url">
<meta content="music.album" property="og:type">
<meta content="Spotify" property="og:site_name">
<meta content="AR" property="og:restrictions:country:allowed">
…
<meta content="XK" property="og:restrictions:country:allowed">
<meta content="https://i.scdn.co/image/ab67616d0000b273ff9434b9650f38d183e91fb1" property="og:image">
2 Likes

Hmmm:

Because <title> takes precedence over open graph in our implementation and we don’t want to hardcode the string “Unsupported browser”…

FIX: update final destination to use more recent user agent by SamSaffron · Pull Request #34207 · discourse/discourse · GitHub should fix this…

This feels way old though:

DEFAULT_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15"

hmmm… now spotify give us the title “spotify” :slight_smile: we are going to need custom “spotify” code :frowning: if we want to get the album name.

2 Likes