aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Isom <[email protected]>2020-03-15 15:13:12 -0500
committerMax Isom <[email protected]>2020-03-15 15:13:12 -0500
commitbf0843dd1d8fbaa7c06cdc6110f45d46ca6b4052 (patch)
treee1e9399d9b6a95298b1bec57b0de09cd3c45b194
parent260d5d2d73edb91e0ace0efd2e9f21b628f34b58 (diff)
downloadmuse-bf0843dd1d8fbaa7c06cdc6110f45d46ca6b4052.tar.xz
muse-bf0843dd1d8fbaa7c06cdc6110f45d46ca6b4052.zip
Don't cache livestreams
-rw-r--r--src/services/player.ts26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/services/player.ts b/src/services/player.ts
index 346b10a..dfdf4b0 100644
--- a/src/services/player.ts
+++ b/src/services/player.ts
@@ -106,14 +106,11 @@ export default class {
}
private getCachedPath(url: string): string {
- const hash = hasha(url);
- return path.join(this.cacheDir, `${hash}.webm`);
+ return path.join(this.cacheDir, hasha(url));
}
private getCachedPathTemp(url: string): string {
- const hash = hasha(url);
-
- return path.join('/tmp', `${hash}.webm`);
+ return path.join('/tmp', hasha(url));
}
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;
if (canDirectPlay) {
@@ -217,7 +207,17 @@ export default class {
youtubeStream.pipe(capacitor);
- capacitor.createReadStream().pipe(cacheStream);
+ // 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);
+ }
return capacitor.createReadStream();
}