[Feature Request]: set background music album/artist/title for mpris metadata #1323

Open
opened 2023-10-16 10:26:53 +00:00 by mokurin000 · 9 comments
mokurin000 commented 2023-10-16 10:26:53 +00:00 (Migrated from github.com)

Preflight Checklist

  • I use the latest version of YouTube Music (Application).
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem Description

current behaviour of youtube-music gives strange metainfo for external mpris controller, while you could find background music title/singers/album on Youtube (for example this MMD video)

Proposed Solution

query youtube api and set album / title / singers

Alternatives Considered

set youtube movie URL in xesam:url, so external players may query the necessary meta info themselves

Additional Information

No response

### Preflight Checklist - [X] I use the latest version of YouTube Music (Application). - [X] I have searched the [issue tracker](https://github.com/th-ch/youtube-music/issues) for a feature request that matches the one I want to file, without success. ### Problem Description current behaviour of youtube-music gives strange metainfo for external mpris controller, while you could find background music title/singers/album on Youtube (for example this [MMD video](https://www.youtube.com/watch?v=H6iBYmRRLYQ)) ### Proposed Solution query youtube api and set album / title / singers ### Alternatives Considered set youtube movie URL in xesam:url, so external players may query the necessary meta info themselves ### Additional Information _No response_
JellyBrick commented 2023-10-16 10:33:33 +00:00 (Migrated from github.com)

Alternatives Considered

set youtube movie URL in xesam:url, so external players may query the necessary meta info themselves

Please enable the shortcuts plugin

6774d54f5e/src/plugins/shortcuts/mpris.ts (L155-L162)

> ### Alternatives Considered > set youtube movie URL in xesam:url, so external players may query the necessary meta info themselves Please enable the `shortcuts` plugin https://github.com/th-ch/youtube-music/blob/6774d54f5eca432edc2e11743d9d1b1c2fda9ac8/src/plugins/shortcuts/mpris.ts#L155-L162
mokurin000 commented 2023-10-16 10:37:16 +00:00 (Migrated from github.com)

thx. I will mention this plugin in my README

thx. I will mention this plugin in my README
JellyBrick commented 2023-10-16 10:43:26 +00:00 (Migrated from github.com)

I keep opening this issue because I think we need extra help to solve it.
If there is a way to get background music data directly from YouTube Music, I don't need to use the ugly hack to fix this issue.

I keep opening this issue because I think we need extra help to solve it. If there is a way to get background music data directly from YouTube Music, I don't need to use [the ugly hack](https://github.com/organization/alspotron/blob/cc25e4f47cfb461e3aeec0293e42329138c7df0b/example/alspotron-plugin/index.js#L1) to fix this issue.
mokurin000 commented 2023-10-16 11:28:51 +00:00 (Migrated from github.com)

I tried every 'part' (contentDetails,id,liveStreamingDetails,localizations,player,recordingDetails,snippet,statistics,status,topicDetails) public but none is related to the background music

https://developers.google.com/youtube/v3/docs/videos/list

or could we locate ytd-video-description-music-section-renderer tag and read SONG, ARTIST and ALBUM with electron?

This is pretty hacky and may easily break with youtube updates

I tried every 'part' (`contentDetails,id,liveStreamingDetails,localizations,player,recordingDetails,snippet,statistics,status,topicDetails`) public but none is related to the background music https://developers.google.com/youtube/v3/docs/videos/list or could we locate `ytd-video-description-music-section-renderer` tag and read SONG, ARTIST and ALBUM with electron? This is pretty hacky and may easily break with youtube updates
JellyBrick commented 2023-10-16 12:34:50 +00:00 (Migrated from github.com)

or could we locate ytd-video-description-music-section-renderer tag and read SONG, ARTIST and ALBUM with electron?

This is pretty hacky and may easily break with youtube updates

It seems to doesn't work on YTM

> or could we locate `ytd-video-description-music-section-renderer` tag and read SONG, ARTIST and ALBUM with electron? > > This is pretty hacky and may easily break with youtube updates It seems to doesn't work on YTM
mokurin000 commented 2023-10-17 02:53:27 +00:00 (Migrated from github.com)

or could we locate ytd-video-description-music-section-renderer tag and read SONG, ARTIST and ALBUM with electron?
This is pretty hacky and may easily break with youtube updates

It seems to doesn't work on YTM

create a hidden BrowserWindow and once received ready-to-show we could locate ytd-video-description-music-section-renderer and read up to three meta info in order of "title, artist, album"

descriptionSection = document.getElementsByTagName("ytd-video-description-music-section-renderer")[0];
metas = descriptionSection.querySelectorAll("yt-formatted-string#default-metadata");
const metainfo = {
        title: metas[0].innerText,
        artist: metas[1].innerText,
        album: metas[2].innerText || null,
};
> > or could we locate `ytd-video-description-music-section-renderer` tag and read SONG, ARTIST and ALBUM with electron? > > This is pretty hacky and may easily break with youtube updates > > It seems to doesn't work on YTM create a hidden BrowserWindow and once received ready-to-show we could locate `ytd-video-description-music-section-renderer` and read up to three meta info in order of "title, artist, album" ```javascript descriptionSection = document.getElementsByTagName("ytd-video-description-music-section-renderer")[0]; metas = descriptionSection.querySelectorAll("yt-formatted-string#default-metadata"); const metainfo = { title: metas[0].innerText, artist: metas[1].innerText, album: metas[2].innerText || null, }; ```
mokurin000 commented 2023-10-18 06:13:12 +00:00 (Migrated from github.com)

for a complete demo:

const {app, ipcMain, BrowserWindow} = require('electron')

app.on('ready', () => {


window = new BrowserWindow({width: 400, height: 300, show: false})

window.on('ready-to-show', () => {
	window.webContents.on('dom-ready', () => {
		  window.webContents.executeJavaScript(`

    descriptionSection = document.getElementsByTagName("ytd-video-description-music-section-renderer")[0];
    let metas = descriptionSection.querySelectorAll("yt-formatted-string#default-metadata");

    const metainfo = {
        title: metas[0].innerText,
        artist: metas[1].innerText,
        album: metas[2].innerText || null,
    };

    require('electron').ipcRenderer.send('ytb-bg-music', metainfo);
        `);
	});
});

ipcMain.on('ytb-bg-music', (_, metainfo) => {
    console.log(metainfo);
});

window.loadURL("https://www.youtube.com/watch?v=H6iBYmRRLYQ")
});
for a complete demo: ```javascript const {app, ipcMain, BrowserWindow} = require('electron') app.on('ready', () => { window = new BrowserWindow({width: 400, height: 300, show: false}) window.on('ready-to-show', () => { window.webContents.on('dom-ready', () => { window.webContents.executeJavaScript(` descriptionSection = document.getElementsByTagName("ytd-video-description-music-section-renderer")[0]; let metas = descriptionSection.querySelectorAll("yt-formatted-string#default-metadata"); const metainfo = { title: metas[0].innerText, artist: metas[1].innerText, album: metas[2].innerText || null, }; require('electron').ipcRenderer.send('ytb-bg-music', metainfo); `); }); }); ipcMain.on('ytb-bg-music', (_, metainfo) => { console.log(metainfo); }); window.loadURL("https://www.youtube.com/watch?v=H6iBYmRRLYQ") }); ```
Readf0x commented 2023-10-20 00:25:23 +00:00 (Migrated from github.com)

This is similarly related, may need it's own issue. Could you possibly set the mpris player to something other than chromium? I know it's hard coded but there is supposedly an npm package that has support for mpris metadata not present in chromium's source code, but idk how well it works nor how difficult implementation of this would be. Using this it would also be possible to set the artUrl so external player controllers could see the album art.

This is similarly related, may need it's own issue. Could you possibly set the mpris player to something other than chromium? I know it's [hard coded](https://source.chromium.org/chromium/chromium/src/+/main:components/system_media_controls/linux/system_media_controls_linux.cc;l=1) but there is supposedly an [npm package](https://www.npmjs.com/package/mpris-service) that has support for mpris metadata not present in chromium's source code, but idk how well it works nor how difficult implementation of this would be. Using this it would also be possible to set the artUrl so external player controllers could see the album art.
JellyBrick commented 2023-10-20 04:45:08 +00:00 (Migrated from github.com)

This is similarly related, may need it's own issue. Could you possibly set the mpris player to something other than chromium? I know it's hard coded but there is supposedly an npm package that has support for mpris metadata not present in chromium's source code, but idk how well it works nor how difficult implementation of this would be. Using this it would also be possible to set the artUrl so external player controllers could see the album art.

https://github.com/th-ch/youtube-music/issues/1323#issuecomment-1764185013

> This is similarly related, may need it's own issue. Could you possibly set the mpris player to something other than chromium? I know it's [hard coded](https://source.chromium.org/chromium/chromium/src/+/main:components/system_media_controls/linux/system_media_controls_linux.cc;l=1) but there is supposedly an [npm package](https://www.npmjs.com/package/mpris-service) that has support for mpris metadata not present in chromium's source code, but idk how well it works nor how difficult implementation of this would be. Using this it would also be possible to set the artUrl so external player controllers could see the album art. https://github.com/th-ch/youtube-music/issues/1323#issuecomment-1764185013
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: YTMD/youtube-music#1323
No description provided.