better handling all around for files and symlinks

This commit is contained in:
2023-10-17 23:09:36 +02:00
parent 5bee1b6382
commit d8ca28f2ff
14 changed files with 90 additions and 260 deletions

View File

@@ -1,17 +1,19 @@
import fs from 'fs';
import path from 'path';
import { error } from "@sveltejs/kit";
import { getStreamInfo } from "$lib/database.js";
import { dev } from "$app/environment";
import { STREAM_JSON_LOCATION } from '$env/static/private';
let getOriginalJson, writeSideloadJson;
export let actions;
// utilities for manipulating original stream JSONs
if (dev) {
const jsonFolder = './db/stream_json/';
const jsonFolder = path.resolve(STREAM_JSON_LOCATION);
getOriginalJson = function (streamId) {
const filePath = jsonFolder + streamId + ".sideload.json";
const filePath = path.join(jsonFolder, streamId + ".sideload.json");
if (fs.existsSync(filePath)) {
const jsonString = fs.readFileSync(filePath, 'utf8');
return jsonString;
@@ -21,7 +23,7 @@ if (dev) {
}
writeSideloadJson = function (streamId, newJson) {
const filePath = jsonFolder + streamId + ".sideload.json";
const filePath = path.join(jsonFolder, streamId + ".sideload.json");
fs.writeFileSync(filePath, JSON.stringify(newJson), 'utf8');
}

View File

@@ -18,7 +18,7 @@
<StreamPage />
</div>
<div id="player">
<Player display={true} src="/files/tracks/{$currentStream.filename}" />
<Player display={true} src="/media/tracks/{$currentStream.filename}" />
</div>
</div>

View File

@@ -27,7 +27,7 @@
export let paused = true;
export let duration = 0;
export let muted = false;
export let volume = 1;
export let volume = 0.67;
export let preload = 'metadata';
export let iconColor = 'gray';
export let textColor = 'gray';
@@ -56,7 +56,7 @@
onMount(async () => {
const volumeData = localStorage.getItem('volume');
volume = volumeData ? parseFloat(volumeData) : 1;
volume = volumeData ? parseFloat(volumeData) : 0.67;
});
$: updateCurrentSong(currentTime, $currentSongIndex);