Nerixyz / current-song2

Display the currently playing song/audio.
https://currentsong.nerixyz.de
89 stars 7 forks source link

Chrome YouTube incorrect title/artist #406

Open ceilingwaffle opened 9 months ago

ceilingwaffle commented 9 months ago

Issue

For this Youtube video, the correct title/artist should be:

Title: "Ob-la-di ob-la-da - The Beatles (LYRICS/LETRA) [Original]" Artist: "el perro beatle"

But instead, it's showing as:

Title: "la-di ob-la-da - The Beatles" Artist: "Ob"

Screenshot

image

Source video: https://www.youtube.com/watch?v=_Paqe2-BCYM

Websocket message

{"type":"Playing","data":{"title":"Ob-la-di ob-la-da - The Beatles (LYRICS/LETRA) [Original]","artist":"el perro beatle","trackNumber":0,"image":{"id":15,"epochId":1},"timeline":{"ts":1705505109989,"durationMs":189761,"progressMs":10,"rate":1.0},"album":{"title":"","trackCount":0},"source":"gsmtc::Chrome"}}

My theme.css

:root {
    --text-color: #ddd;
    --progress-color: #67736e;
    --max-height: 6.0rem;
    --height: 6.0rem;
    --min-height: 4.0rem;
}

#song-container {
    bottom: 0;
    right: 0;
    transform-origin: right;
    background: #2b2b2b;
    box-shadow: 0 0 4px 2px #111;
}

#song-info {
    padding: 10px 20px 10px 10px;
}

Not using any custom JS. The issue also occurs with the default CSS. Tested with other videos, but even those with a similar number of hyphens in the title seem to be fine.

Let me know if you need any more info. Thanks for the great tool :-)

Nerixyz commented 9 months ago

The frontend tries to determine the artist and title if the source is a common browser (src - 'xd' shouldn't be there 🙃). It's to avoid the issue with YouTube in that it sends the whole video title as the title and the channel name as the artist/subtitle, as most music on YouTube has the name of the artist in the title, so you'd get { title: "Artist - My Song (Artist2 remix)", subtitle: "Uploader" }. One thing that is pretty common on YouTube is the format: "Artist - Title" (which your video doesn't use).

Furthermore, once the title and subtitle are parsed, they will be cleaned up if they're too long (e.g. removing "(Remix)" or "[1234]").

Note to self: I should definitely add tests for this.