cyfung1031 / userscript-supports

This is for the userscripts created on GreasyFork.org.
https://cyfung1031.github.io/userscript-supports/
MIT License
48 stars 3 forks source link

Question about Youtube audio only #50

Closed Newcool1230 closed 1 month ago

Newcool1230 commented 1 month ago

Hey there,

I was wondering if you could possible walk through how you are achieving audio only after the recent youtube update, where they are merging both audio and video into one https://*.googlevideo.com/videoplayback/* request.

Previously audio only was achieved by blocking mime=video requests and only allowing mime=audio requests. After the update this doesn't seem to work as they are merged into one request.

Looking at your code it seems like you are updating some flags, but I can't seem to get a grasp on it. Would love to learn more about this.

cyfung1031 commented 1 month ago

I don't know how the actual YouTube engine is working with the network requests.

There is a property deviceIsAudioOnly existing in YouTube coding. My script is to force it to true only, plus some fixes for the live streaming.

Newcool1230 commented 1 month ago

There is a property deviceIsAudioOnly existing in YouTube coding. My script is to force it to true only, plus some fixes for the live streaming.

Oh interesting, this is a pretty cool find.

I looked around for a bit but can't seem to find the deviceIsAudioOnly property. Is it located in the storage configs? or directly in the html5 video player itself?

cyfung1031 commented 1 month ago

No... This is not that simple You need to study the JavaScript code of the YouTube.

Anyway you can just use my script for this feature

cyfung1031 commented 1 month ago

deviceIsAudioOnly

https://github.com/cyfung1031/userscript-supports/blob/f52e0a6040efc4ba80c749b543f058dc5464a7d6/484611-youtube-audio-only.user.js#L2134-L2150

I could not go through all the coding I wrote to tell you how to implement this. You can use my userscript directly or deeply analyse YouTube's JavaScript by yourself.