A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
better progressbars and actual mime type
aminnausinb27932d33e33
diff --git a/app/Jobs/EmbedUidInMetadata.php b/app/Jobs/EmbedUidInMetadata.phpindex 33dddc4d..a5e7a8ee 100644--- a/app/Jobs/EmbedUidInMetadata.php+++ b/app/Jobs/EmbedUidInMetadata.php@@ -35,8 +35,15 @@ class EmbedUidInMetadata implements ShouldQueue {$subTask = SubTask::create(['task_id' => $taskId, 'status' => TaskStatus::PENDING, 'name' => 'Embed UID in video file']); //- DB::table('tasks')->where('id', $this->taskId)->increment('sub_tasks_pending');- DB::table('tasks')->where('id', $this->taskId)->decrement('sub_tasks_total');++ DB::table('tasks')+ ->where('id', $this->taskId)+ ->update([+ 'sub_tasks_pending' => DB::raw('sub_tasks_pending + 1'),+ 'sub_tasks_total' => DB::raw('sub_tasks_total + 1'),+ ]);++$this->taskId = $taskId;$this->subTaskId = $subTask->id;diff --git a/app/Jobs/VerifyFiles.php b/app/Jobs/VerifyFiles.phpindex 257841f6..b41b92a0 100755--- a/app/Jobs/VerifyFiles.php+++ b/app/Jobs/VerifyFiles.php@@ -14,6 +14,7 @@ use Illuminate\Foundation\Bus\Dispatchable;use Illuminate\Queue\InteractsWithQueue;use Illuminate\Queue\SerializesModels;use Illuminate\Support\Facades\DB;+use Illuminate\Support\Facades\File;use Illuminate\Support\Facades\Storage;use Illuminate\Support\Str;use Ramsey\Uuid\Uuid;@@ -187,6 +188,10 @@ class VerifyFiles implements ShouldQueue {$changes['editor_id'] = null;}+ if (is_null($metadata->mime_type)) {+ $changes['mime_type'] = File::mimeType($filePath) ?? 'feee';+ }+is_null($metadata->view_count) ? $changes['view_count'] = Record::where('video_id', $video->id)->count() + ($metadata->id ? Record::where('metadata_id', $metadata->id)->count() : 0) : $stored['view_count'] = $metadata->view_count;if (count($changes) > 0) {@@ -219,7 +224,7 @@ class VerifyFiles implements ShouldQueue {return 'No Changes Found';}- Metadata::upsert($transactions, 'id', ['video_id', 'title', 'description', 'duration', 'season', 'episode', 'view_count', 'uuid', 'file_size', 'date_scanned']);+ Metadata::upsert($transactions, 'id', ['video_id', 'title', 'description', 'duration', 'season', 'episode', 'view_count', 'uuid', 'file_size', 'mime_type', 'date_scanned']);$summary = 'Updated ' . count($transactions) . ' videos from id ' . ($transactions[0]['video_id']) . ' to ' . ($transactions[count($transactions) - 1]['video_id']);dump($summary);diff --git a/app/Models/Metadata.php b/app/Models/Metadata.phpindex 191c6c5b..5ec14c5c 100644--- a/app/Models/Metadata.php+++ b/app/Models/Metadata.php@@ -23,6 +23,7 @@ class Metadata extends Model {'season','view_count','file_size',+ 'mime_type','poster_url','date_released','date_scanned',diff --git a/database/migrations/2024_12_31_154724_add_mime_type_to_metadata.php b/database/migrations/2024_12_31_154724_add_mime_type_to_metadata.phpnew file mode 100644index 00000000..d3f7ac31--- /dev/null+++ b/database/migrations/2024_12_31_154724_add_mime_type_to_metadata.php@@ -0,0 +1,27 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\Schema;++return new class extends Migration {+ /**+ * Run the migrations.+ */+ public function up(): void {+ Schema::table('metadata', function (Blueprint $table) {+ //+ $table->string('mime_type')->nullable();+ });+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void {+ Schema::table('metadata', function (Blueprint $table) {+ //+ $table->dropColumn('mime_type');+ });+ }+};diff --git a/resources/js/components/cards/SubTaskCard.vue b/resources/js/components/cards/SubTaskCard.vueindex db5922b1..d3a9b449 100644--- a/resources/js/components/cards/SubTaskCard.vue+++ b/resources/js/components/cards/SubTaskCard.vue@@ -17,7 +17,7 @@ const props = defineProps<{ data: SubTaskResource; isScreenLarge?: boolean }>();<template><span class="flex text-left rounded-xl dark:text-white w-full"><section- class="flex ring-1 ring-inset ring-gray-900/5 hover:ring-purple-700 rounded-md shadow-sm w-full bg-white dark:bg-primary-dark-800/70 dark:hover:bg-primary-dark-600 hover:bg-primary-800 p-3 gap-4 items-center flex-1"+ class="flex flex-wrap ring-1 ring-inset ring-gray-900/5 hover:ring-purple-700 rounded-md shadow-sm w-full bg-white dark:bg-primary-dark-800/70 dark:hover:bg-primary-dark-600 hover:bg-primary-800 p-3 gap-4 items-center flex-1"><div class="relative group flex flex-col gap-1 flex-1"><HoverCard :content="data.summary ?? ''" class="flex gap-x-4 gap-y-2 items-center">@@ -64,7 +64,7 @@ const props = defineProps<{ data: SubTaskResource; isScreenLarge?: boolean }>();</div></div>- <div class="flex gap-1 items-center">+ <div class="flex gap-1 items-center flex-1 sm:flex-none"><PulseDoughnutChartv-if="isScreenLarge ?? false"v-cloak@@ -96,7 +96,7 @@ const props = defineProps<{ data: SubTaskResource; isScreenLarge?: boolean }>();],}"/>- <p class="text-left lg:!hidden text-xs">{{ Math.max(data.progress, 0) }}%</p>+ <p class="text-left lg:!hidden text-xs flex-1">{{ Math.max(data.progress, 0) }}%</p><ChipTag:class="`h-6 shadow-sm`"@@ -125,6 +125,6 @@ const props = defineProps<{ data: SubTaskResource; isScreenLarge?: boolean }>();</ButtonCorner></div></section>- <ProiconsArrowReply class="-scale-y-100 h-6 w-6 mx-2 my-auto shrink-0" />+ <ProiconsArrowReply class="hidden sm:block -scale-y-100 h-6 w-6 mx-2 my-auto shrink-0" /></span></template>diff --git a/resources/js/components/cards/TaskCard.vue b/resources/js/components/cards/TaskCard.vueindex 8d40020a..0533b151 100644--- a/resources/js/components/cards/TaskCard.vue+++ b/resources/js/components/cards/TaskCard.vue@@ -2,14 +2,15 @@import { type SubTaskResource, type TaskResource } from '@/types/resources';import { toFormattedDate, toFormattedDuration, within24Hrs } from '@/service/util';+import { computed, ref, useTemplateRef, watch } from 'vue';import { getSubTasks } from '@/service/siteAPI';-import { ref, useTemplateRef } from 'vue';import PulseDoughnutChart from '@/components/charts/PulseDoughnutChart.vue';import ButtonCorner from '@/components/inputs/ButtonCorner.vue';import SubTaskCard from '@/components/cards/SubTaskCard.vue';import ButtonIcon from '@/components/inputs/ButtonIcon.vue';import ButtonText from '@/components/inputs/ButtonText.vue';+import TableBase from '@/components/table/TableBase.vue';import HoverCard from '@/components/cards/HoverCard.vue';import Popover from '@/components/pinesUI/Popover.vue';import ChipTag from '@/components/labels/ChipTag.vue';@@ -18,7 +19,6 @@ import ProiconsMoreVertical from '~icons/proicons/more-vertical';import ProiconsChevronDown from '~icons/proicons/chevron-down';import ProiconsArrowSync from '~icons/proicons/arrow-sync';import ProiconsDelete from '~icons/proicons/delete';-import TableBase from '../table/TableBase.vue';const props = defineProps<{ data: TaskResource; isScreenSmall?: boolean; isScreenLarge?: boolean }>();const emit = defineEmits(['clickAction']);@@ -26,6 +26,34 @@ const subTasks = ref<SubTaskResource[]>([]);const popover = useTemplateRef('popover');const subTasksFetched = ref(false);const expanded = ref(false);+const progress = computed(() => {+ const roundDown = (val: number) => {+ return Math.floor(val * 100);+ };++ if (!props.data.id || !props.data.sub_tasks_total) return { complete: 0, processing: 0, failed: 0, pending: 100 };+ let complete = roundDown(props.data.sub_tasks_complete / props.data.sub_tasks_total);+ let failed = roundDown(props.data.sub_tasks_failed / props.data.sub_tasks_total);+ let pending = Math.ceil(+ (Math.max(props.data.sub_tasks_total - props.data.sub_tasks_complete - props.data.sub_tasks_failed, 0) /+ props.data.sub_tasks_total) *+ 100,+ );+ let processing = Math.max(100 - complete - failed - pending, 0);+ console.log(props.data, {+ complete,+ processing,+ failed,+ pending,+ });++ return {+ complete,+ processing,+ failed,+ pending,+ };+});const toggleExpanded = async () => {if (!subTasksFetched.value && !expanded.value) await loadSubTasks();@@ -44,6 +72,18 @@ const handleClick = (cancel: boolean = false) => {popover.value?.handleClose();emit('clickAction', true);};++watch(+ () => props.data,+ () => {+ if (!expanded.value) {+ subTasksFetched.value = false;+ return;+ }++ loadSubTasks();+ },+);</script><template><div@@ -55,7 +95,7 @@ const handleClick = (cancel: boolean = false) => {<div class="flex flex-col gap-2 sm:gap-1 flex-1 relative"><HoverCard :content="data.description ?? ''" class="flex gap-x-4 gap-y-2 items-center"><template #trigger>- <h2 class="truncate capitalize group" :title="data.name">{{ data.name }}</h2>+ <h2 class="truncate capitalize group" :title="data.name">{{ data.id }} - {{ data.name }}</h2><p v-if="data.summary" class="truncate text-neutral-500 dark:text-neutral-400 max-w-64 hidden md:block">{{ data.summary }}</p>@@ -141,16 +181,17 @@ const handleClick = (cancel: boolean = false) => {},}":chart-data="{- labels: ['Pending', 'Completed', 'Failed'],+ labels: ['Completed', 'Pending', 'Failed', 'Unknown'],datasets: [{data: [- Math.max(data.sub_tasks_pending - data.sub_tasks_failed, 0),- Math.max(data.sub_tasks_complete, 0),- data.sub_tasks_failed,+ progress.complete,+ progress.pending,+ progress.failed,+ Math.min(Math.max(100 - progress.complete - progress.pending - progress.failed, 0), 100),],- backgroundColor: ['#f59e0b', '#9333ea', '#be123c'],- hoverBackgroundColor: ['#f59e0b', '#9333ea', '#e11d48'],+ backgroundColor: ['#9333ea', '#f59e0b', '#be123c', '#9333ea26'],+ hoverBackgroundColor: ['#9333ea', '#f59e0b', '#e11d48', '#9333ea26'],},],}"@@ -163,18 +204,18 @@ const handleClick = (cancel: boolean = false) => {{{ Math.ceil((Math.max(data.sub_tasks_complete, 0) / (data.sub_tasks_total ? data.sub_tasks_total : 1)) * 100) }}%Processed</p>- <div class="rounded-full h-1 w-full bg-primary-dark-900 flex overflow-clip">+ <div class="h-1 w-full bg-primary-dark-900 flex overflow-clip rounded-full"><div- :class="`h-1 bg-purple-600 rounded-full`"- :style="`width: ${(Math.max(data.sub_tasks_complete, 0) / (data.sub_tasks_total ? data.sub_tasks_total : 1)) * 100}%;`"+ :class="`${data.sub_tasks_failed + data.sub_tasks_pending == 0 ? 'rounded-full' : 'rounded-l-full'} bg-purple-600`"+ :style="`width: ${progress.complete}%;`"></div><div- :class="`h-1 bg-amber-500 rounded-full`"- :style="`width: ${(Math.max(data.sub_tasks_pending - data.sub_tasks_failed, 0) / (data.sub_tasks_total ? data.sub_tasks_total : 1)) * 100}%;`"+ :class="`${data.sub_tasks_complete === 0 ? 'rounded-l-full' : ''} ${data.sub_tasks_failed === 0 ? 'rounded-r-full' : ''} bg-amber-500`"+ :style="`width: ${progress.pending}%;`"></div><div- :class="`h-1 bg-rose-600 rounded-full`"- :style="`width: ${(data.sub_tasks_failed / (data.sub_tasks_total ? data.sub_tasks_total : 1)) * 100}%;`"+ :class="`${data.sub_tasks_complete + data.sub_tasks_pending == 0 ? 'rounded-full' : 'rounded-r-full'} bg-rose-600`"+ :style="`width: ${progress.failed}%;`"></div></div></div>@@ -277,7 +318,7 @@ const handleClick = (cancel: boolean = false) => {<TableBasev-else:class="'p-1'"- :pagination-class="'pe-10 -mt-2 text-sm'"+ :pagination-class="'sm:pe-10 -mt-2 text-sm'":use-pagination="true":data="subTasks":row="SubTaskCard"diff --git a/resources/js/components/video/VideoPlayer.vue b/resources/js/components/video/VideoPlayer.vueindex 6dcea20f..b69954aa 100755--- a/resources/js/components/video/VideoPlayer.vue+++ b/resources/js/components/video/VideoPlayer.vue@@ -28,6 +28,7 @@ const appStore = useAppStore();const progressCache = ref<{ metadata_id: number; progress: number }[]>([]);const metadata_id = ref<number>(NaN);const currentID = ref(-1);+const isAudio = ref(false);const player = ref<null | HTMLVideoElement>(null);// const url = ref('');@@ -145,7 +146,7 @@ const initVideoPlayer = async () => {}metadata_id.value = stateVideo.value?.metadata ? stateVideo.value?.metadata.id : NaN;-+ isAudio.value = stateVideo.value.metadata?.mime_type?.startsWith('audio') ?? false;// url.value = await getMediaUrl(stateVideo.value.path ?? '');};@@ -266,7 +267,6 @@ onMounted(() => {// console.count('loop restart');// this.play();// });- console.log(stateFolder.value.series?.thumbnail_url);});onUnmounted(() => {@@ -277,7 +277,7 @@ onUnmounted(() => {<template><div class="relative group rounded-xl overflow-clip"><div- v-if="stateVideo.path?.endsWith('.mp3')"+ v-if="isAudio"class="absolute top-0 left-0 w-full h-full blur":style="`background: transparent url('${stateVideo?.metadata?.poster_url ??@@ -295,7 +295,7 @@ onUnmounted(() => {:src="stateVideo?.path ? `../${stateVideo?.path}` : ''":class="`relative focus:outline-none flex object-contain ${stateVideo?.path ? (stateVideo.path.endsWith('.mp3') ? 'max-h-[60vh]' : '') : 'aspect-video'}`":poster="- stateVideo?.path?.endsWith('.mp3')+ isAudio? (stateVideo?.metadata?.poster_url ??stateFolder.series?.thumbnail_url ??'https://m.media-amazon.com/images/M/MV5BMjVjZGU5ZTktYTZiNC00N2Q1LThiZjMtMDVmZDljN2I3ZWIwXkEyXkFqcGdeQXVyMTUzMTg2ODkz._V1_.jpg')@@ -318,7 +318,7 @@ onUnmounted(() => {</video><sectionstyle="z-index: 4"- :class="`absolute ${stateVideo.path?.endsWith('.mp3') ? 'bottom-[52px] z-20 rounded-sm overflow-clip' : 'bottom-6'} w-[94.95%] m-auto left-0 right-0 opacity-0 group-hover:opacity-65 transition-opacity duration-75 h-5 pointer-events-none`"+ :class="`absolute ${isAudio ? 'bottom-[52px] z-20 rounded-sm overflow-clip' : 'bottom-6'} w-[94.95%] m-auto left-0 right-0 opacity-0 group-hover:opacity-65 transition-opacity duration-75 h-5 pointer-events-none`"v-show="playbackHeatmap"><svg class="ytp-heat-map-svg fill-indigo-200/20 h-full w-full" preserveAspectRatio="none" viewBox="0 0 1000 100">diff --git a/resources/js/stores/ContentStore.js b/resources/js/stores/ContentStore.jsindex 707b802e..e060030c 100755--- a/resources/js/stores/ContentStore.js+++ b/resources/js/stores/ContentStore.js@@ -22,8 +22,8 @@ export const useContentStore = defineStore('Content', () => {const videoSort = ref({ column: 'title', dir: 1 });const searchQuery = ref('');- const stateDirectory = ref({ id: 7, name: 'anime', folders: [] });- const stateFolder = ref({ id: 7, name: 'ODDTAXI', videos: [], series: null });+ const stateDirectory = ref({ id: -1, name: '', folders: [] });+ const stateFolder = ref({ id: -1, name: '', videos: [], series: null });const stateVideo = ref({});const stateFilteredPlaylist = computed(() => {diff --git a/resources/js/types/model.ts b/resources/js/types/model.tsindex 5f7fd85c..8c99cef5 100644--- a/resources/js/types/model.ts+++ b/resources/js/types/model.ts@@ -31,6 +31,7 @@ export interface Metadata {updated_at?: string;uuid?: any;file_size?: number;+ mime_type?: string;date_scanned?: string;date_released_formatted: any;video?: Video;diff --git a/resources/js/views/VideoView.vue b/resources/js/views/VideoView.vueindex fcbd9100..36ce03a0 100755--- a/resources/js/views/VideoView.vue+++ b/resources/js/views/VideoView.vue@@ -1,5 +1,5 @@<script setup lang="ts">-import type { FolderResource, VideoResource } from '@/types/resources';+import type { CategoryResource, FolderResource, VideoResource } from '@/types/resources';import type { Metadata } from '@/types/model';import { onMounted, ref, watch, type Ref } from 'vue';@@ -21,9 +21,10 @@ const route = useRoute();const loading = ref(true);const { getFolder, getCategory, getRecords, playlistFind, playlistSort } = ContentStore;-const { searchQuery, stateFilteredPlaylist, stateVideo, stateFolder } = storeToRefs(ContentStore) as {+const { searchQuery, stateFilteredPlaylist, stateDirectory, stateVideo, stateFolder } = storeToRefs(ContentStore) as {searchQuery: Ref<string>;stateFilteredPlaylist: Ref<VideoResource[]>;+ stateDirectory: Ref<CategoryResource>;stateVideo: Ref<VideoResource | { id?: number; metadata?: Metadata; path?: string }>;stateFolder: Ref<FolderResource | any>;};@@ -36,9 +37,19 @@ async function cycleSideBar(state: string) {if (!state) return;}-async function reload(nextFolderName: string | string[]) {+async function reload() {+ const URL_CATEGORY = route.params.category;+ const URL_FOLDER = route.params.folder;+loading.value = true;- await getFolder(nextFolderName.toString());++ if (stateDirectory.value?.name && stateDirectory.value.name === URL_CATEGORY) {+ console.log(stateDirectory.value);+ await getFolder(URL_FOLDER);+ } else {+ console.log('2');+ await getCategory(URL_CATEGORY, URL_FOLDER);+ }loading.value = false;}@@ -93,11 +104,7 @@ const handleSearch = (query: string) => {//#endregiononMounted(async () => {- const URL_CATEGORY = route.params.category;- const URL_FOLDER = route.params.folder;-- await getCategory(URL_CATEGORY, URL_FOLDER);- loading.value = false;+ reload();selectedSideBar.value = '';});