UNPKG

15.2 kBJavaScriptView Raw
1(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.MDB=e()}})(function(){var e,t,r;return function o(e,t,r){function i(n,a){if(!t[n]){if(!e[n]){var u=typeof require=="function"&&require;if(!a&&u)return u(n,!0);if(s)return s(n,!0);var c=new Error("Cannot find module '"+n+"'");throw c.code="MODULE_NOT_FOUND",c}var h=t[n]={exports:{}};e[n][0].call(h.exports,function(t){var r=e[n][1][t];return i(r?r:t)},h,h.exports,o,e,t,r)}return t[n].exports}var s=typeof require=="function"&&require;for(var n=0;n<r.length;n++)i(r[n]);return i}({1:[function(e,t,r){t.exports=e("./lib/moviedb")},{"./lib/moviedb":3}],2:[function(e,t,r){t.exports={base_url:"https://api.themoviedb.org/3/",authentication:{requestToken:"authentication/token/new",sessionId:"authentication/session/new"},methods:{configuration:{"":{resource:"configuration",method:"get"}},find:{"":{resource:"find/:id",method:"get"}},search:{Movie:{resource:"search/movie",method:"get"},Tv:{resource:"search/tv",method:"get"},Multi:{resource:"search/multi",method:"get"},Collection:{resource:"search/collection",method:"get"},Person:{resource:"search/person",method:"get"},List:{resource:"search/list",method:"get"},Company:{resource:"search/company",method:"get"},Keyword:{resource:"search/keyword",method:"get"}},collection:{Info:{resource:"collection/:id",method:"get"},Images:{resource:"collection/:id/images",method:"get"}},discover:{Movie:{resource:"discover/movie",method:"get"},Tv:{resource:"discover/tv",method:"get"}},movie:{Info:{resource:"movie/:id",method:"get"},AlternativeTitles:{resource:"movie/:id/alternative_titles",method:"get"},Credits:{resource:"movie/:id/credits",method:"get"},Images:{resource:"movie/:id/images",method:"get"},Videos:{resource:"movie/:id/videos",method:"get"},Keywords:{resource:"movie/:id/keywords",method:"get"},Releases:{resource:"movie/:id/releases",method:"get"},Trailers:{resource:"movie/:id/trailers",method:"get"},Translations:{resource:"movie/:id/translations",method:"get"},Similar:{resource:"movie/:id/similar_movies",method:"get"},Reviews:{resource:"movie/:id/reviews",method:"get"},Lists:{resource:"movie/:id/lists",method:"get"},Changes:{resource:"movie/:id/changes",method:"get"},RatingUpdate:{resource:"movie/:id/rating",method:"post"}},tv:{Info:{resource:"tv/:id",method:"get"},Credits:{resource:"tv/:id/credits",method:"get"},ExternalIds:{resource:"tv/:id/external_ids",method:"get"},Images:{resource:"tv/:id/images",method:"get"},Videos :{"resource":"tv/:id/videos","method":"get"},Similar:{"resource":"tv/:id/similar","method":"get"},Translations:{resource:"tv/:id/translations",method:"get"},SeasonInfo:{resource:"tv/:id/season/:season_number",method:"get"},SeasonCredits:{resource:"tv/:id/season/:season_number/credits",method:"get"},SeasonExternalIds:{resource:"tv/:id/season/:season_number/external_ids",method:"get"},SeasonImages:{resource:"tv/:id/season/:season_number/images",method:"get"},EpisodeInfo:{resource:"tv/:id/season/:season_number/episode/:episode_number",method:"get"},EpisodeCredits:{resource:"tv/:id/season/:season_number/episode/:episode_number/credits",method:"get"},EpisodeExternalIds:{resource:"tv/:id/season/:season_number/episode/:episode_number/external_ids",method:"get"},EpisodeImages:{resource:"tv/:id/season/:season_number/episode/:episode_number/images",method:"get"}},person:{Info:{resource:"person/:id",method:"get"},Credits:{resource:"person/:id/credits",method:"get"},CombinedCredits:{resource:"person/:id/combined_credits",method:"get"},Images:{resource:"person/:id/images",method:"get"},Changes:{resource:"person/:id/changes",method:"get"},Latest:{resource:"person/latest",method:"get"},Popular:{resource:"person/popular",method:"get"}},list:{Info:{resource:"list/:id",method:"get"}},genre:{List:{resource:"genre/list",method:"get"},Movies:{resource:"genre/:id/movies",method:"get"}},keyword:{Info:{resource:"keyword/:id",method:"get"},Movies:{resource:"keyword/:id/movies",method:"get"}},company:{Info:{resource:"company/:id",method:"get"},Movies:{resource:"company/:id/movies",method:"get"}},account:{Info:{resource:"account",method:"get"},Lists:{resource:"account/:id/lists",method:"get"},FavoriteMovies:{resource:"account/:id/favorite_movies",method:"get"},FavoriteUpdate:{resource:"account/:id/favorite",method:"post"},RatedMovies:{resource:"account/:id/rated_movies",method:"get"},MovieWatchlist:{resource:"account/:id/movie_watchlist",method:"get"},MovieWatchlistUpdate:{resource:"account/:id/movie_watchlist",method:"post"}},misc:{LatestMovies:{resource:"movie/latest",method:"get"},UpcomingMovies:{resource:"movie/upcoming",method:"get"},NowPlayingMovies:{resource:"movie/now_playing",method:"get"},PopularMovies:{resource:"movie/popular",method:"get"},TopRatedMovies:{resource:"movie/top_rated",method:"get"},ChangedMovies:{resource:"movie/changes",method:"get"},ChangedPeople:{resource:"person/changes",method:"get"},TopRatedTvs:{resource:"tv/top_rated",method:"get"},PopularTvs:{resource:"tv/popular",method:"get"}}}}},{}],3:[function(e,t,r){var o=e("superagent"),i=e("./endpoints.json");t.exports=function(e,t){if(e)return new s(e,t);else throw new Error("Bad api key")};function s(e,t){this.api_key=e;if(t)i.base_url=t;return this}s.prototype.requestToken=function(e){var t=this;o.get(i.base_url+i.authentication.requestToken).query({api_key:t.api_key}).set("Accept","application/json").end(function(r){if(r.ok)t.token=r.body;else throw r.error;e()}).on("error",function(e){throw e});return this};Object.keys(i.methods).forEach(function(e){var t=i.methods[e];Object.keys(t).forEach(function(r){s.prototype[e+r]=function(e,o){var i=this;if("function"==typeof e){o=e;e={}}if(!this.token||Date.now()>+new Date(this.token.expires_at)){this.requestToken(function(){n.call(i,t[r].method,e,t[r].resource,o)})}else{n.call(this,t[r].method,e,t[r].resource,o)}return this}})});var n=function(e,t,r,s){t=t||{};r=r.replace(":id",t.id).replace(":season_number",t.season_number).replace(":episode_number",t.episode_number);e=e.toUpperCase();var n=o(e,i.base_url+r).query({api_key:this.api_key}).set("Accept","application/json");if(e==="GET")n.query(t);else n.send(t);n.end(function(e){if(e.ok)s(null,e.body);else s(e.error,null)});n.on("error",s)}},{"./endpoints.json":2,superagent:4}],4:[function(e,t,r){var o=e("emitter");var i=e("reduce");var s="undefined"==typeof window?this:window;function n(){}function a(e){var t={}.toString.call(e);switch(t){case"[object File]":case"[object Blob]":case"[object FormData]":return true;default:return false}}function u(){if(s.XMLHttpRequest&&("file:"!=s.location.protocol||!s.ActiveXObject)){return new XMLHttpRequest}else{try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){}}return false}var c="".trim?function(e){return e.trim()}:function(e){return e.replace(/(^\s*|\s*$)/g,"")};function h(e){return e===Object(e)}function d(e){if(!h(e))return e;var t=[];for(var r in e){if(null!=e[r]){t.push(encodeURIComponent(r)+"="+encodeURIComponent(e[r]))}}return t.join("&")}y.serializeObject=d;function l(e){var t={};var r=e.split("&");var o;var i;for(var s=0,n=r.length;s<n;++s){i=r[s];o=i.split("=");t[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return t}y.parseString=l;y.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"};y.serialize={"application/x-www-form-urlencoded":d,"application/json":JSON.stringify};y.parse={"application/x-www-form-urlencoded":l,"application/json":JSON.parse};function p(e){var t=e.split(/\r?\n/);var r={};var o;var i;var s;var n;t.pop();for(var a=0,u=t.length;a<u;++a){i=t[a];o=i.indexOf(":");s=i.slice(0,o).toLowerCase();n=c(i.slice(o+1));r[s]=n}return r}function f(e){return e.split(/ *; */).shift()}function m(e){return i(e.split(/ *; */),function(e,t){var r=t.split(/ *= */),o=r.shift(),i=r.shift();if(o&&i)e[o]=i;return e},{})}function v(e,t){t=t||{};this.req=e;this.xhr=this.req.xhr;this.text=this.xhr.responseText;this.setStatusProperties(this.xhr.status);this.header=this.headers=p(this.xhr.getAllResponseHeaders());this.header["content-type"]=this.xhr.getResponseHeader("content-type");this.setHeaderProperties(this.header);this.body=this.req.method!="HEAD"?this.parseBody(this.text):null}v.prototype.get=function(e){return this.header[e.toLowerCase()]};v.prototype.setHeaderProperties=function(e){var t=this.header["content-type"]||"";this.type=f(t);var r=m(t);for(var o in r)this[o]=r[o]};v.prototype.parseBody=function(e){var t=y.parse[this.type];return t&&e&&e.length?t(e):null};v.prototype.setStatusProperties=function(e){var t=e/100|0;this.status=e;this.statusType=t;this.info=1==t;this.ok=2==t;this.clientError=4==t;this.serverError=5==t;this.error=4==t||5==t?this.toError():false;this.accepted=202==e;this.noContent=204==e||1223==e;this.badRequest=400==e;this.unauthorized=401==e;this.notAcceptable=406==e;this.notFound=404==e;this.forbidden=403==e};v.prototype.toError=function(){var e=this.req;var t=e.method;var r=e.url;var o="cannot "+t+" "+r+" ("+this.status+")";var i=new Error(o);i.status=this.status;i.method=t;i.url=r;return i};y.Response=v;function g(e,t){var r=this;o.call(this);this._query=this._query||[];this.method=e;this.url=t;this.header={};this._header={};this.on("end",function(){try{var t=new v(r);if("HEAD"==e)t.text=null;r.callback(null,t)}catch(o){var i=new Error("Parser is unable to parse the response");i.parse=true;i.original=o;r.callback(i)}})}o(g.prototype);g.prototype.use=function(e){e(this);return this};g.prototype.timeout=function(e){this._timeout=e;return this};g.prototype.clearTimeout=function(){this._timeout=0;clearTimeout(this._timer);return this};g.prototype.abort=function(){if(this.aborted)return;this.aborted=true;this.xhr.abort();this.clearTimeout();this.emit("abort");return this};g.prototype.set=function(e,t){if(h(e)){for(var r in e){this.set(r,e[r])}return this}this._header[e.toLowerCase()]=t;this.header[e]=t;return this};g.prototype.unset=function(e){delete this._header[e.toLowerCase()];delete this.header[e];return this};g.prototype.getHeader=function(e){return this._header[e.toLowerCase()]};g.prototype.type=function(e){this.set("Content-Type",y.types[e]||e);return this};g.prototype.accept=function(e){this.set("Accept",y.types[e]||e);return this};g.prototype.auth=function(e,t){var r=btoa(e+":"+t);this.set("Authorization","Basic "+r);return this};g.prototype.query=function(e){if("string"!=typeof e)e=d(e);if(e)this._query.push(e);return this};g.prototype.field=function(e,t){if(!this._formData)this._formData=new FormData;this._formData.append(e,t);return this};g.prototype.attach=function(e,t,r){if(!this._formData)this._formData=new FormData;this._formData.append(e,t,r);return this};g.prototype.send=function(e){var t=h(e);var r=this.getHeader("Content-Type");if(t&&h(this._data)){for(var o in e){this._data[o]=e[o]}}else if("string"==typeof e){if(!r)this.type("form");r=this.getHeader("Content-Type");if("application/x-www-form-urlencoded"==r){this._data=this._data?this._data+"&"+e:e}else{this._data=(this._data||"")+e}}else{this._data=e}if(!t)return this;if(!r)this.type("json");return this};g.prototype.callback=function(e,t){var r=this._callback;if(2==r.length)return r(e,t);if(e)return this.emit("error",e);r(t)};g.prototype.crossDomainError=function(){var e=new Error("Origin is not allowed by Access-Control-Allow-Origin");e.crossDomain=true;this.callback(e)};g.prototype.timeoutError=function(){var e=this._timeout;var t=new Error("timeout of "+e+"ms exceeded");t.timeout=e;this.callback(t)};g.prototype.withCredentials=function(){this._withCredentials=true;return this};g.prototype.end=function(e){var t=this;var r=this.xhr=u();var o=this._query.join("&");var i=this._timeout;var s=this._formData||this._data;this._callback=e||n;r.onreadystatechange=function(){if(4!=r.readyState)return;if(0==r.status){if(t.aborted)return t.timeoutError();return t.crossDomainError()}t.emit("end")};if(r.upload){r.upload.onprogress=function(e){e.percent=e.loaded/e.total*100;t.emit("progress",e)}}if(i&&!this._timer){this._timer=setTimeout(function(){t.abort()},i)}if(o){o=y.serializeObject(o);this.url+=~this.url.indexOf("?")?"&"+o:"?"+o}r.open(this.method,this.url,true);if(this._withCredentials)r.withCredentials=true;if("GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof s&&!a(s)){var c=y.serialize[this.getHeader("Content-Type")];if(c)s=c(s)}for(var h in this.header){if(null==this.header[h])continue;r.setRequestHeader(h,this.header[h])}this.emit("request",this);r.send(s);return this};y.Request=g;function y(e,t){if("function"==typeof t){return new g("GET",e).end(t)}if(1==arguments.length){return new g("GET",e)}return new g(e,t)}y.get=function(e,t,r){var o=y("GET",e);if("function"==typeof t)r=t,t=null;if(t)o.query(t);if(r)o.end(r);return o};y.head=function(e,t,r){var o=y("HEAD",e);if("function"==typeof t)r=t,t=null;if(t)o.send(t);if(r)o.end(r);return o};y.del=function(e,t){var r=y("DELETE",e);if(t)r.end(t);return r};y.patch=function(e,t,r){var o=y("PATCH",e);if("function"==typeof t)r=t,t=null;if(t)o.send(t);if(r)o.end(r);return o};y.post=function(e,t,r){var o=y("POST",e);if("function"==typeof t)r=t,t=null;if(t)o.send(t);if(r)o.end(r);return o};y.put=function(e,t,r){var o=y("PUT",e);if("function"==typeof t)r=t,t=null;if(t)o.send(t);if(r)o.end(r);return o};t.exports=y},{emitter:5,reduce:6}],5:[function(e,t,r){t.exports=o;function o(e){if(e)return i(e)}function i(e){for(var t in o.prototype){e[t]=o.prototype[t]}return e}o.prototype.on=o.prototype.addEventListener=function(e,t){this._callbacks=this._callbacks||{};(this._callbacks[e]=this._callbacks[e]||[]).push(t);return this};o.prototype.once=function(e,t){var r=this;this._callbacks=this._callbacks||{};function o(){r.off(e,o);t.apply(this,arguments)}o.fn=t;this.on(e,o);return this};o.prototype.off=o.prototype.removeListener=o.prototype.removeAllListeners=o.prototype.removeEventListener=function(e,t){this._callbacks=this._callbacks||{};if(0==arguments.length){this._callbacks={};return this}var r=this._callbacks[e];if(!r)return this;if(1==arguments.length){delete this._callbacks[e];return this}var o;for(var i=0;i<r.length;i++){o=r[i];if(o===t||o.fn===t){r.splice(i,1);break}}return this};o.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),r=this._callbacks[e];if(r){r=r.slice(0);for(var o=0,i=r.length;o<i;++o){r[o].apply(this,t)}}return this};o.prototype.listeners=function(e){this._callbacks=this._callbacks||{};return this._callbacks[e]||[]};o.prototype.hasListeners=function(e){return!!this.listeners(e).length}},{}],6:[function(e,t,r){t.exports=function(e,t,r){var o=0;var i=e.length;var s=arguments.length==3?r:e[o++];while(o<i){s=t.call(null,s,e[o],++o,e)}return s}},{}]},{},[1])(1)});
\No newline at end of file