raingart / Nova-YouTube-extension

Apache License 2.0
198 stars 9 forks source link

Video quality settings #105

Closed J4CKED closed 10 months ago

J4CKED commented 10 months ago

0.43.4 | Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0

Hi. To save data transfer, I set the video quality to 240p. Some videos, like the one below, do not have 240p, but instead have a choice of 140p, 320p, 720p and 1080p. Then this video loads the highest quality 1080p.

It would be nice if there was an option to set (unless 240p is present) a quality close to the one specified in the settings. Preferably the higher one (320p in this case).

I'm using an translator, I hope this is written clearly.

Sample video: https://www.youtube.com/watch?v=Qc6FJWapiJk

raingart commented 10 months ago

check the beta

During testing, I came across a lot of similar videos. Unfortunately, I almost immediately stopped keeping a list. Since the necessary quality appeared over time. But here is the list that is left. I'm not sure if it's up to date https://github.com/raingart/Nova-YouTube-extension/blob/master/plugins/player/quality.js#L2-L5

It is logically clear what needs to be done. But I can't adequately make the implementation through the code

This is what happens in the new version

  1. The availableQualityList is compared with exampleQualityLevels and all inaccessible Quality is removed except for the one selected in the settings.
  2. The index of the selected one is taken and it is checked whether there is an element in the availableQualityList with such an index. Often this should be the quality that comes next (below) the selected one. If it is not available, then the first element of the list is taken - the largest of the available quality. Such an implementation leads to the following result, for example: if 144p is selected and it is not available in the availableQualityList, then not 240 will be selected, but the maximum. For example 4k video. You can choose not the previous lower value of the list, but the next (higher). I think it's more correct. But I'm unsure of the result

try beta. If the result is unsatisfactory. And it's better to choose the next value in the list instead of the previous one. then replace the following code

nearestQualityIdx = availableQuality.findIndex(q => q === selectedQuality) ;

to

nearestQualityIdx = availableQuality.findIndex(q => q === selectedQuality) - 1;
J4CKED commented 10 months ago

Yes, it works now. Even with "- 1". If there is no 240 quality available it jumps to 360. Cool.