Closed natumbri closed 1 year ago
I think some extra "
are the problem. A .replace()
seems to help. I wonder if there is a proper way to do this?
https://github.com/natumbri/mopidy-youtube/blob/develop/mopidy_youtube/backend.py#L140-L144
This is currently working for me on one system but not another. Kubuntu 22.04, running from a console, playback works. Raspberry Pi OS (latest), mopidy running as a service with yt-dlp installed from pip (because it's not in the repo) I can't play anything back. It works if I revert to musicapi_cookie. Don't know if it's relevant but I can see a Destination: /var/cache/mopidy... in there. I have allow_cache = false in my mopidy.conf
ct 9 16:19:56 kitchen mopidy[13349]: [youtube] 817P8W8-mGE: Downloading webpage
Oct 9 16:19:58 kitchen mopidy[13349]: [youtube] 817P8W8-mGE: Downloading player 17ab0793
Oct 9 16:20:00 kitchen mopidy[13349]: [download] Destination: /var/cache/mopidy/youtube/817P8W8-mGE.webm
Oct 9 16:20:02 kitchen mopidy[13349]: #015[download] 0.0% of 4.38MiB at 6.47KiB/s ETA 11:32#015[download] 0.1% of 4.38MiB at 19.36KiB/s ETA 03:51#015[download] 0.2% of 4.38MiB at 43.98KiB/s ETA 01:41#015[download] 0.3% of 4.38MiB at 93.88KiB/s ETA 00:47#015[download] 0.7% of 4.38MiB at 66.74KiB/s ETA 01:06#015[download] 1.4% of 4.38MiB at 60.91KiB/s ETA 01:12#015[download] 2.7% of 4.38MiB at 53.60KiB/s ETA 01:21INFO [HttpServer] mopidy_youtube.web started serving 817P8W8-mGE.webm to gstreamer
Oct 9 16:20:02 kitchen mopidy[13349]: ERROR [HttpServer] tornado.application Uncaught exception GET /youtube/817P8W8-mGE.webm (127.0.0.1)
Oct 9 16:20:02 kitchen mopidy[13349]: HTTPServerRequest(protocol='http', host='localhost:6680', method='GET', uri='/youtube/817P8W8-mGE.webm', version='HTTP/1.1', remote_ip='127.0.0.1')
Oct 9 16:20:02 kitchen mopidy[13349]: Traceback (most recent call last):
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/tornado/web.py", line 1713, in _execute
Oct 9 16:20:02 kitchen mopidy[13349]: result = await result
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/tornado/gen.py", line 234, in wrapper
Oct 9 16:20:02 kitchen mopidy[13349]: yielded = ctx_run(next, result)
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/mopidy_youtube/web.py", line 100, in get
Oct 9 16:20:02 kitchen mopidy[13349]: yield tornado.gen.Task(self.flush)
Oct 9 16:20:02 kitchen mopidy[13349]: AttributeError: module 'tornado.gen' has no attribute 'Task'
Oct 9 16:20:02 kitchen mopidy[13349]: ERROR [HttpServer] tornado.general Cannot send error response after headers written
Oct 9 16:20:02 kitchen mopidy[13349]: ERROR [HttpServer] tornado.general Failed to flush partial response
Oct 9 16:20:02 kitchen mopidy[13349]: Traceback (most recent call last):
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/tornado/web.py", line 1713, in _execute
Oct 9 16:20:02 kitchen mopidy[13349]: result = await result
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/tornado/gen.py", line 234, in wrapper
Oct 9 16:20:02 kitchen mopidy[13349]: yielded = ctx_run(next, result)
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/mopidy_youtube/web.py", line 100, in get
Oct 9 16:20:02 kitchen mopidy[13349]: yield tornado.gen.Task(self.flush)
Oct 9 16:20:02 kitchen mopidy[13349]: AttributeError: module 'tornado.gen' has no attribute 'Task'
Oct 9 16:20:02 kitchen mopidy[13349]: During handling of the above exception, another exception occurred:
Oct 9 16:20:02 kitchen mopidy[13349]: Traceback (most recent call last):
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/tornado/web.py", line 1206, in send_error
Oct 9 16:20:02 kitchen mopidy[13349]: self.finish()
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/tornado/web.py", line 1160, in finish
Oct 9 16:20:02 kitchen mopidy[13349]: self.request.connection.finish()
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/tornado/http1connection.py", line 514, in finish
Oct 9 16:20:02 kitchen mopidy[13349]: raise httputil.HTTPOutputError(
Oct 9 16:20:02 kitchen mopidy[13349]: tornado.httputil.HTTPOutputError: Tried to write 4466482 bytes less than Content-Length
Oct 9 16:20:02 kitchen mopidy[13349]: INFO [HttpServer] mopidy_youtube.web started serving 817P8W8-mGE.webm to gstreamer
Oct 9 16:20:02 kitchen mopidy[13349]: ERROR [HttpServer] tornado.application Uncaught exception GET /youtube/817P8W8-mGE.webm (127.0.0.1)
Oct 9 16:20:02 kitchen mopidy[13349]: HTTPServerRequest(protocol='http', host='localhost:6680', method='GET', uri='/youtube/817P8W8-mGE.webm', version='HTTP/1.1', remote_ip='127.0.0.1')
Oct 9 16:20:02 kitchen mopidy[13349]: Traceback (most recent call last):
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/tornado/web.py", line 1713, in _execute
Oct 9 16:20:02 kitchen mopidy[13349]: result = await result
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/tornado/gen.py", line 234, in wrapper
Oct 9 16:20:02 kitchen mopidy[13349]: yielded = ctx_run(next, result)
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/mopidy_youtube/web.py", line 100, in get
Oct 9 16:20:02 kitchen mopidy[13349]: yield tornado.gen.Task(self.flush)
Oct 9 16:20:02 kitchen mopidy[13349]: AttributeError: module 'tornado.gen' has no attribute 'Task'
Oct 9 16:20:02 kitchen mopidy[13349]: ERROR [MainThread] mopidy.audio.gst GStreamer error: Server does not support seeking.
Oct 9 16:20:02 kitchen mopidy[13349]: ERROR [HttpServer] tornado.general Cannot send error response after headers written
Oct 9 16:20:02 kitchen mopidy[13349]: ERROR [HttpServer] tornado.general Failed to flush partial response
Oct 9 16:20:02 kitchen mopidy[13349]: Traceback (most recent call last):
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/tornado/web.py", line 1713, in _execute
Oct 9 16:20:02 kitchen mopidy[13349]: result = await result
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/tornado/gen.py", line 234, in wrapper
Oct 9 16:20:02 kitchen mopidy[13349]: yielded = ctx_run(next, result)
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/mopidy_youtube/web.py", line 100, in get
Oct 9 16:20:02 kitchen mopidy[13349]: yield tornado.gen.Task(self.flush)
Oct 9 16:20:02 kitchen mopidy[13349]: AttributeError: module 'tornado.gen' has no attribute 'Task'
Oct 9 16:20:02 kitchen mopidy[13349]: During handling of the above exception, another exception occurred:
Oct 9 16:20:02 kitchen mopidy[13349]: Traceback (most recent call last):
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/tornado/web.py", line 1206, in send_error
Oct 9 16:20:02 kitchen mopidy[13349]: self.finish()
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/tornado/web.py", line 1160, in finish
Oct 9 16:20:02 kitchen mopidy[13349]: self.request.connection.finish()
Oct 9 16:20:02 kitchen mopidy[13349]: File "/usr/local/lib/python3.9/dist-packages/tornado/http1connection.py", line 514, in finish
Oct 9 16:20:02 kitchen mopidy[13349]: raise httputil.HTTPOutputError(
Oct 9 16:20:02 kitchen mopidy[13349]: tornado.httputil.HTTPOutputError: Tried to write 4466482 bytes less than Content-Length
Oct 9 16:20:08 kitchen mopidy[13349]: #015[download] 3.7% of 4.38MiB at 53.64KiB/s ETA 01:20#015[download] 4.9% of 4.38MiB at 55.26KiB/s ETA 01:17#015[download] 6.3% of 4.38MiB at 54.64KiB/s ETA 01:16#015[download] 7.4% of 4.38MiB at 55.39KiB/s ETA 01:14#015[download] 8.8% of 4.38MiB at 54.73KiB/s ETA 01:14INFO [MpdSession-21] mopidy_mpd.session New MPD connection from [::ffff:192.168.0.26]:57906
Oct 9 16:20:08 kitchen mopidy[13349]: #015[download] 9.9% of 4.38MiB at 55.13KiB/s ETA 01:13INFO [MpdSession-22] mopidy_mpd.session New MPD connection from [::ffff:192.168.0.26]:57916
Oct 9 16:20:16 kitchen mopidy[13349]: #015[download] 11.2% of 4.38MiB at 54.35KiB/s ETA 01:13#015[download] 12.3% of 4.38MiB at 54.62KiB/s ETA 01:11#015[download] 13.6% of 4.38MiB at 53.96KiB/s ETA 01:11#015[download] 14.7% of 4.38MiB at 54.05KiB/s ETA 01:10#015[download] 15.9% of 4.38MiB at 54.63KiB/s ETA 01:08#015[download] 17.3% of 4.38MiB at 54.57KiB/s ETA 01:07#015[download] 18.5% of 4.38MiB at 54.88KiB/s ETA 01:06INFO [MpdSession-23] mopidy_mpd.session New MPD connection from [::ffff:192.168.0.26]:50634
Oct 9 16:20:46 kitchen mopidy[13349]: #015[download] 19.9% of 4.38MiB at 54.64KiB/s ETA 01:05#015[download] 21.0% of 4.38MiB at 54.83KiB/s ETA 01:04#015[download] 22.3% of 4.38MiB at 54.46KiB/s ETA 01:03#015[download] 23.4% of 4.38MiB at 54.53KiB/s ETA 01:02#015[download] 24.7% of 4.38MiB at 54.17KiB/s ETA 01:02#015[download] 25.7% of 4.38MiB at 54.20KiB/s ETA 01:01#015[download] 26.9% of 4.38MiB at 54.52KiB/s ETA 01:00#015[download] 28.3% of 4.38MiB at 54.47KiB/s ETA 00:58#015[download] 29.5% of 4.38MiB at 54.71KiB/s ETA 00:57#015[download] 30.9% of 4.38MiB at 54.55KiB/s ETA 00:56#015[download] 32.0% of 4.38MiB at 54.67KiB/s ETA 00:55#015[download] 33.3% of 4.38MiB at 54.47KiB/s ETA 00:54#015[download] 34.5% of 4.38MiB at 54.54KiB/s ETA 00:53#015[download] 35.7% of 4.38MiB at 54.32KiB/s ETA 00:53#015[download] 36.8% of 4.38MiB at 54.36KiB/s ETA 00:52#015[download] 38.1% of 4.38MiB at 54.61KiB/s ETA 00:50#015[download] 39.5% of 4.38MiB at 54.56KiB/s ETA 00:49#015[download] 40.7% of 4.38MiB at 54.73KiB/s ETA 00:48#015[download] 42.0% of 4.38MiB at 54.64KiB/s ETA 00:47#015[download] 43.2% of 4.38MiB at 54.75KiB/s ETA 00:46#015[download] 44.5% of 4.38MiB at 54.63KiB/s ETA 00:45#015[download] 45.6% of 4.38MiB at 54.71KiB/s ETA 00:44#015[download] 46.9% of 4.38MiB at 54.52KiB/s ETA 00:43#015[download] 48.0% of 4.38MiB at 54.58KiB/s ETA 00:42#015[download] 49.3% of 4.38MiB at 54.38KiB/s ETA 00:41#015[download] 50.4% of 4.38MiB at 54.39KiB/s ETA 00:40#015[download] 51.6% of 4.38MiB at 54.55KiB/s ETA 00:39#015[download] 53.0% of 4.38MiB at 54.52KiB/s ETA 00:38#015[download] 54.2% of 4.38MiB at 54.64KiB/s ETA 00:37#015[download] 55.5% of 4.38MiB at 54.56KiB/s ETA 00:36INFO [MainThread] mopidy.commands GLib mainloop got SIGTERM. Exiting...
Oct 9 16:20:46 kitchen mopidy[13349]: INFO [MainThread] mopidy.commands Stopping Mopidy frontends
Oct 9 16:20:46 kitchen systemd[1]: Stopping Mopidy music server...
Oct 9 16:21:22 kitchen mopidy[13349]: #015[download] 56.7% of 4.38MiB at 54.63KiB/s ETA 00:35#015[download] 58.0% of 4.38MiB at 54.49KiB/s ETA 00:34#015[download] 59.1% of 4.38MiB at 54.51KiB/s ETA 00:33#015[download] 60.3% of 4.38MiB at 54.67KiB/s ETA 00:32#015[download] 61.7% of 4.38MiB at 54.67KiB/s ETA 00:31#015[download] 62.9% of 4.38MiB at 54.50KiB/s ETA 00:30#015[download] 64.0% of 4.38MiB at 54.48KiB/s ETA 00:29#015[download] 65.2% of 4.38MiB at 54.58KiB/s ETA 00:28#015[download] 66.5% of 4.38MiB at 54.50KiB/s ETA 00:27#015[download] 67.7% of 4.38MiB at 54.56KiB/s ETA 00:26#015[download] 69.0% of 4.38MiB at 54.46KiB/s ETA 00:25#015[download] 70.1% of 4.38MiB at 54.50KiB/s ETA 00:24#015[download] 71.3% of 4.38MiB at 54.65KiB/s ETA 00:23#015[download] 72.8% of 4.38MiB at 54.67KiB/s ETA 00:22#015[download] 74.0% of 4.38MiB at 54.51KiB/s ETA 00:21#015[download] 75.1% of 4.38MiB at 54.50KiB/s ETA 00:20#015[download] 76.3% of 4.38MiB at 54.58KiB/s ETA 00:19#015[download] 77.6% of 4.38MiB at 54.53KiB/s ETA 00:18#015[download] 78.8% of 4.38MiB at 54.60KiB/s ETA 00:17#015[download] 80.1% of 4.38MiB at 54.53KiB/s ETA 00:16#015[download] 81.2% of 4.38MiB at 54.57KiB/s ETA 00:15#015[download] 82.5% of 4.38MiB at 54.47KiB/s ETA 00:14#015[download] 83.6% of 4.38MiB at 54.48KiB/s ETA 00:13#015[download] 84.8% of 4.38MiB at 54.60KiB/s ETA 00:12#015[download] 86.3% of 4.38MiB at 54.60KiB/s ETA 00:11#015[download] 87.5% of 4.38MiB at 54.48KiB/s ETA 00:10#015[download] 88.5% of 4.38MiB at 54.68KiB/s ETA 00:09#015[download] 90.3% of 4.38MiB at 54.67KiB/s ETA 00:07#015[download] 91.5% of 4.38MiB at 54.51KiB/s ETA 00:06#015[download] 92.5% of 4.38MiB at 54.48KiB/s ETA 00:06#015[download] 93.7% of 4.38MiB at 54.52KiB/s ETA 00:05#015[download] 95.0% of 4.38MiB at 54.65KiB/s ETA 00:04#015[download] 96.4% of 4.38MiB at 54.49KiB/s ETA 00:02#015[download] 97.5% of 4.38MiB at 54.66KiB/s ETA 00:02#015[download] 99.2% of 4.38MiB at 54.61KiB/s ETA 00:00#015[download] 100.0% of 4.38MiB at 54.67KiB/s ETA 00:00#015[download] 100% of 4.38MiB in 01:22
Oct 9 16:21:22 kitchen mopidy[13349]: ERROR [YouTubeCoreListener-10] mopidy_youtube audio_url error [Errno 13] Permission denied: '/home/bob/bin/youtube.com_cookies.txt' (videoId: 817P8W8-mGE)
My bad. My cookiefile wasn't writeable by the mopidy user. Fixed that and now it's working.
Are the high-quality streams available for all tracks? I've been testing using yt-dlp to list formats because now I've enabled the cookiefile in mopidy-youtube and signed up for youtube premium, nothing seems to have changed.
yt-dlp --cookies /path/to/cookie/file --list-formats 9zrYXvUXiQk
and I don't see any high quality streams at all.
[youtube] 9zrYXvUXiQk: Downloading webpage
[youtube] 9zrYXvUXiQk: Downloading android player API JSON
[info] Available formats for 9zrYXvUXiQk:
ID EXT RESOLUTION FPS CH │ FILESIZE TBR PROTO │ VCODEC VBR ACODEC ABR ASR MORE INFO
──────────────────────────────────────────────────────────────────────────────────────────────────────────────
sb2 mhtml 48x27 0 │ mhtml │ images storyboard
sb1 mhtml 45x45 0 │ mhtml │ images storyboard
sb0 mhtml 90x90 0 │ mhtml │ images storyboard
139 m4a audio only 2 │ 1.81MiB 49k https │ audio only mp4a.40.5 49k 22k low, m4a_dash
249 webm audio only 2 │ 1.72MiB 46k https │ audio only opus 46k 48k low, webm_dash
250 webm audio only 2 │ 2.28MiB 61k https │ audio only opus 61k 48k low, webm_dash
140 m4a audio only 2 │ 4.80MiB 130k https │ audio only mp4a.40.2 130k 44k medium, m4a_dash
251 webm audio only 2 │ 4.55MiB 123k https │ audio only opus 123k 48k medium, webm_dash
17 3gp 176x144 6 1 │ 1.91MiB 52k https │ mp4v.20.3 52k mp4a.40.2 0k 22k 144p
394 mp4 144x144 25 │ 766.16KiB 20k https │ av01.0.00M.08 20k video only 144p, mp4_dash
160 mp4 144x144 25 │ 1.49MiB 40k https │ avc1.4d400b 40k video only 144p, mp4_dash
278 webm 144x144 25 │ 808.38KiB 21k https │ vp9 21k video only 144p, webm_dash
395 mp4 240x240 25 │ 2.44MiB 66k https │ av01.0.00M.08 66k video only 240p, mp4_dash
133 mp4 240x240 25 │ 3.47MiB 94k https │ avc1.4d400c 94k video only 240p, mp4_dash
242 webm 240x240 25 │ 1.56MiB 42k https │ vp9 42k video only 240p, webm_dash
396 mp4 360x360 25 │ 4.39MiB 118k https │ av01.0.00M.08 118k video only 360p, mp4_dash
134 mp4 360x360 25 │ 2.49MiB 67k https │ avc1.4d4015 67k video only 360p, mp4_dash
18 mp4 360x360 25 2 │ ~ 4.38MiB 115k https │ avc1.42001E 115k mp4a.40.2 0k 22k 360p
243 webm 360x360 25 │ 2.43MiB 65k https │ vp9 65k video only 360p, webm_dash
397 mp4 480x480 25 │ 7.35MiB 198k https │ av01.0.01M.08 198k video only 480p, mp4_dash
135 mp4 480x480 25 │ 4.56MiB 123k https │ avc1.4d401e 123k video only 480p, mp4_dash
244 webm 480x480 25 │ 5.05MiB 136k https │ vp9 136k video only 480p, webm_dash
22 mp4 720x720 25 2 │ ~ 13.81MiB 364k https │ avc1.64001F 364k mp4a.40.2 0k 44k 720p
398 mp4 720x720 25 │ 13.90MiB 375k https │ av01.0.04M.08 375k video only 720p, mp4_dash
136 mp4 720x720 25 │ 8.71MiB 235k https │ avc1.4d401f 235k video only 720p, mp4_dash
247 webm 720x720 25 │ 14.16MiB 382k https │ vp9 382k video only 720p, webm_dash
399 mp4 1080x1080 25 │ 21.68MiB 585k https │ av01.0.08M.08 585k video only 1080p, mp4_dash
137 mp4 1080x1080 25 │ 15.80MiB 426k https │ avc1.640020 426k video only 1080p, mp4_dash
248 webm 1080x1080 25 │ 23.43MiB 632k https │ vp9 632k video only 1080p, webm_dash
If I'm reading your debug output properly it does look like your fix is working and mopidy-youtube is selecting the high quality audio stream (format 141 is 256KBs AAC). Am I correct? if I am then it looks like the cookiefile format is broken, or yt-dlp isn't parsing it properly.
DEBUG 2022-10-09 19:21:49,304 [23727:YouTubeBackend-3 (_actor_loop)] mopidy_youtube
{'format_id': '141', 'requested_formats': [{'asr': 44100, 'filesize': 6303844, 'format_id': '141', 'format_note': 'high', 'source_preference': -1, 'fps': None, 'audio_channels': 2, 'height': None, 'quality': 4, 'has_drm': False, 'tbr': 257.616, 'url': 'https://rr4---sn-8pgbpohxqp5-ajt6.googlevideo.com/videoplayback?expire=1665361306&ei=OhFDY8XZAqHsxgLO-4DYDg&ip=82.9.71.63&id=o-AHRggwto4Yz7f6CBZUnC7w7lqhtU5EMi8pYVm1CF3OkA&itag=141&source=youtube&requiressl=yes&mh=R8&mm=31%2C29&mn=sn-8pgbpohxqp5-ajt6%2Csn-8pgbpohxqp5-aigr&ms=au%2Crdu&mv=m&mvi=4&pcm2cms=yes&pl=24&ctier=A&pfa=5&gcr=gb&initcwndbps=3197500&hightc=yes&vprv=1&mime=audio%2Fmp4&gir=yes&clen=6303844&dur=195.759&lmt=1635478060454922&mt=1665339207&fvip=1&keepalive=yes&fexp=24001373%2C24007246&c=ANDROID_MUSIC&txp=5532434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cctier%2Cpfa%2Cgcr%2Chightc%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRAIgcu7Z0M2fICrZ1Qomn7rd1WxCdoJfKz5oi3k3E6-rMjwCIHnPWC6bqe3FzakIoqof2WLU4WQvrIoC_OjRrAD4C1Vc&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgSI4T-O4bzveto7fQZFxzAQab7QWYdzzGMM7A4We9m3sCIExKSPuw_zEjDOd4jePELu6QV3VP2ZWMkuLSxo9fOmme', 'width': None, 'language': '', 'language_preference': -1, 'preference': None, 'ext': 'm4a', 'vcodec': 'none', 'acodec': 'mp4a.40.2', 'dynamic_range': None, 'abr': 257.616, 'downloader_options': {'http_chunk_size': 10485760}, 'container': 'm4a_dash', 'protocol': 'https', 'audio_ext': 'm4a', 'video_ext': 'none', 'format': '141 - audio only (high)', 'resolution': 'audio only', 'http_headers': {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.43 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-us,en;q=0.5', 'Sec-Fetch-Mode': 'navigate'}}], 'protocol': 'https'}
DEBUG 2022-10-09 19:21:49,305 [23727:YouTubeBackend-3 (_actor_loop)] mopidy_youtube
caching metadata 5fF7bWC70MM
Yeah, the best audio format goes from 251 (medium) to 141 (high) when it is working, I think. So, maybe a yt-dlp issue, as you suggest? That's strange tho, given in mopidy-youtube, for the yt-dlp part, the Path
of the cookie file is just passed without modification.
Actually, it isn't a Path
, it's just a string. Probably should be a Path
.
I discovered something.
If I just pass the video ID to yt-dlp, it doesn't find the high quality format. But if I convert that to a valid music URL, it does:
yt-dlp --list-formats http://music.youtube.com/watch/?v=XclachpHxis
[youtube] XclachpHxis: Downloading webpage
[youtube] XclachpHxis: Downloading android player API JSON
[youtube] XclachpHxis: Downloading android music player API JSON
[youtube] XclachpHxis: Downloading web music client config
[youtube] XclachpHxis: Downloading player 17ab0793
[youtube] XclachpHxis: Downloading web music player API JSON
[info] Available formats for XclachpHxis:
ID EXT RESOLUTION FPS CH │ FILESIZE TBR PROTO │ VCODEC VBR ACODEC ABR ASR MORE INFO
──────────────────────────────────────────────────────────────────────────────────────────────────────────────
sb2 mhtml 48x27 0 │ mhtml │ images storyboard
sb1 mhtml 45x45 1 │ mhtml │ images storyboard
sb0 mhtml 90x90 1 │ mhtml │ images storyboard
139 m4a audio only 2 │ 1.49MiB 49k https │ audio only mp4a.40.5 49k 22k low, m4a_dash
249 webm audio only 2 │ 1.49MiB 49k https │ audio only opus 49k 48k low, webm_dash
250 webm audio only 2 │ 1.97MiB 64k https │ audio only opus 64k 48k low, webm_dash
140 m4a audio only 2 │ 3.96MiB 130k https │ audio only mp4a.40.2 130k 44k medium, m4a_dash
251 webm audio only 2 │ 3.92MiB 128k https │ audio only opus 128k 48k medium, webm_dash
141 m4a audio only 2 │ 7.88MiB 258k https │ audio only mp4a.40.2 258k 44k high, m4a_dash
17 3gp 176x144 6 1 │ 1.25MiB 41k https │ mp4v.20.3 41k mp4a.40.2 0k 22k 144p
394 mp4 144x144 25 │ 578.69KiB 18k https │ av01.0.00M.08 18k video only 144p, mp4_dash
160 mp4 144x144 25 │ 265.63KiB 8k https │ avc1.4d400b 8k video only 144p, mp4_dash
278 webm 144x144 25 │ 569.01KiB 18k https │ vp9 18k video only 144p, webm_dash
395 mp4 240x240 25 │ 832.62KiB 27k https │ av01.0.00M.08 27k video only 240p, mp4_dash
133 mp4 240x240 25 │ 348.18KiB 11k https │ avc1.4d400c 11k video only 240p, mp4_dash
242 webm 240x240 25 │ 900.29KiB 29k https │ vp9 29k video only 240p, webm_dash
396 mp4 360x360 25 │ 1.02MiB 33k https │ av01.0.00M.08 33k video only 360p, mp4_dash
134 mp4 360x360 25 │ 498.17KiB 16k https │ avc1.4d4015 16k video only 360p, mp4_dash
18 mp4 360x360 25 2 │ ~ 4.55MiB 145k https │ avc1.42001E 145k mp4a.40.2 0k 44k 360p
243 webm 360x360 25 │ 1.12MiB 37k https │ vp9 37k video only 360p, webm_dash
397 mp4 480x480 25 │ 1.43MiB 47k https │ av01.0.01M.08 47k video only 480p, mp4_dash
135 mp4 480x480 25 │ 687.59KiB 22k https │ avc1.4d401e 22k video only 480p, mp4_dash
244 webm 480x480 25 │ 1.82MiB 59k https │ vp9 59k video only 480p, webm_dash
22 mp4 720x720 25 2 │ ~ 5.03MiB 160k https │ avc1.64001F 160k mp4a.40.2 0k 44k 720p
398 mp4 720x720 25 │ 1.82MiB 59k https │ av01.0.04M.08 59k video only 720p, mp4_dash
136 mp4 720x720 25 │ 976.23KiB 31k https │ avc1.4d401f 31k video only 720p, mp4_dash
247 webm 720x720 25 │ 5.46MiB 179k https │ vp9 179k video only 720p, webm_dash
399 mp4 1080x1080 25 │ 9.83MiB 322k https │ av01.0.08M.08 322k video only 1080p, mp4_dash
137 mp4 1080x1080 25 │ 2.15MiB 70k https │ avc1.640020 70k video only 1080p, mp4_dash
248 webm 1080x1080 25 │ 16.66MiB 545k https │ vp9 545k video only 1080p, webm_dash
Without the Premium cookie?
In mopidy-youtube
the whole url gets passed:
https://github.com/natumbri/mopidy-youtube/blob/develop/mopidy_youtube/youtube.py#L435-L441
One of the changes @ReneHollander made was to pass a music.youtube.com
url, which is necessary for premium. Perhaps if you just pass the command line version a videoid, it uses an ordinary youtube.com url to retrieve?
This seems to line up with the yt-dlp docs, which say Music clients [which I assume are necessary for premium audio] can be specifically requested and is enabled by default if music.youtube.com
.
OK yeah that makes sense. I am actually passing the Premium cookie, I set it in /etc/yt-dlp.conf because I kept forgetting to add it on the command line :)
It seems that while the new
musicapi_cookiefile
option does result in higher quality audio for premium accounts, it messes up the YTMusic login, so when you try to list channel playlists, it doesn't work:With the same cookie pasted into
musicapi_cookie
(instead of loaded throughmusicapi_cookiefile
), it works (but no more high quality audio, as expected).