mirror of
https://github.com/BluemediaGER/muse.git
synced 2024-11-10 03:55:29 +01:00
Don't cache livestreams
This commit is contained in:
parent
260d5d2d73
commit
bf0843dd1d
|
@ -106,14 +106,11 @@ export default class {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getCachedPath(url: string): string {
|
private getCachedPath(url: string): string {
|
||||||
const hash = hasha(url);
|
return path.join(this.cacheDir, hasha(url));
|
||||||
return path.join(this.cacheDir, `${hash}.webm`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getCachedPathTemp(url: string): string {
|
private getCachedPathTemp(url: string): string {
|
||||||
const hash = hasha(url);
|
return path.join('/tmp', hasha(url));
|
||||||
|
|
||||||
return path.join('/tmp', `${hash}.webm`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async isCached(url: string): Promise<boolean> {
|
private async isCached(url: string): Promise<boolean> {
|
||||||
|
@ -191,13 +188,6 @@ export default class {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const cacheTempPath = this.getCachedPathTemp(url);
|
|
||||||
const cacheStream = createWriteStream(cacheTempPath);
|
|
||||||
|
|
||||||
cacheStream.on('finish', async () => {
|
|
||||||
await fs.rename(cacheTempPath, cachedPath);
|
|
||||||
});
|
|
||||||
|
|
||||||
let youtubeStream: Readable;
|
let youtubeStream: Readable;
|
||||||
|
|
||||||
if (canDirectPlay) {
|
if (canDirectPlay) {
|
||||||
|
@ -217,7 +207,17 @@ export default class {
|
||||||
|
|
||||||
youtubeStream.pipe(capacitor);
|
youtubeStream.pipe(capacitor);
|
||||||
|
|
||||||
|
// Don't cache livestreams
|
||||||
|
if (!info.player_response.videoDetails.isLiveContent) {
|
||||||
|
const cacheTempPath = this.getCachedPathTemp(url);
|
||||||
|
const cacheStream = createWriteStream(cacheTempPath);
|
||||||
|
|
||||||
|
cacheStream.on('finish', async () => {
|
||||||
|
await fs.rename(cacheTempPath, cachedPath);
|
||||||
|
});
|
||||||
|
|
||||||
capacitor.createReadStream().pipe(cacheStream);
|
capacitor.createReadStream().pipe(cacheStream);
|
||||||
|
}
|
||||||
|
|
||||||
return capacitor.createReadStream();
|
return capacitor.createReadStream();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue