Skip to content

Commit 8a98e55

Browse files
committed
feat: ytdl 옵션 추가
1 parent 4e3efed commit 8a98e55

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/routes/middleware/validation/uploadValidation.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@ const validateUploadUrl = async (req, res, next) => {
3333
throw error;
3434
}
3535

36-
const videoInfo = await ytdl.getBasicInfo(youtubeUrl, { agent });
36+
const videoInfo = await ytdl.getBasicInfo(youtubeUrl, {
37+
agent,
38+
requestOptions: {
39+
headersTimeout: 1000 * 10,
40+
bodyTimeout: 1000 * 10,
41+
headers: {
42+
referer: "https://www.youtube.com/",
43+
},
44+
},
45+
});
3746

3847
validateMetadata(videoInfo.videoDetails);
3948

src/services/videoService.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,17 @@ const getYoutubeVideo = async (youtubeUrl) => {
1111
uri: "http://152.26.229.66:9443",
1212
});
1313

14-
const videoStream = ytdl(youtubeUrl, { quality: "highestvideo", agent });
14+
const videoStream = ytdl(youtubeUrl, {
15+
quality: "highestvideo",
16+
agent,
17+
requestOptions: {
18+
headersTimeout: 1000 * 10,
19+
bodyTimeout: 1000 * 10,
20+
headers: {
21+
referer: "https://www.youtube.com/",
22+
},
23+
},
24+
});
1525

1626
return videoStream;
1727
};

0 commit comments

Comments
 (0)