Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ytmusic): Allow authUser to be number or string #201

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/ytmusic.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"clients": [],
"data": {
"cookie": "VISITOR_INFO1_LIVE=jMDXz2_L8rY; __Secure-3PAPISID=3AxsXpSXGqOInSDn1jEKn; DEVICE_INFO=ChxOekU0TmTBpjek5EWZ0G; YSC=7gZdl3Zdl3; SID=TwhNsaZRXYTAtXxzGyu6rZdpg2HvGROeW8J4Ym_FhkhoZMUYEQ.; __Secure-1PSID=TwhNOsaZRXYTyRBe4rxAtXRIKsIEtk_Qot2VLBNfHQrQ.; __Secure-3PSID=ZRXYTAtXRIKsIEtk_Qot2yRBerZdpg2HvvZRXYTAtXRIKsIEtk_Qot2yRBerkuZICFQ.; HSID=A1UMmELW79; SSID=AKhomOs; APISID=IlHHmuzkPdQzZZDhHn3; SAPISID=3AxsXpy0u75Qb/n1jEKn; __Secure-1PAPISID=3AxsXpQb/AkSDn1jEKn; LOGIN_INFO=AFmP6vFpyVCZZAIgDwbkhWMBBhluaIWAPP:QUQ314UW5NWMjNmd2ZUJnYnJsakdIMjZoaE5zVVMjNmd2ZZUiHRlb3ZlV3ZIcUVyRVIMjNmdjNmd2ZZUivYlNqX2ZNZUiHdUNFNFdaYmJIW1NkJRX3hqdlU2YnFESkFuSS1uTldnZVRmLXNjWFc5OUJuR3dTd3JsZGZYa2EtZFQ2a0k2Ry1KQQ==; PREF=volume=26; SIDCC=AFvI_94PxXwls-ndqpGfPgFX3FWj80y_94PxXwls-ndqfSh15sP; __Secure-1PSIDCC=AFvIBnUbRr96I96UCIp2U4T8HRVk2B0HfKzhzxwsiP; __Secure-3PSIDCC=AFvIB3bINuUN0ETDR9gO91wpwWIVmpGki3BxT3bINuUN0ETDR9gO91wCH",
"authUser": "0"
"authUser": 0
}
}
]
2 changes: 1 addition & 1 deletion src/backend/common/infrastructure/config/source/ytmusic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface YTMusicCredentials {
*
* @example [0]
* */
authUser?: number
authUser?: number | string
}

export interface YTMusicData extends YTMusicCredentials, CommonSourceData, PollingOptions {
Expand Down
5 changes: 4 additions & 1 deletion src/backend/common/schema/aio-source.json
Original file line number Diff line number Diff line change
Expand Up @@ -2734,7 +2734,10 @@
"authUser": {
"description": "If the 'X-Goog-AuthUser' header is present in the Request Headers for music.youtube.com it must also be included",
"title": "authUser",
"type": "number"
"type": [
"string",
"number"
]
},
"cookie": {
"description": "The cookie retrieved from the Request Headers of music.youtube.com after logging in.\n\nSee https://github.com/nickp10/youtube-music-ts-api/blob/master/DOCUMENTATION.md#authenticate and https://ytmusicapi.readthedocs.io/en/latest/setup.html#copy-authentication-headers for how to retrieve this value.",
Expand Down
5 changes: 4 additions & 1 deletion src/backend/common/schema/aio.json
Original file line number Diff line number Diff line change
Expand Up @@ -3692,7 +3692,10 @@
"authUser": {
"description": "If the 'X-Goog-AuthUser' header is present in the Request Headers for music.youtube.com it must also be included",
"title": "authUser",
"type": "number"
"type": [
"string",
"number"
]
},
"cookie": {
"description": "The cookie retrieved from the Request Headers of music.youtube.com after logging in.\n\nSee https://github.com/nickp10/youtube-music-ts-api/blob/master/DOCUMENTATION.md#authenticate and https://ytmusicapi.readthedocs.io/en/latest/setup.html#copy-authentication-headers for how to retrieve this value.",
Expand Down
5 changes: 4 additions & 1 deletion src/backend/common/schema/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -2552,7 +2552,10 @@
"authUser": {
"description": "If the 'X-Goog-AuthUser' header is present in the Request Headers for music.youtube.com it must also be included",
"title": "authUser",
"type": "number"
"type": [
"string",
"number"
]
},
"cookie": {
"description": "The cookie retrieved from the Request Headers of music.youtube.com after logging in.\n\nSee https://github.com/nickp10/youtube-music-ts-api/blob/master/DOCUMENTATION.md#authenticate and https://ytmusicapi.readthedocs.io/en/latest/setup.html#copy-authentication-headers for how to retrieve this value.",
Expand Down
2 changes: 1 addition & 1 deletion src/backend/sources/YTMusicSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export default class YTMusicSource extends AbstractSource {
// @ts-expect-error default does exist
const ytm = new YouTubeMusic.default() as YouTubeMusic;
try {
this.apiInstance = await ytm.authenticate(this.config.data.cookie, this.config.data.authUser, this.onAuthUpdate);
this.apiInstance = await ytm.authenticate(this.currentCreds.cookie, typeof this.config.data.authUser === 'string' ? Number.parseInt(this.config.data.authUser) : this.config.data.authUser, this.onAuthUpdate);
} catch (e: any) {
this.logger.error('Failed to authenticate', e);
throw e;
Expand Down