윤준현

add_Mot_guckkasten_Success

ggg
...@@ -9,6 +9,9 @@ var async = require('async'); ...@@ -9,6 +9,9 @@ var async = require('async');
9 var crawlReol = require('./crawling/Reol'); 9 var crawlReol = require('./crawling/Reol');
10 var crawlYonezu = require('./crawling/Yonezu'); 10 var crawlYonezu = require('./crawling/Yonezu');
11 var crawlYorusika = require('./crawling/Yorusika'); 11 var crawlYorusika = require('./crawling/Yorusika');
12 +var crawlGuckkasten = require('./crawling/Guckkasten');
13 +var crawlMot = require('./crawling/Mot');
14 +
12 var singer; 15 var singer;
13 16
14 //body-parser 미들웨어 사용 17 //body-parser 미들웨어 사용
...@@ -57,6 +60,19 @@ app.post('/message', function(req,res){ ...@@ -57,6 +60,19 @@ app.post('/message', function(req,res){
57 callback(null,yorusika); 60 callback(null,yorusika);
58 }); 61 });
59 break; 62 break;
63 + case 'Guckkasten-Discography':
64 + singer = 'guckkasten';
65 + crawlGuckkasten.crawl_guckkasten(function (guckkasten) {
66 + callback(null, guckkasten);
67 + });
68 + break;
69 + case 'Mot-Discography':
70 + singer = 'mot';
71 + crawlMot.crawl_mot(function (mot) {
72 + callback(null, mot);
73 + });
74 + break;
75 +
60 default: 76 default:
61 if(singer == 'Reol'){ 77 if(singer == 'Reol'){
62 crawlReol.crawl_Reol('https://namu.wiki/w/%EB%A0%88%EC%98%A4%EB%A3%A8/%EC%9D%8C%EB%B0%98#toc',function(Reol){ 78 crawlReol.crawl_Reol('https://namu.wiki/w/%EB%A0%88%EC%98%A4%EB%A3%A8/%EC%9D%8C%EB%B0%98#toc',function(Reol){
...@@ -73,6 +89,16 @@ app.post('/message', function(req,res){ ...@@ -73,6 +89,16 @@ app.post('/message', function(req,res){
73 callback(null,yorusika); 89 callback(null,yorusika);
74 }); 90 });
75 } 91 }
92 + else if(singer=='guckkasten'){
93 + crawlGuckkasten.crawl_guckkasten(function(guckkasten){
94 + callback(null,guckkasten);
95 + });
96 + }
97 + else if(singer=='mot'){
98 + crawlMot.crawl_mot(function (mot) {
99 + callback(null, mot);
100 + });
101 + }
76 else 102 else
77 callback(null,null); 103 callback(null,null);
78 break; 104 break;
...@@ -83,7 +109,12 @@ app.post('/message', function(req,res){ ...@@ -83,7 +109,12 @@ app.post('/message', function(req,res){
83 // 사용자의 msg를 받아 res를 보냄 // 109 // 사용자의 msg를 받아 res를 보냄 //
84 110
85 function(discography, callback){ 111 function(discography, callback){
86 - var index = parseInt(msg[0])-1; 112 + var index;
113 + if(msg[1] != '.'){
114 + index = parseInt(msg[0])*10 + parseInt(msg[1]) -1;
115 + }
116 + else
117 + index = parseInt(msg[0])-1;
87 switch (msg) { 118 switch (msg) {
88 case '일본': 119 case '일본':
89 send = { 120 send = {
...@@ -101,11 +132,11 @@ app.post('/message', function(req,res){ ...@@ -101,11 +132,11 @@ app.post('/message', function(req,res){
101 case '한국': 132 case '한국':
102 send = { 133 send = {
103 'message': { 134 'message': {
104 - 'text': '미구현' 135 + 'text': '등록된 가수 목록입니다.'
105 }, 136 },
106 keyboard: { 137 keyboard: {
107 'type': 'buttons', 138 'type': 'buttons',
108 - 'buttons': ['MOT', 'Gukkasten', 'ZICO'] 139 + 'buttons': ['Mot', 'Guckkasten']
109 } 140 }
110 }; 141 };
111 break; 142 break;
...@@ -241,11 +272,77 @@ app.post('/message', function(req,res){ ...@@ -241,11 +272,77 @@ app.post('/message', function(req,res){
241 272
242 }; 273 };
243 break; 274 break;
275 +////////////////
276 + // Guckkasten //
277 + ////////////////
278 + case 'Guckkasten':
279 + send = {
280 + 'message': {
281 + 'text': '설명 : 4인조 밴드\n멤버 :\n 하현우(Vocal, Guitar)\n 전규호(Guitar)\n 이정길(Drum)\n 김기범(Bass)\n장르 : 싸이키델릭 록\n데뷔 : 2007년\n소속사 : 인터파크',
282 + 'photo': {
283 + 'url': 'http://ticketimage.interpark.com/interparkenter/guckkasten/about/guckkasten_about_pc_image(540x420px).jpg',
284 + 'width': 540,
285 + 'height': 420
286 + },
287 + 'message_button': {
288 + 'label': '공식 홈페이지',
289 + 'url': "http://www.interparkenter.com/guckkasten/Main"
290 + }
291 + },
292 + keyboard: {
293 + 'type': 'buttons',
294 + 'buttons': ['Guckkasten-Discography']
295 + }
296 + };
297 + break;
298 + case 'Guckkasten-Discography':
299 + console.log(discography[0].json_album);
300 + send = {
301 + 'message': {
302 + 'text': 'Album List'
303 + },
304 + keyboard: {
305 + 'type': 'buttons',
306 + 'buttons': discography[0].json_album
307 + }
244 308
309 + };
310 + break;
245 ///////////// 311 /////////////
246 - //// MOT //// 312 + //// Mot ////
247 ///////////// 313 /////////////
314 + case 'Mot':
315 + send = {
316 + 'message': {
317 + 'text': '설명 : 5인조 밴드\n현멤버(3집 이후) :\n 이이언(Vocal)\n 유웅렬(Guitar)\n 조남열(Drum)\n 송인섭(Bass)\n 이하윤(Keyboard)\n구멤버(1, 2집) :\n 이이언(Vocal)\n지이(Guitar)\n장르 : Indie Rock\n 데뷔 : 2007년\n소속사 : 인터파크',
318 + 'photo': {
319 + 'url': 'https://scontent-icn1-1.xx.fbcdn.net/v/t1.0-1/p320x320/31164203_908165976030791_1214044515636084736_n.jpg?_nc_cat=111&_nc_ht=scontent-icn1-1.xx&oh=7da23be5eb9dfcd537287b012f231dbb&oe=5C9B33D0',
320 + 'width': 1000,
321 + 'height': 677
322 + },
323 + 'message_button': {
324 + 'label': '공식 Facebook',
325 + 'url': "https://www.facebook.com/bandmot.official"
326 + }
327 + },
328 + keyboard: {
329 + 'type': 'buttons',
330 + 'buttons': ['Mot-Discography']
331 + }
332 + };
333 + break;
334 + case 'Mot-Discography':
335 + send = {
336 + 'message': {
337 + 'text': 'Album List'
338 + },
339 + keyboard: {
340 + 'type': 'buttons',
341 + 'buttons': discography[0].json_album
342 + }
248 343
344 + };
345 + break;
249 346
250 // 앨범 정보 읽기 // 347 // 앨범 정보 읽기 //
251 348
...@@ -284,8 +381,30 @@ app.post('/message', function(req,res){ ...@@ -284,8 +381,30 @@ app.post('/message', function(req,res){
284 } 381 }
285 } 382 }
286 } 383 }
384 + else if (singer == 'guckkasten'){
385 + send = {
386 + 'message': {
387 + 'text': album + '\n발매년도 : ' + discography[0].json_year[index] + '\n수록곡 : \n' + discography[0].json_track[index]
388 + },
389 + keyboard: {
390 + 'type': 'buttons',
391 + 'buttons': ['Guckkasten-Discography', '초기화면']
392 + }
393 + }
394 + }
395 + else if (singer == 'mot'){
396 + send = {
397 + 'message': {
398 + 'text': album + '\n발매년도 : ' + discography[0].json_year[index] + '\n수록곡 : \n' + discography[0].json_track[index]
399 + },
400 + keyboard: {
401 + 'type': 'buttons',
402 + 'buttons': ['Mot-Discography', '초기화면']
403 + }
404 + }
405 + }
287 break; 406 break;
288 - 407 +
289 // 초기 설정으로 돌아가기 // 408 // 초기 설정으로 돌아가기 //
290 409
291 case '초기화면' : 410 case '초기화면' :
......
...@@ -4,30 +4,30 @@ var cheerio = require('cheerio'); ...@@ -4,30 +4,30 @@ var cheerio = require('cheerio');
4 function crawl_guckkasten(callback){ 4 function crawl_guckkasten(callback){
5 var n = 0; 5 var n = 0;
6 var guckkasten = []; 6 var guckkasten = [];
7 - crawl(function(album,year,track){ 7 + crawl(function(json_album,json_year,json_track){
8 n++ 8 n++
9 if (n == 10) { 9 if (n == 10) {
10 var j; 10 var j;
11 var a, y, t; 11 var a, y, t;
12 - for (var i = 1; i < year.length; i++) { 12 + for (var i = 1; i < json_year.length; i++) {
13 - y = year[i]; 13 + y = json_year[i];
14 - a = album[i]; 14 + a = json_album[i];
15 - t = track[i] 15 + t = json_track[i]
16 j = i - 1; 16 j = i - 1;
17 - while (j >= 0 && year[j] > y) { 17 + while (j >= 0 && json_year[j] > y) {
18 - album[j + 1] = album[j]; 18 + json_album[j + 1] = json_album[j];
19 - year[j + 1] = year[j]; 19 + json_year[j + 1] = json_year[j];
20 - track[j + 1] = track[j]; 20 + json_track[j + 1] = json_track[j];
21 j--; 21 j--;
22 } 22 }
23 - album[j + 1] = a; 23 + json_album[j + 1] = a;
24 - year[j + 1] = y; 24 + json_year[j + 1] = y;
25 - track[j + 1] = t; 25 + json_track[j + 1] = t;
26 } 26 }
27 - for(var i = 0; i<album.length; i++){ 27 + for(var i = 0; i<json_album.length; i++){
28 - album[i] = (i+1)+'. ' +album[i]; 28 + json_album[i] = (i+1)+'. ' +json_album[i];
29 } 29 }
30 - guckkasten.push(album, year, track); 30 + guckkasten.push({json_album, json_year, json_track});
31 callback(guckkasten); 31 callback(guckkasten);
32 } 32 }
33 }) 33 })
......