백승욱

restore some files from merging process

//=============================================================
var express = require('express');
const request = require('request');
const config = require('/config.json');
//=============================================================
const LINE_URL = 'https://api.line.me/v2/bot/message/reply'
const TOKEN = config.TOKEN;
const KOFIC_URL = 'http://www.kobis.or.kr/kobisopenapi/webservice/rest'
const KOFIC_KEY = config.KOFIC_KEY;
//=============================================================
exports.MovieInfo = function(replyToken, message) {
request.get(
{
url: KOFIC_URL+`/movie/searchMovieInfo.json?key=${KOFIC_KEY}&movieCd=${message}`,
json:true
},(error, response, body) => {
if(!error && response.statusCode == 200) {
console.log(body.movieInfoResult);
var MovieInfo = body.movieInfoResult.movieInfo;
var MovieName = MovieInfo.movieNm;
var MovieDate = `${MovieInfo.openDt.slice(0,4)}${MovieInfo.openDt.slice(4,6)}${MovieInfo.openDt.slice(6,8)}일`;
var MovieTime = MovieInfo.showTm;
var MovieGenres = [];
for(var i in MovieInfo.genres)
{
MovieGenres.push(MovieInfo.genres[i].genreNm);
}
var MovieDirec = MovieInfo.directors[0].peopleNm;
var MovieActors = [];
for(var i=0; i<MovieInfo.actors.length && i<5; i++)
{
MovieActors[i] = MovieInfo.actors[i].peopleNm;
}
request.post(
{
url: LINE_URL,
headers: {
'Authorization': `Bearer ${TOKEN}`
},
json: {
"replyToken":replyToken,
"messages":[
{
"type":"text",
"text":`영화명: ${MovieName}\n개봉날짜: ${MovieDate}\n상영시간: ${MovieTime}분\n장르: ${MovieGenres}\n감독: ${MovieDirec}\n출연배우: ${MovieActors}`
}
]
}
},(error, response, body) => {
console.log(body)
});
}
});
}
var express = require('express');
const request = require('request');
var config = require('/config.json');
const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
const TOKEN = config.TOKEN;
const KOFIC_URL = 'http://www.kobis.or.kr/kobisopenapi/webservice/rest'
//Enter a movie title in the message variable.
//It will then return the movie title, director, and actor information to Line Messenger.
exports.movielist = function (replyToken, message) {
var encodedMessage = encodeURI(message);
request.get(
{
url: KOFIC_URL+`/movie/searchMovieList.json?key=${config.KOFIC_KEY}&movieNm=${encodedMessage}`,
json:true
},(error, response, body) => {
if(!error && response.statusCode == 200) {
console.log(body.message);
var result = '', movieNm, prdtYear, directors;
for (let i = 0; i < body.movieListResult.movieList.length; i ++){
movieNm = body.movieListResult.movieList[i].movieNm;
prdtYear = body.movieListResult.movieList[i].prdtYear;
movieCd = body.movieListResult.movieList[i].movieCd;
if(body.movieListResult.movieList[i].directors.length === 0){
directors = "감독정보없음"
}
else{
directors = body.movieListResult.movieList[i].directors[0].peopleNm;
}
result += '제목: ' + movieNm + `(${prdtYear})` + '\n' + '감독: ' + directors + '\n' + '영화코드: ' + movieCd + '\n';
}
request.post(
{
url: TARGET_URL,
headers: {
'Authorization': `Bearer ${TOKEN}`
},
json: {
"replyToken":replyToken,
"messages":[
{
"type":"text",
"text":result
}
]
}
},(error, response, body) => {
console.log(body)
});
}
});
}
This diff is collapsed. Click to expand it.
{
"name": "trans",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"request": "^2.88.2"
}
}