Repository: yt-dlp/yt-dlp

Issue:
YouTube Music search doesn't extract titles
### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\* field

### Checklist

- [X] I'm requesting a site-specific feature
- [X] I've verified that I'm running yt-dlp version **2023.03.04** ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) or later (specify commit)
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)
- [ ] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and I'm willing to share it if required

### Region

_No response_

### Example URLs

https://music.youtube.com/search?q=maroon 5 - sugar

### Provide a description that is worded well enough to be understood

Yt-dlp doesn't extract titles from YouTube Music search results.

It would be great if that were possible, because YouTube Music sometimes has the wrong song as the first search result (e.g. "Maroon 5 - Sugar" lists the Nicki Minaj remix before the original). Fixing that would be possible with title based heuristics, but alas, no titles available. Searching YouTube directly makes the error rate like 10x worse even with title based heuristics, so that's unfortunately not an option.

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [ ] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
[debug] Command-line config: ['-vU', '--dump-json', '--flat-playlist', '--playlist-end', '1', 'https://music.youtube.com/search?q=maroon 5 - sugar']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2023.03.04 [392389b7d] (pip)
[debug] Python 3.10.10 (CPython x86_64 64bit) - Linux-6.2.10-arch1-1-x86_64-with-glibc2.37 (OpenSSL 3.0.8 7 Feb 2023, glibc 2.37)
[debug] exe versions: ffmpeg 6.0 (setts), ffprobe 6.0, rtmpdump 2.4
[debug] Optional libraries: Cryptodome-3.17, brotli-1.0.9, certifi-2022.12.07, mutagen-1.46.0, secretstorage-3.3.3, sqlite3-2.6.0, websockets-10.2
[debug] Proxy map: {}
[debug] Loaded 1786 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Available version: stable@2023.03.04, Current version: stable@2023.03.04
yt-dlp is up to date (stable@2023.03.04)
[youtube:music:search_url] Extracting URL: https://music.youtube.com/search?q=maroon 5 - sugar
[download] Downloading playlist: maroon 5 - sugar
[youtube:music:search_url] query "maroon 5 - sugar": Downloading web music client config
[youtube:music:search_url] query "maroon 5 - sugar" page 1: Downloading API JSON
[youtube:music:search_url] Playlist maroon 5 - sugar: Downloading 1 items
[debug] The information of all playlist entries will be held in memory
[download] Downloading item 1 of 1
{"ie_key": "Youtube", "id": "O_eCQYK4a2Q", "_type": "url", "url": "https://music.youtube.com/watch?v=O_eCQYK4a2Q", "__x_forwarded_for_ip": null, "webpage_url": "https://music.youtube.com/watch?v=O_eCQYK4a2Q", "original_url": "https://music.youtube.com/watch?v=O_eCQYK4a2Q", "webpage_url_basename": "watch", "webpage_url_domain": "music.youtube.com", "extractor": "youtube", "extractor_key": "Youtube", "playlist_count": null, "playlist": "maroon 5 - sugar", "playlist_id": "maroon 5 - sugar", "playlist_title": "maroon 5 - sugar", "playlist_uploader": null, "playlist_uploader_id": null, "n_entries": 1, "playlist_index": 1, "__last_playlist_index": 1, "playlist_autonumber": 1, "epoch": 1684661348, "filename": "NA [O_eCQYK4a2Q].NA", "urls": "https://music.youtube.com/watch?v=O_eCQYK4a2Q", "_version": {"version": "2023.03.04", "current_git_head": null, "release_git_head": "392389b7df7b818f794b231f14dc396d4875fbad", "repository": "yt-dlp/yt-dlp"}}
[download] Finished downloading playlist: maroon 5 - sugar
```



Discussion:

Resolving patch:
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -4579,8 +4579,11 @@ def _grid_entries(self, grid_renderer):
     def _music_reponsive_list_entry(self, renderer):
         video_id = traverse_obj(renderer, ('playlistItemData', 'videoId'))
         if video_id:
+            title = traverse_obj(renderer, (
+                'flexColumns', 0, 'musicResponsiveListItemFlexColumnRenderer',
+                'text', 'runs', 0, 'text'))
             return self.url_result(f'https://music.youtube.com/watch?v={video_id}',
-                                   ie=YoutubeIE.ie_key(), video_id=video_id)
+                                   ie=YoutubeIE.ie_key(), video_id=video_id, title=title)
         playlist_id = traverse_obj(renderer, ('navigationEndpoint', 'watchEndpoint', 'playlistId'))
         if playlist_id:
             video_id = traverse_obj(renderer, ('navigationEndpoint', 'watchEndpoint', 'videoId'))


Test patch: