Skip to content

Commit

Permalink
[feat] 영상 제목
Browse files Browse the repository at this point in the history
  • Loading branch information
jainefer committed Feb 17, 2024
1 parent 29e1ce4 commit 36dadca
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 12 deletions.
191 changes: 191 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"express-session": "^1.17.3",
"ffmpeg": "^0.0.4",
"fluent-ffmpeg": "^2.1.2",
"get-youtube-detail": "^1.2.1",
"get-youtube-title-await": "^1.1.5",
"http-status-codes": "^2.3.0",
"install": "^0.13.0",
Expand Down
24 changes: 15 additions & 9 deletions src/controllers/summary.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@ import { getSummary, getTitle } from '../services/chatGPT.service.js';
import { readFileFromObjectStorage } from '../services/storage.service.js';
import { getScriptFileName } from '../services/storage.service.js';
import { chatGPTCall } from '../services/chatGPT.service.js';

import axios from 'axios';


export const summary = async (req, res) => {
try {

//사용자에게 입력받을 video ID 변수
const videoId=req.body.videoId;
let videoTitle="";

// getYoutubeTitle(videoId, async function(err,title){
// videoTitle=title;
// })



const response =
await axios.get(`https://www.googleapis.com/youtube/v3/videos?id=${videoId}&key=${process.env.YOUTUBE_API_KEY}
&part=snippet`);
console.log( response.data.items[0]?.snippet);

const videoTitle=response.data.items[0]?.snippet.title;
const youtubeDate=response.data.items[0]?.snippet.publishedAt;


// Object Storage에서 스크립트 파일 이름 가져오기
const scriptFileName = await getScriptFileName(process.env.OBJECT_STORAGE_BUCKET_SUMMARY_NAME, videoId);
Expand Down Expand Up @@ -53,7 +59,7 @@ export const summary = async (req, res) => {
console.log(gptResponse);

//유튜브 제목 요약
const titleData=await getTitle("임시");
const titleData=await getTitle(videoTitle);
console.log("제목 요약한것",titleData);
const titleJsonData=JSON.parse(titleData.replace("/",""));

Expand All @@ -62,12 +68,12 @@ export const summary = async (req, res) => {
console.log("돌아온 데이터",data);
console.log(summaryData.video_name);
const tagData=await splitTag(gptData.tag);
const YoutubeUploadTime=new Date();


//데이터 가공
const finalData={
"title":titleJsonData.Title,
"youtube_created_at":YoutubeUploadTime,
"youtube_created_at":youtubeDate,
"link":"https://www.youtube.com/watch?v="+videoId,
"description":summaryData.video_name[0].name,
"subheading":data,
Expand Down
6 changes: 3 additions & 3 deletions src/services/chatGPT.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ export const getSummary = async (scriptText) => {
"content": "content"
},
{
"content": "content",
"content": "content"
},
{
"content": "content",
"content": "content"
},
{
"content": "content",
"content": "content"
},
{
"content": "content"
Expand Down

0 comments on commit 36dadca

Please sign in to comment.