mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 802465 - Limit resolution of youtube streams in YoutubeProtocolHandler r=fabrice
This commit is contained in:
parent
18527f9e0b
commit
c336c77898
@ -75,13 +75,19 @@ YoutubeProtocolHandler.prototype = {
|
||||
let uri;
|
||||
let mimeType;
|
||||
|
||||
// Recognized mime types, ordered from the less usable to the most usable.
|
||||
let recognizedTypes = ["video/webm"];
|
||||
// itag is an undocumented value which maps to resolution and mimetype
|
||||
// see https://en.wikipedia.org/wiki/YouTube#Quality_and_codecs
|
||||
// Ordered from least to most preferred
|
||||
let recognizedItags = [
|
||||
"17", // 144p 3GP
|
||||
"36", // 240p 3GP
|
||||
"43", // 360p WebM
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
recognizedTypes.push("video/mp4");
|
||||
"18", // 360p H.264
|
||||
#endif
|
||||
];
|
||||
|
||||
let bestType = -1;
|
||||
let bestItag = -1;
|
||||
|
||||
let extras = { }
|
||||
|
||||
@ -89,13 +95,14 @@ YoutubeProtocolHandler.prototype = {
|
||||
let params = extractParameters(aStream);
|
||||
let url = params["url"];
|
||||
let type = params["type"] ? params["type"].split(";")[0] : null;
|
||||
let itag = params["itag"];
|
||||
|
||||
let index;
|
||||
if (url && type && ((index = recognizedTypes.indexOf(type)) != -1) &&
|
||||
index > bestType) {
|
||||
if (url && type && ((index = recognizedItags.indexOf(itag)) != -1) &&
|
||||
index > bestItag) {
|
||||
uri = url + '&signature=' + (params["sig"] ? params['sig'] : '');
|
||||
mimeType = type;
|
||||
bestType = index;
|
||||
bestItag = index;
|
||||
}
|
||||
for (let param in params) {
|
||||
if (["thumbnail_url", "length_seconds", "title"].indexOf(param) != -1) {
|
||||
|
Loading…
Reference in New Issue
Block a user