aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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();
}