added total session death function

This commit is contained in:
stratumadev 2025-08-02 11:06:01 +02:00
parent 67d5a39f15
commit 6b1fc3abd0
5 changed files with 26 additions and 0 deletions

View file

@ -10,6 +10,7 @@ export type CrunchyDownloadOptions = {
cstream: keyof typeof CrunchyPlayStreams,
vstream: keyof typeof CrunchyPlayStreams,
astream: keyof typeof CrunchyPlayStreams,
tsd?: boolean,
novids?: boolean,
noaudio?: boolean,
x: number,

View file

@ -1620,6 +1620,18 @@ export default class Crunchy implements ServiceClass {
let videoStream: CrunchyPlayStream | null = null;
let audioStream: CrunchyPlayStream | null = null;
if (options.tsd) {
console.warn('Total Session Death Active');
const activeStreamsReq = await this.req.getData(api.streaming, AuthHeaders);
if (activeStreamsReq.ok && activeStreamsReq.res){
const data = await activeStreamsReq.res.json();
for (const s of data.items) {
await this.req.getData(`https://www.crunchyroll.com/playback/v1/token/${s.contentId}/${s.token}`, {...{method: 'DELETE'}, ...AuthHeaders});
}
console.warn(`Killed ${data.items?.length ?? 0} Sessions`);
}
}
const videoPlaybackReq = await this.req.getData(`https://www.crunchyroll.com/playback/v3/${currentVersion ? currentVersion.guid : currentMediaId}/${CrunchyPlayStreams[options.vstream]}/play`, AuthHeaders);
if (!videoPlaybackReq.ok || !videoPlaybackReq.res) {
console.warn('Request Video Stream URLs FAILED!');

View file

@ -34,6 +34,7 @@ export type APIType = {
drm: string;
drm_widevine: string;
drm_playready: string;
streaming: string;
/**
* Header
*/
@ -81,6 +82,8 @@ const api: APIType = {
drm_widevine: `${domain.www}/license/v1/license/widevine`,
// playready endpoint currently broken
drm_playready: `${domain.www}/license/v1/license/playReady`,
// endpoint to get active streaming sessions
streaming: `${domain.www}/playback/v1/sessions/streaming`,
crunchyDefHeader: {},
crunchyAuthHeader: {},
//hidive API

View file

@ -49,6 +49,7 @@ let argvC: {
cstream: keyof typeof CrunchyPlayStreams;
vstream: keyof typeof CrunchyPlayStreams;
astream: keyof typeof CrunchyPlayStreams;
tsd: boolean | undefined;
partsize: number;
hslang: string;
dlsubs: string[];

View file

@ -364,6 +364,15 @@ const args: TAppArg<boolean|number|string|unknown[]>[] = [
docDescribe: true,
usage: '${device}'
},
{
name: 'tsd',
group: 'dl',
describe: '(Total Session Death) Kills all active Crunchyroll Streaming Sessions to prevent getting the "TOO_MANY_ACTIVE_STREAMS" error',
docDescribe: true,
service: ['crunchy'],
type: 'boolean',
usage: ''
},
{
name: 'hslang',
group: 'dl',