BUG with userFormats
|
|
The userFormats is ignored because of a bug in the underlined line.
// Extends the video formats array with properties regarding the user configuration (userFormats array)
videoFormatsArray.userFormatsLength = 0; // Counter of the video formats selected by the user which are supported
videoFormatsArray.forEach(function(vf) { // Adds properties to each video format object
// isAvailable will be updated by selVideoFormatAvailability or its initialization code (1: available, 0: not available, -1: unknown [request error], -2: not checked)
vf.isAvailable = null;
// userChosen indicates if the video format has been selected by the user, userQI holds the QI given to it by the user (higher is better)
if (userFormats === null) {
// userFormats is unavailable. The properties get their default values
vf.userQI = vf.QI;
vf.userChosen = vf.defaultChosen;
}
else {
// userFormats is available. Tries to find the video format in userFormats
if (userFormats.indexOf(vf.idx) != -1) {
// The video format has been selected
vf.userQI = videoFormatsArray.userFormatsLength + 1; // 1 for the first one, 2 for the second one, etc...
vf.userChosen = true;
}
else {
// The video format hasn't been selected
vf.userQI = null;
vf.userChosen = false;
}
}
// Updates the counter if the video format has been selected
if (vf.userChosen) videoFormatsArray.userFormatsLength++;
});
The line should read:
This is due to the video formats array always being passed as [0] = FLV Low Quality -- This always gets userQI = 1
whereas userFormats.indexOf(vf.idx) + 1 gives the proper result according to the user preference For example: ["18", "6", "", "22"] will result in this [0] = FLV Low Quality -- This gets userQI = 2
P.S: Sorry, I had to use the deprecated width element of pre to avoid border overflow since userscripts.org doesn't allow styles in posts. |
|
|
Yes, you're right. That code section got several rewrites, and I forgot to change that line. It'll be fixed in next version. BTW, your change isn't totally ok, because userFormats can hold invalid indexes if it isn't validated first, and that will affect the operation (invalid indexes should be ignored). |