Skip to content

Commit 4e3efed

Browse files
committed
feat: ytdl-core proxy 추가
1 parent 31fdf50 commit 4e3efed

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/routes/middleware/validation/uploadValidation.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ const validateUploadUrl = async (req, res, next) => {
2020
validateFields(req.body, REQUIRED_FIELDS.VIDEO_UPLOAD_REQUEST);
2121

2222
const { youtubeUrl } = req.body;
23+
const agent = ytdl.createProxyAgent({
24+
uri: "http://152.26.229.66:9443",
25+
});
2326
const isValid = ytdl.validateURL(youtubeUrl);
2427

2528
if (!isValid) {
@@ -30,7 +33,7 @@ const validateUploadUrl = async (req, res, next) => {
3033
throw error;
3134
}
3235

33-
const videoInfo = await ytdl.getBasicInfo(youtubeUrl);
36+
const videoInfo = await ytdl.getBasicInfo(youtubeUrl, { agent });
3437

3538
validateMetadata(videoInfo.videoDetails);
3639

src/services/videoService.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import { MESSAGES } from "../config/constants.js";
77
import { bucket } from "../config/gcs.js";
88

99
const getYoutubeVideo = async (youtubeUrl) => {
10-
const videoStream = ytdl(youtubeUrl, { quality: "highestvideo" });
10+
const agent = ytdl.createProxyAgent({
11+
uri: "http://152.26.229.66:9443",
12+
});
13+
14+
const videoStream = ytdl(youtubeUrl, { quality: "highestvideo", agent });
1115

1216
return videoStream;
1317
};

0 commit comments

Comments
 (0)