Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api_imdb #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ mongoose.connect(config.DB_URL, {
// {
// "uuid": "f123",
// "name": "Inception",
// "name_rus": "Начадло",
// "type": "action",
// "year": "2010",
// "rate": 8.665,
Expand All @@ -33,6 +34,7 @@ mongoose.connect(config.DB_URL, {
// {
// "uuid": "f234",
// "name": "Gladiator",
// "name_rus": "Гладиатор",
// "type": "action",
// "year": "2000",
// "rate": 8.592,
Expand All @@ -45,6 +47,7 @@ mongoose.connect(config.DB_URL, {
// {
// "uuid": "f345",
// "name": "The Matrix",
// "name_rus": "Матрица",
// "type": "action",
// "year": "1999",
// "rate": 8.491,
Expand All @@ -57,6 +60,7 @@ mongoose.connect(config.DB_URL, {
// {
// "uuid": "f456",
// "name": "Pulp Fiction",
// "name_rus": "Криминальное чтиво",
// "type": "action",
// "year": "1994",
// "rate": 8.691,
Expand All @@ -69,6 +73,7 @@ mongoose.connect(config.DB_URL, {
// {
// "uuid": "f567",
// "name": "Lock Stock and Two Smoking Barrels",
// "name_rus": "Карты деньги два ствола",
// "type": "comedy",
// "year": "1998",
// "rate": 8.543,
Expand All @@ -81,6 +86,7 @@ mongoose.connect(config.DB_URL, {
// {
// "uuid": "f678",
// "name": "Forrest Gump",
// "name_rus": "Форест Гамп",
// "type": "comedy",
// "year": "1994",
// "rate": 8.922,
Expand All @@ -93,6 +99,7 @@ mongoose.connect(config.DB_URL, {
// {
// "uuid": "f789",
// "name": "The Intouchables",
// "name_rus": "Неприкасаемые",
// "type": "comedy",
// "year": "2011",
// "rate": 8.812,
Expand All @@ -105,6 +112,7 @@ mongoose.connect(config.DB_URL, {
// {
// "uuid": "f890",
// "name": "Knockin' on Heaven's Door",
// "name_rus": "Достучаться до небес",
// "type": "comedy",
// "year": "1997",
// "rate": 8.634,
Expand Down Expand Up @@ -462,17 +470,11 @@ function getLinkToWatch(filmName = null) {

console.log(`начал поиск по ${config.IMDB_AUTH_LINK + '&t=Pulp+Fiction'}`);

// request.get(config.IMDB_AUTH_LINK + '&t=Pulp+Fiction')
// .on('response', function (err, httpResponse) {
// console.log(response.toJSON());
// })
// .on('error', function (err) {
// console.log(err)
// });
request.get({url: config.IMDB_AUTH_LINK + '&t=Pulp+Fiction'}, function (err, httpResponse, body){


request.get({url: config.IMDB_AUTH_LINK + '&t=Pulp+Fiction'}, function (err,httpResponse,body){
console.log(body);
const filmInfo = JSON.parse(body);
const mountToInt = utlits.getMountToInt(filmInfo.Released);
console.log(mountToInt);
});


Expand Down
12 changes: 12 additions & 0 deletions src/utlits.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,16 @@ module.exports = {
return deg * (Math.PI / 180)
},


getMountToInt(filmData) {
const stringMount = this.getMountFromData(filmData)[0];
return mountList.indexOf(stringMount.toLowerCase()) + 1;
},

getMountFromData(filmData) {
return filmData.match(/[a-zA-z]+/);
}

};

const mountList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sept' , 'oct', 'nov', 'dec'];