add ability to change locale

This commit is contained in:
zS1L3NT Mac 2024-01-13 12:18:09 +08:00
parent 0c9137a5af
commit f59cfc7f29
No known key found for this signature in database
GPG Key ID: 02BE07CD431E4F42
3 changed files with 12 additions and 3 deletions

View File

@ -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)

View File

@ -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",

View File

@ -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
}