A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
Switch to forward slash for linux - this will break everything :)
aminnausin822ad1f1ab6a
diff --git a/app/Jobs/IndexFiles.php b/app/Jobs/IndexFiles.phpindex 644da5b2..be7091b1 100644--- a/app/Jobs/IndexFiles.php+++ b/app/Jobs/IndexFiles.php@@ -35,7 +35,7 @@ class IndexFiles implements ShouldQueue, ShouldBeUnique}public function generateData() {- $path = "public\media\\";+ $path = "public/media/";if(!Storage::exists($path)){$error = 'Invalid Directory: "media"';@@ -155,7 +155,7 @@ class IndexFiles implements ShouldQueue, ShouldBeUnique$data = array("categories"=>$categories,"folders"=>$folders,"videos"=>$videos);- $dataCache = Storage::json('public\dataCache.json') ?? array();+ $dataCache = Storage::json('public/dataCache.json') ?? array();$dataCache[date("Y-m-d-h:i:sa")] = array("job"=>"index", "data"=>$data);// TODO: stop adding empty data cache entries if the last entry was also empty. Need to check last one but popping removes it and loses the key so I cannot add it back on if it wasnt empty.@@ -165,7 +165,7 @@ class IndexFiles implements ShouldQueue, ShouldBeUnique}private function generateCategories($path){- $data = Storage::json('public\categories.json') ?? array("next_ID"=>1, "categoryStructure" => array()); //array("anime"=>1,"tv"=>2,"yogscast"=>3); // read from json+ $data = Storage::json('public/categories.json') ?? array("next_ID"=>1, "categoryStructure" => array()); //array("anime"=>1,"tv"=>2,"yogscast"=>3); // read from json$scanned = array_map("htmlspecialchars", scandir($path)); // read folder structure$currentID = $data["next_ID"];@@ -218,7 +218,7 @@ class IndexFiles implements ShouldQueue, ShouldBeUnique}private function generateFolders($path, $categoryStructure){- $data = Storage::json('public\folders.json') ?? array("next_ID"=>1,"folderStructure"=>array()); //array("anime/frieren"=>array("id"=>0,"name"=>"frieren"),"starwars/andor"=>array("id"=1,"name"="andor")); // read from json+ $data = Storage::json('public/folders.json') ?? array("next_ID"=>1,"folderStructure"=>array()); //array("anime/frieren"=>array("id"=>0,"name"=>"frieren"),"starwars/andor"=>array("id"=1,"name"="andor")); // read from json$scannedCategories = array_keys($categoryStructure);$cost = 0;@@ -257,13 +257,13 @@ class IndexFiles implements ShouldQueue, ShouldBeUniqueforeach ($scannedCategories as $category) { // O(n) where n = number of folders * 2 (for scan)$cost++;- $folders = Storage::directories("$path\\$category"); // Immediate folders (dont scan sub folders)+ $folders = Storage::directories("$path/$category"); // Immediate folders (dont scan sub folders)foreach ($folders as $folder){$cost++;$name = basename($folder);- $key = "$category\\$name";+ $key = "$category/$name";if($name === ".thumbs") continue;@@ -291,7 +291,7 @@ class IndexFiles implements ShouldQueue, ShouldBeUnique}private function generateVideos($path, $folderStructure){- $data = Storage::json('public\videos.json') ?? array("next_ID"=>1,"videoStructure"=>array()); //array("anime/frieren/S1E01.mp4"=>array("id"=>0,"name"=>"S1E01"),"starwars/andor/S1E01.mkv"=>array("id"=1,"name"="S1E01.mkv")); // read from json+ $data = Storage::json('public/videos.json') ?? array("next_ID"=>1,"videoStructure"=>array()); //array("anime/frieren/S1E01.mp4"=>array("id"=>0,"name"=>"S1E01"),"starwars/andor/S1E01.mkv"=>array("id"=1,"name"="S1E01.mkv")); // read from json$scannedFolders = array_keys($folderStructure);$cost = 0;@@ -336,10 +336,10 @@ class IndexFiles implements ShouldQueue, ShouldBeUniqueforeach ($scannedFolders as $folder) { // O(n) where n = number of folders * 2 (for scan)$cost++;- $folderAccessTime = filemtime("{$rawPath}public\media\\$folder\\");+ $folderAccessTime = filemtime("{$rawPath}public/media/$folder/");if($folderAccessTime <= $folderStructure[$folder]["last_scan"]){- $unModefiedFolders["storage\\". basename($path) . "\\$folder"] = 1;+ $unModefiedFolders["storage/". basename($path) . "/$folder"] = 1;continue;}@@ -352,7 +352,7 @@ class IndexFiles implements ShouldQueue, ShouldBeUnique$name = basename($file);$cleanName = basename($file,".$ext");- $key = "storage\\". basename($path) . "\\$folder\\$name";+ $key = "storage/". basename($path) . "/$folder/$name";$rawFile = "$rawPath$file";if(isset($stored[$key])){$current[$key] = $stored[$key]; // add to currentdiff --git a/app/Jobs/SyncFiles.php b/app/Jobs/SyncFiles.phpindex a0f1fd90..ec4ebff8 100644--- a/app/Jobs/SyncFiles.php+++ b/app/Jobs/SyncFiles.php@@ -37,7 +37,7 @@ class SyncFiles implements ShouldQueue, ShouldBeUnique// Idea: Compare categories folders and videos json files with data on sql server. Sync local copies with sql server if this is master storage (ie all files should be available)// -> then if you index files, it should delete sql entries correctly if anything there does not exist locally- $path = "public\media\\";+ $path = "public/media/";if(!Storage::exists($path)){$error = 'Invalid Directory: "media"';@@ -61,7 +61,7 @@ class SyncFiles implements ShouldQueue, ShouldBeUnique$data = array("categories"=>$categories,"folders"=>$folders,"videos"=>$videos);- $dataCache = Storage::json('public\dataCache.json') ?? array();+ $dataCache = Storage::json('public/dataCache.json') ?? array();$dataCache[date("Y-m-d-h:i:sa")] = array("job"=>"sync", "data"=>$data);Storage::disk('public')->put('dataCache.json', json_encode($dataCache, JSON_UNESCAPED_SLASHES));@@ -69,7 +69,7 @@ class SyncFiles implements ShouldQueue, ShouldBeUnique}private function generateCategories(){- $data = Storage::json('public\categories.json') ?? array("next_ID"=>1, "categoryStructure" => array()); //array("anime"=>1,"tv"=>2,"yogscast"=>3); // read from json+ $data = Storage::json('public/categories.json') ?? array("next_ID"=>1, "categoryStructure" => array()); //array("anime"=>1,"tv"=>2,"yogscast"=>3); // read from json$scanned = Category::all(); // read folder structure$currentID = $data["next_ID"];@@ -111,7 +111,7 @@ class SyncFiles implements ShouldQueue, ShouldBeUnique}private function generateFolders($path){- $data = Storage::json('public\folders.json') ?? array("next_ID"=>1,"folderStructure"=>array()); //array("anime/frieren"=>array("id"=>0,"name"=>"frieren"),"starwars/andor"=>array("id"=1,"name"="andor")); // read from json+ $data = Storage::json('public/folders.json') ?? array("next_ID"=>1,"folderStructure"=>array()); //array("anime/frieren"=>array("id"=>0,"name"=>"frieren"),"starwars/andor"=>array("id"=1,"name"="andor")); // read from json$cost = 0;$scanned = Folder::all();@@ -156,7 +156,7 @@ class SyncFiles implements ShouldQueue, ShouldBeUnique}private function generateVideos($path, $folderStructure){- $data = Storage::json('public\videos.json') ?? array("next_ID"=>1,"videoStructure"=>array()); //array("anime/frieren/S1E01.mp4"=>array("id"=>0,"name"=>"S1E01"),"starwars/andor/S1E01.mkv"=>array("id"=1,"name"="S1E01.mkv")); // read from json+ $data = Storage::json('public/videos.json') ?? array("next_ID"=>1,"videoStructure"=>array()); //array("anime/frieren/S1E01.mp4"=>array("id"=>0,"name"=>"S1E01"),"starwars/andor/S1E01.mkv"=>array("id"=1,"name"="S1E01.mkv")); // read from json$scanned = Video::all();$cost = 0;@@ -172,7 +172,7 @@ class SyncFiles implements ShouldQueue, ShouldBeUnique// if that exists locally in stored, overwrite with db data (add to current) if different else add to current// if not exists, add db directly to current$name = $video->name;- $path = dirname($video->path) . "\\" . basename($video->path);+ $path = dirname($video->path) . "/" . basename($video->path);$id = $video->id;$current[$path] = $id;diff --git a/app/Jobs/VerifyFiles.php b/app/Jobs/VerifyFiles.phpindex 95c9ae67..27f1c69f 100644--- a/app/Jobs/VerifyFiles.php+++ b/app/Jobs/VerifyFiles.php@@ -56,10 +56,10 @@ class VerifyFiles implements ShouldQueueif(is_null($video->duration)){- // dump(Storage::path('') . 'public\\' . substr($video->path, 8));+ // dump(Storage::path('') . 'public//' . substr($video->path, 8));$ffprobe = FFMpegFFProbe::create();$duration = floor($ffprobe- ->format(Storage::path('') . 'public\\' . substr($video->path, 8)) // extracts file informations+ ->format(Storage::path('') . 'public/' . substr($video->path, 8)) // extracts file informations->get('duration'));$changes['duration'] = $duration;}