From f59cfc7f290164acfacf23977c0203a945c630df Mon Sep 17 00:00:00 2001 From: zS1L3NT Mac Date: Sat, 13 Jan 2024 12:18:09 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20add=20ability=20to=20change=20local?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- package.json | 2 +- src/YTMusic.ts | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8bdb84c..cb2c32a 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,6 @@ $ bun test - [![eslint-plugin-simple-import-sort](https://img.shields.io/badge/eslint--plugin--simple--import--sort-latest-red?style=flat-square)](https://npmjs.com/package/eslint-plugin-simple-import-sort/v/latest) - [![prettier](https://img.shields.io/badge/prettier-latest-red?style=flat-square)](https://npmjs.com/package/prettier/v/latest) - Miscellaneous - - [![arktype](https://img.shields.io/badge/arktype-%5E1.0.28--alpha-red?style=flat-square)](https://npmjs.com/package/arktype/v/1.0.28-alpha) + - [![arktype](https://img.shields.io/badge/arktype-%5E1.0.29--alpha-red?style=flat-square)](https://npmjs.com/package/arktype/v/1.0.29-alpha) - [![axios](https://img.shields.io/badge/axios-%5E0.27.2-red?style=flat-square)](https://npmjs.com/package/axios/v/0.27.2) - [![tough-cookie](https://img.shields.io/badge/tough--cookie-%5E4.1.2-red?style=flat-square)](https://npmjs.com/package/tough-cookie/v/4.1.2) diff --git a/package.json b/package.json index 8b6f543..736a7d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ytmusic-api", - "version": "5.0.3", + "version": "5.1.0", "description": "YouTube Music API", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/YTMusic.ts b/src/YTMusic.ts index 31f7b90..39ffbbe 100644 --- a/src/YTMusic.ts +++ b/src/YTMusic.ts @@ -77,7 +77,9 @@ export default class YTMusic { /** * Initializes the API */ - public async initialize(cookies?: string) { + public async initialize(options?: { cookies?: string; GL?: string; HL?: string }) { + const { cookies, GL, HL } = options ?? {} + if (cookies) { for (const cookieString of cookies.split("; ")) { const cookie = Cookie.parse(`${cookieString}`) @@ -108,6 +110,13 @@ export default class YTMusic { } } + if (!this.config) { + this.config = {} + } + + if (GL) this.config.GL = GL + if (HL) this.config.HL = HL + return this }