summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--assets/.well-known/dnt-policy.txt52
-rw-r--r--assets/js/silvermine-videojs-quality-selector.js1979
-rw-r--r--assets/js/silvermine-videojs-quality-selector.min.js5
-rw-r--r--assets/js/videojs-dash.min.js6
-rw-r--r--assets/js/videojs.hotkeys.js413
-rw-r--r--src/invidious.cr42
-rw-r--r--src/invidious/comments.cr25
-rw-r--r--src/invidious/helpers/helpers.cr52
-rw-r--r--src/invidious/mixes.cr2
-rw-r--r--src/invidious/playlists.cr2
-rw-r--r--src/invidious/users.cr58
-rw-r--r--src/invidious/videos.cr26
-rw-r--r--src/invidious/views/components/player.ecr1
-rw-r--r--src/invidious/views/licenses.ecr153
-rw-r--r--src/invidious/views/preferences.ecr5
-rw-r--r--src/invidious/views/template.ecr1
-rw-r--r--src/invidious/views/watch.ecr49
17 files changed, 2746 insertions, 125 deletions
diff --git a/assets/.well-known/dnt-policy.txt b/assets/.well-known/dnt-policy.txt
index 795a37ec..ad946d1f 100644
--- a/assets/.well-known/dnt-policy.txt
+++ b/assets/.well-known/dnt-policy.txt
@@ -1,4 +1,4 @@
-Do Not Track Compliance Policy
+Do Not Track Compliance Policy
Version 1.0
@@ -32,23 +32,23 @@ When this domain receives Web requests from a user who enables DNT by actively
choosing an opt-out setting in their browser or by installing software that is
primarily designed to protect privacy ("DNT User"), we will take the following
measures with respect to those users' data, subject to the Exceptions, also
-listed below:
+listed below:
-1. END USER IDENTIFIERS:
+1. END USER IDENTIFIERS:
a. If a DNT User has logged in to our service, all user identifiers, such as
- unique or nearly unique cookies, "supercookies" and fingerprints are
- discarded as soon as the HTTP(S) response is issued.
+ unique or nearly unique cookies, "supercookies" and fingerprints are
+ discarded as soon as the HTTP(S) response is issued.
Data structures which associate user identifiers with accounts may be
employed to recognize logged in users per Exception 4 below, but may not
be associated with records of the user's activities unless otherwise
excepted.
- b. If a DNT User is not logged in to our service, we will take steps to ensure
- that no user identifiers are transmitted to us at all.
+ b. If a DNT User is not logged in to our service, we will take steps to ensure
+ that no user identifiers are transmitted to us at all.
-2. LOG RETENTION:
+2. LOG RETENTION:
a. Logs with DNT Users' identifiers removed (but including IP addresses and
User Agent strings) may be retained for a period of 10 days or less,
@@ -58,13 +58,13 @@ listed below:
and performance problems; and that security and data aggregation systems
have time to operate.
- b. These logs will not be used for any other purposes.
+ b. These logs will not be used for any other purposes.
-3. OTHER DOMAINS:
+3. OTHER DOMAINS:
a. If this domain transfers identifiable user data about DNT Users to
contractors, affiliates or other parties, or embeds from or posts data to
- other domains, we will either:
+ other domains, we will either:
b. ensure that the operators of those domains abide by this policy overall
by posting it at /.well-known/dnt-policy.txt via HTTPS on the domains in
@@ -75,7 +75,7 @@ listed below:
ensure that the recipient's policies and practices require the recipient
to respect the policy for our DNT Users' data.
- OR
+ OR
obtain a contractual commitment from the recipient to respect this policy
for our DNT Users' data.
@@ -88,14 +88,14 @@ listed below:
c. "Identifiable" means any records which are not Anonymized or otherwise
covered by the Exceptions below.
-4. PERIODIC REASSERTION OF COMPLIANCE:
+4. PERIODIC REASSERTION OF COMPLIANCE:
At least once every 12 months, we will take reasonable steps commensurate
with the size of our organization and the nature of our service to confirm
our ongoing compliance with this document, and we will publicly reassert our
compliance.
-5. USER NOTIFICATION:
+5. USER NOTIFICATION:
a. If we are required by law to retain or disclose user identifiers, we will
attempt to provide the users with notice (unless we are prohibited or it
@@ -105,7 +105,7 @@ listed below:
b. We will attempt to provide this notice by email, if the users have given
us an email address, and by postal mail if the users have provided a
- postal address.
+ postal address.
c. If the users do not challenge the disclosure request, we may be legally
required to turn over their information.
@@ -120,17 +120,17 @@ EXCEPTIONS
Data from DNT Users collected by this domain may be logged or retained only in
the following specific situations:
-1. CONSENT / "OPT BACK IN"
+1. CONSENT / "OPT BACK IN"
a. DNT Users are opting out from tracking across the Web. It is possible
that for some feature or functionality, we will need to ask a DNT User to
- "opt back in" to be tracked by us across the entire Web.
+ "opt back in" to be tracked by us across the entire Web.
b. If we do that, we will take reasonable steps to verify that the users who
select this option have genuinely intended to opt back in to tracking.
One way to do this is by performing scientifically reasonable user
studies with a representative sample of our users, but smaller
- organizations can satisfy this requirement by other means.
+ organizations can satisfy this requirement by other means.
c. Where we believe that we have opt back in consent, our server will
send a tracking value status header "Tk: C" as described in section 6.2
@@ -138,7 +138,7 @@ the following specific situations:
http://www.w3.org/TR/tracking-dnt/#tracking-status-value
-2. TRANSACTIONS
+2. TRANSACTIONS
If a DNT User actively and knowingly enters a transaction with our
services (for instance, clicking on a clearly-labeled advertisement,
@@ -151,19 +151,19 @@ the following specific situations:
item will be shipped. By their nature, some transactions will require data
to be retained indefinitely.
-3. TECHNICAL AND SECURITY LOGGING:
+3. TECHNICAL AND SECURITY LOGGING:
a. If, during the processing of the initial request (for unique identifiers)
or during the subsequent 10 days (for IP addresses and User Agent strings),
we obtain specific information that causes our employees or systems to
believe that a request is, or is likely to be, part of a security attack,
- spam submission, or fraudulent transaction, then logs of those requests
- are not subject to this policy.
+ spam submission, or fraudulent transaction, then logs of those requests
+ are not subject to this policy.
b. If we encounter technical problems with our site, then, in rare
circumstances, we may retain logs for longer than 10 days, if that is
necessary to diagnose and fix those problems, but this practice will not be
- routinized and we will strive to delete such logs as soon as possible.
+ routinized and we will strive to delete such logs as soon as possible.
4. AGGREGATION:
@@ -179,13 +179,13 @@ the following specific situations:
that the dataset, plus any additional information that is in our
possession or likely to be available to us, does not allow the
reconstruction of reading habits, online or offline activity of groups of
- fewer than 5000 individuals or devices.
+ fewer than 5000 individuals or devices.
c. If we generate anonymized datasets under this exception we will publicly
document our anonymization methods in sufficient detail to allow outside
experts to evaluate the effectiveness of those methods.
-5. ERRORS:
+5. ERRORS:
From time to time, there may be errors by which user data is temporarily
logged or retained in violation of this policy. If such errors are
@@ -215,4 +215,4 @@ threshold.
those domains pertain to specific topics or activities, but records of visited
DNS names are not reading habits if those domain names serve content of a very
diverse and general nature, thereby revealing minimal information about the
-opinions, interests or activities of the user. \ No newline at end of file
+opinions, interests or activities of the user.
diff --git a/assets/js/silvermine-videojs-quality-selector.js b/assets/js/silvermine-videojs-quality-selector.js
new file mode 100644
index 00000000..9b92fc80
--- /dev/null
+++ b/assets/js/silvermine-videojs-quality-selector.js
@@ -0,0 +1,1979 @@
+(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
+(function(){
+ var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
+
+ // The base Class implementation (does nothing)
+ this.Class = function(){};
+
+ // Create a new Class that inherits from this class
+ Class.extend = function(className, prop) {
+ if(prop == undefined) {
+ prop = className;
+ className = "Class";
+ }
+
+ var _super = this.prototype;
+
+ // Instantiate a base class (but only create the instance,
+ // don't run the init constructor)
+ initializing = true;
+ var prototype = new this();
+ initializing = false;
+
+ // Copy the properties over onto the new prototype
+ for (var name in prop) {
+ // Check if we're overwriting an existing function
+ prototype[name] = typeof prop[name] == "function" &&
+ typeof _super[name] == "function" && fnTest.test(prop[name]) ?
+ (function(name, fn){
+ return function() {
+ var tmp = this._super;
+
+ // Add a new ._super() method that is the same method
+ // but on the super-class
+ this._super = _super[name];
+
+ // The method only need to be bound temporarily, so we
+ // remove it when we're done executing
+ var ret = fn.apply(this, arguments);
+ this._super = tmp;
+
+ return ret;
+ };
+ })(name, prop[name]) :
+ prop[name];
+ }
+
+ // The dummy class constructor
+ function Class() {
+ // All construction is actually done in the init method
+ if ( !initializing && this.init )
+ this.init.apply(this, arguments);
+ }
+
+ // Populate our constructed prototype object
+ Class.prototype = prototype;
+
+ // Enforce the constructor to be what we expect
+ var func = new Function(
+ "return function " + className + "(){ }"
+ )();
+ Class.prototype.constructor = func;
+
+ // And make this class extendable
+ Class.extend = arguments.callee;
+
+ return Class;
+ };
+
+ //I only added this line
+ module.exports = Class;
+})();
+
+},{}],2:[function(require,module,exports){
+// Underscore.js 1.8.3
+// http://underscorejs.org
+// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
+// Underscore may be freely distributed under the MIT license.
+
+(function() {
+
+ // Baseline setup
+ // --------------
+
+ // Establish the root object, `window` in the browser, or `exports` on the server.
+ var root = this;
+
+ // Save the previous value of the `_` variable.
+ var previousUnderscore = root._;
+
+ // Save bytes in the minified (but not gzipped) version:
+ var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
+
+ // Create quick reference variables for speed access to core prototypes.
+ var
+ push = ArrayProto.push,
+ slice = ArrayProto.slice,
+ toString = ObjProto.toString,
+ hasOwnProperty = ObjProto.hasOwnProperty;
+
+ // All **ECMAScript 5** native function implementations that we hope to use
+ // are declared here.
+ var
+ nativeIsArray = Array.isArray,
+ nativeKeys = Object.keys,
+ nativeBind = FuncProto.bind,
+ nativeCreate = Object.create;
+
+ // Naked function reference for surrogate-prototype-swapping.
+ var Ctor = function(){};
+
+ // Create a safe reference to the Underscore object for use below.
+ var _ = function(obj) {
+ if (obj instanceof _) return obj;
+ if (!(this instanceof _)) return new _(obj);
+ this._wrapped = obj;
+ };
+
+ // Export the Underscore object for **Node.js**, with
+ // backwards-compatibility for the old `require()` API. If we're in
+ // the browser, add `_` as a global object.
+ if (typeof exports !== 'undefined') {
+ if (typeof module !== 'undefined' && module.exports) {
+ exports = module.exports = _;
+ }
+ exports._ = _;
+ } else {
+ root._ = _;
+ }
+
+ // Current version.
+ _.VERSION = '1.8.3';
+
+ // Internal function that returns an efficient (for current engines) version
+ // of the passed-in callback, to be repeatedly applied in other Underscore
+ // functions.
+ var optimizeCb = function(func, context, argCount) {
+ if (context === void 0) return func;
+ switch (argCount == null ? 3 : argCount) {
+ case 1: return function(value) {
+ return func.call(context, value);
+ };
+ case 2: return function(value, other) {
+ return func.call(context, value, other);
+ };
+ case 3: return function(value, index, collection) {
+ return func.call(context, value, index, collection);
+ };
+ case 4: return function(accumulator, value, index, collection) {
+ return func.call(context, accumulator, value, index, collection);
+ };
+ }
+ return function() {
+ return func.apply(context, arguments);
+ };
+ };
+
+ // A mostly-internal function to generate callbacks that can be applied
+ // to each element in a collection, returning the desired result — either
+ // identity, an arbitrary callback, a property matcher, or a property accessor.
+ var cb = function(value, context, argCount) {
+ if (value == null) return _.identity;
+ if (_.isFunction(value)) return optimizeCb(value, context, argCount);
+ if (_.isObject(value)) return _.matcher(value);
+ return _.property(value);
+ };
+ _.iteratee = function(value, context) {
+ return cb(value, context, Infinity);
+ };
+
+ // An internal function for creating assigner functions.
+ var createAssigner = function(keysFunc, undefinedOnly) {
+ return function(obj) {
+ var length = arguments.length;
+ if (length < 2 || obj == null) return obj;
+ for (var index = 1; index < length; index++) {
+ var source = arguments[index],
+ keys = keysFunc(source),
+ l = keys.length;
+ for (var i = 0; i < l; i++) {
+ var key = keys[i];
+ if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key];
+ }
+ }
+ return obj;
+ };
+ };
+
+ // An internal function for creating a new object that inherits from another.
+ var baseCreate = function(prototype) {
+ if (!_.isObject(prototype)) return {};
+ if (nativeCreate) return nativeCreate(prototype);
+ Ctor.prototype = prototype;
+ var result = new Ctor;
+ Ctor.prototype = null;
+ return result;
+ };
+
+ var property = function(key) {
+ return function(obj) {
+ return obj == null ? void 0 : obj[key];
+ };
+ };
+
+ // Helper for collection methods to determine whether a collection
+ // should be iterated as an array or as an object
+ // Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
+ // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094
+ var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
+ var getLength = property('length');
+ var isArrayLike = function(collection) {
+ var length = getLength(collection);
+ return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX;
+ };
+
+ // Collection Functions
+ // --------------------
+
+ // The cornerstone, an `each` implementation, aka `forEach`.
+ // Handles raw objects in addition to array-likes. Treats all
+ // sparse array-likes as if they were dense.
+ _.each = _.forEach = function(obj, iteratee, context) {
+ iteratee = optimizeCb(iteratee, context);
+ var i, length;
+ if (isArrayLike(obj)) {
+ for (i = 0, length = obj.length; i < length; i++) {
+ iteratee(obj[i], i, obj);
+ }
+ } else {
+ var keys = _.keys(obj);
+ for (i = 0, length = keys.length; i < length; i++) {
+ iteratee(obj[keys[i]], keys[i], obj);
+ }
+ }
+ return obj;
+ };
+
+ // Return the results of applying the iteratee to each element.
+ _.map = _.collect = function(obj, iteratee, context) {
+ iteratee = cb(iteratee, context);
+ var keys = !isArrayLike(obj) && _.keys(obj),
+ length = (keys || obj).length,
+ results = Array(length);
+ for (var index = 0; index < length; index++) {
+ var currentKey = keys ? keys[index] : index;
+ results[index] = iteratee(obj[currentKey], currentKey, obj);
+ }
+ return results;
+ };
+
+ // Create a reducing function iterating left or right.
+ function createReduce(dir) {
+ // Optimized iterator function as using arguments.length
+ // in the main function will deoptimize the, see #1991.
+ function iterator(obj, iteratee, memo, keys, index, length) {
+ for (; index >= 0 && index < length; index += dir) {
+ var currentKey = keys ? keys[index] : index;
+ memo = iteratee(memo, obj[currentKey], currentKey, obj);
+ }
+ return memo;
+ }
+
+ return function(obj, iteratee, memo, context) {
+ iteratee = optimizeCb(iteratee, context, 4);
+ var keys = !isArrayLike(obj) && _.keys(obj),
+ length = (keys || obj).length,
+ index = dir > 0 ? 0 : length - 1;
+ // Determine the initial value if none is provided.
+ if (arguments.length < 3) {
+ memo = obj[keys ? keys[index] : index];
+ index += dir;
+ }
+ return iterator(obj, iteratee, memo, keys, index, length);
+ };
+ }
+
+ // **Reduce** builds up a single result from a list of values, aka `inject`,
+ // or `foldl`.
+ _.reduce = _.foldl = _.inject = createReduce(1);
+
+ // The right-associative version of reduce, also known as `foldr`.
+ _.reduceRight = _.foldr = createReduce(-1);
+
+ // Return the first value which passes a truth test. Aliased as `detect`.
+ _.find = _.detect = function(obj, predicate, context) {
+ var key;
+ if (isArrayLike(obj)) {
+ key = _.findIndex(obj, predicate, context);
+ } else {
+ key = _.findKey(obj, predicate, context);
+ }
+ if (key !== void 0 && key !== -1) return obj[key];
+ };
+
+ // Return all the elements that pass a truth test.
+ // Aliased as `select`.
+ _.filter = _.select = function(obj, predicate, context) {
+ var results = [];
+ predicate = cb(predicate, context);
+ _.each(obj, function(value, index, list) {
+ if (predicate(value, index, list)) results.push(value);
+ });
+ return results;
+ };
+
+ // Return all the elements for which a truth test fails.
+ _.reject = function(obj, predicate, context) {
+ return _.filter(obj, _.negate(cb(predicate)), context);
+ };
+
+ // Determine whether all of the elements match a truth test.
+ // Aliased as `all`.
+ _.every = _.all = function(obj, predicate, context) {
+ predicate = cb(predicate, context);
+ var keys = !isArrayLike(obj) && _.keys(obj),
+ length = (keys || obj).length;
+ for (var index = 0; index < length; index++) {
+ var currentKey = keys ? keys[index] : index;
+ if (!predicate(obj[currentKey], currentKey, obj)) return false;
+ }
+ return true;
+ };
+
+ // Determine if at least one element in the object matches a truth test.
+ // Aliased as `any`.
+ _.some = _.any = function(obj, predicate, context) {
+ predicate = cb(predicate, context);
+ var keys = !isArrayLike(obj) && _.keys(obj),
+ length = (keys || obj).length;
+ for (var index = 0; index < length; index++) {
+ var currentKey = keys ? keys[index] : index;
+ if (predicate(obj[currentKey], currentKey, obj)) return true;
+ }
+ return false;
+ };
+
+ // Determine if the array or object contains a given item (using `===`).
+ // Aliased as `includes` and `include`.
+ _.contains = _.includes = _.include = function(obj, item, fromIndex, guard) {
+ if (!isArrayLike(obj)) obj = _.values(obj);
+ if (typeof fromIndex != 'number' || guard) fromIndex = 0;
+ return _.indexOf(obj, item, fromIndex) >= 0;
+ };
+
+ // Invoke a method (with arguments) on every item in a collection.
+ _.invoke = function(obj, method) {
+ var args = slice.call(arguments, 2);
+ var isFunc = _.isFunction(method);
+ return _.map(obj, function(value) {
+ var func = isFunc ? method : value[method];
+ return func == null ? func : func.apply(value, args);
+ });
+ };
+
+ // Convenience version of a common use case of `map`: fetching a property.
+ _.pluck = function(obj, key) {
+ return _.map(obj, _.property(key));
+ };
+
+ // Convenience version of a common use case of `filter`: selecting only objects
+ // containing specific `key:value` pairs.
+ _.where = function(obj, attrs) {
+ return _.filter(obj, _.matcher(attrs));
+ };
+
+ // Convenience version of a common use case of `find`: getting the first object
+ // containing specific `key:value` pairs.
+ _.findWhere = function(obj, attrs) {
+ return _.find(obj, _.matcher(attrs));
+ };
+
+ // Return the maximum element (or element-based computation).
+ _.max = function(obj, iteratee, context) {
+ var result = -Infinity, lastComputed = -Infinity,
+ value, computed;
+ if (iteratee == null && obj != null) {
+ obj = isArrayLike(obj) ? obj : _.values(obj);
+ for (var i = 0, length = obj.length; i < length; i++) {
+ value = obj[i];
+ if (value > result) {
+ result = value;
+ }
+ }
+ } else {
+ iteratee = cb(iteratee, context);
+ _.each(obj, function(value, index, list) {
+ computed = iteratee(value, index, list);
+ if (computed > lastComputed || computed === -Infinity && result === -Infinity) {
+ result = value;
+ lastComputed = computed;
+ }
+ });
+ }
+ return result;
+ };
+
+ // Return the minimum element (or element-based computation).
+ _.min = function(obj, iteratee, context) {
+ var result = Infinity, lastComputed = Infinity,
+ value, computed;
+ if (iteratee == null && obj != null) {
+ obj = isArrayLike(obj) ? obj : _.values(obj);
+ for (var i = 0, length = obj.length; i < length; i++) {
+ value = obj[i];
+ if (value < result) {
+ result = value;
+ }
+ }
+ } else {
+ iteratee = cb(iteratee, context);
+ _.each(obj, function(value, index, list) {
+ computed = iteratee(value, index, list);
+ if (computed < lastComputed || computed === Infinity && result === Infinity) {
+ result = value;
+ lastComputed = computed;
+ }
+ });
+ }
+ return result;
+ };
+
+ // Shuffle a collection, using the modern version of the
+ // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
+ _.shuffle = function(obj) {
+ var set = isArrayLike(obj) ? obj : _.values(obj);
+ var length = set.length;
+ var shuffled = Array(length);
+ for (var index = 0, rand; index < length; index++) {
+ rand = _.random(0, index);
+ if (rand !== index) shuffled[index] = shuffled[rand];
+ shuffled[rand] = set[index];
+ }
+ return shuffled;
+ };
+
+ // Sample **n** random values from a collection.
+ // If **n** is not specified, returns a single random element.
+ // The internal `guard` argument allows it to work with `map`.
+ _.sample = function(obj, n, guard) {
+ if (n == null || guard) {
+ if (!isArrayLike(obj)) obj = _.values(obj);
+ return obj[_.random(obj.length - 1)];
+ }
+ return _.shuffle(obj).slice(0, Math.max(0, n));
+ };
+
+ // Sort the object's values by a criterion produced by an iteratee.
+ _.sortBy = function(obj, iteratee, context) {
+ iteratee = cb(iteratee, context);
+ return _.pluck(_.map(obj, function(value, index, list) {
+ return {
+ value: value,
+ index: index,
+ criteria: iteratee(value, index, list)
+ };
+ }).sort(function(left, right) {
+ var a = left.criteria;
+ var b = right.criteria;
+ if (a !== b) {
+ if (a > b || a === void 0) return 1;
+ if (a < b || b === void 0) return -1;
+ }
+ return left.index - right.index;
+ }), 'value');
+ };
+
+ // An internal function used for aggregate "group by" operations.
+ var group = function(behavior) {
+ return function(obj, iteratee, context) {
+ var result = {};
+ iteratee = cb(iteratee, context);
+ _.each(obj, function(value, index) {
+ var key = iteratee(value, index, obj);
+ behavior(result, value, key);
+ });
+ return result;
+ };
+ };
+
+ // Groups the object's values by a criterion. Pass either a string attribute
+ // to group by, or a function that returns the criterion.
+ _.groupBy = group(function(result, value, key) {
+ if (_.has(result, key)) result[key].push(value); else result[key] = [value];
+ });
+
+ // Indexes the object's values by a criterion, similar to `groupBy`, but for
+ // when you know that your index values will be unique.
+ _.indexBy = group(function(result, value, key) {
+ result[key] = value;
+ });
+
+ // Counts instances of an object that group by a certain criterion. Pass
+ // either a string attribute to count by, or a function that returns the
+ // criterion.
+ _.countBy = group(function(result, value, key) {
+ if (_.has(result, key)) result[key]++; else result[key] = 1;
+ });
+
+ // Safely create a real, live array from anything iterable.
+ _.toArray = function(obj) {
+ if (!obj) return [];
+ if (_.isArray(obj)) return slice.call(obj);
+ if (isArrayLike(obj)) return _.map(obj, _.identity);
+ return _.values(obj);
+ };
+
+ // Return the number of elements in an object.
+ _.size = function(obj) {
+ if (obj == null) return 0;
+ return isArrayLike(obj) ? obj.length : _.keys(obj).length;
+ };
+
+ // Split a collection into two arrays: one whose elements all satisfy the given
+ // predicate, and one whose elements all do not satisfy the predicate.
+ _.partition = function(obj, predicate, context) {
+ predicate = cb(predicate, context);
+ var pass = [], fail = [];
+ _.each(obj, function(value, key, obj) {
+ (predicate(value, key, obj) ? pass : fail).push(value);
+ });
+ return [pass, fail];
+ };
+
+ // Array Functions
+ // ---------------
+
+ // Get the first element of an array. Passing **n** will return the first N
+ // values in the array. Aliased as `head` and `take`. The **guard** check
+ // allows it to work with `_.map`.
+ _.first = _.head = _.take = function(array, n, guard) {
+ if (array == null) return void 0;
+ if (n == null || guard) return array[0];
+ return _.initial(array, array.length - n);
+ };
+
+ // Returns everything but the last entry of the array. Especially useful on
+ // the arguments object. Passing **n** will return all the values in
+ // the array, excluding the last N.
+ _.initial = function(array, n, guard) {
+ return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
+ };
+
+ // Get the last element of an array. Passing **n** will return the last N
+ // values in the array.
+ _.last = function(array, n, guard) {
+ if (array == null) return void 0;
+ if (n == null || guard) return array[array.length - 1];
+ return _.rest(array, Math.max(0, array.length - n));
+ };
+
+ // Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
+ // Especially useful on the arguments object. Passing an **n** will return
+ // the rest N values in the array.
+ _.rest = _.tail = _.drop = function(array, n, guard) {
+ return slice.call(array, n == null || guard ? 1 : n);
+ };
+
+ // Trim out all falsy values from an array.
+ _.compact = function(array) {
+ return _.filter(array, _.identity);
+ };
+
+ // Internal implementation of a recursive `flatten` function.
+ var flatten = function(input, shallow, strict, startIndex) {
+ var output = [], idx = 0;
+ for (var i = startIndex || 0, length = getLength(input); i < length; i++) {
+ var value = input[i];
+ if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) {
+ //flatten current level of array or arguments object
+ if (!shallow) value = flatten(value, shallow, strict);
+ var j = 0, len = value.length;
+ output.length += len;
+ while (j < len) {
+ output[idx++] = value[j++];
+ }
+ } else if (!strict) {
+ output[idx++] = value;
+ }
+ }
+ return output;
+ };
+
+ // Flatten out an array, either recursively (by default), or just one level.
+ _.flatten = function(array, shallow) {
+ return flatten(array, shallow, false);
+ };
+
+ // Return a version of the array that does not contain the specified value(s).
+ _.without = function(array) {
+ return _.difference(array, slice.call(arguments, 1));
+ };
+
+ // Produce a duplicate-free version of the array. If the array has already
+ // been sorted, you have the option of using a faster algorithm.
+ // Aliased as `unique`.
+ _.uniq = _.unique = function(array, isSorted, iteratee, context) {
+ if (!_.isBoolean(isSorted)) {
+ context = iteratee;
+ iteratee = isSorted;
+ isSorted = false;
+ }
+ if (iteratee != null) iteratee = cb(iteratee, context);
+ var result = [];
+ var seen = [];
+ for (var i = 0, length = getLength(array); i < length; i++) {
+ var value = array[i],
+ computed = iteratee ? iteratee(value, i, array) : value;
+ if (isSorted) {
+ if (!i || seen !== computed) result.push(value);
+ seen = computed;
+ } else if (iteratee) {
+ if (!_.contains(seen, computed)) {
+ seen.push(computed);
+ result.push(value);
+ }
+ } else if (!_.contains(result, value)) {
+ result.push(value);
+ }
+ }
+ return result;
+ };
+
+ // Produce an array that contains the union: each distinct element from all of
+ // the passed-in arrays.
+ _.union = function() {
+ return _.uniq(flatten(arguments, true, true));
+ };
+
+ // Produce an array that contains every item shared between all the
+ // passed-in arrays.
+ _.intersection = function(array) {
+ var result = [];
+ var argsLength = arguments.length;
+ for (var i = 0, length = getLength(array); i < length; i++) {
+ var item = array[i];
+ if (_.contains(result, item)) continue;
+ for (var j = 1; j < argsLength; j++) {
+ if (!_.contains(arguments[j], item)) break;
+ }
+ if (j === argsLength) result.push(item);
+ }
+ return result;
+ };
+
+ // Take the difference between one array and a number of other arrays.
+ // Only the elements present in just the first array will remain.
+ _.difference = function(array) {
+ var rest = flatten(arguments, true, true, 1);
+ return _.filter(array, function(value){
+ return !_.contains(rest, value);
+ });
+ };
+
+ // Zip together multiple lists into a single array -- elements that share
+ // an index go together.
+ _.zip = function() {
+ return _.unzip(arguments);
+ };
+
+ // Complement of _.zip. Unzip accepts an array of arrays and groups
+ // each array's elements on shared indices
+ _.unzip = function(array) {
+ var length = array && _.max(array, getLength).length || 0;
+ var result = Array(length);
+
+ for (var index = 0; index < length; index++) {
+ result[index] = _.pluck(array, index);
+ }
+ return result;
+ };
+
+ // Converts lists into objects. Pass either a single array of `[key, value]`
+ // pairs, or two parallel arrays of the same length -- one of keys, and one of
+ // the corresponding values.
+ _.object = function(list, values) {
+ var result = {};
+ for (var i = 0, length = getLength(list); i < length; i++) {
+ if (values) {
+ result[list[i]] = values[i];
+ } else {
+ result[list[i][0]] = list[i][1];
+ }
+ }
+ return result;
+ };
+
+ // Generator function to create the findIndex and findLastIndex functions
+ function createPredicateIndexFinder(dir) {
+ return function(array, predicate, context) {
+ predicate = cb(predicate, context);
+ var length = getLength(array);
+ var index = dir > 0 ? 0 : length - 1;
+ for (; index >= 0 && index < length; index += dir) {
+ if (predicate(array[index], index, array)) return index;
+ }
+ return -1;
+ };
+ }
+
+ // Returns the first index on an array-like that passes a predicate test
+ _.findIndex = createPredicateIndexFinder(1);
+ _.findLastIndex = createPredicateIndexFinder(-1);
+
+ // Use a comparator function to figure out the smallest index at which
+ // an object should be inserted so as to maintain order. Uses binary search.
+ _.sortedIndex = function(array, obj, iteratee, context) {
+ iteratee = cb(iteratee, context, 1);
+ var value = iteratee(obj);
+ var low = 0, high = getLength(array);
+ while (low < high) {
+ var mid = Math.floor((low + high) / 2);
+ if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
+ }
+ return low;
+ };
+
+ // Generator function to create the indexOf and lastIndexOf functions
+ function createIndexFinder(dir, predicateFind, sortedIndex) {
+ return function(array, item, idx) {
+ var i = 0, length = getLength(array);
+ if (typeof idx == 'number') {
+ if (dir > 0) {
+ i = idx >= 0 ? idx : Math.max(idx + length, i);
+ } else {
+ length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
+ }
+ } else if (sortedIndex && idx && length) {
+ idx = sortedIndex(array, item);
+ return array[idx] === item ? idx : -1;
+ }
+ if (item !== item) {
+ idx = predicateFind(slice.call(array, i, length), _.isNaN);
+ return idx >= 0 ? idx + i : -1;
+ }
+ for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {
+ if (array[idx] === item) return idx;
+ }
+ return -1;
+ };
+ }
+
+ // Return the position of the first occurrence of an item in an array,
+ // or -1 if the item is not included in the array.
+ // If the array is large and already in sort order, pass `true`
+ // for **isSorted** to use binary search.
+ _.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex);
+ _.lastIndexOf = createIndexFinder(-1, _.findLastIndex);
+
+ // Generate an integer Array containing an arithmetic progression. A port of
+ // the native Python `range()` function. See
+ // [the Python documentation](http://docs.python.org/library/functions.html#range).
+ _.range = function(start, stop, step) {
+ if (stop == null) {
+ stop = start || 0;
+ start = 0;
+ }
+ step = step || 1;
+
+ var length = Math.max(Math.ceil((stop - start) / step), 0);
+ var range = Array(length);
+
+ for (var idx = 0; idx < length; idx++, start += step) {
+ range[idx] = start;
+ }
+
+ return range;
+ };
+
+ // Function (ahem) Functions
+ // ------------------
+
+ // Determines whether to execute a function as a constructor
+ // or a normal function with the provided arguments
+ var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) {
+ if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
+ var self = baseCreate(sourceFunc.prototype);
+ var result = sourceFunc.apply(self, args);
+ if (_.isObject(result)) return result;
+ return self;
+ };
+
+ // Create a function bound to a given object (assigning `this`, and arguments,
+ // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
+ // available.
+ _.bind = function(func, context) {
+ if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
+ if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function');
+ var args = slice.call(arguments, 2);
+ var bound = function() {
+ return executeBound(func, bound, context, this, args.concat(slice.call(arguments)));
+ };
+ return bound;
+ };
+
+ // Partially apply a function by creating a version that has had some of its
+ // arguments pre-filled, without changing its dynamic `this` context. _ acts
+ // as a placeholder, allowing any combination of arguments to be pre-filled.
+ _.partial = function(func) {
+ var boundArgs = slice.call(arguments, 1);
+ var bound = function() {
+ var position = 0, length = boundArgs.length;
+ var args = Array(length);
+ for (var i = 0; i < length; i++) {
+ args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i];
+ }
+ while (position < arguments.length) args.push(arguments[position++]);
+ return executeBound(func, bound, this, this, args);
+ };
+ return bound;
+ };
+
+ // Bind a number of an object's methods to that object. Remaining arguments
+ // are the method names to be bound. Useful for ensuring that all callbacks
+ // defined on an object belong to it.
+ _.bindAll = function(obj) {
+ var i, length = arguments.length, key;
+ if (length <= 1) throw new Error('bindAll must be passed function names');
+ for (i = 1; i < length; i++) {
+ key = arguments[i];
+ obj[key] = _.bind(obj[key], obj);
+ }
+ return obj;
+ };
+
+ // Memoize an expensive function by storing its results.
+ _.memoize = function(func, hasher) {
+ var memoize = function(key) {
+ var cache = memoize.cache;
+ var address = '' + (hasher ? hasher.apply(this, arguments) : key);
+ if (!_.has(cache, address)) cache[address] = func.apply(this, arguments);
+ return cache[address];
+ };
+ memoize.cache = {};
+ return memoize;
+ };
+
+ // Delays a function for the given number of milliseconds, and then calls
+ // it with the arguments supplied.
+ _.delay = function(func, wait) {
+ var args = slice.call(arguments, 2);
+ return setTimeout(function(){
+ return func.apply(null, args);
+ }, wait);
+ };
+
+ // Defers a function, scheduling it to run after the current call stack has
+ // cleared.
+ _.defer = _.partial(_.delay, _, 1);
+
+ // Returns a function, that, when invoked, will only be triggered at most once
+ // during a given window of time. Normally, the throttled function will run
+ // as much as it can, without ever going more than once per `wait` duration;
+ // but if you'd like to disable the execution on the leading edge, pass
+ // `{leading: false}`. To disable execution on the trailing edge, ditto.
+ _.throttle = function(func, wait, options) {
+ var context, args, result;
+ var timeout = null;
+ var previous = 0;
+ if (!options) options = {};
+ var later = function() {
+ previous = options.leading === false ? 0 : _.now();
+ timeout = null;
+ result = func.apply(context, args);
+ if (!timeout) context = args = null;
+ };
+ return function() {
+ var now = _.now();
+ if (!previous && options.leading === false) previous = now;
+ var remaining = wait - (now - previous);
+ context = this;
+ args = arguments;
+ if (remaining <= 0 || remaining > wait) {
+ if (timeout) {
+ clearTimeout(timeout);
+ timeout = null;
+ }
+ previous = now;
+ result = func.apply(context, args);
+ if (!timeout) context = args = null;
+ } else if (!timeout && options.trailing !== false) {
+ timeout = setTimeout(later, remaining);
+ }
+ return result;
+ };
+ };
+
+ // Returns a function, that, as long as it continues to be invoked, will not
+ // be triggered. The function will be called after it stops being called for
+ // N milliseconds. If `immediate` is passed, trigger the function on the
+ // leading edge, instead of the trailing.
+ _.debounce = function(func, wait, immediate) {
+ var timeout, args, context, timestamp, result;
+
+ var later = function() {
+ var last = _.now() - timestamp;
+
+ if (last < wait && last >= 0) {
+ timeout = setTimeout(later, wait - last);
+ } else {
+ timeout = null;
+ if (!immediate) {
+ result = func.apply(context, args);
+ if (!timeout) context = args = null;
+ }
+ }
+ };
+
+ return function() {
+ context = this;
+ args = arguments;
+ timestamp = _.now();
+ var callNow = immediate && !timeout;
+ if (!timeout) timeout = setTimeout(later, wait);
+ if (callNow) {
+ result = func.apply(context, args);
+ context = args = null;
+ }
+
+ return result;
+ };
+ };
+
+ // Returns the first function passed as an argument to the second,
+ // allowing you to adjust arguments, run code before and after, and
+ // conditionally execute the original function.
+ _.wrap = function(func, wrapper) {
+ return _.partial(wrapper, func);
+ };
+
+ // Returns a negated version of the passed-in predicate.
+ _.negate = function(predicate) {
+ return function() {
+ return !predicate.apply(this, arguments);
+ };
+ };
+
+ // Returns a function that is the composition of a list of functions, each
+ // consuming the return value of the function that follows.
+ _.compose = function() {
+ var args = arguments;
+ var start = args.length - 1;
+ return function() {
+ var i = start;
+ var result = args[start].apply(this, arguments);
+ while (i--) result = args[i].call(this, result);
+ return result;
+ };
+ };
+
+ // Returns a function that will only be executed on and after the Nth call.
+ _.after = function(times, func) {
+ return function() {
+ if (--times < 1) {
+ return func.apply(this, arguments);
+ }
+ };
+ };
+
+ // Returns a function that will only be executed up to (but not including) the Nth call.
+ _.before = function(times, func) {
+ var memo;
+ return function() {
+ if (--times > 0) {
+ memo = func.apply(this, arguments);
+ }
+ if (times <= 1) func = null;
+ return memo;
+ };
+ };
+
+ // Returns a function that will be executed at most one time, no matter how
+ // often you call it. Useful for lazy initialization.
+ _.once = _.partial(_.before, 2);
+
+ // Object Functions
+ // ----------------
+
+ // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
+ var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
+ var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
+ 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
+
+ function collectNonEnumProps(obj, keys) {
+ var nonEnumIdx = nonEnumerableProps.length;
+ var constructor = obj.constructor;
+ var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto;
+
+ // Constructor is a special case.
+ var prop = 'constructor';
+ if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop);
+
+ while (nonEnumIdx--) {
+ prop = nonEnumerableProps[nonEnumIdx];
+ if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) {
+ keys.push(prop);
+ }
+ }
+ }
+
+ // Retrieve the names of an object's own properties.
+ // Delegates to **ECMAScript 5**'s native `Object.keys`
+ _.keys = function(obj) {
+ if (!_.isObject(obj)) return [];
+ if (nativeKeys) return nativeKeys(obj);
+ var keys = [];
+ for (var key in obj) if (_.has(obj, key)) keys.push(key);
+ // Ahem, IE < 9.
+ if (hasEnumBug) collectNonEnumProps(obj, keys);
+ return keys;
+ };
+
+ // Retrieve all the property names of an object.
+ _.allKeys = function(obj) {
+ if (!_.isObject(obj)) return [];
+ var keys = [];
+ for (var key in obj) keys.push(key);
+ // Ahem, IE < 9.
+ if (hasEnumBug) collectNonEnumProps(obj, keys);
+ return keys;
+ };
+
+ // Retrieve the values of an object's properties.
+ _.values = function(obj) {
+ var keys = _.keys(obj);
+ var length = keys.length;
+ var values = Array(length);
+ for (var i = 0; i < length; i++) {
+ values[i] = obj[keys[i]];
+ }
+ return values;
+ };
+
+ // Returns the results of applying the iteratee to each element of the object
+ // In contrast to _.map it returns an object
+ _.mapObject = function(obj, iteratee, context) {
+ iteratee = cb(iteratee, context);
+ var keys = _.keys(obj),
+ length = keys.length,
+ results = {},
+ currentKey;
+ for (var index = 0; index < length; index++) {
+ currentKey = keys[index];
+ results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
+ }
+ return results;
+ };
+
+ // Convert an object into a list of `[key, value]` pairs.
+ _.pairs = function(obj) {
+ var keys = _.keys(obj);
+ var length = keys.length;
+ var pairs = Array(length);
+ for (var i = 0; i < length; i++) {
+ pairs[i] = [keys[i], obj[keys[i]]];
+ }
+ return pairs;
+ };
+
+ // Invert the keys and values of an object. The values must be serializable.
+ _.invert = function(obj) {
+ var result = {};
+ var keys = _.keys(obj);
+ for (var i = 0, length = keys.length; i < length; i++) {
+ result[obj[keys[i]]] = keys[i];
+ }
+ return result;
+ };
+
+ // Return a sorted list of the function names available on the object.
+ // Aliased as `methods`
+ _.functions = _.methods = function(obj) {
+ var names = [];
+ for (var key in obj) {
+ if (_.isFunction(obj[key])) names.push(key);
+ }
+ return names.sort();
+ };
+
+ // Extend a given object with all the properties in passed-in object(s).
+ _.extend = createAssigner(_.allKeys);
+
+ // Assigns a given object with all the own properties in the passed-in object(s)
+ // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
+ _.extendOwn = _.assign = createAssigner(_.keys);
+
+ // Returns the first key on an object that passes a predicate test
+ _.findKey = function(obj, predicate, context) {
+ predicate = cb(predicate, context);
+ var keys = _.keys(obj), key;
+ for (var i = 0, length = keys.length; i < length; i++) {
+ key = keys[i];
+ if (predicate(obj[key], key, obj)) return key;
+ }
+ };
+
+ // Return a copy of the object only containing the whitelisted properties.
+ _.pick = function(object, oiteratee, context) {
+ var result = {}, obj = object, iteratee, keys;
+ if (obj == null) return result;
+ if (_.isFunction(oiteratee)) {
+ keys = _.allKeys(obj);
+ iteratee = optimizeCb(oiteratee, context);
+ } else {
+ keys = flatten(arguments, false, false, 1);
+ iteratee = function(value, key, obj) { return key in obj; };
+ obj = Object(obj);
+ }
+ for (var i = 0, length = keys.length; i < length; i++) {
+ var key = keys[i];
+ var value = obj[key];
+ if (iteratee(value, key, obj)) result[key] = value;
+ }
+ return result;
+ };
+
+ // Return a copy of the object without the blacklisted properties.
+ _.omit = function(obj, iteratee, context) {
+ if (_.isFunction(iteratee)) {
+ iteratee = _.negate(iteratee);
+ } else {
+ var keys = _.map(flatten(arguments, false, false, 1), String);
+ iteratee = function(value, key) {
+ return !_.contains(keys, key);
+ };
+ }
+ return _.pick(obj, iteratee, context);
+ };
+
+ // Fill in a given object with default properties.
+ _.defaults = createAssigner(_.allKeys, true);
+
+ // Creates an object that inherits from the given prototype object.
+ // If additional properties are provided then they will be added to the
+ // created object.
+ _.create = function(prototype, props) {
+ var result = baseCreate(prototype);
+ if (props) _.extendOwn(result, props);
+ return result;
+ };
+
+ // Create a (shallow-cloned) duplicate of an object.
+ _.clone = function(obj) {
+ if (!_.isObject(obj)) return obj;
+ return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
+ };
+
+ // Invokes interceptor with the obj, and then returns obj.
+ // The primary purpose of this method is to "tap into" a method chain, in
+ // order to perform operations on intermediate results within the chain.
+ _.tap = function(obj, interceptor) {
+ interceptor(obj);
+ return obj;
+ };
+
+ // Returns whether an object has a given set of `key:value` pairs.
+ _.isMatch = function(object, attrs) {
+ var keys = _.keys(attrs), length = keys.length;
+ if (object == null) return !length;
+ var obj = Object(object);
+ for (var i = 0; i < length; i++) {
+ var key = keys[i];
+ if (attrs[key] !== obj[key] || !(key in obj)) return false;
+ }
+ return true;
+ };
+
+
+ // Internal recursive comparison function for `isEqual`.
+ var eq = function(a, b, aStack, bStack) {
+ // Identical objects are equal. `0 === -0`, but they aren't identical.
+ // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
+ if (a === b) return a !== 0 || 1 / a === 1 / b;
+ // A strict comparison is necessary because `null == undefined`.
+ if (a == null || b == null) return a === b;
+ // Unwrap any wrapped objects.
+ if (a instanceof _) a = a._wrapped;
+ if (b instanceof _) b = b._wrapped;
+ // Compare `[[Class]]` names.
+ var className = toString.call(a);
+ if (className !== toString.call(b)) return false;
+ switch (className) {
+ // Strings, numbers, regular expressions, dates, and booleans are compared by value.
+ case '[object RegExp]':
+ // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
+ case '[object String]':
+ // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
+ // equivalent to `new String("5")`.
+ return '' + a === '' + b;
+ case '[object Number]':
+ // `NaN`s are equivalent, but non-reflexive.
+ // Object(NaN) is equivalent to NaN
+ if (+a !== +a) return +b !== +b;
+ // An `egal` comparison is performed for other numeric values.
+ return +a === 0 ? 1 / +a === 1 / b : +a === +b;
+ case '[object Date]':
+ case '[object Boolean]':
+ // Coerce dates and booleans to numeric primitive values. Dates are compared by their
+ // millisecond representations. Note that invalid dates with millisecond representations
+ // of `NaN` are not equivalent.
+ return +a === +b;
+ }
+
+ var areArrays = className === '[object Array]';
+ if (!areArrays) {
+ if (typeof a != 'object' || typeof b != 'object') return false;
+
+ // Objects with different constructors are not equivalent, but `Object`s or `Array`s
+ // from different frames are.
+ var aCtor = a.constructor, bCtor = b.constructor;
+ if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor &&
+ _.isFunction(bCtor) && bCtor instanceof bCtor)
+ && ('constructor' in a && 'constructor' in b)) {
+ return false;
+ }
+ }
+ // Assume equality for cyclic structures. The algorithm for detecting cyclic
+ // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
+
+ // Initializing stack of traversed objects.
+ // It's done here since we only need them for objects and arrays comparison.
+ aStack = aStack || [];
+ bStack = bStack || [];
+ var length = aStack.length;
+ while (length--) {
+ // Linear search. Performance is inversely proportional to the number of
+ // unique nested structures.
+ if (aStack[length] === a) return bStack[length] === b;
+ }
+
+ // Add the first object to the stack of traversed objects.
+ aStack.push(a);
+ bStack.push(b);
+
+ // Recursively compare objects and arrays.
+ if (areArrays) {
+ // Compare array lengths to determine if a deep comparison is necessary.
+ length = a.length;
+ if (length !== b.length) return false;
+ // Deep compare the contents, ignoring non-numeric properties.
+ while (length--) {
+ if (!eq(a[length], b[length], aStack, bStack)) return false;
+ }
+ } else {
+ // Deep compare objects.
+ var keys = _.keys(a), key;
+ length = keys.length;
+ // Ensure that both objects contain the same number of properties before comparing deep equality.
+ if (_.keys(b).length !== length) return false;
+ while (length--) {
+ // Deep compare each member
+ key = keys[length];
+ if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
+ }
+ }
+ // Remove the first object from the stack of traversed objects.
+ aStack.pop();
+ bStack.pop();
+ return true;
+ };
+
+ // Perform a deep comparison to check if two objects are equal.
+ _.isEqual = function(a, b) {
+ return eq(a, b);
+ };
+
+ // Is a given array, string, or object empty?
+ // An "empty" object has no enumerable own-properties.
+ _.isEmpty = function(obj) {
+ if (obj == null) return true;
+ if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0;
+ return _.keys(obj).length === 0;
+ };
+
+ // Is a given value a DOM element?
+ _.isElement = function(obj) {
+ return !!(obj && obj.nodeType === 1);
+ };
+
+ // Is a given value an array?
+ // Delegates to ECMA5's native Array.isArray
+ _.isArray = nativeIsArray || function(obj) {
+ return toString.call(obj) === '[object Array]';
+ };
+
+ // Is a given variable an object?
+ _.isObject = function(obj) {
+ var type = typeof obj;
+ return type === 'function' || type === 'object' && !!obj;
+ };
+
+ // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError.
+ _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) {
+ _['is' + name] = function(obj) {
+ return toString.call(obj) === '[object ' + name + ']';
+ };
+ });
+
+ // Define a fallback version of the method in browsers (ahem, IE < 9), where
+ // there isn't any inspectable "Arguments" type.
+ if (!_.isArguments(arguments)) {
+ _.isArguments = function(obj) {
+ return _.has(obj, 'callee');
+ };
+ }
+
+ // Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8,
+ // IE 11 (#1621), and in Safari 8 (#1929).
+ if (typeof /./ != 'function' && typeof Int8Array != 'object') {
+ _.isFunction = function(obj) {
+ return typeof obj == 'function' || false;
+ };
+ }
+
+ // Is a given object a finite number?
+ _.isFinite = function(obj) {
+ return isFinite(obj) && !isNaN(parseFloat(obj));
+ };
+
+ // Is the given value `NaN`? (NaN is the only number which does not equal itself).
+ _.isNaN = function(obj) {
+ return _.isNumber(obj) && obj !== +obj;
+ };
+
+ // Is a given value a boolean?
+ _.isBoolean = function(obj) {
+ return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
+ };
+
+ // Is a given value equal to null?
+ _.isNull = function(obj) {
+ return obj === null;
+ };
+
+ // Is a given variable undefined?
+ _.isUndefined = function(obj) {
+ return obj === void 0;
+ };
+
+ // Shortcut function for checking if an object has a given property directly
+ // on itself (in other words, not on a prototype).
+ _.has = function(obj, key) {
+ return obj != null && hasOwnProperty.call(obj, key);
+ };
+
+ // Utility Functions
+ // -----------------
+
+ // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
+ // previous owner. Returns a reference to the Underscore object.
+ _.noConflict = function() {
+ root._ = previousUnderscore;
+ return this;
+ };
+
+ // Keep the identity function around for default iteratees.
+ _.identity = function(value) {
+ return value;
+ };
+
+ // Predicate-generating functions. Often useful outside of Underscore.
+ _.constant = function(value) {
+ return function() {
+ return value;
+ };
+ };
+
+ _.noop = function(){};
+
+ _.property = property;
+
+ // Generates a function for a given object that returns a given property.
+ _.propertyOf = function(obj) {
+ return obj == null ? function(){} : function(key) {
+ return obj[key];
+ };
+ };
+
+ // Returns a predicate for checking whether an object has a given set of
+ // `key:value` pairs.
+ _.matcher = _.matches = function(attrs) {
+ attrs = _.extendOwn({}, attrs);
+ return function(obj) {
+ return _.isMatch(obj, attrs);
+ };
+ };
+
+ // Run a function **n** times.
+ _.times = function(n, iteratee, context) {
+ var accum = Array(Math.max(0, n));
+ iteratee = optimizeCb(iteratee, context, 1);
+ for (var i = 0; i < n; i++) accum[i] = iteratee(i);
+ return accum;
+ };
+
+ // Return a random integer between min and max (inclusive).
+ _.random = function(min, max) {
+ if (max == null) {
+ max = min;
+ min = 0;
+ }
+ return min + Math.floor(Math.random() * (max - min + 1));
+ };
+
+ // A (possibly faster) way to get the current timestamp as an integer.
+ _.now = Date.now || function() {
+ return new Date().getTime();
+ };
+
+ // List of HTML entities for escaping.
+ var escapeMap = {
+ '&': '&amp;',
+ '<': '&lt;',
+ '>': '&gt;',
+ '"': '&quot;',
+ "'": '&#x27;',
+ '`': '&#x60;'
+ };
+ var unescapeMap = _.invert(escapeMap);
+
+ // Functions for escaping and unescaping strings to/from HTML interpolation.
+ var createEscaper = function(map) {
+ var escaper = function(match) {
+ return map[match];
+ };
+ // Regexes for identifying a key that needs to be escaped
+ var source = '(?:' + _.keys(map).join('|') + ')';
+ var testRegexp = RegExp(source);
+ var replaceRegexp = RegExp(source, 'g');
+ return function(string) {
+ string = string == null ? '' : '' + string;
+ return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
+ };
+ };
+ _.escape = createEscaper(escapeMap);
+ _.unescape = createEscaper(unescapeMap);
+
+ // If the value of the named `property` is a function then invoke it with the
+ // `object` as context; otherwise, return it.
+ _.result = function(object, property, fallback) {
+ var value = object == null ? void 0 : object[property];
+ if (value === void 0) {
+ value = fallback;
+ }
+ return _.isFunction(value) ? value.call(object) : value;
+ };
+
+ // Generate a unique integer id (unique within the entire client session).
+ // Useful for temporary DOM ids.
+ var idCounter = 0;
+ _.uniqueId = function(prefix) {
+ var id = ++idCounter + '';
+ return prefix ? prefix + id : id;
+ };
+
+ // By default, Underscore uses ERB-style template delimiters, change the
+ // following template settings to use alternative delimiters.
+ _.templateSettings = {
+ evaluate : /<%([\s\S]+?)%>/g,
+ interpolate : /<%=([\s\S]+?)%>/g,
+ escape : /<%-([\s\S]+?)%>/g
+ };
+
+ // When customizing `templateSettings`, if you don't want to define an
+ // interpolation, evaluation or escaping regex, we need one that is
+ // guaranteed not to match.
+ var noMatch = /(.)^/;
+
+ // Certain characters need to be escaped so that they can be put into a
+ // string literal.
+ var escapes = {
+ "'": "'",
+ '\\': '\\',
+ '\r': 'r',
+ '\n': 'n',
+ '\u2028': 'u2028',
+ '\u2029': 'u2029'
+ };
+
+ var escaper = /\\|'|\r|\n|\u2028|\u2029/g;
+
+ var escapeChar = function(match) {
+ return '\\' + escapes[match];
+ };
+
+ // JavaScript micro-templating, similar to John Resig's implementation.
+ // Underscore templating handles arbitrary delimiters, preserves whitespace,
+ // and correctly escapes quotes within interpolated code.
+ // NB: `oldSettings` only exists for backwards compatibility.
+ _.template = function(text, settings, oldSettings) {
+ if (!settings && oldSettings) settings = oldSettings;
+ settings = _.defaults({}, settings, _.templateSettings);
+
+ // Combine delimiters into one regular expression via alternation.
+ var matcher = RegExp([
+ (settings.escape || noMatch).source,
+ (settings.interpolate || noMatch).source,
+ (settings.evaluate || noMatch).source
+ ].join('|') + '|$', 'g');
+
+ // Compile the template source, escaping string literals appropriately.
+ var index = 0;
+ var source = "__p+='";
+ text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
+ source += text.slice(index, offset).replace(escaper, escapeChar);
+ index = offset + match.length;
+
+ if (escape) {
+ source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
+ } else if (interpolate) {
+ source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
+ } else if (evaluate) {
+ source += "';\n" + evaluate + "\n__p+='";
+ }
+
+ // Adobe VMs need the match returned to produce the correct offest.
+ return match;
+ });
+ source += "';\n";
+
+ // If a variable is not specified, place data values in local scope.
+ if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
+
+ source = "var __t,__p='',__j=Array.prototype.join," +
+ "print=function(){__p+=__j.call(arguments,'');};\n" +
+ source + 'return __p;\n';
+
+ try {
+ var render = new Function(settings.variable || 'obj', '_', source);
+ } catch (e) {
+ e.source = source;
+ throw e;
+ }
+
+ var template = function(data) {
+ return render.call(this, data, _);
+ };
+
+ // Provide the compiled source as a convenience for precompilation.
+ var argument = settings.variable || 'obj';
+ template.source = 'function(' + argument + '){\n' + source + '}';
+
+ return template;
+ };
+
+ // Add a "chain" function. Start chaining a wrapped Underscore object.
+ _.chain = function(obj) {
+ var instance = _(obj);
+ instance._chain = true;
+ return instance;
+ };
+
+ // OOP
+ // ---------------
+ // If Underscore is called as a function, it returns a wrapped object that
+ // can be used OO-style. This wrapper holds altered versions of all the
+ // underscore functions. Wrapped objects may be chained.
+
+ // Helper function to continue chaining intermediate results.
+ var result = function(instance, obj) {
+ return instance._chain ? _(obj).chain() : obj;
+ };
+
+ // Add your own custom functions to the Underscore object.
+ _.mixin = function(obj) {
+ _.each(_.functions(obj), function(name) {
+ var func = _[name] = obj[name];
+ _.prototype[name] = function() {
+ var args = [this._wrapped];
+ push.apply(args, arguments);
+ return result(this, func.apply(_, args));
+ };
+ });
+ };
+
+ // Add all of the Underscore functions to the wrapper object.
+ _.mixin(_);
+
+ // Add all mutator Array functions to the wrapper.
+ _.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
+ var method = ArrayProto[name];
+ _.prototype[name] = function() {
+ var obj = this._wrapped;
+ method.apply(obj, arguments);
+ if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0];
+ return result(this, obj);
+ };
+ });
+
+ // Add all accessor Array functions to the wrapper.
+ _.each(['concat', 'join', 'slice'], function(name) {
+ var method = ArrayProto[name];
+ _.prototype[name] = function() {
+ return result(this, method.apply(this._wrapped, arguments));
+ };
+ });
+
+ // Extracts the result from a wrapped and chained object.
+ _.prototype.value = function() {
+ return this._wrapped;
+ };
+
+ // Provide unwrapping proxy for some methods used in engine operations
+ // such as arithmetic and JSON stringification.
+ _.prototype.valueOf = _.prototype.toJSON = _.prototype.value;
+
+ _.prototype.toString = function() {
+ return '' + this._wrapped;
+ };
+
+ // AMD registration happens at the end for compatibility with AMD loaders
+ // that may not enforce next-turn semantics on modules. Even though general
+ // practice for AMD registration is to be anonymous, underscore registers
+ // as a named module because, like jQuery, it is a base library that is
+ // popular enough to be bundled in a third party lib, but not be part of
+ // an AMD load request. Those cases could generate an error when an
+ // anonymous define() is called outside of a loader request.
+ if (typeof define === 'function' && define.amd) {
+ define('underscore', [], function() {
+ return _;
+ });
+ }
+}.call(this));
+
+},{}],3:[function(require,module,exports){
+'use strict';
+
+var _ = require('underscore'),
+ events = require('../events');
+
+module.exports = function(videojs) {
+ var MenuItem = videojs.getComponent('MenuItem');
+
+ /**
+ * A MenuItem to represent a video resolution
+ *
+ * @class QualityOption
+ * @extends videojs.MenuItem
+ */
+ return videojs.extend(MenuItem, {
+
+ /**
+ * @inheritdoc
+ */
+ constructor: function(player, options) {
+ var source = options.source;
+
+ if (!_.isObject(source)) {
+ throw new Error('was not provided a "source" object, but rather: ' + (typeof source));
+ }
+
+ options = _.extend({
+ selectable: true,
+ label: source.label,
+ }, options);
+
+ MenuItem.call(this, player, options);
+
+ this.source = source;
+ },
+
+ /**
+ * @inheritdoc
+ */
+ handleClick: function(event) {
+ MenuItem.prototype.handleClick.call(this, event);
+ this.player().trigger(events.QUALITY_REQUESTED, this.source);
+ },
+
+ });
+};
+
+},{"../events":5,"underscore":2}],4:[function(require,module,exports){
+'use strict';
+
+var _ = require('underscore'),
+ events = require('../events'),
+ qualityOptionFactory = require('./QualityOption'),
+ QUALITY_CHANGE_CLASS = 'vjs-quality-changing';
+
+module.exports = function(videojs) {
+ var MenuButton = videojs.getComponent('MenuButton'),
+ QualityOption = qualityOptionFactory(videojs),
+ QualitySelector;
+
+ /**
+ * A component for changing video resolutions
+ *
+ * @class QualitySelector
+ * @extends videojs.Button
+ */
+ QualitySelector = videojs.extend(MenuButton, {
+
+ /**
+ * @inheritdoc
+ */
+ constructor: function(player, options) {
+ MenuButton.call(this, player, options);
+
+ // Update interface instantly so the user's change is acknowledged
+ player.on(events.QUALITY_REQUESTED, function(event, newSource) {
+ this.setSelectedSource(newSource);
+ player.addClass(QUALITY_CHANGE_CLASS);
+
+ player.one('loadeddata', function() {
+ player.removeClass(QUALITY_CHANGE_CLASS);
+ });
+ }.bind(this));
+
+ player.on(events.QUALITY_SELECTED, function(event, newSource) {
+ // Update the selected source with the source that was actually selected
+ this.setSelectedSource(newSource);
+ }.bind(this));
+
+ // Since it's possible for the player to get a source before the selector is
+ // created, make sure to update once we get a "ready" signal.
+ player.one('ready', function() {
+ this.selectedSrc = player.src();
+ this.update();
+ }.bind(this));
+
+ this.controlText('Open quality selector menu');
+ },
+
+ /**
+ * Updates the source that is selected in the menu
+ *
+ * @param source {object} player source to display as selected
+ */
+ setSelectedSource: function(source) {
+ var src = (source ? source.src : undefined);
+
+ if (this.selectedSrc !== src) {
+ this.selectedSrc = src;
+ this.update();
+ }
+ },
+
+ /**
+ * @inheritdoc
+ */
+ createItems: function() {
+ var player = this.player(),
+ sources = player.currentSources();
+
+ return _.map(sources, function(source) {
+ return new QualityOption(player, {
+ source: source,
+ selected: source.src === this.selectedSrc,
+ });
+ }.bind(this));
+ },
+
+ /**
+ * @inheritdoc
+ */
+ buildWrapperCSSClass: function() {
+ return 'vjs-quality-selector ' + MenuButton.prototype.buildWrapperCSSClass.call(this);
+ },
+
+ });
+
+ videojs.registerComponent('QualitySelector', QualitySelector);
+
+ return QualitySelector;
+};
+
+},{"../events":5,"./QualityOption":3,"underscore":2}],5:[function(require,module,exports){
+'use strict';
+
+module.exports = {
+
+ QUALITY_REQUESTED: 'qualityRequested',
+ QUALITY_SELECTED: 'qualitySelected',
+
+};
+
+},{}],6:[function(require,module,exports){
+'use strict';
+
+var _ = require('underscore'),
+ events = require('./events'),
+ qualitySelectorFactory = require('./components/QualitySelector'),
+ sourceInterceptorFactory = require('./middleware/SourceInterceptor'),
+ SafeSeek = require('./util/SafeSeek');
+
+module.exports = function(videojs) {
+ videojs = videojs || window.videojs;
+
+ qualitySelectorFactory(videojs);
+ sourceInterceptorFactory(videojs);
+
+ videojs.hook('setup', function(player) {
+ function changeQuality(event, newSource) {
+ var sources = player.currentSources(),
+ currentTime = player.currentTime(),
+ currentPlaybackRate = player.playbackRate(),
+ isPaused = player.paused(),
+ selectedSource;
+
+ // Clear out any previously selected sources (see: #11)
+ _.each(sources, function(source) {
+ source.selected = false;
+ });
+
+ selectedSource = _.findWhere(sources, { src: newSource.src });
+ // Note: `_.findWhere` returns a reference to an object. Thus the
+ // following updates the original object in `sources`.
+ selectedSource.selected = true;
+
+ if (player._qualitySelectorSafeSeek) {
+ player._qualitySelectorSafeSeek.onQualitySelectionChange();
+ }
+
+ player.src(sources);
+
+ player.ready(function() {
+ if (!player._qualitySelectorSafeSeek || player._qualitySelectorSafeSeek.hasFinished()) {
+ // Either we don't have a pending seek action or the one that we have is no
+ // longer applicable. This block must be within a `player.ready` callback
+ // because the call to `player.src` above is asynchronous, and so not
+ // having it within this `ready` callback would cause the SourceInterceptor
+ // to execute after this block instead of before.
+ //
+ // We save the `currentTime` within the SafeSeek instance because if
+ // multiple QUALITY_REQUESTED events are received before the SafeSeek
+ // operation finishes, the player's `currentTime` will be `0` if the
+ // player's `src` is updated but the player's `currentTime` has not yet
+ // been set by the SafeSeek operation.
+ player._qualitySelectorSafeSeek = new SafeSeek(player, currentTime);
+ player.playbackRate = playbackRate;
+ }
+
+ if (!isPaused) {
+ player.play();
+ }
+ });
+ }
+
+ // Add handler to switch sources when the user requests a change
+ player.on(events.QUALITY_REQUESTED, changeQuality);
+ });
+};
+
+module.exports.EVENTS = events;
+
+},{"./components/QualitySelector":4,"./events":5,"./middleware/SourceInterceptor":7,"./util/SafeSeek":9,"underscore":2}],7:[function(require,module,exports){
+'use strict';
+
+var _ = require('underscore'),
+ events = require('../events');
+
+module.exports = function(videojs) {
+
+ videojs.use('*', function(player) {
+
+ return {
+
+ setSource: function(playerSelectedSource, next) {
+ var sources = player.currentSources(),
+ userSelectedSource, chosenSource;
+
+ if (player._qualitySelectorSafeSeek) {
+ player._qualitySelectorSafeSeek.onPlayerSourcesChange();
+ }
+
+ // There are generally two source options, the one that videojs
+ // auto-selects and the one that a "user" of this plugin has
+ // supplied via the `selected` property. `selected` can come from
+ // either the `<source>` tag or the list of sources passed to
+ // videojs using `src()`.
+
+ userSelectedSource = _.find(sources, function(source) {
+ // Must check for both boolean and string 'true' as sources set
+ // programmatically should use a boolean, but those coming from
+ // a `<source>` tag will use a string.
+ return source.selected === true || source.selected === 'true';
+ });
+
+ chosenSource = userSelectedSource || playerSelectedSource;
+
+ player.trigger(events.QUALITY_SELECTED, chosenSource);
+
+ // Pass along the chosen source
+ next(null, chosenSource);
+ },
+
+ };
+
+ });
+
+};
+
+},{"../events":5,"underscore":2}],8:[function(require,module,exports){
+'use strict';
+
+require('./index')();
+
+},{"./index":6}],9:[function(require,module,exports){
+'use strict';
+
+var Class = require('class.extend');
+
+module.exports = Class.extend({
+ init: function(player, seekToTime) {
+ this._player = player;
+ this._seekToTime = seekToTime;
+ this._hasFinished = false;
+ this._keepThisInstanceWhenPlayerSourcesChange = false;
+ this._seekWhenSafe();
+ },
+
+ _seekWhenSafe: function() {
+ var HAVE_FUTURE_DATA = 3;
+
+ // `readyState` in Video.js is the same as the HTML5 Media element's `readyState`
+ // property.
+ //
+ // `readyState` is an enum of 5 values (0-4), each of which represent a state of
+ // readiness to play. The meaning of the values range from HAVE_NOTHING (0), meaning
+ // no data is available to HAVE_ENOUGH_DATA (4), meaning all data is loaded and the
+ // video can be played all the way through.
+ //
+ // In order to seek successfully, the `readyState` must be at least HAVE_FUTURE_DATA
+ // (3).
+ //
+ // @see http://docs.videojs.com/player#readyState
+ // @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/readyState
+ // @see https://dev.w3.org/html5/spec-preview/media-elements.html#seek-the-media-controller
+ if (this._player.readyState() < HAVE_FUTURE_DATA) {
+ this._seekFn = this._seek.bind(this);
+ // The `canplay` event means that the `readyState` is at least HAVE_FUTURE_DATA.
+ this._player.one('canplay', this._seekFn);
+ } else {
+ this._seek();
+ }
+ },
+
+ onPlayerSourcesChange: function() {
+ if (this._keepThisInstanceWhenPlayerSourcesChange) {
+ // By setting this to `false`, we know that if the player sources change again
+ // the change did not originate from a quality selection change, the new sources
+ // are likely different from the old sources, and so this pending seek no longer
+ // applies.
+ this._keepThisInstanceWhenPlayerSourcesChange = false;
+ } else {
+ this.cancel();
+ }
+ },
+
+ onQualitySelectionChange: function() {
+ // `onPlayerSourcesChange` will cancel this pending seek unless we tell it not to.
+ // We need to reuse this same pending seek instance because when the player is
+ // paused, the `preload` attribute is set to `none`, and the user selects one
+ // quality option and then another, the player cannot seek until the player has
+ // enough data to do so (and the `canplay` event is fired) and thus on the second
+ // selection the player's `currentTime()` is `0` and when the video plays we would
+ // seek to `0` instead of the correct time.
+ if (!this.hasFinished()) {
+ this._keepThisInstanceWhenPlayerSourcesChange = true;
+ }
+ },
+
+ _seek: function() {
+ this._player.currentTime(this._seekToTime);
+ this._keepThisInstanceWhenPlayerSourcesChange = false;
+ this._hasFinished = true;
+ },
+
+ hasFinished: function() {
+ return this._hasFinished;
+ },
+
+ cancel: function() {
+ this._player.off('canplay', this._seekFn);
+ this._keepThisInstanceWhenPlayerSourcesChange = false;
+ this._hasFinished = true;
+ },
+});
+
+},{"class.extend":1}]},{},[8]);
diff --git a/assets/js/silvermine-videojs-quality-selector.min.js b/assets/js/silvermine-videojs-quality-selector.min.js
index b40c51b3..0addc1fb 100644
--- a/assets/js/silvermine-videojs-quality-selector.min.js
+++ b/assets/js/silvermine-videojs-quality-selector.min.js
@@ -1,4 +1,3 @@
-/*! silvermine-videojs-quality-selector 2018-01-09 v1.1.2 */
+/*! silvermine-videojs-quality-selector 2018-11-10 v1.1.2-dirty */
-!function n(t,e,r){function i(o,c){if(!e[o]){if(!t[o]){var a="function"==typeof require&&require;if(!c&&a)return a(o,!0);if(u)return u(o,!0);var s=new Error("Cannot find module '"+o+"'");throw s.code="MODULE_NOT_FOUND",s}var l=e[o]={exports:{}};t[o][0].call(l.exports,function(n){var e=t[o][1][n];return i(e||n)},l,l.exports,n,t,e,r)}return e[o].exports}for(var u="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}({1:[function(n,t,e){!function(){var n=!1,e=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.Class=function(){},Class.extend=function(t,r){function i(){!n&&this.init&&this.init.apply(this,arguments)}void 0==r&&(r=t,t="Class");var u=this.prototype;n=!0;var o=new this;n=!1;for(var c in r)o[c]="function"==typeof r[c]&&"function"==typeof u[c]&&e.test(r[c])?function(n,t){return function(){var e=this._super;this._super=u[n];var r=t.apply(this,arguments);return this._super=e,r}}(c,r[c]):r[c];i.prototype=o;var a=new Function("return function "+t+"(){ }")();return i.prototype.constructor=a,i.extend=arguments.callee,i},t.exports=Class}()},{}],2:[function(n,t,e){(function(){function n(n){function t(t,e,r,i,u,o){for(;u>=0&&u<o;u+=n){var c=i?i[u]:u;r=e(r,t[c],c,t)}return r}return function(e,r,i,u){r=b(r,u,4);var o=!A(e)&&m.keys(e),c=(o||e).length,a=n>0?0:c-1;return arguments.length<3&&(i=e[o?o[a]:a],a+=n),t(e,r,i,o,a,c)}}function r(n){return function(t,e,r){e=x(e,r);for(var i=T(t),u=n>0?0:i-1;u>=0&&u<i;u+=n)if(e(t[u],u,t))return u;return-1}}function i(n,t,e){return function(r,i,u){var o=0,c=T(r);if("number"==typeof u)n>0?o=u>=0?u:Math.max(u+c,o):c=u>=0?Math.min(u+1,c):u+c+1;else if(e&&u&&c)return u=e(r,i),r[u]===i?u:-1;if(i!==i)return(u=t(p.call(r,o,c),m.isNaN))>=0?u+o:-1;for(u=n>0?o:c-1;u>=0&&u<c;u+=n)if(r[u]===i)return u;return-1}}function u(n,t){var e=q.length,r=n.constructor,i=m.isFunction(r)&&r.prototype||s,u="constructor";for(m.has(n,u)&&!m.contains(t,u)&&t.push(u);e--;)(u=q[e])in n&&n[u]!==i[u]&&!m.contains(t,u)&&t.push(u)}var o=this,c=o._,a=Array.prototype,s=Object.prototype,l=Function.prototype,f=a.push,p=a.slice,h=s.toString,v=s.hasOwnProperty,d=Array.isArray,y=Object.keys,g=l.bind,S=Object.create,_=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};void 0!==e?(void 0!==t&&t.exports&&(e=t.exports=m),e._=m):o._=m,m.VERSION="1.8.3";var b=function(n,t,e){if(void 0===t)return n;switch(null==e?3:e){case 1:return function(e){return n.call(t,e)};case 2:return function(e,r){return n.call(t,e,r)};case 3:return function(e,r,i){return n.call(t,e,r,i)};case 4:return function(e,r,i,u){return n.call(t,e,r,i,u)}}return function(){return n.apply(t,arguments)}},x=function(n,t,e){return null==n?m.identity:m.isFunction(n)?b(n,t,e):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return x(n,t,1/0)};var k=function(n,t){return function(e){var r=arguments.length;if(r<2||null==e)return e;for(var i=1;i<r;i++)for(var u=arguments[i],o=n(u),c=o.length,a=0;a<c;a++){var s=o[a];t&&void 0!==e[s]||(e[s]=u[s])}return e}},w=function(n){if(!m.isObject(n))return{};if(S)return S(n);_.prototype=n;var t=new _;return _.prototype=null,t},j=function(n){return function(t){return null==t?void 0:t[n]}},E=Math.pow(2,53)-1,T=j("length"),A=function(n){var t=T(n);return"number"==typeof t&&t>=0&&t<=E};m.each=m.forEach=function(n,t,e){t=b(t,e);var r,i;if(A(n))for(r=0,i=n.length;r<i;r++)t(n[r],r,n);else{var u=m.keys(n);for(r=0,i=u.length;r<i;r++)t(n[u[r]],u[r],n)}return n},m.map=m.collect=function(n,t,e){t=x(t,e);for(var r=!A(n)&&m.keys(n),i=(r||n).length,u=Array(i),o=0;o<i;o++){var c=r?r[o]:o;u[o]=t(n[c],c,n)}return u},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,e){var r;if(void 0!==(r=A(n)?m.findIndex(n,t,e):m.findKey(n,t,e))&&-1!==r)return n[r]},m.filter=m.select=function(n,t,e){var r=[];return t=x(t,e),m.each(n,function(n,e,i){t(n,e,i)&&r.push(n)}),r},m.reject=function(n,t,e){return m.filter(n,m.negate(x(t)),e)},m.every=m.all=function(n,t,e){t=x(t,e);for(var r=!A(n)&&m.keys(n),i=(r||n).length,u=0;u<i;u++){var o=r?r[u]:u;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,e){t=x(t,e);for(var r=!A(n)&&m.keys(n),i=(r||n).length,u=0;u<i;u++){var o=r?r[u]:u;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,e,r){return A(n)||(n=m.values(n)),("number"!=typeof e||r)&&(e=0),m.indexOf(n,t,e)>=0},m.invoke=function(n,t){var e=p.call(arguments,2),r=m.isFunction(t);return m.map(n,function(n){var i=r?t:n[t];return null==i?i:i.apply(n,e)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,e){var r,i,u=-1/0,o=-1/0;if(null==t&&null!=n)for(var c=0,a=(n=A(n)?n:m.values(n)).length;c<a;c++)(r=n[c])>u&&(u=r);else t=x(t,e),m.each(n,function(n,e,r){((i=t(n,e,r))>o||i===-1/0&&u===-1/0)&&(u=n,o=i)});return u},m.min=function(n,t,e){var r,i,u=1/0,o=1/0;if(null==t&&null!=n)for(var c=0,a=(n=A(n)?n:m.values(n)).length;c<a;c++)(r=n[c])<u&&(u=r);else t=x(t,e),m.each(n,function(n,e,r){((i=t(n,e,r))<o||i===1/0&&u===1/0)&&(u=n,o=i)});return u},m.shuffle=function(n){for(var t,e=A(n)?n:m.values(n),r=e.length,i=Array(r),u=0;u<r;u++)(t=m.random(0,u))!==u&&(i[u]=i[t]),i[t]=e[u];return i},m.sample=function(n,t,e){return null==t||e?(A(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,e){return t=x(t,e),m.pluck(m.map(n,function(n,e,r){return{value:n,index:e,criteria:t(n,e,r)}}).sort(function(n,t){var e=n.criteria,r=t.criteria;if(e!==r){if(e>r||void 0===e)return 1;if(e<r||void 0===r)return-1}return n.index-t.index}),"value")};var O=function(n){return function(t,e,r){var i={};return e=x(e,r),m.each(t,function(r,u){var o=e(r,u,t);n(i,r,o)}),i}};m.groupBy=O(function(n,t,e){m.has(n,e)?n[e].push(t):n[e]=[t]}),m.indexBy=O(function(n,t,e){n[e]=t}),m.countBy=O(function(n,t,e){m.has(n,e)?n[e]++:n[e]=1}),m.toArray=function(n){return n?m.isArray(n)?p.call(n):A(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:A(n)?n.length:m.keys(n).length},m.partition=function(n,t,e){t=x(t,e);var r=[],i=[];return m.each(n,function(n,e,u){(t(n,e,u)?r:i).push(n)}),[r,i]},m.first=m.head=m.take=function(n,t,e){if(null!=n)return null==t||e?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,e){return p.call(n,0,Math.max(0,n.length-(null==t||e?1:t)))},m.last=function(n,t,e){if(null!=n)return null==t||e?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,e){return p.call(n,null==t||e?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var C=function(n,t,e,r){for(var i=[],u=0,o=r||0,c=T(n);o<c;o++){var a=n[o];if(A(a)&&(m.isArray(a)||m.isArguments(a))){t||(a=C(a,t,e));var s=0,l=a.length;for(i.length+=l;s<l;)i[u++]=a[s++]}else e||(i[u++]=a)}return i};m.flatten=function(n,t){return C(n,t,!1)},m.without=function(n){return m.difference(n,p.call(arguments,1))},m.uniq=m.unique=function(n,t,e,r){m.isBoolean(t)||(r=e,e=t,t=!1),null!=e&&(e=x(e,r));for(var i=[],u=[],o=0,c=T(n);o<c;o++){var a=n[o],s=e?e(a,o,n):a;t?(o&&u===s||i.push(a),u=s):e?m.contains(u,s)||(u.push(s),i.push(a)):m.contains(i,a)||i.push(a)}return i},m.union=function(){return m.uniq(C(arguments,!0,!0))},m.intersection=function(n){for(var t=[],e=arguments.length,r=0,i=T(n);r<i;r++){var u=n[r];if(!m.contains(t,u)){for(var o=1;o<e&&m.contains(arguments[o],u);o++);o===e&&t.push(u)}}return t},m.difference=function(n){var t=C(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,T).length||0,e=Array(t),r=0;r<t;r++)e[r]=m.pluck(n,r);return e},m.object=function(n,t){for(var e={},r=0,i=T(n);r<i;r++)t?e[n[r]]=t[r]:e[n[r][0]]=n[r][1];return e},m.findIndex=r(1),m.findLastIndex=r(-1),m.sortedIndex=function(n,t,e,r){for(var i=(e=x(e,r,1))(t),u=0,o=T(n);u<o;){var c=Math.floor((u+o)/2);e(n[c])<i?u=c+1:o=c}return u},m.indexOf=i(1,m.findIndex,m.sortedIndex),m.lastIndexOf=i(-1,m.findLastIndex),m.range=function(n,t,e){null==t&&(t=n||0,n=0),e=e||1;for(var r=Math.max(Math.ceil((t-n)/e),0),i=Array(r),u=0;u<r;u++,n+=e)i[u]=n;return i};var I=function(n,t,e,r,i){if(!(r instanceof t))return n.apply(e,i);var u=w(n.prototype),o=n.apply(u,i);return m.isObject(o)?o:u};m.bind=function(n,t){if(g&&n.bind===g)return g.apply(n,p.call(arguments,1));if(!m.isFunction(n))throw new TypeError("Bind must be called on a function");var e=p.call(arguments,2),r=function(){return I(n,r,t,this,e.concat(p.call(arguments)))};return r},m.partial=function(n){var t=p.call(arguments,1),e=function(){for(var r=0,i=t.length,u=Array(i),o=0;o<i;o++)u[o]=t[o]===m?arguments[r++]:t[o];for(;r<arguments.length;)u.push(arguments[r++]);return I(n,e,this,this,u)};return e},m.bindAll=function(n){var t,e,r=arguments.length;if(r<=1)throw new Error("bindAll must be passed function names");for(t=1;t<r;t++)n[e=arguments[t]]=m.bind(n[e],n);return n},m.memoize=function(n,t){var e=function(r){var i=e.cache,u=""+(t?t.apply(this,arguments):r);return m.has(i,u)||(i[u]=n.apply(this,arguments)),i[u]};return e.cache={},e},m.delay=function(n,t){var e=p.call(arguments,2);return setTimeout(function(){return n.apply(null,e)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,e){var r,i,u,o=null,c=0;e||(e={});var a=function(){c=!1===e.leading?0:m.now(),o=null,u=n.apply(r,i),o||(r=i=null)};return function(){var s=m.now();c||!1!==e.leading||(c=s);var l=t-(s-c);return r=this,i=arguments,l<=0||l>t?(o&&(clearTimeout(o),o=null),c=s,u=n.apply(r,i),o||(r=i=null)):o||!1===e.trailing||(o=setTimeout(a,l)),u}},m.debounce=function(n,t,e){var r,i,u,o,c,a=function(){var s=m.now()-o;s<t&&s>=0?r=setTimeout(a,t-s):(r=null,e||(c=n.apply(u,i),r||(u=i=null)))};return function(){u=this,i=arguments,o=m.now();var s=e&&!r;return r||(r=setTimeout(a,t)),s&&(c=n.apply(u,i),u=i=null),c}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var e=t,r=n[t].apply(this,arguments);e--;)r=n[e].call(this,r);return r}},m.after=function(n,t){return function(){if(--n<1)return t.apply(this,arguments)}},m.before=function(n,t){var e;return function(){return--n>0&&(e=t.apply(this,arguments)),n<=1&&(t=null),e}},m.once=m.partial(m.before,2);var F=!{toString:null}.propertyIsEnumerable("toString"),q=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];m.keys=function(n){if(!m.isObject(n))return[];if(y)return y(n);var t=[];for(var e in n)m.has(n,e)&&t.push(e);return F&&u(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var e in n)t.push(e);return F&&u(n,t),t},m.values=function(n){for(var t=m.keys(n),e=t.length,r=Array(e),i=0;i<e;i++)r[i]=n[t[i]];return r},m.mapObject=function(n,t,e){t=x(t,e);for(var r,i=m.keys(n),u=i.length,o={},c=0;c<u;c++)o[r=i[c]]=t(n[r],r,n);return o},m.pairs=function(n){for(var t=m.keys(n),e=t.length,r=Array(e),i=0;i<e;i++)r[i]=[t[i],n[t[i]]];return r},m.invert=function(n){for(var t={},e=m.keys(n),r=0,i=e.length;r<i;r++)t[n[e[r]]]=e[r];return t},m.functions=m.methods=function(n){var t=[];for(var e in n)m.isFunction(n[e])&&t.push(e);return t.sort()},m.extend=k(m.allKeys),m.extendOwn=m.assign=k(m.keys),m.findKey=function(n,t,e){t=x(t,e);for(var r,i=m.keys(n),u=0,o=i.length;u<o;u++)if(r=i[u],t(n[r],r,n))return r},m.pick=function(n,t,e){var r,i,u={},o=n;if(null==o)return u;m.isFunction(t)?(i=m.allKeys(o),r=b(t,e)):(i=C(arguments,!1,!1,1),r=function(n,t,e){return t in e},o=Object(o));for(var c=0,a=i.length;c<a;c++){var s=i[c],l=o[s];r(l,s,o)&&(u[s]=l)}return u},m.omit=function(n,t,e){if(m.isFunction(t))t=m.negate(t);else{var r=m.map(C(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(r,t)}}return m.pick(n,t,e)},m.defaults=k(m.allKeys,!0),m.create=function(n,t){var e=w(n);return t&&m.extendOwn(e,t),e},m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var e=m.keys(t),r=e.length;if(null==n)return!r;for(var i=Object(n),u=0;u<r;u++){var o=e[u];if(t[o]!==i[o]||!(o in i))return!1}return!0};var Q=function(n,t,e,r){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var i=h.call(n);if(i!==h.call(t))return!1;switch(i){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!=+n?+t!=+t:0==+n?1/+n==1/t:+n==+t;case"[object Date]":case"[object Boolean]":return+n==+t}var u="[object Array]"===i;if(!u){if("object"!=typeof n||"object"!=typeof t)return!1;var o=n.constructor,c=t.constructor;if(o!==c&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(c)&&c instanceof c)&&"constructor"in n&&"constructor"in t)return!1}e=e||[],r=r||[];for(var a=e.length;a--;)if(e[a]===n)return r[a]===t;if(e.push(n),r.push(t),u){if((a=n.length)!==t.length)return!1;for(;a--;)if(!Q(n[a],t[a],e,r))return!1}else{var s,l=m.keys(n);if(a=l.length,m.keys(t).length!==a)return!1;for(;a--;)if(s=l[a],!m.has(t,s)||!Q(n[s],t[s],e,r))return!1}return e.pop(),r.pop(),!0};m.isEqual=function(n,t){return Q(n,t)},m.isEmpty=function(n){return null==n||(A(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length)},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=d||function(n){return"[object Array]"===h.call(n)},m.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},m.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(n){m["is"+n]=function(t){return h.call(t)==="[object "+n+"]"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(m.isFunction=function(n){return"function"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return!0===n||!1===n||"[object Boolean]"===h.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return void 0===n},m.has=function(n,t){return null!=n&&v.call(n,t)},m.noConflict=function(){return o._=c,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=j,m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,e){var r=Array(Math.max(0,n));t=b(t,e,1);for(var i=0;i<n;i++)r[i]=t(i);return r},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var M={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},N=m.invert(M),L=function(n){var t=function(t){return n[t]},e="(?:"+m.keys(n).join("|")+")",r=RegExp(e),i=RegExp(e,"g");return function(n){return n=null==n?"":""+n,r.test(n)?n.replace(i,t):n}};m.escape=L(M),m.unescape=L(N),m.result=function(n,t,e){var r=null==n?void 0:n[t];return void 0===r&&(r=e),m.isFunction(r)?r.call(n):r};var U=0;m.uniqueId=function(n){var t=++U+"";return n?n+t:t},m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var D=/(.)^/,R={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},W=/\\|'|\r|\n|\u2028|\u2029/g,P=function(n){return"\\"+R[n]};m.template=function(n,t,e){!t&&e&&(t=e),t=m.defaults({},t,m.templateSettings);var r=RegExp([(t.escape||D).source,(t.interpolate||D).source,(t.evaluate||D).source].join("|")+"|$","g"),i=0,u="__p+='";n.replace(r,function(t,e,r,o,c){return u+=n.slice(i,c).replace(W,P),i=c+t.length,e?u+="'+\n((__t=("+e+"))==null?'':_.escape(__t))+\n'":r?u+="'+\n((__t=("+r+"))==null?'':__t)+\n'":o&&(u+="';\n"+o+"\n__p+='"),t}),u+="';\n",t.variable||(u="with(obj||{}){\n"+u+"}\n"),u="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+u+"return __p;\n";try{var o=new Function(t.variable||"obj","_",u)}catch(n){throw n.source=u,n}var c=function(n){return o.call(this,n,m)},a=t.variable||"obj";return c.source="function("+a+"){\n"+u+"}",c},m.chain=function(n){var t=m(n);return t._chain=!0,t};var B=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var e=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return f.apply(n,arguments),B(this,e.apply(m,n))}})},m.mixin(m),m.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=a[n];m.prototype[n]=function(){var e=this._wrapped;return t.apply(e,arguments),"shift"!==n&&"splice"!==n||0!==e.length||delete e[0],B(this,e)}}),m.each(["concat","join","slice"],function(n){var t=a[n];m.prototype[n]=function(){return B(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return m})}).call(this)},{}],3:[function(n,t,e){"use strict";var r=n("underscore"),i=n("../events");t.exports=function(n){var t=n.getComponent("MenuItem");return n.extend(t,{constructor:function(n,e){var i=e.source;if(!r.isObject(i))throw new Error('was not provided a "source" object, but rather: '+typeof i);e=r.extend({selectable:!0,label:i.label},e),t.call(this,n,e),this.source=i},handleClick:function(n){t.prototype.handleClick.call(this,n),this.player().trigger(i.QUALITY_REQUESTED,this.source)}})}},{"../events":5,underscore:2}],4:[function(n,t,e){"use strict";var r=n("underscore"),i=n("../events"),u=n("./QualityOption");t.exports=function(n){var t,e=n.getComponent("MenuButton"),o=u(n);return t=n.extend(e,{constructor:function(n,t){e.call(this,n,t),n.on(i.QUALITY_REQUESTED,function(t,e){this.setSelectedSource(e),n.addClass("vjs-quality-changing"),n.one("loadeddata",function(){n.removeClass("vjs-quality-changing")})}.bind(this)),n.on(i.QUALITY_SELECTED,function(n,t){this.setSelectedSource(t)}.bind(this)),n.one("ready",function(){this.selectedSrc=n.src(),this.update()}.bind(this)),this.controlText("Open quality selector menu")},setSelectedSource:function(n){var t=n?n.src:void 0;this.selectedSrc!==t&&(this.selectedSrc=t,this.update())},createItems:function(){var n=this.player(),t=n.currentSources();return!t?[]:r.map(t,function(t){return new o(n,{source:t,selected:t.src===this.selectedSrc})}.bind(this))},buildWrapperCSSClass:function(){return"vjs-quality-selector "+e.prototype.buildWrapperCSSClass.call(this)}}),n.registerComponent("QualitySelector",t),t}},{"../events":5,"./QualityOption":3,underscore:2}],5:[function(n,t,e){"use strict";t.exports={QUALITY_REQUESTED:"qualityRequested",QUALITY_SELECTED:"qualitySelected"}},{}],6:[function(n,t,e){"use strict";var r=n("underscore"),i=n("./events"),u=n("./components/QualitySelector"),o=n("./middleware/SourceInterceptor"),c=n("./util/SafeSeek");t.exports=function(n){n=n||window.videojs,u(n),o(n),n.hook("setup",function(n){n.on(i.QUALITY_REQUESTED,function(t,e){var i=n.currentSources(),u=n.currentTime(),o=n.paused();r.each(i,function(n){n.selected=!1}),r.findWhere(i,{src:e.src}).selected=!0,n._qualitySelectorSafeSeek&&n._qualitySelectorSafeSeek.onQualitySelectionChange(),n.src(i),n.ready(function(){n._qualitySelectorSafeSeek&&!n._qualitySelectorSafeSeek.hasFinished()||(n._qualitySelectorSafeSeek=new c(n,u)),o||n.play()})})})},t.exports.EVENTS=i},{"./components/QualitySelector":4,"./events":5,"./middleware/SourceInterceptor":7,"./util/SafeSeek":9,underscore:2}],7:[function(n,t,e){"use strict";var r=n("underscore"),i=n("../events");t.exports=function(n){n.use("*",function(n){return{setSource:function(t,e){var u,o=n.currentSources();n._qualitySelectorSafeSeek&&n._qualitySelectorSafeSeek.onPlayerSourcesChange(),u=r.find(o,function(n){return!0===n.selected||"true"===n.selected})||t,n.trigger(i.QUALITY_SELECTED,u),e(null,u)}}})}},{"../events":5,underscore:2}],8:[function(n,t,e){"use strict";n("./index")()},{"./index":6}],9:[function(n,t,e){"use strict";var r=n("class.extend");t.exports=r.extend({init:function(n,t){this._player=n,this._seekToTime=t,this._hasFinished=!1,this._keepThisInstanceWhenPlayerSourcesChange=!1,this._seekWhenSafe()},_seekWhenSafe:function(){this._player.readyState()<3?(this._seekFn=this._seek.bind(this),this._player.one("canplay",this._seekFn)):this._seek()},onPlayerSourcesChange:function(){this._keepThisInstanceWhenPlayerSourcesChange?this._keepThisInstanceWhenPlayerSourcesChange=!1:this.cancel()},onQualitySelectionChange:function(){this.hasFinished()||(this._keepThisInstanceWhenPlayerSourcesChange=!0)},_seek:function(){this._player.currentTime(this._seekToTime),this._keepThisInstanceWhenPlayerSourcesChange=!1,this._hasFinished=!0},hasFinished:function(){return this._hasFinished},cancel:function(){this._player.off("canplay",this._seekFn),this._keepThisInstanceWhenPlayerSourcesChange=!1,this._hasFinished=!0}})},{"class.extend":1}]},{},[8]);
-//# sourceMappingURL=silvermine-videojs-quality-selector.min.js.map \ No newline at end of file
+!function(){function n(t,e,r){function i(o,a){if(!e[o]){if(!t[o]){var c="function"==typeof require&&require;if(!a&&c)return c(o,!0);if(u)return u(o,!0);var s=new Error("Cannot find module '"+o+"'");throw s.code="MODULE_NOT_FOUND",s}var l=e[o]={exports:{}};t[o][0].call(l.exports,function(n){return i(t[o][1][n]||n)},l,l.exports,n,t,e,r)}return e[o].exports}for(var u="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}return n}()({1:[function(n,t,e){!function(){var n=!1,e=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.Class=function(){},Class.extend=function(t,r){function i(){!n&&this.init&&this.init.apply(this,arguments)}void 0==r&&(r=t,t="Class");var u=this.prototype;n=!0;var o=new this;n=!1;for(var a in r)o[a]="function"==typeof r[a]&&"function"==typeof u[a]&&e.test(r[a])?function(n,t){return function(){var e=this._super;this._super=u[n];var r=t.apply(this,arguments);return this._super=e,r}}(a,r[a]):r[a];i.prototype=o;var c=new Function("return function "+t+"(){ }")();return i.prototype.constructor=c,i.extend=arguments.callee,i},t.exports=Class}()},{}],2:[function(n,t,e){(function(){function n(n){function t(t,e,r,i,u,o){for(;u>=0&&u<o;u+=n){var a=i?i[u]:u;r=e(r,t[a],a,t)}return r}return function(e,r,i,u){r=b(r,u,4);var o=!A(e)&&m.keys(e),a=(o||e).length,c=n>0?0:a-1;return arguments.length<3&&(i=e[o?o[c]:c],c+=n),t(e,r,i,o,c,a)}}function r(n){return function(t,e,r){e=x(e,r);for(var i=T(t),u=n>0?0:i-1;u>=0&&u<i;u+=n)if(e(t[u],u,t))return u;return-1}}function i(n,t,e){return function(r,i,u){var o=0,a=T(r);if("number"==typeof u)n>0?o=u>=0?u:Math.max(u+a,o):a=u>=0?Math.min(u+1,a):u+a+1;else if(e&&u&&a)return u=e(r,i),r[u]===i?u:-1;if(i!==i)return(u=t(p.call(r,o,a),m.isNaN))>=0?u+o:-1;for(u=n>0?o:a-1;u>=0&&u<a;u+=n)if(r[u]===i)return u;return-1}}function u(n,t){var e=q.length,r=n.constructor,i=m.isFunction(r)&&r.prototype||s,u="constructor";for(m.has(n,u)&&!m.contains(t,u)&&t.push(u);e--;)(u=q[e])in n&&n[u]!==i[u]&&!m.contains(t,u)&&t.push(u)}var o=this,a=o._,c=Array.prototype,s=Object.prototype,l=Function.prototype,f=c.push,p=c.slice,h=s.toString,v=s.hasOwnProperty,y=Array.isArray,d=Object.keys,g=l.bind,S=Object.create,_=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};void 0!==e?(void 0!==t&&t.exports&&(e=t.exports=m),e._=m):o._=m,m.VERSION="1.8.3";var b=function(n,t,e){if(void 0===t)return n;switch(null==e?3:e){case 1:return function(e){return n.call(t,e)};case 2:return function(e,r){return n.call(t,e,r)};case 3:return function(e,r,i){return n.call(t,e,r,i)};case 4:return function(e,r,i,u){return n.call(t,e,r,i,u)}}return function(){return n.apply(t,arguments)}},x=function(n,t,e){return null==n?m.identity:m.isFunction(n)?b(n,t,e):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return x(n,t,1/0)};var k=function(n,t){return function(e){var r=arguments.length;if(r<2||null==e)return e;for(var i=1;i<r;i++)for(var u=arguments[i],o=n(u),a=o.length,c=0;c<a;c++){var s=o[c];t&&void 0!==e[s]||(e[s]=u[s])}return e}},w=function(n){if(!m.isObject(n))return{};if(S)return S(n);_.prototype=n;var t=new _;return _.prototype=null,t},j=function(n){return function(t){return null==t?void 0:t[n]}},E=Math.pow(2,53)-1,T=j("length"),A=function(n){var t=T(n);return"number"==typeof t&&t>=0&&t<=E};m.each=m.forEach=function(n,t,e){t=b(t,e);var r,i;if(A(n))for(r=0,i=n.length;r<i;r++)t(n[r],r,n);else{var u=m.keys(n);for(r=0,i=u.length;r<i;r++)t(n[u[r]],u[r],n)}return n},m.map=m.collect=function(n,t,e){t=x(t,e);for(var r=!A(n)&&m.keys(n),i=(r||n).length,u=Array(i),o=0;o<i;o++){var a=r?r[o]:o;u[o]=t(n[a],a,n)}return u},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,e){var r;if(void 0!==(r=A(n)?m.findIndex(n,t,e):m.findKey(n,t,e))&&-1!==r)return n[r]},m.filter=m.select=function(n,t,e){var r=[];return t=x(t,e),m.each(n,function(n,e,i){t(n,e,i)&&r.push(n)}),r},m.reject=function(n,t,e){return m.filter(n,m.negate(x(t)),e)},m.every=m.all=function(n,t,e){t=x(t,e);for(var r=!A(n)&&m.keys(n),i=(r||n).length,u=0;u<i;u++){var o=r?r[u]:u;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,e){t=x(t,e);for(var r=!A(n)&&m.keys(n),i=(r||n).length,u=0;u<i;u++){var o=r?r[u]:u;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,e,r){return A(n)||(n=m.values(n)),("number"!=typeof e||r)&&(e=0),m.indexOf(n,t,e)>=0},m.invoke=function(n,t){var e=p.call(arguments,2),r=m.isFunction(t);return m.map(n,function(n){var i=r?t:n[t];return null==i?i:i.apply(n,e)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,e){var r,i,u=-1/0,o=-1/0;if(null==t&&null!=n)for(var a=0,c=(n=A(n)?n:m.values(n)).length;a<c;a++)(r=n[a])>u&&(u=r);else t=x(t,e),m.each(n,function(n,e,r){((i=t(n,e,r))>o||i===-1/0&&u===-1/0)&&(u=n,o=i)});return u},m.min=function(n,t,e){var r,i,u=1/0,o=1/0;if(null==t&&null!=n)for(var a=0,c=(n=A(n)?n:m.values(n)).length;a<c;a++)(r=n[a])<u&&(u=r);else t=x(t,e),m.each(n,function(n,e,r){((i=t(n,e,r))<o||i===1/0&&u===1/0)&&(u=n,o=i)});return u},m.shuffle=function(n){for(var t,e=A(n)?n:m.values(n),r=e.length,i=Array(r),u=0;u<r;u++)(t=m.random(0,u))!==u&&(i[u]=i[t]),i[t]=e[u];return i},m.sample=function(n,t,e){return null==t||e?(A(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,e){return t=x(t,e),m.pluck(m.map(n,function(n,e,r){return{value:n,index:e,criteria:t(n,e,r)}}).sort(function(n,t){var e=n.criteria,r=t.criteria;if(e!==r){if(e>r||void 0===e)return 1;if(e<r||void 0===r)return-1}return n.index-t.index}),"value")};var O=function(n){return function(t,e,r){var i={};return e=x(e,r),m.each(t,function(r,u){var o=e(r,u,t);n(i,r,o)}),i}};m.groupBy=O(function(n,t,e){m.has(n,e)?n[e].push(t):n[e]=[t]}),m.indexBy=O(function(n,t,e){n[e]=t}),m.countBy=O(function(n,t,e){m.has(n,e)?n[e]++:n[e]=1}),m.toArray=function(n){return n?m.isArray(n)?p.call(n):A(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:A(n)?n.length:m.keys(n).length},m.partition=function(n,t,e){t=x(t,e);var r=[],i=[];return m.each(n,function(n,e,u){(t(n,e,u)?r:i).push(n)}),[r,i]},m.first=m.head=m.take=function(n,t,e){if(null!=n)return null==t||e?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,e){return p.call(n,0,Math.max(0,n.length-(null==t||e?1:t)))},m.last=function(n,t,e){if(null!=n)return null==t||e?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,e){return p.call(n,null==t||e?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var C=function(n,t,e,r){for(var i=[],u=0,o=r||0,a=T(n);o<a;o++){var c=n[o];if(A(c)&&(m.isArray(c)||m.isArguments(c))){t||(c=C(c,t,e));var s=0,l=c.length;for(i.length+=l;s<l;)i[u++]=c[s++]}else e||(i[u++]=c)}return i};m.flatten=function(n,t){return C(n,t,!1)},m.without=function(n){return m.difference(n,p.call(arguments,1))},m.uniq=m.unique=function(n,t,e,r){m.isBoolean(t)||(r=e,e=t,t=!1),null!=e&&(e=x(e,r));for(var i=[],u=[],o=0,a=T(n);o<a;o++){var c=n[o],s=e?e(c,o,n):c;t?(o&&u===s||i.push(c),u=s):e?m.contains(u,s)||(u.push(s),i.push(c)):m.contains(i,c)||i.push(c)}return i},m.union=function(){return m.uniq(C(arguments,!0,!0))},m.intersection=function(n){for(var t=[],e=arguments.length,r=0,i=T(n);r<i;r++){var u=n[r];if(!m.contains(t,u)){for(var o=1;o<e&&m.contains(arguments[o],u);o++);o===e&&t.push(u)}}return t},m.difference=function(n){var t=C(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,T).length||0,e=Array(t),r=0;r<t;r++)e[r]=m.pluck(n,r);return e},m.object=function(n,t){for(var e={},r=0,i=T(n);r<i;r++)t?e[n[r]]=t[r]:e[n[r][0]]=n[r][1];return e},m.findIndex=r(1),m.findLastIndex=r(-1),m.sortedIndex=function(n,t,e,r){for(var i=(e=x(e,r,1))(t),u=0,o=T(n);u<o;){var a=Math.floor((u+o)/2);e(n[a])<i?u=a+1:o=a}return u},m.indexOf=i(1,m.findIndex,m.sortedIndex),m.lastIndexOf=i(-1,m.findLastIndex),m.range=function(n,t,e){null==t&&(t=n||0,n=0),e=e||1;for(var r=Math.max(Math.ceil((t-n)/e),0),i=Array(r),u=0;u<r;u++,n+=e)i[u]=n;return i};var I=function(n,t,e,r,i){if(!(r instanceof t))return n.apply(e,i);var u=w(n.prototype),o=n.apply(u,i);return m.isObject(o)?o:u};m.bind=function(n,t){if(g&&n.bind===g)return g.apply(n,p.call(arguments,1));if(!m.isFunction(n))throw new TypeError("Bind must be called on a function");var e=p.call(arguments,2),r=function(){return I(n,r,t,this,e.concat(p.call(arguments)))};return r},m.partial=function(n){var t=p.call(arguments,1),e=function(){for(var r=0,i=t.length,u=Array(i),o=0;o<i;o++)u[o]=t[o]===m?arguments[r++]:t[o];for(;r<arguments.length;)u.push(arguments[r++]);return I(n,e,this,this,u)};return e},m.bindAll=function(n){var t,e,r=arguments.length;if(r<=1)throw new Error("bindAll must be passed function names");for(t=1;t<r;t++)n[e=arguments[t]]=m.bind(n[e],n);return n},m.memoize=function(n,t){var e=function(r){var i=e.cache,u=""+(t?t.apply(this,arguments):r);return m.has(i,u)||(i[u]=n.apply(this,arguments)),i[u]};return e.cache={},e},m.delay=function(n,t){var e=p.call(arguments,2);return setTimeout(function(){return n.apply(null,e)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,e){var r,i,u,o=null,a=0;e||(e={});var c=function(){a=!1===e.leading?0:m.now(),o=null,u=n.apply(r,i),o||(r=i=null)};return function(){var s=m.now();a||!1!==e.leading||(a=s);var l=t-(s-a);return r=this,i=arguments,l<=0||l>t?(o&&(clearTimeout(o),o=null),a=s,u=n.apply(r,i),o||(r=i=null)):o||!1===e.trailing||(o=setTimeout(c,l)),u}},m.debounce=function(n,t,e){var r,i,u,o,a,c=function(){var s=m.now()-o;s<t&&s>=0?r=setTimeout(c,t-s):(r=null,e||(a=n.apply(u,i),r||(u=i=null)))};return function(){u=this,i=arguments,o=m.now();var s=e&&!r;return r||(r=setTimeout(c,t)),s&&(a=n.apply(u,i),u=i=null),a}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var e=t,r=n[t].apply(this,arguments);e--;)r=n[e].call(this,r);return r}},m.after=function(n,t){return function(){if(--n<1)return t.apply(this,arguments)}},m.before=function(n,t){var e;return function(){return--n>0&&(e=t.apply(this,arguments)),n<=1&&(t=null),e}},m.once=m.partial(m.before,2);var F=!{toString:null}.propertyIsEnumerable("toString"),q=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];m.keys=function(n){if(!m.isObject(n))return[];if(d)return d(n);var t=[];for(var e in n)m.has(n,e)&&t.push(e);return F&&u(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var e in n)t.push(e);return F&&u(n,t),t},m.values=function(n){for(var t=m.keys(n),e=t.length,r=Array(e),i=0;i<e;i++)r[i]=n[t[i]];return r},m.mapObject=function(n,t,e){t=x(t,e);for(var r,i=m.keys(n),u=i.length,o={},a=0;a<u;a++)o[r=i[a]]=t(n[r],r,n);return o},m.pairs=function(n){for(var t=m.keys(n),e=t.length,r=Array(e),i=0;i<e;i++)r[i]=[t[i],n[t[i]]];return r},m.invert=function(n){for(var t={},e=m.keys(n),r=0,i=e.length;r<i;r++)t[n[e[r]]]=e[r];return t},m.functions=m.methods=function(n){var t=[];for(var e in n)m.isFunction(n[e])&&t.push(e);return t.sort()},m.extend=k(m.allKeys),m.extendOwn=m.assign=k(m.keys),m.findKey=function(n,t,e){t=x(t,e);for(var r,i=m.keys(n),u=0,o=i.length;u<o;u++)if(r=i[u],t(n[r],r,n))return r},m.pick=function(n,t,e){var r,i,u={},o=n;if(null==o)return u;m.isFunction(t)?(i=m.allKeys(o),r=b(t,e)):(i=C(arguments,!1,!1,1),r=function(n,t,e){return t in e},o=Object(o));for(var a=0,c=i.length;a<c;a++){var s=i[a],l=o[s];r(l,s,o)&&(u[s]=l)}return u},m.omit=function(n,t,e){if(m.isFunction(t))t=m.negate(t);else{var r=m.map(C(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(r,t)}}return m.pick(n,t,e)},m.defaults=k(m.allKeys,!0),m.create=function(n,t){var e=w(n);return t&&m.extendOwn(e,t),e},m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var e=m.keys(t),r=e.length;if(null==n)return!r;for(var i=Object(n),u=0;u<r;u++){var o=e[u];if(t[o]!==i[o]||!(o in i))return!1}return!0};var Q=function(n,t,e,r){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var i=h.call(n);if(i!==h.call(t))return!1;switch(i){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!=+n?+t!=+t:0==+n?1/+n==1/t:+n==+t;case"[object Date]":case"[object Boolean]":return+n==+t}var u="[object Array]"===i;if(!u){if("object"!=typeof n||"object"!=typeof t)return!1;var o=n.constructor,a=t.constructor;if(o!==a&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(a)&&a instanceof a)&&"constructor"in n&&"constructor"in t)return!1}e=e||[],r=r||[];for(var c=e.length;c--;)if(e[c]===n)return r[c]===t;if(e.push(n),r.push(t),u){if((c=n.length)!==t.length)return!1;for(;c--;)if(!Q(n[c],t[c],e,r))return!1}else{var s,l=m.keys(n);if(c=l.length,m.keys(t).length!==c)return!1;for(;c--;)if(s=l[c],!m.has(t,s)||!Q(n[s],t[s],e,r))return!1}return e.pop(),r.pop(),!0};m.isEqual=function(n,t){return Q(n,t)},m.isEmpty=function(n){return null==n||(A(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length)},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=y||function(n){return"[object Array]"===h.call(n)},m.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},m.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(n){m["is"+n]=function(t){return h.call(t)==="[object "+n+"]"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(m.isFunction=function(n){return"function"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return!0===n||!1===n||"[object Boolean]"===h.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return void 0===n},m.has=function(n,t){return null!=n&&v.call(n,t)},m.noConflict=function(){return o._=a,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=j,m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,e){var r=Array(Math.max(0,n));t=b(t,e,1);for(var i=0;i<n;i++)r[i]=t(i);return r},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var M={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},N=m.invert(M),R=function(n){var t=function(t){return n[t]},e="(?:"+m.keys(n).join("|")+")",r=RegExp(e),i=RegExp(e,"g");return function(n){return n=null==n?"":""+n,r.test(n)?n.replace(i,t):n}};m.escape=R(M),m.unescape=R(N),m.result=function(n,t,e){var r=null==n?void 0:n[t];return void 0===r&&(r=e),m.isFunction(r)?r.call(n):r};var L=0;m.uniqueId=function(n){var t=++L+"";return n?n+t:t},m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var U=/(.)^/,D={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},W=/\\|'|\r|\n|\u2028|\u2029/g,P=function(n){return"\\"+D[n]};m.template=function(n,t,e){!t&&e&&(t=e),t=m.defaults({},t,m.templateSettings);var r=RegExp([(t.escape||U).source,(t.interpolate||U).source,(t.evaluate||U).source].join("|")+"|$","g"),i=0,u="__p+='";n.replace(r,function(t,e,r,o,a){return u+=n.slice(i,a).replace(W,P),i=a+t.length,e?u+="'+\n((__t=("+e+"))==null?'':_.escape(__t))+\n'":r?u+="'+\n((__t=("+r+"))==null?'':__t)+\n'":o&&(u+="';\n"+o+"\n__p+='"),t}),u+="';\n",t.variable||(u="with(obj||{}){\n"+u+"}\n"),u="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+u+"return __p;\n";try{var o=new Function(t.variable||"obj","_",u)}catch(n){throw n.source=u,n}var a=function(n){return o.call(this,n,m)},c=t.variable||"obj";return a.source="function("+c+"){\n"+u+"}",a},m.chain=function(n){var t=m(n);return t._chain=!0,t};var B=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var e=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return f.apply(n,arguments),B(this,e.apply(m,n))}})},m.mixin(m),m.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=c[n];m.prototype[n]=function(){var e=this._wrapped;return t.apply(e,arguments),"shift"!==n&&"splice"!==n||0!==e.length||delete e[0],B(this,e)}}),m.each(["concat","join","slice"],function(n){var t=c[n];m.prototype[n]=function(){return B(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return m})}).call(this)},{}],3:[function(n,t,e){"use strict";var r=n("underscore"),i=n("../events");t.exports=function(n){var t=n.getComponent("MenuItem");return n.extend(t,{constructor:function(n,e){var i=e.source;if(!r.isObject(i))throw new Error('was not provided a "source" object, but rather: '+typeof i);e=r.extend({selectable:!0,label:i.label},e),t.call(this,n,e),this.source=i},handleClick:function(n){t.prototype.handleClick.call(this,n),this.player().trigger(i.QUALITY_REQUESTED,this.source)}})}},{"../events":5,underscore:2}],4:[function(n,t,e){"use strict";var r=n("underscore"),i=n("../events"),u=n("./QualityOption");t.exports=function(n){var t,e=n.getComponent("MenuButton"),o=u(n);return t=n.extend(e,{constructor:function(n,t){e.call(this,n,t),n.on(i.QUALITY_REQUESTED,function(t,e){this.setSelectedSource(e),n.addClass("vjs-quality-changing"),n.one("loadeddata",function(){n.removeClass("vjs-quality-changing")})}.bind(this)),n.on(i.QUALITY_SELECTED,function(n,t){this.setSelectedSource(t)}.bind(this)),n.one("ready",function(){this.selectedSrc=n.src(),this.update()}.bind(this)),this.controlText("Open quality selector menu")},setSelectedSource:function(n){var t=n?n.src:void 0;this.selectedSrc!==t&&(this.selectedSrc=t,this.update())},createItems:function(){var n=this.player(),t=n.currentSources();return r.map(t,function(t){return new o(n,{source:t,selected:t.src===this.selectedSrc})}.bind(this))},buildWrapperCSSClass:function(){return"vjs-quality-selector "+e.prototype.buildWrapperCSSClass.call(this)}}),n.registerComponent("QualitySelector",t),t}},{"../events":5,"./QualityOption":3,underscore:2}],5:[function(n,t,e){"use strict";t.exports={QUALITY_REQUESTED:"qualityRequested",QUALITY_SELECTED:"qualitySelected"}},{}],6:[function(n,t,e){"use strict";var r=n("underscore"),i=n("./events"),u=n("./components/QualitySelector"),o=n("./middleware/SourceInterceptor"),a=n("./util/SafeSeek");t.exports=function(n){n=n||window.videojs,u(n),o(n),n.hook("setup",function(n){n.on(i.QUALITY_REQUESTED,function(t,e){var i=n.currentSources(),u=n.currentTime(),o=(n.playbackRate(),n.paused());r.each(i,function(n){n.selected=!1}),r.findWhere(i,{src:e.src}).selected=!0,n._qualitySelectorSafeSeek&&n._qualitySelectorSafeSeek.onQualitySelectionChange(),n.src(i),n.ready(function(){n._qualitySelectorSafeSeek&&!n._qualitySelectorSafeSeek.hasFinished()||(n._qualitySelectorSafeSeek=new a(n,u),n.playbackRate=playbackRate),o||n.play()})})})},t.exports.EVENTS=i},{"./components/QualitySelector":4,"./events":5,"./middleware/SourceInterceptor":7,"./util/SafeSeek":9,underscore:2}],7:[function(n,t,e){"use strict";var r=n("underscore"),i=n("../events");t.exports=function(n){n.use("*",function(n){return{setSource:function(t,e){var u,o=n.currentSources();n._qualitySelectorSafeSeek&&n._qualitySelectorSafeSeek.onPlayerSourcesChange(),u=r.find(o,function(n){return!0===n.selected||"true"===n.selected})||t,n.trigger(i.QUALITY_SELECTED,u),e(null,u)}}})}},{"../events":5,underscore:2}],8:[function(n,t,e){"use strict";n("./index")()},{"./index":6}],9:[function(n,t,e){"use strict";var r=n("class.extend");t.exports=r.extend({init:function(n,t){this._player=n,this._seekToTime=t,this._hasFinished=!1,this._keepThisInstanceWhenPlayerSourcesChange=!1,this._seekWhenSafe()},_seekWhenSafe:function(){this._player.readyState()<3?(this._seekFn=this._seek.bind(this),this._player.one("canplay",this._seekFn)):this._seek()},onPlayerSourcesChange:function(){this._keepThisInstanceWhenPlayerSourcesChange?this._keepThisInstanceWhenPlayerSourcesChange=!1:this.cancel()},onQualitySelectionChange:function(){this.hasFinished()||(this._keepThisInstanceWhenPlayerSourcesChange=!0)},_seek:function(){this._player.currentTime(this._seekToTime),this._keepThisInstanceWhenPlayerSourcesChange=!1,this._hasFinished=!0},hasFinished:function(){return this._hasFinished},cancel:function(){this._player.off("canplay",this._seekFn),this._keepThisInstanceWhenPlayerSourcesChange=!1,this._hasFinished=!0}})},{"class.extend":1}]},{},[8]); \ No newline at end of file
diff --git a/assets/js/videojs-dash.min.js b/assets/js/videojs-dash.min.js
index b6fb901a..c3f7ea07 100644
--- a/assets/js/videojs-dash.min.js
+++ b/assets/js/videojs-dash.min.js
@@ -1,3 +1,3 @@
-/*! videojs-contrib-dash - v2.8.2 - 2018-09-24
- * Copyright (c) 2018 Brightcove */
-!function(){function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c||a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}return a}()({1:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d=function(a,b){var c={};return c.id=a.qualityIndex+"",c.width=a.width,c.height=a.height,c.bandwidth=a.bitrate,c.isEnabled_=!0,c.enabled=function(a){return void 0===a?c.isEnabled_:void(a!==c.isEnabled_&&(a!==!0&&a!==!1||(c.isEnabled_=a,b())))},c},e=function(a){var b=[],c=function(){var c=b.filter(function(a){return a.enabled()});if(c.length===b.length||0===c.length)return a.setMinAllowedBitrateFor("video",NaN),void a.setMaxAllowedBitrateFor("video",NaN);c.sort(function(a,b){return a.bandwidth-b.bandwidth});var d=c[0].bandwidth,e=c[c.length-1].bandwidth;a.setMinAllowedBitrateFor("video",d/1e3),a.setMaxAllowedBitrateFor("video",e/1e3)};return function(){return b=b.length?b:a.getBitrateInfoListFor("video").map(function(a){return d(a,c)})}};c.default=e},{}],2:[function(a,b,c){(function(a){"use strict";function b(a){return a&&a.__esModule?a:{default:a}}function d(a,b){function c(a){return"dash-audio-"+a}function d(a,b){return a.find(function(a){var d=a.index;return c(d)===b.id})}var e=a.dash.mediaPlayer,f=e.getTracksFor("audio"),g=a.audioTracks();g.length&&b.clearTracks(["audio"]);var h=e.getCurrentTrackFor("audio");f.forEach(function(a){var b=a.lang;a.roles&&a.roles.length&&(b+=" ("+a.roles.join(", ")+")"),g.addTrack(new i.default.AudioTrack({enabled:a===h,id:c(a.index),kind:a.kind||"main",label:b,language:a.lang}))}),g.addEventListener("change",function(){for(var a=0;a<g.length;a++){var b=g[a];if(b.enabled){var c=d(f,b);e.setCurrentTrack(c)}else;}})}function e(a,b){a.dash.mediaPlayer.on(g.default.MediaPlayer.events.PLAYBACK_METADATA_LOADED,d.bind(null,a,b))}Object.defineProperty(c,"__esModule",{value:!0}),c.default=e;var f="undefined"!=typeof window?window.dashjs:"undefined"!=typeof a?a.dashjs:null,g=b(f),h="undefined"!=typeof window?window.videojs:"undefined"!=typeof a?a.videojs:null,i=b(h)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d=function(a,b){if(a.dash&&a.dash.representations&&a.qualityLevels){var c=a.qualityLevels();c.dispose();var d=function(){a.dash.representations().forEach(c.addQualityLevel.bind(c))},e=function(a){"video"===a.mediaType&&(c.selectedIndex_=a.newQuality,c.trigger("change"))};b.on("playbackMetaDataLoaded",d),b.on("qualityChangeRendered",e)}};c.default=d},{}],4:[function(a,b,c){(function(a){"use strict";function b(a){return a&&a.__esModule?a:{default:a}}function d(a,b,c){function d(){for(var b=a.dash.mediaPlayer,d=a.textTracks(),f=-1,g=function(a){var b=d[a];if("showing"===b.mode){var g=e.find(function(a){var c=a.textTrack;return c===b}),h=g?g.dashTrack:null;h&&(f=c.indexOf(h))}},h=0;h<d.length;h+=1)g(h);f!==b.getCurrentTextTrackIndex()&&b.setTextTrack(f)}var e=[],f=c.map(function(a){return{dashTrack:a,trackConfig:{default:a.defaultTrack,kind:a.kind,label:a.lang,language:a.lang,srclang:a.lang}}}).map(function(b){var c=b.trackConfig,d=b.dashTrack,f=a.addRemoteTextTrack(c,!0);return e.push({textTrack:f.track,dashTrack:d}),f});a.textTracks().on("change",d),a.one("loadstart",function(){a.textTracks().off("change",d)});for(var g=a.textTracks(),h=0;h<g.length;h+=1){var i=g[h];"subtitles"!==i.kind&&"captions"!==i.kind||(i.mode=i.default?"showing":"hidden")}return d(),f}function e(a,b,c){function e(){j.forEach(a.removeRemoteTextTrack.bind(a)),j=[]}function f(h){var i=(h.index,h.tracks);k.off(g.default.MediaPlayer.events.TEXT_TRACKS_ADDED,f),e(),i.length&&(j=d(a,b,i,c))}function h(){k.off(g.default.MediaPlayer.events.TEXT_TRACKS_ADDED,f),a.one("loadstart",e)}var j=[];if(b.featuresNativeTextTracks)return void i.default.log.error("You must pass {html: {nativeCaptions: false}} in the videojs constructor to use text tracks in videojs-contrib-dash");var k=a.dash.mediaPlayer;k.on(g.default.MediaPlayer.events.TEXT_TRACKS_ADDED,f),k.on(g.default.MediaPlayer.events.CAN_PLAY,h)}Object.defineProperty(c,"__esModule",{value:!0}),c.default=e;var f="undefined"!=typeof window?window.dashjs:"undefined"!=typeof a?a.dashjs:null,g=b(f),h="undefined"!=typeof window?window.videojs:"undefined"!=typeof a?a.videojs:null,i=b(h)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],5:[function(a,b,c){(function(b){"use strict";function d(a){return a&&a.__esModule?a:{default:a}}function e(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}return Array.from(a)}function f(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(c,"__esModule",{value:!0});var g=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),h=a("global/window"),i=d(h),j="undefined"!=typeof window?window.videojs:"undefined"!=typeof b?b.videojs:null,k=d(j),l="undefined"!=typeof window?window.dashjs:"undefined"!=typeof b?b.dashjs:null,m=d(l),n=a("./setup-audio-tracks"),o=d(n),p=a("./setup-text-tracks"),q=d(p),r=a("./create-representations"),s=d(r),t=a("./setup-quality-levels"),u=d(t),v=function(){function a(b,c,d){var g=this;if(f(this,a),d=d||c.options_,this.player=(0,k.default)(d.playerId),this.player.dash=this.player.dash||{},this.el_=c.el(),b.src){c.isReady_=!1,a.updateSourceData&&(k.default.log.warn('updateSourceData has been deprecated. Please switch to using hook("updatesource", callback).'),b=a.updateSourceData(b)),a.hooks("updatesource").forEach(function(a){b=a(b)});var h=b.src,i=a.buildDashJSProtData(b.keySystemOptions);this.player.dash.mediaPlayer=m.default.MediaPlayer().create(),this.mediaPlayer_=this.player.dash.mediaPlayer,this.mediaPlayer_.setFastSwitchEnabled(!0),a.useVideoJSDebug&&(k.default.log.warn('useVideoJSDebug has been deprecated. Please switch to using hook("beforeinitialize", callback).'),a.useVideoJSDebug(this.mediaPlayer_)),a.beforeInitialize&&(k.default.log.warn('beforeInitialize has been deprecated. Please switch to using hook("beforeinitialize", callback).'),a.beforeInitialize(this.player,this.mediaPlayer_)),this.player.dash.representations=(0,s.default)(this.mediaPlayer_),(0,u.default)(this.player,this.mediaPlayer_),a.hooks("beforeinitialize").forEach(function(a){a(g.player,g.mediaPlayer_)}),this.mediaPlayer_.initialize(),d.dash&&Object.keys(d.dash).forEach(function(a){var b,c="set"+a.charAt(0).toUpperCase()+a.slice(1),f=d.dash[a];return g.mediaPlayer_.hasOwnProperty(c)&&(k.default.log.warn("Using dash options in videojs-contrib-dash without the set prefix "+("has been deprecated. Change '"+a+"' to '"+c+"'")),a=c),g.mediaPlayer_.hasOwnProperty(a)?(Array.isArray(f)||(f=[f]),void(b=g.mediaPlayer_)[a].apply(b,e(f))):void k.default.log.warn("Warning: dash configuration option unrecognized: "+a)}),this.mediaPlayer_.attachView(this.el_),this.mediaPlayer_.setAutoPlay(!1),o.default.call(null,this.player,c),q.default.call(null,this.player,c,d),this.mediaPlayer_.setProtectionData(i),this.mediaPlayer_.attachSource(h),c.triggerReady()}}return g(a,[{key:"dispose",value:function(){this.mediaPlayer_&&this.mediaPlayer_.reset(),this.player.dash&&delete this.player.dash,this.player.qualityLevels&&this.player.qualityLevels().dispose()}},{key:"duration",value:function a(){var a=this.el_.duration;return a===Number.MAX_VALUE?1/0:a}}],[{key:"buildDashJSProtData",value:function(a){var b={};if(!a||!Array.isArray(a))return null;for(var c=0;c<a.length;c++){var d=a[c],e=k.default.mergeOptions({},d.options);e.licenseUrl&&(e.serverURL=e.licenseUrl,delete e.licenseUrl),b[d.name]=e}return b}},{key:"hooks",value:function(b,c){return a.hooks_[b]=a.hooks_[b]||[],c&&(a.hooks_[b]=a.hooks_[b].concat(c)),a.hooks_[b]}},{key:"hook",value:function(b,c){a.hooks(b,c)}},{key:"removeHook",value:function(b,c){var d=a.hooks(b).indexOf(c);return d!==-1&&(a.hooks_[b]=a.hooks_[b].slice(),a.hooks_[b].splice(d,1),!0)}}]),a}();v.hooks_={};var w=function(a){a=JSON.parse(JSON.stringify(a)),v.updateSourceData&&(k.default.log.warn('updateSourceData has been deprecated. Please switch to using hook("updatesource", callback).'),a=v.updateSourceData(a)),v.hooks("updatesource").forEach(function(b){a=b(a)});var b=document.createElement("video");return!(a.keySystemOptions&&!navigator.requestMediaKeySystemAccess&&!b.msSetMediaKeys)};k.default.DashSourceHandler=function(){return{canHandleSource:function(a){var b=/\.mpd/i;return w(a)?k.default.DashSourceHandler.canPlayType(a.type)?"probably":b.test(a.src)?"maybe":"":""},handleSource:function(a,b,c){return new v(a,b,c)},canPlayType:function(a){return k.default.DashSourceHandler.canPlayType(a)}}},k.default.DashSourceHandler.canPlayType=function(a){var b=/^application\/dash\+xml/i;return b.test(a)?"probably":""},i.default.MediaSource&&k.default.getTech("Html5").registerSourceHandler(k.default.DashSourceHandler(),0),k.default.Html5DashJS=v,c.default=v}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./create-representations":1,"./setup-audio-tracks":2,"./setup-quality-levels":3,"./setup-text-tracks":4,"global/window":6}],6:[function(a,b,c){(function(a){var c;c="undefined"!=typeof window?window:"undefined"!=typeof a?a:"undefined"!=typeof self?self:{},b.exports=c}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[5]); \ No newline at end of file
+/*! videojs-contrib-dash - v2.8.2 - 2017-04-26
+ * Copyright (c) 2017 Brightcove */
+!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){(function(a){"use strict";function b(a){return a&&a.__esModule?a:{default:a}}function d(a,b){function c(a){return"dash-audio-"+a}function d(a,b){return a.find(function(a){var d=a.index;return c(d)===b.id})}var e=a.dash.mediaPlayer,f=e.getTracksFor("audio"),g=a.audioTracks();g.length&&b.clearTracks(["audio"]);var h=e.getCurrentTrackFor("audio");f.forEach(function(a){var b=a.lang;a.roles&&a.roles.length&&(b+=" ("+a.roles.join(", ")+")"),g.addTrack(new i.default.AudioTrack({enabled:a===h,id:c(a.index),kind:a.kind||"main",label:b,language:a.lang}))}),g.addEventListener("change",function(){for(var a=0;a<g.length;a++){var b=g[a];if(b.enabled){var c=d(f,b);e.setCurrentTrack(c)}else;}})}function e(a,b){a.dash.mediaPlayer.on(g.default.MediaPlayer.events.PLAYBACK_METADATA_LOADED,d.bind(null,a,b))}Object.defineProperty(c,"__esModule",{value:!0}),c.default=e;var f="undefined"!=typeof window?window.dashjs:"undefined"!=typeof a?a.dashjs:null,g=b(f),h="undefined"!=typeof window?window.videojs:"undefined"!=typeof a?a.videojs:null,i=b(h)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(a,b,c){(function(b){"use strict";function d(a){return a&&a.__esModule?a:{default:a}}function e(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}return Array.from(a)}function f(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(c,"__esModule",{value:!0});var g=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),h=a("global/window"),i=d(h),j="undefined"!=typeof window?window.videojs:"undefined"!=typeof b?b.videojs:null,k=d(j),l="undefined"!=typeof window?window.dashjs:"undefined"!=typeof b?b.dashjs:null,m=d(l),n=a("./setup-audio-tracks"),o=d(n),p=function(a){return"[object Array]"===Object.prototype.toString.call(a)},q=function(){function a(b,c,d){var g=this;if(f(this,a),d=d||c.options_,this.player=(0,k.default)(d.playerId),this.player.dash=this.player.dash||{},this.tech_=c,this.el_=c.el(),this.elParent_=this.el_.parentNode,b.src){c.isReady_=!1,a.updateSourceData&&(k.default.log.warn('updateSourceData has been deprecated. Please switch to using hook("updatesource", callback).'),b=a.updateSourceData(b)),a.hooks("updatesource").forEach(function(a){b=a(b)});var h=b.src;this.keySystemOptions_=a.buildDashJSProtData(b.keySystemOptions),this.player.dash.mediaPlayer=m.default.MediaPlayer().create(),this.mediaPlayer_=this.player.dash.mediaPlayer,a.useVideoJSDebug&&(k.default.log.warn('useVideoJSDebug has been deprecated. Please switch to using hook("beforeinitialize", callback).'),a.useVideoJSDebug(this.mediaPlayer_)),a.beforeInitialize&&(k.default.log.warn('beforeInitialize has been deprecated. Please switch to using hook("beforeinitialize", callback).'),a.beforeInitialize(this.player,this.mediaPlayer_)),a.hooks("beforeinitialize").forEach(function(a){a(g.player,g.mediaPlayer_)}),this.mediaPlayer_.initialize(),d.dash&&Object.keys(d.dash).forEach(function(a){var b,c="set"+a.charAt(0).toUpperCase()+a.slice(1),f=d.dash[a];return g.mediaPlayer_.hasOwnProperty(c)&&(k.default.log.warn("Using dash options in videojs-contrib-dash without the set prefix "+("has been deprecated. Change '"+a+"' to '"+c+"'")),a=c),g.mediaPlayer_.hasOwnProperty(a)?(p(f)||(f=[f]),void(b=g.mediaPlayer_)[a].apply(b,e(f))):void k.default.log.warn("Warning: dash configuration option unrecognized: "+a)}),this.mediaPlayer_.attachView(this.el_),this.mediaPlayer_.setAutoPlay(!1),o.default.call(null,this.player,c),this.mediaPlayer_.setProtectionData(this.keySystemOptions_),this.mediaPlayer_.attachSource(h),this.tech_.triggerReady()}}return g(a,[{key:"dispose",value:function(){this.mediaPlayer_&&this.mediaPlayer_.reset(),this.player.dash&&delete this.player.dash}},{key:"duration",value:function a(){var a=this.el_.duration;return a===Number.MAX_VALUE?1/0:a}}],[{key:"buildDashJSProtData",value:function(a){var b={};if(!a||!p(a))return null;for(var c=0;c<a.length;c++){var d=a[c],e=k.default.mergeOptions({},d.options);e.licenseUrl&&(e.serverURL=e.licenseUrl,delete e.licenseUrl),b[d.name]=e}return b}},{key:"hooks",value:function(b,c){return a.hooks_[b]=a.hooks_[b]||[],c&&(a.hooks_[b]=a.hooks_[b].concat(c)),a.hooks_[b]}},{key:"hook",value:function(b,c){a.hooks(b,c)}},{key:"removeHook",value:function(b,c){var d=a.hooks(b).indexOf(c);return d!==-1&&(a.hooks_[b]=a.hooks_[b].slice(),a.hooks_[b].splice(d,1),!0)}}]),a}();q.hooks_={};var r=function(a){a=JSON.parse(JSON.stringify(a)),q.updateSourceData&&(k.default.log.warn('updateSourceData has been deprecated. Please switch to using hook("updatesource", callback).'),a=q.updateSourceData(a)),q.hooks("updatesource").forEach(function(b){a=b(a)});var b=document.createElement("video");return!(a.keySystemOptions&&!navigator.requestMediaKeySystemAccess&&!b.msSetMediaKeys)};k.default.DashSourceHandler=function(){return{canHandleSource:function(a){var b=/\.mpd/i;return r(a)?k.default.DashSourceHandler.canPlayType(a.type)?"probably":b.test(a.src)?"maybe":"":""},handleSource:function(a,b,c){return new q(a,b,c)},canPlayType:function(a){return k.default.DashSourceHandler.canPlayType(a)}}},k.default.DashSourceHandler.canPlayType=function(a){var b=/^application\/dash\+xml/i;return b.test(a)?"probably":""},i.default.MediaSource&&k.default.getTech("Html5").registerSourceHandler(k.default.DashSourceHandler(),0),k.default.Html5DashJS=q,c.default=q}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./setup-audio-tracks":1,"global/window":3}],3:[function(a,b,c){(function(a){var c;c="undefined"!=typeof window?window:"undefined"!=typeof a?a:"undefined"!=typeof self?self:{},b.exports=c}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[2]); \ No newline at end of file
diff --git a/assets/js/videojs.hotkeys.js b/assets/js/videojs.hotkeys.js
new file mode 100644
index 00000000..fed12206
--- /dev/null
+++ b/assets/js/videojs.hotkeys.js
@@ -0,0 +1,413 @@
+/*
+ * Video.js Hotkeys
+ * https://github.com/ctd1500/videojs-hotkeys
+ *
+ * Copyright (c) 2015 Chris Dougherty
+ * Licensed under the Apache-2.0 license.
+ */
+
+;(function(root, factory) {
+ if (typeof window !== 'undefined' && window.videojs) {
+ factory(window.videojs);
+ } else if (typeof define === 'function' && define.amd) {
+ define('videojs-hotkeys', ['video.js'], function (module) {
+ return factory(module.default || module);
+ });
+ } else if (typeof module !== 'undefined' && module.exports) {
+ module.exports = factory(require('video.js'));
+ }
+}(this, function (videojs) {
+ "use strict";
+ if (typeof window !== 'undefined') {
+ window['videojs_hotkeys'] = { version: "0.2.22" };
+ }
+
+ var hotkeys = function(options) {
+ var player = this;
+ var pEl = player.el();
+ var doc = document;
+ var def_options = {
+ volumeStep: 0.1,
+ seekStep: 5,
+ enableMute: true,
+ enableVolumeScroll: true,
+ enableHoverScroll: true,
+ enableFullscreen: true,
+ enableNumbers: true,
+ enableJogStyle: false,
+ alwaysCaptureHotkeys: false,
+ enableModifiersForNumbers: true,
+ enableInactiveFocus: true,
+ skipInitialFocus: false,
+ playPauseKey: playPauseKey,
+ rewindKey: rewindKey,
+ forwardKey: forwardKey,
+ volumeUpKey: volumeUpKey,
+ volumeDownKey: volumeDownKey,
+ muteKey: muteKey,
+ fullscreenKey: fullscreenKey,
+ customKeys: {}
+ };
+
+ var cPlay = 1,
+ cRewind = 2,
+ cForward = 3,
+ cVolumeUp = 4,
+ cVolumeDown = 5,
+ cMute = 6,
+ cFullscreen = 7;
+
+ // Use built-in merge function from Video.js v5.0+ or v4.4.0+
+ var mergeOptions = videojs.mergeOptions || videojs.util.mergeOptions;
+ options = mergeOptions(def_options, options || {});
+
+ var volumeStep = options.volumeStep,
+ seekStep = options.seekStep,
+ enableMute = options.enableMute,
+ enableVolumeScroll = options.enableVolumeScroll,
+ enableHoverScroll = options.enableHoverScroll,
+ enableFull = options.enableFullscreen,
+ enableNumbers = options.enableNumbers,
+ enableJogStyle = options.enableJogStyle,
+ alwaysCaptureHotkeys = options.alwaysCaptureHotkeys,
+ enableModifiersForNumbers = options.enableModifiersForNumbers,
+ enableInactiveFocus = options.enableInactiveFocus,
+ skipInitialFocus = options.skipInitialFocus;
+
+ // Set default player tabindex to handle keydown and doubleclick events
+ if (!pEl.hasAttribute('tabIndex')) {
+ pEl.setAttribute('tabIndex', '-1');
+ }
+
+ // Remove player outline to fix video performance issue
+ pEl.style.outline = "none";
+
+ if (alwaysCaptureHotkeys || !player.autoplay()) {
+ if (!skipInitialFocus) {
+ player.one('play', function() {
+ pEl.focus(); // Fixes the .vjs-big-play-button handing focus back to body instead of the player
+ });
+ }
+ }
+
+ if (enableInactiveFocus) {
+ player.on('userinactive', function() {
+ // When the control bar fades, re-apply focus to the player if last focus was a control button
+ var cancelFocusingPlayer = function() {
+ clearTimeout(focusingPlayerTimeout);
+ };
+ var focusingPlayerTimeout = setTimeout(function() {
+ player.off('useractive', cancelFocusingPlayer);
+ var activeElement = doc.activeElement;
+ var controlBar = pEl.querySelector('.vjs-control-bar');
+ if (activeElement && activeElement.parentElement == controlBar) {
+ pEl.focus();
+ }
+ }, 10);
+
+ player.one('useractive', cancelFocusingPlayer);
+ });
+ }
+
+ player.on('play', function() {
+ // Fix allowing the YouTube plugin to have hotkey support.
+ var ifblocker = pEl.querySelector('.iframeblocker');
+ if (ifblocker && ifblocker.style.display === '') {
+ ifblocker.style.display = "block";
+ ifblocker.style.bottom = "39px";
+ }
+ });
+
+ var keyDown = function keyDown(event) {
+ var ewhich = event.which, wasPlaying, seekTime;
+ var ePreventDefault = event.preventDefault;
+ var duration = player.duration();
+ // When controls are disabled, hotkeys will be disabled as well
+ if (player.controls()) {
+
+ // Don't catch keys if any control buttons are focused, unless alwaysCaptureHotkeys is true
+ var activeEl = doc.activeElement;
+ if (alwaysCaptureHotkeys ||
+ activeEl == pEl ||
+ activeEl == pEl.querySelector('.vjs-tech') ||
+ activeEl == pEl.querySelector('.vjs-control-bar') ||
+ activeEl == pEl.querySelector('.iframeblocker')) {
+
+ switch (checkKeys(event, player)) {
+ // Spacebar toggles play/pause
+ case cPlay:
+ ePreventDefault();
+ if (alwaysCaptureHotkeys) {
+ // Prevent control activation with space
+ event.stopPropagation();
+ }
+
+ if (player.paused()) {
+ player.play();
+ } else {
+ player.pause();
+ }
+ break;
+
+ // Seeking with the left/right arrow keys
+ case cRewind: // Seek Backward
+ wasPlaying = !player.paused();
+ ePreventDefault();
+ if (wasPlaying) {
+ player.pause();
+ }
+ seekTime = player.currentTime() - seekStepD(event);
+ // The flash player tech will allow you to seek into negative
+ // numbers and break the seekbar, so try to prevent that.
+ if (seekTime <= 0) {
+ seekTime = 0;
+ }
+ player.currentTime(seekTime);
+ if (wasPlaying) {
+ player.play();
+ }
+ break;
+ case cForward: // Seek Forward
+ wasPlaying = !player.paused();
+ ePreventDefault();
+ if (wasPlaying) {
+ player.pause();
+ }
+ seekTime = player.currentTime() + seekStepD(event);
+ // Fixes the player not sending the end event if you
+ // try to seek past the duration on the seekbar.
+ if (seekTime >= duration) {
+ seekTime = wasPlaying ? duration - .001 : duration;
+ }
+ player.currentTime(seekTime);
+ if (wasPlaying) {
+ player.play();
+ }
+ break;
+
+ // Volume control with the up/down arrow keys
+ case cVolumeDown:
+ ePreventDefault();
+ if (!enableJogStyle) {
+ player.volume(player.volume() - volumeStep);
+ } else {
+ seekTime = player.currentTime() - 1;
+ if (player.currentTime() <= 1) {
+ seekTime = 0;
+ }
+ player.currentTime(seekTime);
+ }
+ break;
+ case cVolumeUp:
+ ePreventDefault();
+ if (!enableJogStyle) {
+ player.volume(player.volume() + volumeStep);
+ } else {
+ seekTime = player.currentTime() + 1;
+ if (seekTime >= duration) {
+ seekTime = duration;
+ }
+ player.currentTime(seekTime);
+ }
+ break;
+
+ // Toggle Mute with the M key
+ case cMute:
+ if (enableMute) {
+ player.muted(!player.muted());
+ }
+ break;
+
+ // Toggle Fullscreen with the F key
+ case cFullscreen:
+ if (enableFull) {
+ if (player.isFullscreen()) {
+ player.exitFullscreen();
+ } else {
+ player.requestFullscreen();
+ }
+ }
+ break;
+
+ default:
+ // Number keys from 0-9 skip to a percentage of the video. 0 is 0% and 9 is 90%
+ if ((ewhich > 47 && ewhich < 59) || (ewhich > 95 && ewhich < 106)) {
+ // Do not handle if enableModifiersForNumbers set to false and keys are Ctrl, Cmd or Alt
+ if (enableModifiersForNumbers || !(event.metaKey || event.ctrlKey || event.altKey)) {
+ if (enableNumbers) {
+ var sub = 48;
+ if (ewhich > 95) {
+ sub = 96;
+ }
+ var number = ewhich - sub;
+ ePreventDefault();
+ player.currentTime(player.duration() * number * 0.1);
+ }
+ }
+ }
+
+ // Handle any custom hotkeys
+ for (var customKey in options.customKeys) {
+ var customHotkey = options.customKeys[customKey];
+ // Check for well formed custom keys
+ if (customHotkey && customHotkey.key && customHotkey.handler) {
+ // Check if the custom key's condition matches
+ if (customHotkey.key(event)) {
+ ePreventDefault();
+ customHotkey.handler(player, options, event);
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+
+ var doubleClick = function doubleClick(event) {
+ // When controls are disabled, hotkeys will be disabled as well
+ if (player.controls()) {
+
+ // Don't catch clicks if any control buttons are focused
+ var activeEl = event.relatedTarget || event.toElement || doc.activeElement;
+ if (activeEl == pEl ||
+ activeEl == pEl.querySelector('.vjs-tech') ||
+ activeEl == pEl.querySelector('.iframeblocker')) {
+
+ if (enableFull) {
+ if (player.isFullscreen()) {
+ player.exitFullscreen();
+ } else {
+ player.requestFullscreen();
+ }
+ }
+ }
+ }
+ };
+
+ var volumeHover = false;
+ var volumeSelector = pEl.querySelector('.vjs-volume-menu-button') || pEl.querySelector('.vjs-volume-panel');
+ volumeSelector.onmouseover = function() { volumeHover = true; }
+ volumeSelector.onmouseout = function() { volumeHover = false; }
+
+ var mouseScroll = function mouseScroll(event) {
+ if (enableHoverScroll) {
+ // If we leave this undefined then it can match non-existent elements below
+ var activeEl = 0;
+ } else {
+ var activeEl = doc.activeElement;
+ }
+
+ // When controls are disabled, hotkeys will be disabled as well
+ if (player.controls()) {
+ if (alwaysCaptureHotkeys ||
+ activeEl == pEl ||
+ activeEl == pEl.querySelector('.vjs-tech') ||
+ activeEl == pEl.querySelector('.iframeblocker') ||
+ activeEl == pEl.querySelector('.vjs-control-bar') ||
+ volumeHover) {
+
+ if (enableVolumeScroll) {
+ event = window.event || event;
+ var delta = Math.max(-1, Math.min(1, (event.wheelDelta || -event.detail)));
+ event.preventDefault();
+
+ if (delta == 1) {
+ player.volume(player.volume() + volumeStep);
+ } else if (delta == -1) {
+ player.volume(player.volume() - volumeStep);
+ }
+ }
+ }
+ }
+ };
+
+ var checkKeys = function checkKeys(e, player) {
+ // Allow some modularity in defining custom hotkeys
+
+ // Play/Pause check
+ if (options.playPauseKey(e, player)) {
+ return cPlay;
+ }
+
+ // Seek Backward check
+ if (options.rewindKey(e, player)) {
+ return cRewind;
+ }
+
+ // Seek Forward check
+ if (options.forwardKey(e, player)) {
+ return cForward;
+ }
+
+ // Volume Up check
+ if (options.volumeUpKey(e, player)) {
+ return cVolumeUp;
+ }
+
+ // Volume Down check
+ if (options.volumeDownKey(e, player)) {
+ return cVolumeDown;
+ }
+
+ // Mute check
+ if (options.muteKey(e, player)) {
+ return cMute;
+ }
+
+ // Fullscreen check
+ if (options.fullscreenKey(e, player)) {
+ return cFullscreen;
+ }
+ };
+
+ function playPauseKey(e) {
+ // Space bar or MediaPlayPause
+ return (e.which === 32 || e.which === 179);
+ }
+
+ function rewindKey(e) {
+ // Left Arrow or MediaRewind
+ return (e.which === 37 || e.which === 177);
+ }
+
+ function forwardKey(e) {
+ // Right Arrow or MediaForward
+ return (e.which === 39 || e.which === 176);
+ }
+
+ function volumeUpKey(e) {
+ // Up Arrow
+ return (e.which === 38);
+ }
+
+ function volumeDownKey(e) {
+ // Down Arrow
+ return (e.which === 40);
+ }
+
+ function muteKey(e) {
+ // M key
+ return (e.which === 77);
+ }
+
+ function fullscreenKey(e) {
+ // F key
+ return (e.which === 70);
+ }
+
+ function seekStepD(e) {
+ // SeekStep caller, returns an int, or a function returning an int
+ return (typeof seekStep === "function" ? seekStep(e) : seekStep);
+ }
+
+ player.on('keydown', keyDown);
+ player.on('dblclick', doubleClick);
+ player.on('mousewheel', mouseScroll);
+ player.on("DOMMouseScroll", mouseScroll);
+
+ return this;
+ };
+
+ var registerPlugin = videojs.registerPlugin || videojs.plugin;
+ registerPlugin('hotkeys', hotkeys);
+}));
diff --git a/src/invidious.cr b/src/invidious.cr
index c7de22fb..96af04fa 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -188,6 +188,10 @@ get "/" do |env|
templated "index"
end
+get "/licenses" do |env|
+ rendered "licenses"
+end
+
# Videos
get "/:id" do |env|
@@ -278,9 +282,7 @@ get "/watch" do |env|
if source == "youtube"
begin
- comments = fetch_youtube_comments(id, "", proxies, "html")
- comments = JSON.parse(comments)
- comment_html = template_youtube_comments(comments)
+ comment_html = JSON.parse(fetch_youtube_comments(id, "", proxies, "html"))["contentHtml"]
rescue ex
if preferences.comments[1] == "reddit"
comments, reddit_thread = fetch_reddit_comments(id)
@@ -299,16 +301,12 @@ get "/watch" do |env|
comment_html = replace_links(comment_html)
rescue ex
if preferences.comments[1] == "youtube"
- comments = fetch_youtube_comments(id, "", proxies, "html")
- comments = JSON.parse(comments)
- comment_html = template_youtube_comments(comments)
+ comment_html = JSON.parse(fetch_youtube_comments(id, "", proxies, "html"))["contentHtml"]
end
end
end
else
- comments = fetch_youtube_comments(id, "", proxies, "html")
- comments = JSON.parse(comments)
- comment_html = template_youtube_comments(comments)
+ comment_html = JSON.parse(fetch_youtube_comments(id, "", proxies, "html"))["contentHtml"]
end
comment_html ||= ""
@@ -961,6 +959,10 @@ post "/preferences" do |env|
autoplay ||= "off"
autoplay = autoplay == "on"
+ continue = env.params.body["continue"]?.try &.as(String)
+ continue ||= "off"
+ continue = continue == "on"
+
listen = env.params.body["listen"]?.try &.as(String)
listen ||= "off"
listen = listen == "on"
@@ -1020,6 +1022,7 @@ post "/preferences" do |env|
preferences = {
"video_loop" => video_loop,
"autoplay" => autoplay,
+ "continue" => continue,
"listen" => listen,
"speed" => speed,
"quality" => quality,
@@ -2041,26 +2044,7 @@ get "/api/v1/comments/:id" do |env|
halt env, status_code: 500, response: error_message
end
- if format == "json"
- next comments
- else
- comments = JSON.parse(comments)
- content_html = template_youtube_comments(comments)
-
- response = JSON.build do |json|
- json.object do
- json.field "contentHtml", content_html
-
- if comments["commentCount"]?
- json.field "commentCount", comments["commentCount"]
- else
- json.field "commentCount", 0
- end
- end
- end
-
- next response
- end
+ next comments
elsif source == "reddit"
begin
comments, reddit_thread = fetch_reddit_comments(id)
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr
index a699aaac..f4398b58 100644
--- a/src/invidious/comments.cr
+++ b/src/invidious/comments.cr
@@ -58,7 +58,7 @@ end
def fetch_youtube_comments(id, continuation, proxies, format)
client = make_client(YT_URL)
- html = client.get("/watch?v=#{id}&bpctr=#{Time.new.to_unix + 2000}&gl=US&hl=en&disable_polymer=1")
+ html = client.get("/watch?v=#{id}&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999")
headers = HTTP::Headers.new
headers["cookie"] = html.cookies.add_request_headers(headers)["cookie"]
body = html.body
@@ -83,7 +83,7 @@ def fetch_youtube_comments(id, continuation, proxies, format)
proxy = HTTPProxy.new(proxy_host: proxy[:ip], proxy_port: proxy[:port])
proxy_client.set_proxy(proxy)
- response = proxy_client.get("/watch?v=#{id}&bpctr=#{Time.new.to_unix + 2000}&gl=US&hl=en&disable_polymer=1")
+ response = proxy_client.get("/watch?v=#{id}&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999")
proxy_headers = HTTP::Headers.new
proxy_headers["cookie"] = response.cookies.add_request_headers(headers)["cookie"]
proxy_html = response.body
@@ -140,8 +140,8 @@ def fetch_youtube_comments(id, continuation, proxies, format)
headers["content-type"] = "application/x-www-form-urlencoded"
headers["x-client-data"] = "CIi2yQEIpbbJAQipncoBCNedygEIqKPKAQ=="
- headers["x-spf-previous"] = "https://www.youtube.com/watch?v=#{id}&bpctr=#{Time.new.to_unix + 2000}&gl=US&hl=en&disable_polymer=1"
- headers["x-spf-referer"] = "https://www.youtube.com/watch?v=#{id}&bpctr=#{Time.new.to_unix + 2000}&gl=US&hl=en&disable_polymer=1"
+ headers["x-spf-previous"] = "https://www.youtube.com/watch?v=#{id}&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999"
+ headers["x-spf-referer"] = "https://www.youtube.com/watch?v=#{id}&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999"
headers["x-youtube-client-name"] = "1"
headers["x-youtube-client-version"] = "2.20180719"
@@ -264,6 +264,23 @@ def fetch_youtube_comments(id, continuation, proxies, format)
end
end
+ if format == "html"
+ comments = JSON.parse(comments)
+ content_html = template_youtube_comments(comments)
+
+ comments = JSON.build do |json|
+ json.object do
+ json.field "contentHtml", content_html
+
+ if comments["commentCount"]?
+ json.field "commentCount", comments["commentCount"]
+ else
+ json.field "commentCount", 0
+ end
+ end
+ end
+ end
+
return comments
end
diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr
index 877a9d32..92a2e1b1 100644
--- a/src/invidious/helpers/helpers.cr
+++ b/src/invidious/helpers/helpers.cr
@@ -389,55 +389,3 @@ def extract_items(nodeset, ucid = nil)
return items
end
-
-def create_response(user_id, operation, key, expire = 6.hours)
- expire = Time.now + expire
- nonce = Random::Secure.hex(4)
-
- challenge = "#{expire.to_unix}-#{nonce}-#{user_id}-#{operation}"
- token = OpenSSL::HMAC.digest(:sha256, key, challenge)
-
- challenge = Base64.urlsafe_encode(challenge)
- token = Base64.urlsafe_encode(token)
-
- return challenge, token
-end
-
-def validate_response(challenge, token, user_id, operation, key)
- if !challenge
- raise "Hidden field \"challenge\" is a required field"
- end
-
- if !token
- raise "Hidden field \"token\" is a required field"
- end
-
- challenge = Base64.decode_string(challenge)
- if challenge.split("-").size == 4
- expire, nonce, challenge_user_id, challenge_operation = challenge.split("-")
-
- expire = expire.to_i?
- expire ||= 0
- else
- raise "Invalid challenge"
- end
-
- challenge = OpenSSL::HMAC.digest(:sha256, HMAC_KEY, challenge)
- challenge = Base64.urlsafe_encode(challenge)
-
- if challenge != token
- raise "Invalid token"
- end
-
- if challenge_operation != operation
- raise "Invalid token"
- end
-
- if challenge_user_id != user_id
- raise "Invalid token"
- end
-
- if expire < Time.now.to_unix
- raise "Token is expired, please try again"
- end
-end
diff --git a/src/invidious/mixes.cr b/src/invidious/mixes.cr
index 66f7371d..688a8622 100644
--- a/src/invidious/mixes.cr
+++ b/src/invidious/mixes.cr
@@ -26,7 +26,7 @@ def fetch_mix(rdid, video_id, cookies = nil)
if cookies
headers = cookies.add_request_headers(headers)
end
- response = client.get("/watch?v=#{video_id}&list=#{rdid}&bpctr=#{Time.new.to_unix + 2000}&gl=US&hl=en", headers)
+ response = client.get("/watch?v=#{video_id}&list=#{rdid}&gl=US&hl=en&has_verified=1&bpctr=9999999999", headers)
yt_data = response.body.match(/window\["ytInitialData"\] = (?<data>.*);/)
if yt_data
diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr
index cc149ea8..c1adb1d9 100644
--- a/src/invidious/playlists.cr
+++ b/src/invidious/playlists.cr
@@ -30,7 +30,7 @@ def fetch_playlist_videos(plid, page, video_count, continuation = nil)
client = make_client(YT_URL)
if continuation
- html = client.get("/watch?v=#{continuation}&list=#{plid}&bpctr=#{Time.new.to_unix + 2000}&gl=US&hl=en&disable_polymer=1")
+ html = client.get("/watch?v=#{continuation}&list=#{plid}&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999")
html = XML.parse_html(html.body)
index = html.xpath_node(%q(//span[@id="playlist-current-index"])).try &.content.to_i?
diff --git a/src/invidious/users.cr b/src/invidious/users.cr
index b354306f..113fa1c2 100644
--- a/src/invidious/users.cr
+++ b/src/invidious/users.cr
@@ -70,7 +70,11 @@ class Preferences
JSON.mapping({
video_loop: Bool,
autoplay: Bool,
- listen: {
+ continue: {
+ type: Bool,
+ default: false,
+ },
+ listen: {
type: Bool,
default: false,
},
@@ -195,3 +199,55 @@ def create_user(sid, email, password)
return user
end
+
+def create_response(user_id, operation, key, expire = 6.hours)
+ expire = Time.now + expire
+ nonce = Random::Secure.hex(4)
+
+ challenge = "#{expire.to_unix}-#{nonce}-#{user_id}-#{operation}"
+ token = OpenSSL::HMAC.digest(:sha256, key, challenge)
+
+ challenge = Base64.urlsafe_encode(challenge)
+ token = Base64.urlsafe_encode(token)
+
+ return challenge, token
+end
+
+def validate_response(challenge, token, user_id, operation, key)
+ if !challenge
+ raise "Hidden field \"challenge\" is a required field"
+ end
+
+ if !token
+ raise "Hidden field \"token\" is a required field"
+ end
+
+ challenge = Base64.decode_string(challenge)
+ if challenge.split("-").size == 4
+ expire, nonce, challenge_user_id, challenge_operation = challenge.split("-")
+
+ expire = expire.to_i?
+ expire ||= 0
+ else
+ raise "Invalid challenge"
+ end
+
+ challenge = OpenSSL::HMAC.digest(:sha256, HMAC_KEY, challenge)
+ challenge = Base64.urlsafe_encode(challenge)
+
+ if challenge != token
+ raise "Invalid token"
+ end
+
+ if challenge_operation != operation
+ raise "Invalid token"
+ end
+
+ if challenge_user_id != user_id
+ raise "Invalid token"
+ end
+
+ if expire < Time.now.to_unix
+ raise "Token is expired, please try again"
+ end
+end
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index eaf2e17a..64e817dd 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -546,7 +546,7 @@ def fetch_video(id, proxies)
spawn do
client = make_client(YT_URL)
- html = client.get("/watch?v=#{id}&bpctr=#{Time.new.to_unix + 2000}&gl=US&hl=en&disable_polymer=1")
+ html = client.get("/watch?v=#{id}&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999")
if md = html.headers["location"]?.try &.match(/v=(?<id>[a-zA-Z0-9_-]{11})/)
next html_channel.send(md["id"])
@@ -620,7 +620,7 @@ def fetch_video(id, proxies)
client.connect_timeout = 10.seconds
client.set_proxy(proxy)
- html = XML.parse_html(client.get("/watch?v=#{id}&bpctr=#{Time.new.to_unix + 2000}&gl=US&hl=en&disable_polymer=1").body)
+ html = XML.parse_html(client.get("/watch?v=#{id}&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999").body)
info = HTTP::Params.parse(client.get("/get_video_info?video_id=#{id}&el=detailpage&ps=default&eurl=&gl=US&hl=en&disable_polymer=1").body)
if info["reason"]?
@@ -641,7 +641,19 @@ def fetch_video(id, proxies)
end
if info["reason"]?
- raise info["reason"]
+ html_info = html.to_s.match(/ytplayer\.config = (?<info>.*?);ytplayer\.load/).try &.["info"]
+ if html_info
+ html_info = JSON.parse(html_info)["args"].as_h
+ info.delete("reason")
+
+ html_info.each do |k, v|
+ info[k] = v.to_s
+ end
+ end
+
+ if info["reason"]?
+ raise info["reason"]
+ end
end
title = info["title"]
@@ -680,8 +692,7 @@ def fetch_video(id, proxies)
genre_url = "/channel/UClgRkhTL3_hImCAmdLfDE4g"
when "Education"
# Education channel is linked but does not exist
- # genre_url = "/channel/UC3yA8nDwraeOfnYfBWun83g"
- genre_url = ""
+ genre_url = "/channel/UC3yA8nDwraeOfnYfBWun83g"
end
genre_url ||= ""
@@ -718,6 +729,7 @@ end
def process_video_params(query, preferences)
autoplay = query["autoplay"]?.try &.to_i?
+ continue = query["continue"]?.try &.to_i?
listen = query["listen"]? && (query["listen"] == "true" || query["listen"] == "1").to_unsafe
preferred_captions = query["subtitles"]?.try &.split(",").map { |a| a.downcase }
quality = query["quality"]?
@@ -727,6 +739,7 @@ def process_video_params(query, preferences)
if preferences
autoplay ||= preferences.autoplay.to_unsafe
+ continue ||= preferences.continue.to_unsafe
listen ||= preferences.listen.to_unsafe
preferred_captions ||= preferences.captions
quality ||= preferences.quality
@@ -736,6 +749,7 @@ def process_video_params(query, preferences)
end
autoplay ||= 0
+ continue ||= 0
listen ||= 0
preferred_captions ||= [] of String
quality ||= "hd720"
@@ -744,6 +758,7 @@ def process_video_params(query, preferences)
volume ||= 100
autoplay = autoplay == 1
+ continue = continue == 1
listen = listen == 1
video_loop = video_loop == 1
@@ -774,6 +789,7 @@ def process_video_params(query, preferences)
params = {
autoplay: autoplay,
+ continue: continue,
controls: controls,
listen: listen,
preferred_captions: preferred_captions,
diff --git a/src/invidious/views/components/player.ecr b/src/invidious/views/components/player.ecr
index 0dbdb05f..51f7182a 100644
--- a/src/invidious/views/components/player.ecr
+++ b/src/invidious/views/components/player.ecr
@@ -1,5 +1,6 @@
<video style="width:100%" playsinline poster="<%= thumbnail %>" title="<%= HTML.escape(video.title) %>"
id="player" class="video-js"
+ onmouseenter='this["title"]=""'
<% if params[:autoplay] %>autoplay<% end %>
<% if params[:video_loop] %>loop<% end %>
<% if params[:controls] %>controls<% end %>>
diff --git a/src/invidious/views/licenses.ecr b/src/invidious/views/licenses.ecr
new file mode 100644
index 00000000..4ceff3f4
--- /dev/null
+++ b/src/invidious/views/licenses.ecr
@@ -0,0 +1,153 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+</head>
+
+<body>
+ <h1>JavaScript license information</h1>
+ <table id="jslicense-labels1">
+ <tr>
+ <td>
+ <a href="/js/dash.mediaplayer.min.js">dash.mediaplayer.min.js</a>
+ </td>
+
+ <td>
+ <a href="http://directory.fsf.org/wiki/License:BSD_3Clause">Modified-BSD</a>
+ </td>
+
+ <td>
+ <a href="https://unpkg.com/dashjs@2.9.0/dist/dash.mediaplayer.debug.js">source</a>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="/js/silvermine-videojs-quality-selector.min.js">silvermine-videojs-quality-selector.min.js</a>
+ </td>
+
+ <td>
+ <a href="http://www.jclark.com/xml/copying.txt">Expat</a>
+ </td>
+
+ <td>
+ <a href="/js/silvermine-videojs-quality-selector.js">source</a>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="/js/video.min.js">video.min.js</a>
+ </td>
+
+ <td>
+ <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache-2.0-only</a>
+ </td>
+
+ <td>
+ <a href="https://unpkg.com/video.js@6.12.1/dist/video.js">source</a>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="/js/videojs-contrib-quality-levels.min.js">videojs-contrib-quality-levels.min.js</a>
+ </td>
+
+ <td>
+ <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache-2.0-only</a>
+ </td>
+
+ <td>
+ <a href="https://unpkg.com/videojs-contrib-quality-levels@2.0.7/dist/videojs-contrib-quality-levels.js">source</a>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="/js/videojs-dash.min.js">videojs-dash.min.js</a>
+ </td>
+
+ <td>
+ <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache-2.0-only</a>
+ </td>
+
+ <td>
+ <a href="https://unpkg.com/videojs-contrib-dash@2.8.2/dist/videojs-dash.js">source</a>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="/js/videojs-http-streaming.min.js">videojs-http-streaming.min.js</a>
+ </td>
+
+ <td>
+ <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache-2.0-only</a>
+ </td>
+
+ <td>
+ <a href="https://unpkg.com/@videojs/http-streaming@1.2.2/dist/videojs-http-streaming.js">source</a>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="/js/videojs-markers.min.js">videojs-markers.min.js</a>
+ </td>
+
+ <td>
+ <a href="http://www.jclark.com/xml/copying.txt">Expat</a>
+ </td>
+
+ <td>
+ <a href="https://unpkg.com/videojs-markers@1.0.1/dist/videojs-markers.js">source</a>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="/js/videojs-share.min.js">videojs-share.min.js</a>
+ </td>
+
+ <td>
+ <a href="http://www.jclark.com/xml/copying.txt">Expat</a>
+ </td>
+
+ <td>
+ <a href="https://unpkg.com/videojs-share@2.0.1/dist/videojs-share.js">source</a>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="/js/videojs.hotkeys.min.js">videojs.hotkeys.min.js</a>
+ </td>
+
+ <td>
+ <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache-2.0-only</a>
+ </td>
+
+ <td>
+ <a href="/js/videojs.hotkeys.js">source</a>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <a href="/js/watch.js">watch.js</a>
+ </td>
+
+ <td>
+ <a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU-AGPL-3.0-or-later</a>
+ </td>
+
+ <td>
+ <a href="/js/watch.js">source</a>
+ </td>
+ </tr>
+ </table>
+</body>
+</html> \ No newline at end of file
diff --git a/src/invidious/views/preferences.ecr b/src/invidious/views/preferences.ecr
index 72b1d609..f7da7540 100644
--- a/src/invidious/views/preferences.ecr
+++ b/src/invidious/views/preferences.ecr
@@ -24,6 +24,11 @@ function update_value(element) {
</div>
<div class="pure-control-group">
+ <label for="continue">Automatically play next video: </label>
+ <input name="continue" id="continue" type="checkbox" <% if user.preferences.continue %>checked<% end %>>
+ </div>
+
+ <div class="pure-control-group">
<label for="listen">Listen by default: </label>
<input name="listen" id="listen" type="checkbox" <% if user.preferences.listen %>checked<% end %>>
</div>
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index a6191d36..748a691f 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -92,6 +92,7 @@
</p>
<p>BTC: 356DpZyMXu6rYd55Yqzjs29n79kGKWcYrY</p>
<p>BCH: qq4ptclkzej5eza6a50et5ggc58hxsq5aylqut2npk</p>
+ <p>View <a rel="jslicense" href="/licenses">JavaScript license information</a>.</p>
</div>
</div>
<div class="pure-u-1 pure-u-md-2-24"></div>
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr
index f9d98681..ba3692e2 100644
--- a/src/invidious/views/watch.ecr
+++ b/src/invidious/views/watch.ecr
@@ -140,6 +140,15 @@
<% if !preferences || preferences && preferences.related_videos %>
<div class="h-box">
+
+ <% if !plid && !rvs.empty? %>
+ <div class="pure-control-group">
+ <label for="continue">Autoplay next video: </label>
+ <input name="continue" onclick="continue_autoplay(this)" id="continue" type="checkbox" <% if params[:continue] %>checked<% end %>>
+ </div>
+ <hr>
+ <% end %>
+
<% rvs.each do |rv| %>
<% if rv.has_key?("id") %>
<a href="/watch?v=<%= rv["id"] %>">
@@ -163,6 +172,46 @@
</div>
<script>
+<% if !rvs.empty? && !plid && params[:continue] %>
+player.on('ended', function() {
+ window.location.replace("/watch?v="
+ + "<%= rvs[0]?.try &.["id"] %>"
+ + "&continue=1"
+ <% if params[:listen] %>
+ + "&listen=1"
+ <% end %>
+ <% if params[:autoplay] %>
+ + "&autoplay=1"
+ <% end %>
+ <% if params[:speed] %>
+ + "&speed=<%= params[:speed] %>"
+ <% end %>
+ );
+});
+<% end %>
+
+function continue_autoplay(target) {
+ if (target.checked) {
+ player.on('ended', function() {
+ window.location.replace("/watch?v="
+ + "<%= rvs[0]?.try &.["id"] %>"
+ + "&continue=1"
+ <% if params[:listen] %>
+ + "&listen=1"
+ <% end %>
+ <% if params[:autoplay] %>
+ + "&autoplay=1"
+ <% end %>
+ <% if params[:speed] %>
+ + "&speed=<%= params[:speed] %>"
+ <% end %>
+ );
+ });
+ } else {
+ player.off('ended');
+ }
+}
+
function number_with_separator(val) {
while (/(\d+)(\d{3})/.test(val.toString())) {
val = val.toString().replace(/(\d+)(\d{3})/, "$1" + "," + "$2");