search validation added

This commit is contained in:
killer069
2021-10-09 16:18:05 +05:30
parent 1ba762d10c
commit 6698a87983
11 changed files with 199 additions and 187 deletions

View File

@@ -10,22 +10,22 @@ interface youtubeDataOptions {
}
export function getCookies(): undefined | string {
let result = ''
if(!youtubeData?.cookie) return undefined
for (const [ key, value ] of Object.entries(youtubeData.cookie)){
result+= `${key}=${value};`
let result = '';
if (!youtubeData?.cookie) return undefined;
for (const [key, value] of Object.entries(youtubeData.cookie)) {
result += `${key}=${value};`;
}
return result;
}
export function setCookie(key: string, value: string): boolean {
if (!youtubeData?.cookie) return false;
key = key.trim()
value = value.trim()
Object.assign(youtubeData.cookie, { [key] : value })
return true
key = key.trim();
value = value.trim();
Object.assign(youtubeData.cookie, { [key]: value });
return true;
}
export function uploadCookie() {
if(youtubeData) fs.writeFileSync('.data/youtube.data', JSON.stringify(youtubeData, undefined, 4));
if (youtubeData) fs.writeFileSync('.data/youtube.data', JSON.stringify(youtubeData, undefined, 4));
}