Skip to content

Commit 010f6f2

Browse files
committed
refactor(content-utils): remove YTDL_COOKIE_PATH and related YouTube duration retrieval logic
1 parent 0fab030 commit 010f6f2

File tree

3 files changed

+0
-34
lines changed

3 files changed

+0
-34
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ docker run -p 3000:3000 qlaffont-livechatccb \
6262
-e DEFAULT_DURATION='5' \ # <-- Durée par défaut si le contenu n'est pas vidéo ou audio
6363
-e HIDE_COMMANDS_DISABLED='false' \ # <-- Si vous souhaitez désactiver les commandes masquées, vous pouvez modifier la valeur de 'false' à 'true'
6464
-e API_URL='API-URL-TO-REPLACE' # <-- Remplacer par l'adresse où l'utilisateur se connectera (Ex: https://livechat.domainname.com)
65-
-e YTDL_COOKIE_PATH='YTDL-COOKIE-PATH-TO-REPLACE' # <-- Remplacer par le chemin du fichier cookies.json (voir https://github.com/distubejs/ytdl-core#cookies-support)
6665
```
6766

6867
OU
@@ -148,7 +147,6 @@ docker run -p 3000:3000 qlaffont-livechatccb \
148147
-e DEFAULT_DURATION='5' \ # <-- Default duration if content is not video or audio
149148
-e HIDE_COMMANDS_DISABLED='false' \ # <-- If you want to disable hided commands, you can change the value from 'false' to 'true'
150149
-e API_URL='API-URL-TO-REPLACE' \ # <--Replace with the endpoint where user will connect (Ex: https://livechat.domainname.com)
151-
-e YTDL_COOKIE_PATH='YTDL-COOKIE-PATH-TO-REPLACE' # <-- Replace with the path of the cookies.json file (see https://github.com/distubejs/ytdl-core#cookies-support)
152150
-e I18N='en'
153151
```
154152

src/services/content-utils.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import fetch from 'node-fetch';
33
import { getVideoDurationInSeconds } from 'get-video-duration';
44
import { fileTypeFromBuffer } from 'file-type';
55
import mime from 'mime-types';
6-
import { Innertube } from 'youtubei.js';
7-
import { env } from './env';
86

97
function getFileTypeWithRegex(url) {
108
const regex = /(?:\.([^.]+))?$/; // Regular expression to capture file extension
@@ -49,33 +47,5 @@ export const getContentInformationsFromUrl = async (url: string) => {
4947
mediaDuration = await getVideoDurationInSeconds(url, 'ffprobe');
5048
} catch (error) {}
5149

52-
//if it is a youtube video, get the duration from the url
53-
if (url.includes('youtube.com') || url.includes('youtu.be')) {
54-
try {
55-
// Create Innertube instance with optional cookie data
56-
const options: any = {};
57-
58-
//if file exist on root of app, use it
59-
if (fs.existsSync(env.YTDL_COOKIE_PATH)) {
60-
const cookieData = JSON.parse(fs.readFileSync(env.YTDL_COOKIE_PATH, 'utf8'));
61-
options.cookie = cookieData;
62-
}
63-
64-
const innertube = await Innertube.create(options);
65-
const info = await innertube.getInfo(url);
66-
67-
// Get duration from basic_info
68-
if (info.basic_info?.duration) {
69-
mediaDuration = info.basic_info.duration;
70-
}
71-
72-
// Check if it's crawlable (similar to isCrawlable)
73-
mediaIsShort = info.basic_info?.is_crawlable ?? true;
74-
contentType = 'video/mp4';
75-
} catch (error) {
76-
console.error('Error getting YouTube video info:', error);
77-
}
78-
}
79-
8050
return { contentType, mediaDuration, mediaIsShort };
8151
};

src/services/env.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ export const env = createEnv({
2727
.string()
2828
.default('5')
2929
.transform((s) => parseInt(s)),
30-
31-
YTDL_COOKIE_PATH: z.string(),
3230
},
3331
runtimeEnv: process.env,
3432
});

0 commit comments

Comments
 (0)