Skip to content

Commit

Permalink
[CR] Implement deleting streams
Browse files Browse the repository at this point in the history
Allows endless non-drm downloads
  • Loading branch information
AnimeDL committed May 23, 2024
1 parent dbc2c7d commit fc0736c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions crunchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1414,21 +1414,22 @@ export default class Crunchy implements ServiceClass {
pbData = await playbackReq.res.json() as PlaybackData;
}

let switchStream: CrunchyPlayStream | null = null;
const playbackReq = await this.req.getData(`https://cr-play-service.prd.crunchyrollsvc.com/v1/${currentVersion ? currentVersion.guid : currentMediaId}/console/switch/play`, AuthHeaders);
if(!playbackReq.ok || !playbackReq.res){
if(!playbackReq.ok || !playbackReq.res) {
console.error('Non-DRM Request Stream URLs FAILED!');
} else {
const playStream = await playbackReq.res.json() as CrunchyPlayStream;
switchStream = await playbackReq.res.json() as CrunchyPlayStream;
const derivedPlaystreams = {} as CrunchyStreams;
for (const hardsub in playStream.hardSubs) {
const stream = playStream.hardSubs[hardsub];
for (const hardsub in switchStream.hardSubs) {
const stream = switchStream.hardSubs[hardsub];
derivedPlaystreams[hardsub] = {
url: stream.url,
'hardsub_locale': stream.hlang
};
}
derivedPlaystreams[''] = {
url: playStream.url,
url: switchStream.url,
hardsub_locale: ''
};
pbData.data[0]['adaptive_switch_dash'] = {
Expand Down Expand Up @@ -1460,7 +1461,7 @@ export default class Crunchy implements ServiceClass {
console.warn('Decryption not enabled!');
}

for(const s of Object.keys(pbStreams)){
for (const s of Object.keys(pbStreams)) {
if (
(s.match(/hls/) || s.match(/dash/))
&& !(s.match(/hls/) && s.match(/drm/))
Expand All @@ -1483,7 +1484,7 @@ export default class Crunchy implements ServiceClass {
}
}

if(streams.length < 1){
if (streams.length < 1) {
console.warn('No full streams found!');
return undefined;
}
Expand Down Expand Up @@ -1522,8 +1523,7 @@ export default class Crunchy implements ServiceClass {
}
dlFailed = true;
}
}
else{
} else {
streams = streams.filter((s) => {
if(s.hardsub_lang != '-'){
return false;
Expand All @@ -1543,7 +1543,7 @@ export default class Crunchy implements ServiceClass {
let curStream:
undefined|typeof streams[0]
= undefined;
if(!dlFailed){
if (!dlFailed) {
options.kstream = typeof options.kstream == 'number' ? options.kstream : 1;
options.kstream = options.kstream > streams.length ? 1 : options.kstream;

Expand Down Expand Up @@ -2127,10 +2127,14 @@ export default class Crunchy implements ServiceClass {
else{
console.warn('Can\'t find urls for subtitles!');
}
}
else{
} else{
console.info('Subtitles downloading skipped!');
}

if (switchStream) {
await this.req.getData(`https://cr-play-service.prd.crunchyrollsvc.com/v1/token/${currentVersion ? currentVersion.guid : currentMediaId}/${switchStream.token}`, {...{method: 'DELETE'}, ...AuthHeaders});
}

await this.sleep(options.waittime);
}
return {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "multi-downloader-nx",
"short_name": "aniDL",
"version": "5.0.1",
"version": "5.0.2",
"description": "Downloader for Crunchyroll, Hidive, AnimeOnegai, and AnimationDigitalNetwork with CLI and GUI",
"keywords": [
"download",
Expand Down

0 comments on commit fc0736c

Please sign in to comment.