diff --git a/src/CommandLineParser.ts b/src/CommandLineParser.ts index 44f6b09..b1bb3cb 100644 --- a/src/CommandLineParser.ts +++ b/src/CommandLineParser.ts @@ -224,7 +224,7 @@ function checkQualityValue(argv: any): boolean { export function promptUser(choices: Array): number { - let index: number = readlineSync.keyInSelect(choices, 'Which resolution/format do you prefer?'); + const index: number = readlineSync.keyInSelect(choices, 'Which resolution/format do you prefer?'); if (index === -1) { process.exit(ERROR_CODE.CANCELLED_USER_INPUT); diff --git a/src/DownloadManager.ts b/src/DownloadManager.ts index 6360f05..547d162 100644 --- a/src/DownloadManager.ts +++ b/src/DownloadManager.ts @@ -135,7 +135,7 @@ export class DownloadManager { * @param options object with key: value pairs */ private setOptions(options: {[option: string]: string}, guid?: string): void { - let message: string = guid ? + const message: string = guid ? this.createMessage('aria2.changeOption', [guid, options]) : this.createMessage('aria2.changeGlobalOption', [options]); @@ -186,7 +186,7 @@ export class DownloadManager { // TODO: test download error parsing, not had a chance to yet logger.error(JSON.stringify(parsed)); - let errorGid: string = parsed.params.pop().gid.toString(); + const errorGid: string = parsed.params.pop().gid.toString(); this.queue.delete(errorGid); // TODO: add this to createMessage diff --git a/src/Thumbnail.ts b/src/Thumbnail.ts index aea3940..0502977 100644 --- a/src/Thumbnail.ts +++ b/src/Thumbnail.ts @@ -8,7 +8,7 @@ import { AxiosResponse } from 'axios'; export async function drawThumbnail(posterImage: string, session: Session): Promise { const apiClient: ApiClient = ApiClient.getInstance(session); - let thumbnail: Buffer = await apiClient.callUrl(posterImage, 'get', null, 'arraybuffer') + const thumbnail: Buffer = await apiClient.callUrl(posterImage, 'get', null, 'arraybuffer') .then((response: AxiosResponse | undefined) => response?.data); console.log(await terminalImage.buffer(thumbnail, { width: 70 } )); diff --git a/src/TokenCache.ts b/src/TokenCache.ts index d46360e..db9ff37 100644 --- a/src/TokenCache.ts +++ b/src/TokenCache.ts @@ -19,16 +19,16 @@ export class TokenCache { return null; } - let session: Session = JSON.parse(fs.readFileSync(this.tokenCacheFile, 'utf8')); + const session: Session = JSON.parse(fs.readFileSync(this.tokenCacheFile, 'utf8')); type Jwt = { [key: string]: any } const decodedJwt: Jwt = jwtDecode(session.AccessToken); - let now: number = Math.floor(Date.now() / 1000); - let exp: number = decodedJwt['exp']; - let timeLeft: number = exp - now; + const now: number = Math.floor(Date.now() / 1000); + const exp: number = decodedJwt['exp']; + const timeLeft: number = exp - now; if (timeLeft < 120) { logger.warn('Access token has expired! \n'); @@ -42,7 +42,7 @@ export class TokenCache { } public Write(session: Session): void { - let s: string = JSON.stringify(session, null, 4); + const s: string = JSON.stringify(session, null, 4); fs.writeFile('.token_cache', s, (err: any) => { if (err) { return logger.error(err); diff --git a/src/Utils.ts b/src/Utils.ts index 910c9e8..15346b2 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -23,7 +23,7 @@ async function extractGuids(url: string, client: ApiClient): Promise | undefined) => response?.data.metrics.videos); - let result: Array = await client.callApi(`groups/${groupMatch[1]}/videos?$top=${videoNumber}&$orderby=publishedDate asc`, 'get') + const result: Array = await client.callApi(`groups/${groupMatch[1]}/videos?$top=${videoNumber}&$orderby=publishedDate asc`, 'get') .then((response: AxiosResponse | undefined) => response?.data.value.map((item: any) => item.id)); return result; @@ -48,7 +48,7 @@ export async function parseCLIinput(urlList: Array, defaultOutDir: strin session: Session): Promise>> { const apiClient: ApiClient = ApiClient.getInstance(session); - let guidList: Array = []; + const guidList: Array = []; for (const url of urlList) { const guids: Array | null = await extractGuids(url, apiClient); @@ -85,8 +85,8 @@ export async function parseInputFile(inputFile: string, defaultOutDir: string, .split(/\r?\n/); const apiClient: ApiClient = ApiClient.getInstance(session); - let guidList: Array = []; - let outDirList: Array = []; + const guidList: Array = []; + const outDirList: Array = []; // if the last line was an url set this let foundUrl = false; @@ -101,7 +101,7 @@ export async function parseInputFile(inputFile: string, defaultOutDir: string, // parse if line is option else if (line.includes('-dir')) { if (foundUrl) { - let outDir: string | null = parseOption('-dir', line); + const outDir: string | null = parseOption('-dir', line); if (outDir && checkOutDir(outDir)) { outDirList.push(...Array(guidList.length - outDirList.length) diff --git a/src/VideoUtils.ts b/src/VideoUtils.ts index 804b1b2..5524f28 100644 --- a/src/VideoUtils.ts +++ b/src/VideoUtils.ts @@ -39,7 +39,7 @@ function isoDurationToString(time: string): string { export async function getVideosInfo(videoGuids: Array, session: Session, subtitles?: boolean): Promise> { - let metadata: Array