A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
Upgraded to Laravel
aminnausin0ec468a1a9a6
diff --git a/.gitignore b/.gitignoreindex 7fe978f8..7fe28539 100644--- a/.gitignore+++ b/.gitignore@@ -17,3 +17,4 @@ yarn-error.log/.fleet/.idea/.vscode+/media/*\ No newline at end of filediff --git a/README.md b/README.mdindex 1824fc1b..59cfec73 100644--- a/README.md+++ b/README.md@@ -1,66 +1,31 @@-<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>+## This is a simple web based media hosting server.-<p align="center">-<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>-<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>-<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>-<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>-</p>+Videos are grouped by folders and listed in a table with the file name and date.+This is good for a home server and provides fast and easy access to media.+The website is responsive by design and works on mobile devices. HVEC support depends on the device used.-## About Laravel+### Installation-Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:+Rquires Apache and PHP 8.-- [Simple, fast routing engine](https://laravel.com/docs/routing).-- [Powerful dependency injection container](https://laravel.com/docs/container).-- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.-- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).-- Database agnostic [schema migrations](https://laravel.com/docs/migrations).-- [Robust background job processing](https://laravel.com/docs/queues).-- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).+Create symbolic links in the resources folder that point to where videos are stored.-Laravel is accessible, powerful, and provides tools required for large, robust applications.+Different folders are accessed ?dir=foldername after the website's url.-## Learning Laravel+The default folder is defined on the second line of index.php as RESOURCE_DEFAULT.+This folder is shown when the user does not specify a folder.-Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.+Supported File Types:+- MP4+- MKV-You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.+### Demo-If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.+Screenshots of the current webpage on Desktop and on Android.-## Laravel Sponsors+!+!-We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).--### Premium Partners--- **[Vehikl](https://vehikl.com/)**-- **[Tighten Co.](https://tighten.co)**-- **[WebReinvent](https://webreinvent.com/)**-- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**-- **[64 Robots](https://64robots.com)**-- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**-- **[Cyber-Duck](https://cyber-duck.co.uk)**-- **[DevSquad](https://devsquad.com/hire-laravel-developers)**-- **[Jump24](https://jump24.co.uk)**-- **[Redberry](https://redberry.international/laravel/)**-- **[Active Logic](https://activelogic.com)**-- **[byte5](https://byte5.de)**-- **[OP.GG](https://op.gg)**--## Contributing--Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).--## Code of Conduct--In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).--## Security Vulnerabilities--If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [[email protected]](mailto:[email protected]). All security vulnerabilities will be promptly addressed.--## License--The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).+|||+|:-:|:-:|+|Dark Mode on Desktop|Light Mode on Android|\ No newline at end of filediff --git a/app/Http/Controllers/DirectoryController.php b/app/Http/Controllers/DirectoryController.phpnew file mode 100644index 00000000..66a02735--- /dev/null+++ b/app/Http/Controllers/DirectoryController.php@@ -0,0 +1,97 @@+<?php++namespace App\Http\Controllers;++use Illuminate\Http\Request;+use Illuminate\Support\Facades\Storage;+use Illuminate\Support\Facades\File;++class DirectoryController extends Controller+{+ public function showDirectory() {+ return view('home');+ }++ public function generateDirectory(Request $request) {+ $dir = $request->dir;+ $mediaRoot = '/media/';+ $publicRoot = '/storage';+ $default = 'tv';+ $path = isset($dir) ? $mediaRoot . $dir : $mediaRoot . $default ;++ if(!Storage::exists('public/' . $path)){+ $error = 'Invalid Directory: "' . $path . '"';++ return json_encode(array("success"=>false, "result"=>"", "error"=>$error), JSON_UNESCAPED_SLASHES);+ }++ $allDirectories = Storage::directories('public' . $path);++ $folders = array();+ $currentFolder = array("name"=>"", "files"=>array());++ foreach ($allDirectories as $directory) {+ if (basename($directory) != '.thumbs') {+ $currentFolder['name'] = basename($directory);+ $files = File::allFiles(storage_path('app') . '/' . $directory);++ foreach($files as $file){+ if ($file->getExtension() == 'mp4' || $file->getExtension() == 'mkv' ) {+ $fileData = array('name'=> $publicRoot . $path . '/' . basename($directory) . '/' . basename($file), 'title'=>basename($file), 'date' => filectime($file), 'formattedDate' => date("Y-m-d g:i A", filectime($file)));+ array_push($currentFolder['files'], $fileData);+ }+ }+ }+ array_push($folders, $currentFolder);+ $currentFolder['files'] = array();+ }++ return json_encode(array("success"=>true, "result"=>$folders, "error"=>""), JSON_UNESCAPED_SLASHES);+ }++ public function testStorage() {+ $dir = 'tv';+ $mediaRoot = '/storage/media/';+ $default = 'tv';+ $path = isset($dir) ? $mediaRoot . $dir : $mediaRoot . $default ;++++ $allDirectories = Storage::directories('public' . $path);++ dd($allDirectories);+ $folders = array();+ $currentFolder = array("name"=>"", "files"=>array());++ foreach ($allDirectories as $directory) {+ if (basename($directory) != '.thumbs') {+ $currentFolder['name'] = basename($directory);++ //$files = File::allFiles(public_path('resources\\' . $dir) . '\\' . basename($directory));+++ $files = File::allFiles(storage_path('app') . '/' . $directory);+++ foreach($files as $file){+ if ($file->getExtension() == 'mp4' || $file->getExtension() == 'mkv' ) {+ $fileData = array('name'=> $path . '/' . basename($directory) . '/' . basename($file), 'title'=>basename($file), 'date' => filectime($file), 'formattedDate' => date("Y-m-d g:i A", filectime($file)));+ array_push($currentFolder['files'], $fileData);+ }+ }+ }+ array_push($folders, $currentFolder);+ $currentFolder['files'] = array();+ }++ dd(json_encode(array("success"=>true, "result"=>$folders, "error"=>""), JSON_UNESCAPED_SLASHES));+ }+}+++++ // $files = array(array("name"=>"\\resources\\tv\\Frieren\\S1E01.mp4","title"=>"S1E01.mp4","date"=>1704677712,"formattedDate"=>"2024-01-08 1:35 AM"));+ // $folders = array(array("name"=>"Frieren", "files"=>$files));+ //dd($dirs, $files);+ //dd($files);\ No newline at end of filediff --git a/legacy/.gitignore b/legacy/.gitignoredeleted file mode 100644index c49182ab..00000000--- a/legacy/.gitignore+++ /dev/null@@ -1 +0,0 @@-/resources/*\ No newline at end of filediff --git a/legacy/README.md b/legacy/README.mddeleted file mode 100644index 59cfec73..00000000--- a/legacy/README.md+++ /dev/null@@ -1,31 +0,0 @@-## This is a simple web based media hosting server.--Videos are grouped by folders and listed in a table with the file name and date.-This is good for a home server and provides fast and easy access to media.-The website is responsive by design and works on mobile devices. HVEC support depends on the device used.--### Installation--Rquires Apache and PHP 8.--Create symbolic links in the resources folder that point to where videos are stored.--Different folders are accessed ?dir=foldername after the website's url.--The default folder is defined on the second line of index.php as RESOURCE_DEFAULT.-This folder is shown when the user does not specify a folder.--Supported File Types:-- MP4-- MKV--### Demo--Screenshots of the current webpage on Desktop and on Android.--!-!--|||-|:-:|:-:|-|Dark Mode on Desktop|Light Mode on Android|\ No newline at end of filediff --git a/legacy/index.php b/legacy/index.phpdeleted file mode 100644index 799169b4..00000000--- a/legacy/index.php+++ /dev/null@@ -1,132 +0,0 @@-<?php-require_once "./config.php";-?>-<!doctype html>-<html lang="en" >- <head>- <meta charset="utf-8">- <meta name="viewport" content="width=device-width, initial-scale=1">- <title>Anime?</title>-- <!-- Bootstrap -->- <link href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css" rel="stylesheet" >- <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>-- <!-- Jquery -->- <script src="https://code.jquery.com/jquery-3.7.1.js"></script>-- <!-- DataTables -->- <script src="https://cdn.datatables.net/1.13.7/js/jquery.dataTables.min.js"></script>- <!-- <script src="https://cdn.datatables.net/1.13.7/js/dataTables.bootstrap5.min.js"></script> -->-- <!-- <link href="https://cdn.datatables.net/1.13.7/css/dataTables.bootstrap5.min.css" rel="stylesheet" crossorigin="anonymous"> -->- <link href="https://cdn.datatables.net/1.13.7/css/jquery.dataTables.min.css" rel="stylesheet">--- <!-- Local -->- <link href="./css/main.css" rel="stylesheet" >- <script src="./js/main.js"></script>- </head>- <body class="light-mode">- <main class="container">- <div class="row">- <div class="col-sm-12">- <div class="neu-card light-mode">- <div class="col-sm-12">- <!-- <h3 id="mp4-title" class="col-sm-11"></h3>- <hr> -->- <div style="display: flex; flex-direction: row-reverse;">- <div style="width:auto; display: flex; align-items: center;" class="ms-3">- <div class="toggle-switch">- <label class="switch-label">- <input type="checkbox" class="checkbox" id="dark-mode-toggle">- <span class="slider"></span>- </label>- </div>- </div>- <div style="display: flex; justify-content: space-between; width: 100%;">- <h3 id="mp4-title" ></h3>- <h3 id="mp4-title-folder"></h3>- </div>- </div>- <hr class="mt-2">- <video id="vid-source" width="100%" src="" type="video/mp4" controls>- </video>- </div>- <hr id='preData'>-- <div id='dataContainer'>- <!-- <?php- // $path = RESOURCE_DIR . RESOURCE_DEFAULT;-- // if(isset($_GET['dir'])) $path = RESOURCE_DIR . $_GET['dir'] . '\\';- // $folderCount = 0;-- // if(! is_dir(($path))){- // echo '<p>Invalid Directory: ' . $path . '</p>';- // return;- // }-- // foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST) as $file) {- // /** @var SplFileInfo $file */-- // if ($file->isDir() && basename($file) != '.thumbs') {-- // $out = '- // <div class="col-sm-12" style="padding: 2%;">- // <div class="row mb-4">- // <h4 class="col-sm-10">' . basename($file) . '</h4>- // <button class="col-sm-2 btn btn-light folder-toggle" id="dataTable-' . $folderCount . '-collapse-toggle" type="button" data-bs-toggle="collapse" data-bs-target="#dataTable-' . $folderCount . '-collapse">- // <i class="bi bi-list"></i>- // Show Folder- // </button>- // </div>- // <div class="collapse show" id="dataTable-' . $folderCount . '-collapse" data-state="0">- // <table class="vid-table hover stripe" id="dataTable-' . $folderCount . '" data-folder="' . basename($file) . '">- // <thead>- // <tr>- // <th>Title</th>- // <!-- <th>Length</th> -->- // <th>Date</th>- // </tr>- // </thead>- // <tbody>- // ';-- // if($folderCount != 0) $out = '- // </tbody>- // </table>- // </div>- // </div>- // <hr>- // ' . $out;-- // echo $out;-- // $folderCount += 1;- // } else {- // if ($file->getExtension() == 'mp4' || $file->getExtension() == 'mkv' ) {- // echo('- // <tr>- // <td class="vid-row" data-col="col-title" value="' . $file . '">' . basename($file) . '</td>- // <!-- <td class="vid-row" data-col="col-length" value="0">Unimplemented</td> -->- // <td class="vid-row" data-col="col-date" value="' . filectime($file) . '">' . date("Y-m-d g:i A", filectime($file)) . '</td>- // </tr>-- // ');- // }- // }- // }- // ?>- </tbody>- </table>- </div> -->- </div>- </div>- </div>- </div>- </main>- </body>-</html>\ No newline at end of filediff --git a/legacy/css/main.css b/public/css/main.csssimilarity index 97%rename from legacy/css/main.cssrename to public/css/main.cssindex dfab809f..b503ff89 100644--- a/legacy/css/main.css+++ b/public/css/main.css@@ -28,6 +28,11 @@ html[data-bs-theme="dark"] div.dtsp-panesContainer div.dtsp-searchPane div.dataTpadding: 2%;}+.folder-header{+ margin-left: 0%;+ margin-right: 0%;+}+.toggle-switch {position: relative;width: 60px;diff --git a/legacy/js/main.js b/public/js/main.jssimilarity index 77%rename from legacy/js/main.jsrename to public/js/main.jsindex a8644733..ee770913 100644--- a/legacy/js/main.js+++ b/public/js/main.js@@ -1,40 +1,27 @@document.addEventListener("DOMContentLoaded", function(event) {- //loadVideosJQuery();loadVideos();- //initVideos();toggleDarkMode();document.getElementById('dark-mode-toggle').addEventListener('click', () => { toggleDarkMode(); });});-function loadVideosJQuery(){- $.ajax({- type: 'post',- url: './ajax/get_videos.ajax.php',- data: {- dir: 'tv'- }- }).done((result) => {- console.log(result);- });-}-async function loadVideos(){- fetch('./ajax/get_videos.ajax.php', {+ const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');++ fetch('/ajax/generateDir', {method: 'post',- body: JSON.stringify({- dir:'tv'- }),headers: {'Accept': 'application/json',- 'Content-Type': 'application/json'- }+ 'Content-Type': 'application/json',+ 'X-CSRF-TOKEN': csrfToken+ },+ body: JSON.stringify({+ dir:'tv'+ })}).then((response) =>response.json()).then((json) => {console.log(json);- //let border = document.getElementById('preData');- //border.insertAdjacentHTML("afterend", json.result);parseVideos(json.result);}).catch((error) => {console.log(error);@@ -42,15 +29,17 @@ async function loadVideos(){}function parseVideos(data){+ console.log('hi');+const dataContainer = document.getElementById('dataContainer');const darkModeSettings = getDarkModeSettings();var folderTemplate = function(folderName, folderCount, fileElements) {return `- <div class="col-sm-12" style="padding: 2%;">- <div class="row mb-4">- <h4 class="col-sm-10"> ${folderName} </h4>- <button class="col-sm-2 btn ${darkModeSettings.btnClass} folder-toggle" id="dataTable-${folderCount}-collapse-toggle" type="button" data-bs-toggle="collapse" data-bs-target="#dataTable-${folderCount}-collapse">+ <div class="col-sm-12">+ <div class="folder-header row mb-4">+ <h4 class="col-sm-8 col-lg-10 ps-0 text-center text-sm-start"> ${folderName} </h4>+ <button class="col-sm-4 col-lg-2 btn ${darkModeSettings.btnClass} folder-toggle" id="dataTable-${folderCount}-collapse-toggle" type="button" data-bs-toggle="collapse" data-bs-target="#dataTable-${folderCount}-collapse"><i class="bi bi-list"></i>Show Folder</button>@@ -87,6 +76,8 @@ function parseVideos(data){`}+ console.log(data.length);+for (let folderCount = 0; folderCount < data.length; folderCount++) {const folderName = data[folderCount]['name'];const files = data[folderCount]['files'];@@ -127,7 +118,6 @@ function initVideos(){let table = new DataTable('#' + id, {responsive: true,columnDefs: [{ "width": "80%", "targets": 0 }]- // columns: [{ "width": "80%" },{ "width": "20%" }]});document.getElementById(id).style.removeProperty('width');@@ -171,19 +161,6 @@ function toggleDarkMode(){for (let btn of btns) {btn.classList.replace(currBtnClass, nextBtnClass);}-- // if (document.getElementById('dark-mode-toggle').checked) {- // $('.dark-mode').addClass('light-mode').removeClass('dark-mode');- // $('.btn-dark').addClass('btn-light').removeClass('btn-dark');- // // html.setAttribute('data-bs-theme', '');- // root_html.classList.remove("dark");- // }- // else{- // $('.light-mode').addClass('dark-mode').removeClass('light-mode');- // $('.btn-light').addClass('btn-dark').removeClass('btn-light');- // // html.setAttribute('data-bs-theme', 'dark');- // root_html.classList.add("dark");- // }}function getDarkModeSettings(){diff --git a/resources/views/account.blade.php b/resources/views/account.blade.phpnew file mode 100644index 00000000..a01690d4--- /dev/null+++ b/resources/views/account.blade.php@@ -0,0 +1,2 @@+<!DOCTYPE html>+<a href='/'>test</a>\ No newline at end of filediff --git a/resources/views/home.blade.php b/resources/views/home.blade.phpnew file mode 100644index 00000000..885996c0--- /dev/null+++ b/resources/views/home.blade.php@@ -0,0 +1,64 @@+<!doctype html>+<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">+ <head>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1">+ <meta name="csrf-token" content="{{ csrf_token() }}">++ <title>Anime?</title>++ <!-- Bootstrap -->+ <link href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css" rel="stylesheet" >+ <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">++ <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>++ <!-- Jquery -->+ <script src="https://code.jquery.com/jquery-3.7.1.js"></script>++ <!-- DataTables -->+ <script src="https://cdn.datatables.net/1.13.7/js/jquery.dataTables.min.js"></script>+ <!-- <script src="https://cdn.datatables.net/1.13.7/js/dataTables.bootstrap5.min.js"></script> -->++ <!-- <link href="https://cdn.datatables.net/1.13.7/css/dataTables.bootstrap5.min.css" rel="stylesheet" crossorigin="anonymous"> -->+ <link href="https://cdn.datatables.net/1.13.7/css/jquery.dataTables.min.css" rel="stylesheet">+++ <!-- Local -->+ <link href="./css/main.css" rel="stylesheet" >+ <script src="./js/main.js"></script>+ </head>+ <body class="light-mode">+ <main class="container">+ <div class="row">+ <div class="col-sm-12">+ <div class="neu-card light-mode">+ <div class="col-sm-12">+ <div style="display: flex; flex-direction: row-reverse;">+ <div style="width:auto; display: flex; align-items: center;" class="ms-3">+ <div class="toggle-switch">+ <label class="switch-label">+ <input type="checkbox" class="checkbox" id="dark-mode-toggle">+ <span class="slider"></span>+ </label>+ </div>+ </div>+ <div style="display: flex; justify-content: space-between; width: 100%;">+ <h3 id="mp4-title" ></h3>+ <h3 id="mp4-title-folder"></h3>+ </div>+ </div>+ <hr class="mt-2">+ <video id="vid-source" width="100%" src="" type="video/mp4" controls>+ </video>+ </div>++ <hr id='preData'>++ <div id='dataContainer'></div>+ </div>+ </div>+ </div>+ </main>+ </body>+</html>\ No newline at end of filediff --git a/routes/web.php b/routes/web.phpindex d259f33e..a1ec5e46 100644--- a/routes/web.php+++ b/routes/web.php@@ -1,6 +1,7 @@<?phpuse Illuminate\Support\Facades\Route;+use App\Http\Controllers\DirectoryController;/*|--------------------------------------------------------------------------@@ -16,3 +17,7 @@ use Illuminate\Support\Facades\Route;Route::get('/', function () {return view('welcome');});++Route::get('/{dir}', [DirectoryController::class, 'showDirectory']);+Route::get('/storage/test', [DirectoryController::class, 'testStorage']);+Route::post('/ajax/generateDir', [DirectoryController::class, 'generateDirectory']);\ No newline at end of filediff --git a/legacy/ajax/get_videos.ajax.php b/z_legacy/ajax/get_videos.ajax.phpsimilarity index 100%rename from legacy/ajax/get_videos.ajax.phprename to z_legacy/ajax/get_videos.ajax.phpdiff --git a/legacy/config.php b/z_legacy/config.phpsimilarity index 100%rename from legacy/config.phprename to z_legacy/config.phpdiff --git a/legacy/doc/img/DarkMode.png b/z_legacy/doc/img/DarkMode.pngsimilarity index 100%rename from legacy/doc/img/DarkMode.pngrename to z_legacy/doc/img/DarkMode.pngdiff --git a/legacy/doc/img/LightMode.png b/z_legacy/doc/img/LightMode.pngsimilarity index 100%rename from legacy/doc/img/LightMode.pngrename to z_legacy/doc/img/LightMode.png