Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 53 additions and 24 deletions.
  1. +53 −24 lib/tmdb.js
77 lib/tmdb.js
View
@@ -41,6 +41,10 @@ var tmdb = function(api_key) {
write_rate_movie: this.base+'/movie/{0}/rating?session_id={1}&api_key='+this.api_key,
company_info: this.base+'/company/{0}?api_key='+this.api_key,
company_movies: this.base+'/company/{0}/movies?api_key='+this.api_key,
+ account_info: this.base+'/account?session_id={0}&api_key='+this.api_key,
+ account_favorite_movies: this.base+'/account/{0}/favorite_movies?session_id={1}&api_key='+this.api_key,
+ account_rated_movies: this.base+'/account/{0}/rated_movies?session_id={1}&api_key='+this.api_key,
+ account_add_favorite: this.base+'/account/{0}/favorite?session_id={1}&api_key='+this.api_key,
};
this.configuration(function(err,res) {
@@ -66,7 +70,7 @@ module.exports.init = function(apikey) {
**/
tmdb.prototype.misc = {
latest: function(callback) {
- var url = me.api_urls['misc_latest'];
+ var url = me.api_urls.misc_latest;
executeQuery({url: url}, callback);
},
nowPlaying: function(p, callback) {
@@ -76,7 +80,7 @@ tmdb.prototype.misc = {
} else {
var page = ((typeof p !== 'number') ? page = 1 : page = p);
}
- var url = me.api_urls['misc_now_playing'].format(page);
+ var url = me.api_urls.misc_now_playing.format(page);
executeQuery({url: url}, callback);
},
popular: function(p, callback) {
@@ -86,7 +90,7 @@ tmdb.prototype.misc = {
} else {
var page = ((typeof p !== 'number') ? page = 1 : page = p);
}
- var url = me.api_urls['misc_popular'].format(page);
+ var url = me.api_urls.misc_popular.format(page);
executeQuery({url: url}, callback);
},
topRated: function(p, callback) {
@@ -96,7 +100,7 @@ tmdb.prototype.misc = {
} else {
var page = ((typeof p !== 'number') ? page = 1 : page = p);
}
- var url = me.api_urls['misc_top_rated'].format(page);
+ var url = me.api_urls.misc_top_rated.format(page);
executeQuery({url: url}, callback);
},
};
@@ -105,7 +109,7 @@ tmdb.prototype.misc = {
* Get current configuration for constructing complete image urls
**/
tmdb.prototype.configuration = function(callback) {
- var url = me.api_urls['configuration'];
+ var url = me.api_urls.configuration;
executeQuery({url: url}, callback);
};
@@ -115,35 +119,35 @@ tmdb.prototype.configuration = function(callback) {
**/
tmdb.prototype.movie = {
info: function(q, callback) {
- var url = me.api_urls['movie_info'].format(q);
+ var url = me.api_urls.movie_info.format(q);
executeQuery({url:url}, callback);
},
alternativeTitles: function(q, callback) {
- var url = me.api_urls['movie_alternative_titles'].format(q);
+ var url = me.api_urls.movie_alternative_titles.format(q);
executeQuery({url:url}, callback);
},
casts: function(q, callback) {
- var url = me.api_urls['movie_casts'].format(q);
+ var url = me.api_urls.movie_casts.format(q);
executeQuery({url:url}, callback);
},
images: function(q, callback) {
- var url = me.api_urls['movie_images'].format(q);
+ var url = me.api_urls.movie_images.format(q);
executeQuery({url:url}, callback);
},
keywords: function(q, callback) {
- var url = me.api_urls['movie_keywords'].format(q);
+ var url = me.api_urls.movie_keywords.format(q);
executeQuery({url:url}, callback);
},
releases: function(q, callback) {
- var url = me.api_urls['movie_releases'].format(q);
+ var url = me.api_urls.movie_releases.format(q);
executeQuery({url:url}, callback);
},
trailers: function(q, callback) {
- var url = me.api_urls['movie_trailers'].format(q);
+ var url = me.api_urls.movie_trailers.format(q);
executeQuery({url:url}, callback);
},
translations: function(q, callback) {
- var url = me.api_urls['movie_translations'].format(q);
+ var url = me.api_urls.movie_translations.format(q);
executeQuery({url:url}, callback);
},
};
@@ -161,7 +165,7 @@ tmdb.prototype.search = {
} else {
if (typeof p !== 'number') { p = 1; }
}
- var url = me.api_urls['search_movie'].format(q, p);
+ var url = me.api_urls.search_movie.format(q, p);
executeQuery({url:url}, callback);
},
person: function(q, p, callback) {
@@ -171,7 +175,7 @@ tmdb.prototype.search = {
} else {
if (typeof p !== 'number') { p = 1; }
}
- var url = me.api_urls['search_person'].format(q, p);
+ var url = me.api_urls.search_person.format(q, p);
executeQuery({url:url}, callback);
},
};
@@ -182,15 +186,15 @@ tmdb.prototype.search = {
**/
tmdb.prototype.person = {
info: function(id, callback) {
- var url = me.api_urls['person_info'].format(id);
+ var url = me.api_urls.person_info.format(id);
executeQuery({url:url}, callback);
},
credits: function(id, callback) {
- var url = me.api_urls['person_credits'].format(id);
+ var url = me.api_urls.person_credits.format(id);
executeQuery({url:url}, callback);
},
images: function(id, callback) {
- var url = me.api_urls['person_images'].format(id);
+ var url = me.api_urls.person_images.format(id);
executeQuery({url:url}, callback);
},
};
@@ -201,7 +205,7 @@ tmdb.prototype.person = {
**/
tmdb.prototype.collection = {
info: function(id, callback) {
- var url = me.api_urls['collection_info'].format(id);
+ var url = me.api_urls.collection_info.format(id);
executeQuery({url: url}, callback);
},
};
@@ -211,11 +215,11 @@ tmdb.prototype.collection = {
**/
tmdb.prototype.authentication = {
requestToken: function(callback) {
- var url = me.api_urls['auth_request_token'];
+ var url = me.api_urls.auth_request_token;
executeQuery({url:url}, callback);
},
sessionId: function(token, callback) {
- var url = me.api_urls['auth_session_id'].format(token);
+ var url = me.api_urls.auth_session_id.format(token);
executeQuery({url:url}, callback);
}
};
@@ -235,14 +239,36 @@ tmdb.prototype.company = {
};
/**
+ * account methods
+ **/
+tmdb.prototype.account = {
+ info: function(sid, callback) {
+ var url = me.api_urls.account_info.format(sid);
+ executeQuery({url: url}, callback);
+ },
+ favorite_movies: function(id, sid, callback) {
+ var url = me.api_urls.account_favorite_movies.format(id,sid);
+ executeQuery({url: url}, callback);
+ },
+ rated_movies: function(id, sid, callback) {
+ var url = me.api_urls.account_rated_movies.format(id,sid);
+ executeQuery({url: url}, callback);
+ },
+ add_favorite: function(aid, mid, sid, isfavorite, callback) {
+ var url = me.api_urls.account_add_favorite.format(aid,sid);
+ executePost({url: url},{movie_id: mid, favorite: isfavorite}, callback);
+ },
+};
+
+
+/**
* write methods
* id = item id (movie id etc.)
* sid = session id
**/
tmdb.prototype.write = {
rateMovie: function(id, sid, rating, callback) {
- var url = me.api_urls['write_rate_movie'].format(id,sid);
- console.log(url);
+ var url = me.api_urls.write_rate_movie.format(id,sid);
executePost({url:url}, {value:rating}, callback);
},
};
@@ -347,8 +373,11 @@ var processPost = function(url, error, response, body, callback) {
callback(res,undefined);
break;
case 12: // The item/record was updated successfully
- callback(res,undefined);
+ callback(undefined,res);
break;
+ case 13: // The item/record was deleted successfully
+ callback(undefined,res);
+ break;
case 17: // Session denied
callback(res,undefined);
break;

No commit comments for this range

Something went wrong with that request. Please try again.