forked from GitHub/dbot
rt instead of mymovieapi
This commit is contained in:
parent
14bb252a73
commit
6b2f2f8484
@ -1,32 +0,0 @@
|
||||
## IMDB
|
||||
|
||||
Adds various IMDB functionalities.
|
||||
|
||||
### Description
|
||||
|
||||
This module provides a command which allows users to search IMDB for a movie.
|
||||
|
||||
### Dependencies
|
||||
|
||||
It has following dependencies:
|
||||
+ [request](https://github.com/mikeal/request)
|
||||
|
||||
### config.json
|
||||
|
||||
output prefix can be set.
|
||||
```
|
||||
{
|
||||
"outputPrefix": "\u00033IMDB\u000f"
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Commands
|
||||
|
||||
|
||||
#### ~imdb [movie]
|
||||
Searches IMDB for a movie.
|
||||
Example:
|
||||
+ ~imdb Fear and Loathing in Las Vegas
|
||||
|
||||
### TODO
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"outputPrefix": "\u00033IMDB\u000f"
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/**
|
||||
* Module Name: IMDB
|
||||
* Description: Various IMDB functionality.
|
||||
*/
|
||||
|
||||
var _ = require('underscore')._,
|
||||
request = require('request');
|
||||
|
||||
var imdb = function(dbot) {
|
||||
var ApiRoot = 'http://mymovieapi.com/';
|
||||
|
||||
this.internalAPI = {
|
||||
'formatLink': function(m) {
|
||||
var rating = m.rating;
|
||||
var rColour = (rating <= 5) ? '\u00033 ' : '\u00034 ';
|
||||
rating = rColour + String(rating) + '\u000f';
|
||||
|
||||
var mString = dbot.t('imdb_film', {
|
||||
'title': m.title,
|
||||
'year': m.year,
|
||||
'rating': rating
|
||||
});
|
||||
|
||||
if(_.has(m, 'directors')) mString += ' [Director: ' + m.directors[0] + ']';
|
||||
if(_.has(m, 'genres')) mString += ' [Genre: ' + m.genres[0] + ']';
|
||||
if(_.has(m, 'plot_simple')) mString += ' [Description: ' + m.plot_simple + ']';
|
||||
mString += ' - ' + m.imdb_url;
|
||||
|
||||
return mString;
|
||||
}
|
||||
};
|
||||
|
||||
this.commands = {
|
||||
'~imdb': function(event) {
|
||||
request.get(ApiRoot, {
|
||||
'qs': {
|
||||
'q': event.input[1],
|
||||
'page_limit': 1
|
||||
},
|
||||
'json': true
|
||||
}, function(error, response, body) {
|
||||
if(_.isObject(body) && !_.isUndefined(body[0])) {
|
||||
event.reply(this.internalAPI.formatLink(body[0]));
|
||||
} else {
|
||||
event.reply(dbot.t('imdb_noresults'));
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
this.commands['~imdb'].regex = [/^imdb (.+)$/, 2];
|
||||
|
||||
this.onLoad = function() {
|
||||
dbot.api.link.addHandler('imdb', /https?:\/\/(www\.)?imdb\.com\/title\/([a-zA-Z0-9]+)/, function(matches, name, callback) {
|
||||
var id = matches[2];
|
||||
request.get(ApiRoot, {
|
||||
'qs': {
|
||||
'id': id,
|
||||
'page_limit': 1
|
||||
},
|
||||
'json': true
|
||||
}, function(error, response, body) {
|
||||
if(_.isObject(body) && !_.has(body, 'error')) {
|
||||
callback(this.internalAPI.formatLink(body));
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
}.bind(this));
|
||||
}.bind(this)
|
||||
};
|
||||
|
||||
exports.fetch = function(dbot) {
|
||||
return new imdb(dbot);
|
||||
};
|
33
modules/rt/README.md
Normal file
33
modules/rt/README.md
Normal file
@ -0,0 +1,33 @@
|
||||
## RT
|
||||
|
||||
Adds various RottenTomatoes functionalities.
|
||||
|
||||
### Description
|
||||
|
||||
This module provides a command which allows users to search RT for a movie.
|
||||
|
||||
### Dependencies
|
||||
|
||||
It has following dependencies:
|
||||
+ [request](https://github.com/mikeal/request)
|
||||
|
||||
### config.json
|
||||
|
||||
output prefix can be set, and an API key must be obtained from
|
||||
http://developer.rottentomatoes.com/
|
||||
```
|
||||
{
|
||||
"outputPrefix": "\u00033RT\u000f"
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Commands
|
||||
|
||||
|
||||
#### ~rt [movie]
|
||||
Searches IMDB for a movie.
|
||||
Example:
|
||||
+ ~rt Fear and Loathing in Las Vegas
|
||||
|
||||
### TODO
|
4
modules/rt/config.json
Normal file
4
modules/rt/config.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"outputPrefix": "\u00033RT\u000f",
|
||||
"api_key": "http://developer.rottentomatoes.com"
|
||||
}
|
60
modules/rt/rt.js
Normal file
60
modules/rt/rt.js
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Module Name: RT
|
||||
* Description: Various RT functionality.
|
||||
*/
|
||||
|
||||
var _ = require('underscore')._,
|
||||
request = require('request');
|
||||
|
||||
var rt = function(dbot) {
|
||||
var ApiRoot = 'http://api.rottentomatoes.com/api/public/v1.0/';
|
||||
|
||||
this.internalAPI = {
|
||||
'formatLink': function(m) {
|
||||
var rating = m.ratings.audience_score;
|
||||
var rColour = (rating <= 5) ? '\u00033 ' : '\u00034 ';
|
||||
rating = rColour + String(rating) + '%\u000f';
|
||||
|
||||
var mString = dbot.t('rt_film', {
|
||||
'title': m.title,
|
||||
'year': m.year,
|
||||
'rating': rating
|
||||
});
|
||||
|
||||
if(_.has(m, 'directors')) mString += ' [Director: ' + m.directors[0] + ']';
|
||||
if(_.has(m, 'genres')) mString += ' [Genre: ' + m.genres[0] + ']';
|
||||
if(_.has(m, 'synopsis') && m.synopsis != '') {
|
||||
mString += ' [Synopsis: ' + m.synopsis + ']';
|
||||
} else if(_.has(m, 'critics_consensus')) {
|
||||
mString += ' [Review: ' + m.critics_consensus + ']';
|
||||
}
|
||||
mString += ' - ' + m.links.alternate;
|
||||
|
||||
return mString;
|
||||
}
|
||||
};
|
||||
|
||||
this.commands = {
|
||||
'~rt': function(event) {
|
||||
request.get(ApiRoot + 'movies.json', {
|
||||
'qs': {
|
||||
'q': event.input[1],
|
||||
'page_limit': 1,
|
||||
'apikey': this.config.api_key
|
||||
},
|
||||
'json': true
|
||||
}, function(error, response, body) {
|
||||
if(_.isObject(body) && _.has(body, 'movies') && !_.isUndefined(body.movies[0])) {
|
||||
event.reply(this.internalAPI.formatLink(body.movies[0]));
|
||||
} else {
|
||||
event.reply(dbot.t('rt_noresults'));
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
this.commands['~rt'].regex = [/^rt (.+)$/, 2];
|
||||
};
|
||||
|
||||
exports.fetch = function(dbot) {
|
||||
return new rt(dbot);
|
||||
};
|
@ -1,9 +1,9 @@
|
||||
{
|
||||
"imdb_film": {
|
||||
"rt_film": {
|
||||
"en": "[{title} -{rating} - {year}]",
|
||||
"de": "[{title} -{rating} - {year}]"
|
||||
},
|
||||
"imdb_noresults": {
|
||||
"rt_noresults": {
|
||||
"en": "No films found.",
|
||||
"de": "Kein Film gefunden."
|
||||
}
|
Loading…
Reference in New Issue
Block a user