feat: make Player instance optional (#240)

This commit is contained in:
LuanRT
2022-11-16 03:17:59 -03:00
committed by GitHub
parent 0e5e0c0fab
commit fe4c5433cf
5 changed files with 11 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
import Player from '../../../core/Player';
import { InnertubeError } from '../../../utils/Utils';
class Format {
itag: string;
@@ -73,7 +74,8 @@ class Format {
* Decipher the streaming url of the format.
* @returns Deciphered URL.
*/
decipher(player: Player): string {
decipher(player: Player | undefined): string {
if (!player) throw new InnertubeError('Cannot decipher format, this session appears to have no valid player.');
return player.decipher(this.url, this.signature_cipher, this.cipher);
}
}