Skip to content

Commit

Permalink
[fix] 빈배열 주기
Browse files Browse the repository at this point in the history
  • Loading branch information
jainefer committed Feb 17, 2024
1 parent 4f2a170 commit 7dfec47
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .platform/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions src/controllers/summary.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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`);
Expand All @@ -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);

}

Expand All @@ -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=[];
Expand All @@ -67,15 +67,15 @@ 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);
const summaryData=JSON.parse(summaryResult);
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);
Expand Down
29 changes: 17 additions & 12 deletions src/dtos/video.dto.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<tag.length;i++){
const tagData=[]
for(let j=0;j<tag[i].length;j++){
tagData.push({"name":tag[i][j].name});
}
videoData.push({"video_id":video[i].id,"category":video[i].category_id,"title":video[i].title,"description":video[i].description,"image":video[i].image,"link":video[i].link,"created_at":video[i].updated_at,"youtube_created_at":video[i].youtube_created_at,"open_at":video[i].open_at,"tag":tagData});
try {
const videoData=[]
console.log("비디오 데이터",video);
console.log("태그 데이터",tag);
for(let i=0;i<tag.length;i++){
const tagData=[]
for(let j=0;j<tag[i].length;j++){
tagData.push({"name":tag[i][j].name});
}
videoData.push({"video_id":video[i].id,"category":video[i].category_id,"title":video[i].title,"description":video[i].description,"image":video[i].image,"link":video[i].link,"created_at":video[i].updated_at,"youtube_created_at":video[i].youtube_created_at,"open_at":video[i].open_at,"tag":tagData});



}
console.log("최종데이터",videoData);
return {"videos":videoData};
} catch (error) {
return {"videos":[]}
}
console.log("최종데이터",videoData);
return {"videos":videoData};

}
export const insertDummyVideoReadResponseDTO=(data)=>{
return{"id":data};
Expand Down
1 change: 1 addition & 0 deletions src/routes/video.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)=>{
Expand Down
6 changes: 4 additions & 2 deletions src/services/chatGPT.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/services/video.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const viewSimpleVideo=async(data)=>{

}
export const viewRecentVideo=async(data)=>{

console.log("서비스에서 전달되는 요청정보",data);
console.log("123");
const TagData=[];
Expand Down

0 comments on commit 7dfec47

Please sign in to comment.