A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
history and auth working on testing and should work universally
aminnausina299d57eb544
diff --git a/app/Http/Controllers/Api/V1/AuthController.php b/app/Http/Controllers/Api/V1/AuthController.phpindex ed96fccb..13ddecca 100644--- a/app/Http/Controllers/Api/V1/AuthController.php+++ b/app/Http/Controllers/Api/V1/AuthController.php@@ -34,26 +34,25 @@ class AuthController extends Controller{$request->validated($request->all());- if(!Auth::attempt($request->only('email', 'password'))){+ if(!Auth::attempt($request->only('email', 'password'),$request->remember)){return $this->error('', 'Invalid Credentials.', 401);}$user = User::where('email', $request->email)->first();+ $token = $user->createToken('API token of ' . $user->name)->plainTextToken;if ($request->expectsJson()){+return $this->success(['user' => $user,- 'token' => $user->createToken('API token of ' . $user->name)->plainTextToken+ 'token' => $token]);}if (! $request->expectsJson()) {-$request->session()->regenerate();return redirect()->route('testing');}--}public function register(StoreUserRequest $request)diff --git a/app/Http/Controllers/DirectoryController.php b/app/Http/Controllers/DirectoryController.phpindex aa74416e..11e4ecd9 100644--- a/app/Http/Controllers/DirectoryController.php+++ b/app/Http/Controllers/DirectoryController.php@@ -18,6 +18,12 @@ class DirectoryController extends Controllerreturn view('home', $data);}+ public function showDirectoryTest($dir,$folder_name = null) {+ $data['dir'] = $dir;+ $data['folder_name'] = $folder_name;+ return view('testing', $data);+ }+public function getDirectory(Request $request){try {$default = 'tv';diff --git a/app/Http/Kernel.php b/app/Http/Kernel.phpindex 494c0501..7a3930b8 100644--- a/app/Http/Kernel.php+++ b/app/Http/Kernel.php@@ -39,7 +39,7 @@ class Kernel extends HttpKernel],'api' => [- // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,+ \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',\Illuminate\Routing\Middleware\SubstituteBindings::class,],diff --git a/app/Http/Requests/LoginUserRequest.php b/app/Http/Requests/LoginUserRequest.phpindex d819330f..f09a7853 100644--- a/app/Http/Requests/LoginUserRequest.php+++ b/app/Http/Requests/LoginUserRequest.php@@ -23,7 +23,8 @@ class LoginUserRequest extends FormRequest{return ['email' => ['required', 'string', 'email'],- 'password' => ['required', 'string', 'min:6']+ 'password' => ['required', 'string', 'min:6'],+ 'remember' => ['boolean']];}}diff --git a/config/sanctum.php b/config/sanctum.phpindex 948d6365..9e37acb6 100644--- a/config/sanctum.php+++ b/config/sanctum.php@@ -17,7 +17,8 @@ return ['stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf('%s%s',- 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',+ // 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',+ 'app.test:8080',Sanctum::currentApplicationUrlWithPort()))),diff --git a/public/js/auth.js b/public/js/auth.jsindex 9a8be7f9..f4c46a72 100644--- a/public/js/auth.js+++ b/public/js/auth.js@@ -1,4 +1,13 @@+document.addEventListener("DOMContentLoaded", function(event) {+ fetch(`/sanctum/csrf-cookie`, {+ method: 'get'+ }).catch((error) => {+ console.log(error);+ });+});+function login(){+ const remember_me = document.getElementById("remember_me");fetch(`/api/login`, {method: 'post',headers: {@@ -6,15 +15,19 @@ function login(){'Content-Type': 'application/json'},body: JSON.stringify({- 'email': '[email protected]',- 'password': '123456789!aB'+ 'email': $('#email').val(),+ 'password': $('#password').val(), //'123456789!aB'+ 'remember_me': remember_me.checked})}).then((response) =>response.json()).then((json) => {console.log(json);- localStorage.setItem('auth-token', json.data.token)- toastr['info'](localStorage.getItem('auth-token'));+ if(json.success){+ localStorage.setItem('auth-token', json.data.token)+ toastr['info'](localStorage.getItem('auth-token'));+ window.location.href = '/testing';+ }}).catch((error) => {console.log(error);});diff --git a/public/js/main.js b/public/js/main.jsindex 18af2663..d1e84f99 100644--- a/public/js/main.js+++ b/public/js/main.js@@ -107,8 +107,7 @@ async function loadHistory(){headers: {'Accept': 'application/json','Content-Type': 'application/json',- 'X-CSRF-TOKEN': csrfToken,- Authorization: 'Bearer 31|N45UbR6IOMgHhlHkdPvKmzJvxUgodPEO8l6hkLab2e4f6e40'+ 'X-CSRF-TOKEN': csrfToken}}).then((response) =>response.json()@@ -125,13 +124,13 @@ async function loadHistory(){async function addToHistory(id){const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');+fetch(`/api/records`, {method: 'post',headers: {'Accept': 'application/json','Content-Type': 'application/json',- 'X-CSRF-TOKEN': csrfToken,- Authorization: 'Bearer 31|N45UbR6IOMgHhlHkdPvKmzJvxUgodPEO8l6hkLab2e4f6e40'+ 'X-CSRF-TOKEN': csrfToken},body: JSON.stringify({'video_id': id,@@ -308,13 +307,13 @@ async function parseFolders(data){</section><aside class="flex justify-between items-center w-full pt-1"><h3 class="text-lg text-left text-neutral-500">${folderCount} Episodes</h2>- <span class="flex space-x-1 invisible group-hover:visible">- <a class="flex hover:bg-orange-500 hover:stroke-none border-orange-500 border-2 rounded shadow px-2" href="http://99.226.252.66:2662/${videoDirectory ?? 'anime'}/${folderName}">Watch- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4">- <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 13.5 12 21m0 0-7.5-7.5M12 21V3" />- </svg>+ <span class="hidden group-hover:flex space-x-1">+ <a class="flex hover:bg-orange-500 hover:stroke-none border-orange-500 border-2 rounded shadow px-2 space-x-1" href="http://99.226.252.66:2662/${videoDirectory ?? 'anime'}/${folderName}">+ Watch</a>-+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">+ <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 13.5 12 21m0 0-7.5-7.5M12 21V3" />+ </svg></span></aside></div>diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.phpindex 4ce23aab..84f7b8c3 100644--- a/resources/views/auth/login.blade.php+++ b/resources/views/auth/login.blade.php@@ -1,5 +1,4 @@<x-app-layout>-<main class="min-h-screen flex flex-col sm:justify-center items-center pt-6 sm:pt-0 m-auto bg-gray-100"><div class=" w-full sm:max-w-md mt-6 px-6 py-4 bg-white dark:bg-gray-800 shadow-md overflow-hidden sm:rounded-lg"><!-- Session Status -->diff --git a/resources/views/home.blade.php b/resources/views/home.blade.phpindex a3c4a74f..319305f0 100644--- a/resources/views/home.blade.php+++ b/resources/views/home.blade.php@@ -1,89 +1,34 @@-<!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">-- <!-- toastr -->- <link href="<?php if (isset($folder_name)) echo (".."); else echo (".");?>/css/toastr.min.css" rel="stylesheet">-- <script src="<?php if (isset($folder_name)) echo (".."); else echo (".");?>/js/toastr.min.js"></script>- <!-- Local -->- <link href="<?php if (isset($folder_name)) echo (".."); else echo (".");?>/css/main.css" rel="stylesheet" >- <script>- var videoDirectory = <?php echo json_encode($dir ?? 'anime')?>;- var folderName = <?php echo json_encode($folder_name)?>;-- toastr.options = {- "closeButton": true,- "debug": false,- "newestOnTop": false,- "progressBar": true,- "positionClass": "toast-bottom-left",- "preventDuplicates": false,- "onclick": null,- "showDuration": "300",- "hideDuration": "1000",- "timeOut": "5000",- "extendedTimeOut": "1000",- "showEasing": "swing",- "hideEasing": "linear",- "showMethod": "fadeIn",- "hideMethod": "fadeOut"- }- </script>- <script src="<?php if (isset($folder_name)) echo (".."); else echo (".");?>/js/main.js"></script>- </head>- <body class="light-mode" id="root">- <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>+<x-app-layout>+ <script src="{{ URL::asset('js/auth.js') }}"></script>+ <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>- <hr class="mt-2">- <video id="vid-source" width="100%" src="" type="video/mp4" controls>- </video>+ <div style="display: flex; justify-content: space-between; width: 100%;">+ <h3 id="mp4-title"></h3>+ <h3 id="mp4-title-folder"></h3>+ </div></div>-- <hr id='preData'>-- <div id='dataContainer'></div>+ <hr class="mt-2">+ <video id="vid-source" width="100%" src="" type="video/mp4" controls>+ </video></div>- </div>++ <hr id='preData'>++ <div id='dataContainer'></div>+ </div></div>- </main>- </body>-</html>\ No newline at end of file+ </div>+ </main>+</x-app-layout>\ No newline at end of filediff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.phpindex 4cb8496c..5de85828 100644--- a/resources/views/layouts/app.blade.php+++ b/resources/views/layouts/app.blade.php@@ -24,22 +24,24 @@<!-- <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/dataTables.tailwindcss.min.css" rel="stylesheet"> --><link href="https://cdn.datatables.net/1.13.7/css/jquery.dataTables.min.css" rel="stylesheet">-<!-- toastr -->- <link href="<?php if (isset($folder_name)) echo ("..");- else echo ("."); ?>/css/toastr.min.css" rel="stylesheet">+ <link href="{{ URL::asset('css/toastr.min.css') }}" rel="stylesheet">+ <script src="{{ URL::asset('js/toastr.min.js') }}"></script>- <script src="<?php if (isset($folder_name)) echo ("..");- else echo ("."); ?>/js/toastr.min.js"></script>- <!-- Local -->- <link href="<?php if (isset($folder_name)) echo ("..");- else echo ("."); ?>/css/main.css" rel="stylesheet">+ <!-- local -->+ <link href="{{ URL::asset('css/main.css') }}" rel="stylesheet">+ <script src="{{ URL::asset('js/main.js') }}"></script>+ <script src="{{ URL::asset('js/auth.js') }}"></script>@vite('resources/css/app.css')++<script>var videoDirectory = <?php echo json_encode($dir ?? 'anime') ?>;var folderName = <?php echo json_encode($folder_name ?? 'ODDTAXI') ?>;+ console.log(videoDirectory);+ console.log(folderName);toastr.options = {"closeButton": true,"debug": false,diff --git a/resources/views/testing.blade.php b/resources/views/testing.blade.phpindex 424ea13f..33e7fe86 100644--- a/resources/views/testing.blade.php+++ b/resources/views/testing.blade.php@@ -14,10 +14,7 @@<line x1="6" y1="6" x2="18" y2="18"></line></svg></button>- <script src="<?php if (isset($folder_name)) echo ("..");- else echo ("."); ?>/js/main.js"></script>- <script src="<?php if (isset($folder_name)) echo ("..");- else echo ("."); ?>/js/auth.js"></script>+<main class="mx-[4%] flex flex-row-reverse flex-wrap-reverse lg:flex-nowrap"><section id="list-card" class="invisible dark:bg-neutral-900 shadow-xl m-[1%] p-[1%] pb-[2%] rounded-[15px] light-mode w-full lg:w-[18%] space-y-2"><div class="flex p-1 text-ri">@@ -26,14 +23,14 @@<hr class="mt-2 mb-3"><section id="list-content-folders" class="hidden flex space-y-2 flex-wrap">- <div class="hidden flex flex-wrap rounded-xl dark:bg-neutral-800 bg-slate-100 dark:text-white shadow p-[3%] w-full divide-y divide-gray-300 group flex-grow">+ <div class=" flex flex-wrap rounded-xl dark:bg-neutral-800 bg-slate-100 dark:text-white shadow p-[3%] w-full divide-y divide-gray-300 group flex-grow"><section class="flex flex-row-reverse justify-between items-baseline w-full"><h2 class="text-lg text-right text-neutral-500 text-nowrap">24 Episodes</h2><h2 class="text-xl text-left">Frieren</h2></section>- <aside class="hidden group-hover:flex justify-between items-center w-full pt-1">+ <aside class="flex justify-between items-center w-full pt-1"><h3 class="text-lg text-left text-neutral-500">Drama</h2>- <span class="flex space-x-1">+ <span class="hidden group-hover:flex space-x-1"><button class="hover:bg-orange-500 hover:stroke-none border-orange-500 border-2 rounded shadow px-2">Watch</button><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 13.5 12 21m0 0-7.5-7.5M12 21V3" />@@ -43,7 +40,7 @@</div></section><section id="list-content-history" class="hidden flex space-y-2 flex-wrap">- <div class="flex flex-wrap rounded-xl dark:bg-neutral-800 dark:hover:bg-neutral-700 hover:bg-slate-200 bg-slate-100 dark:text-white shadow p-[3%] w-full divide-y divide-gray-300 group flex-grow">+ <div class="hidden flex flex-wrap rounded-xl dark:bg-neutral-800 dark:hover:bg-neutral-700 hover:bg-slate-200 bg-slate-100 dark:text-white shadow p-[3%] w-full divide-y divide-gray-300 group flex-grow"><section class="flex justify-between items-baseline w-full"><h2 class="text-xl text-left">S1E24</h2></section>@@ -183,7 +180,7 @@</section><section id="content-history">-+</section></section><section id="left-card" class="w-full lg:w-[15%]"></section>diff --git a/routes/api.php b/routes/api.phpindex 396c03ae..1adfb481 100644--- a/routes/api.php+++ b/routes/api.php@@ -1,8 +1,8 @@<?phpuse App\Http\Controllers\Api\V1\AuthController;+use App\Http\Controllers\ProfileController;use App\Http\Controllers\RecordController;-use App\Http\Controllers\TasksController;use Illuminate\Http\Request;use Illuminate\Support\Facades\Route;@@ -20,4 +20,5 @@ Route::post('/register', [AuthController::class, 'register']);Route::group(['middleware' => ['auth:sanctum']], function () {Route::post('/logout', [AuthController::class, 'logout']);Route::resource('/records', RecordController::class);+ Route::resource('/profile', ProfileController::class);});\ No newline at end of filediff --git a/routes/web.php b/routes/web.phpindex 9cb6dab4..d52b18cc 100644--- a/routes/web.php+++ b/routes/web.php@@ -24,12 +24,12 @@ Route::get('/testing', function () {})->name('testing');;Route::get('/', function () {- return view('home', ['dir' => 'anime', 'folder_name' => null]);+ return view('testing', ['dir' => 'anime', 'folder_name' => null]);});-Route::get('/account', function () {- return view('account', ['dir' => 'none', 'folder_name' => null]);-});+// Route::get('/account', function () {+// return view('account', ['dir' => 'none', 'folder_name' => null]);+// });@@ -40,16 +40,26 @@ Route::post('login', [AuthController::class, 'login'])->name('login');Route::get('register', [AuthController::class, 'generate'])->name('register');Route::post('register', [AuthController::class, 'register'])->name('register');+Route::get('/{dir}', [DirectoryController::class, 'showDirectory']);+Route::get('/{dir}/{folder_name}', [DirectoryController::class, 'showDirectory']);+Route::middleware('auth')->group(function () {Route::post('/logout', [AuthController::class, 'destroy'])->name('logout');--Route::get('/storage/data', [DirectoryController::class, 'generateData']);-Route::get('/test/folders/{dir}', [DirectoryController::class, 'getDirectoryContents']);Route::get('/test/videos/{folder_name}/{category_id}', [DirectoryController::class, 'getFolderContents']);++ Route::get('/{dir}', [DirectoryController::class, 'showDirectoryTest']);+ Route::get('/{dir}/{folder_name}', [DirectoryController::class, 'showDirectoryTest']);++ // Route::get('/{dir}', function ($dir) {+ // return view('testing', ['dir' => $dir]);+ // });+ // Route::get('/{dir}/{folder_name}', function ($dir,$folder_name) {+ // return view('testing', ['dir' => $dir, 'folder_name' => $folder_name]);+ // });});@@ -61,5 +71,4 @@ Route::post('/ajax/generateDir', [DirectoryController::class, 'generateDirectoryRoute::post('/ajax/getFolders', [DirectoryController::class, 'getDirectoryContents']);Route::post('/ajax/getVideos', [DirectoryController::class, 'getFolderContents']);-Route::get('/{dir}', [DirectoryController::class, 'showDirectory']);-Route::get('/{dir}/{folder_name}', [DirectoryController::class, 'showDirectory']);\ No newline at end of file+