From 7dfec47a647254e03f001d03806afe5547dbe592 Mon Sep 17 00:00:00 2001 From: jainefer Date: Sat, 17 Feb 2024 14:23:21 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[fix]=20=EB=B9=88=EB=B0=B0=EC=97=B4=20?= =?UTF-8?q?=EC=A3=BC=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .platform/nginx/nginx.conf | 2 ++ src/controllers/summary.controller.js | 18 ++++++++--------- src/dtos/video.dto.js | 29 ++++++++++++++++----------- src/routes/video.route.js | 1 + src/services/chatGPT.service.js | 6 ++++-- src/services/video.service.js | 1 + 6 files changed, 34 insertions(+), 23 deletions(-) diff --git a/.platform/nginx/nginx.conf b/.platform/nginx/nginx.conf index 3873382..538e1d8 100644 --- a/.platform/nginx/nginx.conf +++ b/.platform/nginx/nginx.conf @@ -46,6 +46,8 @@ http { proxy_send_timeout 300s; proxy_read_timeout 300s; send_timeout 300s; + proxy_buffers 8 16k; + proxy_buffer_size 32k; } access_log /var/log/nginx/access.log main; diff --git a/src/controllers/summary.controller.js b/src/controllers/summary.controller.js index 632cd79..290e652 100644 --- a/src/controllers/summary.controller.js +++ b/src/controllers/summary.controller.js @@ -14,15 +14,15 @@ export const processVideo = async (req, res) => { try { //사용자에게 입력받을 video ID 변수 - const token = req.cookies['tempToken']; + // const token = req.cookies['tempToken']; const videoUrl=req.query.v ?? ''; console.log(encodeURI(videoUrl)); const videoId = await extractYouTubeVideoId(encodeURI(videoUrl)); - if(!token) { - return res.status(401).send("비정상 접근입니다."); - } + // if(!token) { + // return res.status(401).send("비정상 접근입니다."); + // } const id =videoId; console.log("id",id); @@ -32,7 +32,7 @@ export const processVideo = async (req, res) => { videoTitle=title; }) - const clientId = token; + // const clientId = token; // Object Storage에서 해당 MP3 파일이 존재하는지 확인 const mp3Exists = await checkFileExistsInStorage(process.env.OBJECT_STORAGE_BUCKET_NAME, `${videoId}.mp3`); @@ -41,7 +41,7 @@ export const processVideo = async (req, res) => { if (!mp3Exists) { const audioFilePath = await convertVideoToAudio(videoId); // MP3 파일 변환 await uploadFileToStorage(audioFilePath); // 파일 업로드 후 로컬파일 삭제 - sendProgress(clientId, '음성파일 변환 완료.', 25); + // sendProgress(clientId, '음성파일 변환 완료.', 25); } @@ -51,7 +51,7 @@ export const processVideo = async (req, res) => { if (scriptFileName) { // 스크립트 파일이 이미 존재하면 해당 데이터 사용 const jsonData = await readFileFromObjectStorage(process.env.OBJECT_STORAGE_BUCKET_SUMMARY_NAME, scriptFileName); - sendProgress(clientId, '스크립트 불러오기 완료', 50); + // sendProgress(clientId, '스크립트 불러오기 완료', 50); const scriptText = jsonData.text; const timeStampData=[]; @@ -67,7 +67,7 @@ export const processVideo = async (req, res) => { const summaryResult = await getSummary(scriptText); console.log("요약데이터",summaryResult); - sendProgress(clientId, '요약 불러오기 완료', 75); + // sendProgress(clientId, '요약 불러오기 완료', 75); // const startSummaryIndex = summaryResult.indexOf('{'); // 첫 번째 '{'의 인덱스 찾기 // console.log("찾은 인덱스",startSummaryIndex); // const trimmedSummaryResponse = summaryResult.substring(startSummaryIndex); @@ -75,7 +75,7 @@ export const processVideo = async (req, res) => { console.log("summary json 데이터",summaryData); //gpt 데이터 const gptResponse = await chatGPTCall(scriptText); - sendProgress(clientId, '서비스 완료', 100); + // sendProgress(clientId, '서비스 완료', 100); const startIndex = gptResponse.indexOf('{'); // 첫 번째 '{'의 인덱스 찾기 const trimmedResponse = gptResponse.substring(startIndex); const gptData=JSON.parse(trimmedResponse); diff --git a/src/dtos/video.dto.js b/src/dtos/video.dto.js index 4e10983..69a6a72 100644 --- a/src/dtos/video.dto.js +++ b/src/dtos/video.dto.js @@ -28,20 +28,25 @@ export const updateVideoResponseDTO=(video) =>{ return {"status": video} } export const getSimpleVideoResponseDTO=(video,tag)=>{ - const videoData=[] - console.log("비디오 데이터",video); - console.log("태그 데이터",tag); - for(let i=0;i{ return{"id":data}; diff --git a/src/routes/video.route.js b/src/routes/video.route.js index 78c4b4f..c248e60 100644 --- a/src/routes/video.route.js +++ b/src/routes/video.route.js @@ -6,6 +6,7 @@ export const videoRoute = express.Router(); videoRoute.get('/dummyVideos/unRead',async(req,res)=>{ const result =await getUnReadDummyVideo(req,res); + }) videoRoute.get('/',async(req,res)=>{ diff --git a/src/services/chatGPT.service.js b/src/services/chatGPT.service.js index 40958da..c09689f 100644 --- a/src/services/chatGPT.service.js +++ b/src/services/chatGPT.service.js @@ -89,13 +89,15 @@ export const chatGPTCall = async (scriptText) => { export const getTitle=async(title)=>{ + console.log("유튜브제목",title); try { - const system_prompt='Step 1. Please summarize the title in one sentence when you receive the title. It should be given in Korean. Please give it in this json format'+ + const system_prompt='Step 1. Please summarize the title in one sentence when you receive the title. It should be given in Korean. Please give it in this json format '+ '{'+ '"Title": The original title summarized in one sentence'+ '}' - const prompt=`Run this script from step 1 , Make sure to fulfill the condition given to the system promport, response to korean. original title: ${title}\n ` + const prompt=` Please summarize the title in one sentence when you receive the title. It should be given in Korean. Please give it in this json format + { "title":"original title summary"} original title: ${title}\n ` const response = await axios.post( diff --git a/src/services/video.service.js b/src/services/video.service.js index 6254381..ed329bd 100644 --- a/src/services/video.service.js +++ b/src/services/video.service.js @@ -68,6 +68,7 @@ export const viewSimpleVideo=async(data)=>{ } export const viewRecentVideo=async(data)=>{ + console.log("서비스에서 전달되는 요청정보",data); console.log("123"); const TagData=[]; From 6223d8e7dd74fa28f330b9fa0c3dbcd82b6a5394 Mon Sep 17 00:00:00 2001 From: jainefer Date: Sat, 17 Feb 2024 14:31:23 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[fix]=20=EB=B9=88=EB=B0=B0=EC=97=B4=20?= =?UTF-8?q?=EC=A3=BC=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/video.service.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/services/video.service.js b/src/services/video.service.js index ed329bd..6018db2 100644 --- a/src/services/video.service.js +++ b/src/services/video.service.js @@ -68,20 +68,24 @@ export const viewSimpleVideo=async(data)=>{ } export const viewRecentVideo=async(data)=>{ - - console.log("서비스에서 전달되는 요청정보",data); - console.log("123"); - const TagData=[]; - const getVideoData=await getRecentVideo(data); - console.log(getVideoData[0].id); - for(let i =0; i{ try { From 491146bef242a4bcc4e2e0ae1ab9abbc2d7ad1e4 Mon Sep 17 00:00:00 2001 From: jainefer Date: Sat, 17 Feb 2024 16:22:02 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[fix]=20=EC=98=81=EC=83=81=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EB=B9=88=EA=B0=92=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 11 +++++++++-- package.json | 3 ++- src/controllers/summary.controller.js | 15 +++++++++------ src/services/video.service.js | 4 ++-- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 74ee942..88df814 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "express-session": "^1.17.3", "ffmpeg": "^0.0.4", "fluent-ffmpeg": "^2.1.2", - "get-youtube-title": "^1.0.1", + "get-youtube-title-await": "^1.1.5", "http-status-codes": "^2.3.0", "install": "^0.13.0", "jsonwebtoken": "^9.0.2", @@ -46,6 +46,7 @@ "@babel/preset-env": "^7.23.7", "babel-cli": "^6.26.0", "babel-loader": "^9.1.3", + "get-youtube-title": "^1.0.1", "nodemon": "^3.0.2", "swagger": "^0.7.5", "webpack": "^5.89.0", @@ -6144,7 +6145,13 @@ "node_modules/get-youtube-title": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/get-youtube-title/-/get-youtube-title-1.0.1.tgz", - "integrity": "sha512-UtaDf69QDkLoSRpUazUC420QlcG59+VmzIjZUqPn2aW5LB99C3c8OLIlDQy7kKAeqIhp/K/ZVDcscDF6K1MJ+Q==" + "integrity": "sha512-UtaDf69QDkLoSRpUazUC420QlcG59+VmzIjZUqPn2aW5LB99C3c8OLIlDQy7kKAeqIhp/K/ZVDcscDF6K1MJ+Q==", + "dev": true + }, + "node_modules/get-youtube-title-await": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/get-youtube-title-await/-/get-youtube-title-await-1.1.5.tgz", + "integrity": "sha512-kegsz6qLYlRjBlJHVJIl+Eh/fBi0rtpQ98RquJuftx9UuZTqW3n/6Zout9KM6wEP6uvDcSLiy35RP3xhPO0lxw==" }, "node_modules/glob": { "version": "7.2.3", diff --git a/package.json b/package.json index 935553f..8188d06 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "express-session": "^1.17.3", "ffmpeg": "^0.0.4", "fluent-ffmpeg": "^2.1.2", - "get-youtube-title": "^1.0.1", + "get-youtube-title-await": "^1.1.5", "http-status-codes": "^2.3.0", "install": "^0.13.0", "jsonwebtoken": "^9.0.2", @@ -50,6 +50,7 @@ "@babel/preset-env": "^7.23.7", "babel-cli": "^6.26.0", "babel-loader": "^9.1.3", + "get-youtube-title": "^1.0.1", "nodemon": "^3.0.2", "swagger": "^0.7.5", "webpack": "^5.89.0", diff --git a/src/controllers/summary.controller.js b/src/controllers/summary.controller.js index 290e652..835ae39 100644 --- a/src/controllers/summary.controller.js +++ b/src/controllers/summary.controller.js @@ -8,6 +8,7 @@ import { readFileFromObjectStorage } from '../services/storage.service.js'; import { checkFileExistsInStorage } from '../services/storage.service.js'; import { getScriptFileName } from '../services/storage.service.js'; import { chatGPTCall } from '../services/chatGPT.service.js'; + import getYoutubeTitle from 'get-youtube-title'; export const processVideo = async (req, res) => { @@ -26,12 +27,14 @@ export const processVideo = async (req, res) => { const id =videoId; console.log("id",id); - let videoTitle=""; - - getYoutubeTitle(videoId,async function(err,title){ - videoTitle=title; - }) - + + let videoTitle="" + const titleData=await getYoutubeTitle(id, async function (err, title) { + console.log("타이틀",title); + return title; // 'SLCHLD - EMOTIONS (feat. RIPELY) (prod. by GILLA)' + }) + + console.log("비디오 테그",titleData); // const clientId = token; // Object Storage에서 해당 MP3 파일이 존재하는지 확인 diff --git a/src/services/video.service.js b/src/services/video.service.js index 6018db2..7dfd6cc 100644 --- a/src/services/video.service.js +++ b/src/services/video.service.js @@ -63,7 +63,7 @@ export const viewSimpleVideo=async(data)=>{ } catch (error) { console.error(error); - throw new BaseError(status.VIDEO_NOT_FOUND); + return {"videos":[]} } } @@ -121,7 +121,7 @@ export const viewCategoryVideo=async(data)=>{ return getCategoryVideoResponseDTO(getVideoData,tagData); } catch (error) { console.error(error); - throw new BaseError(status.CATEGORY_IS_EMPTY); + return {"videos":[]} } } async function findCategory(categoryData, category, user) {