YousableTubeFix

By Mindeye Last update Feb 2, 2012 — Installed 594,590 times.

BUG with userFormats

in
Subscribe to BUG with userFormats 2 posts, 2 voices



Chrono Defyi... User

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:
vf.userQI = userFormats.indexOf(vf.idx) + 1; // 1 for the first one, 2 for the second one, etc...

This is due to the video formats array always being passed as

[0] = FLV Low Quality -- This always gets userQI = 1
[1] = FLV High Quality -- This always gets userQI = 2
[2] = MPEG-4 H.264 -- This always gets userQI = 3
[3] = MPEG-4 H.264 HQ -- This always gets userQI = 4

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
[1] = FLV High Quality -- This gets userQI = 3
[2] = MPEG-4 H.264 -- This gets userQI = 4
[3] = MPEG-4 H.264 HQ -- This gets userQI = 1

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.

 
Mindeye Script's Author

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).

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel