A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
fix: replace date_uploaded with file_modified_at on metadata
aminnausin5e3684e96333
diff --git a/app/Http/Resources/MetadataResource.php b/app/Http/Resources/MetadataResource.phpindex e7245bfb..65b94e9c 100644--- a/app/Http/Resources/MetadataResource.php+++ b/app/Http/Resources/MetadataResource.php@@ -24,8 +24,8 @@ class MetadataResource extends JsonResource {'file_size' => $this->file_size,'date_released' => $this->date_released,'date_updated' => $this->updated_at,- 'date_uploaded' => $this->date_uploaded,- 'edited_at' => $this->edited_at,+ 'edited_at' => $this->edited_at, // last user edit time+ 'file_modified_at' => $this->file_modified_at, // file_mtime from disk (required)],'relationships' => ['video_id' => $this->video_id,diff --git a/app/Http/Resources/VideoResource.php b/app/Http/Resources/VideoResource.phpindex ea98bc05..a3ea0fa7 100755--- a/app/Http/Resources/VideoResource.php+++ b/app/Http/Resources/VideoResource.php@@ -64,7 +64,6 @@ class VideoResource extends JsonResource {** date_released -> date (nullable)* date_scanned -> date (nullable)- * date_uploaded -> timestamp (nullable)** edited_at -> timestamptz (nullable)* file_scanned_at -> timestamptz (nullable)@@ -72,6 +71,7 @@ class VideoResource extends JsonResource {* created_at -> timestamp (nullable)* updated_at -> timestamp (nullable)*+ * file_modified_at -> timestamptz (nullable)** @return array<string, mixed>*/@@ -104,7 +104,7 @@ class VideoResource extends JsonResource {'date_created' => $this->created_at, // Date Added to Server'date_updated' => $metadata?->updated_at ?: null, // Metadata Last Updated'date_released' => $metadata?->date_released ?: null, // User Provided Release Date- 'date_uploaded' => $metadata?->date_uploaded ?: null, // File Last Modified (Should be date_added)+ 'file_modified_at' => $metadata?->file_modified_at ?: null, // File Last Modified (Should be date_added)'edited_at' => $metadata?->edited_at,'metadata' => $metadata,'subtitles' => SubtitleResource::collection($metadata->subtitles ?? []),diff --git a/app/Jobs/IndexFiles.php b/app/Jobs/IndexFiles.phpindex ee30b3e2..150cf810 100755--- a/app/Jobs/IndexFiles.php+++ b/app/Jobs/IndexFiles.php@@ -11,6 +11,7 @@ use App\Models\Series;use App\Models\SubTask;use App\Models\Video;use App\Services\TaskService;+use Carbon\Carbon;use Illuminate\Support\Facades\File;use Illuminate\Support\Facades\Log;use Illuminate\Support\Facades\Storage;@@ -174,9 +175,9 @@ class IndexFiles extends ManagedSubTask {$file_size = $metadataChange['file_size'];$duration = $metadataChange['duration'];$file_scanned_at = $metadataChange['file_scanned_at'];- $date_uploaded = $metadataChange['date_uploaded'];+ $file_modified_at = $metadataChange['file_modified_at'];- $dbOut .= "UPSERT INTO [metadata] VALUES ({$videoId}, {$compositeId}, {$uuid}, {$file_size}, {$duration}, {$file_scanned_at}, {$date_uploaded});\n\n"; // upsert+ $dbOut .= "UPSERT INTO [metadata] VALUES ({$videoId}, {$compositeId}, {$uuid}, {$file_size}, {$duration}, {$file_scanned_at}, {$file_modified_at});\n\n"; // upsert$metadataTransactions[] = $metadataChange;}@@ -202,7 +203,7 @@ class IndexFiles extends ManagedSubTask {'mime_type','media_type','file_scanned_at',- 'date_uploaded',+ 'file_modified_at',]);// One day logging should be put in the database@@ -579,7 +580,7 @@ class IndexFiles extends ManagedSubTask {'mime_type' => $mime_type ?? null,'media_type' => $media_type,'file_scanned_at' => now(),- 'date_uploaded' => date('Y-m-d h:i A', $mtime < $ctime ? $mtime : $ctime),+ 'file_modified_at' => Carbon::createFromTimestampUTC($mtime < $ctime ? $mtime : $ctime),];$current[$key] = $currentID; // add to current$changes[] = $generated; // add to new (insert)diff --git a/app/Jobs/VerifyFiles.php b/app/Jobs/VerifyFiles.phpindex c40e9988..ccc5b9c0 100755--- a/app/Jobs/VerifyFiles.php+++ b/app/Jobs/VerifyFiles.php@@ -10,6 +10,7 @@ use App\Models\SubTask;use App\Models\Subtitle;use App\Services\Subtitles\SubtitleScanner;use App\Services\TaskService;+use Carbon\Carbon;use Illuminate\Support\Facades\Bus;use Illuminate\Support\Facades\Log;use Illuminate\Support\Facades\Storage;@@ -146,11 +147,11 @@ class VerifyFiles extends ManagedSubTask {$changes['mime_type'] = $this->extractMimeType($filePath);}- if (is_null($metadata->date_uploaded) || $fileUpdated) {+ if (is_null($metadata->file_modified_at) || $fileUpdated) {$mtime = filemtime($filePath);$ctime = filectime($filePath);- $changes['date_uploaded'] = date('Y-m-d h:i A', $mtime < $ctime ? $mtime : $ctime);+ $changes['file_modified_at'] = Carbon::createFromTimestampUTC($mtime < $ctime ? $mtime : $ctime);}$mime_type = $changes['mime_type'] ?? $metadata->mime_type;@@ -376,7 +377,7 @@ class VerifyFiles extends ManagedSubTask {'frame_rate','poster_url','file_scanned_at',- 'date_uploaded',+ 'file_modified_at','media_type','subtitles_scanned_at',]diff --git a/app/Models/Metadata.php b/app/Models/Metadata.phpindex f0d9ffd2..039b44de 100644--- a/app/Models/Metadata.php+++ b/app/Models/Metadata.php@@ -38,8 +38,6 @@ class Metadata extends Model {* mime_type -> varchar(255) (nullable)* captions -> text (nullable)*- * date_uploaded -> timestamp (nullable)- ** resolution_width -> int4 (nullable)* resolution_height -> int4 (nullable)* frame_rate -> int4 (nullable)@@ -57,19 +55,32 @@ class Metadata extends Model {** edited_at -> timestamptz (nullable)* file_scanned_at -> timestamptz (nullable)+ *+ * file_modified_at -> timestamptz (nullable)*/protected $fillable = [+ // Id'uuid','composite_id',++ // Fk'video_id','editor_id',++ // User Editable'title','description','lyrics',- 'duration','episode','season',- 'view_count',+ 'poster_url',+ 'album',+ 'artist',+ // To Be Renamed+ 'date_released',++ // FFmpeg Generated+ 'duration','file_size','mime_type','codec',@@ -77,21 +88,23 @@ class Metadata extends Model {'resolution_width','resolution_height','frame_rate',- 'poster_url',- 'date_released',- 'file_scanned_at',- 'date_uploaded','media_type',- 'album',- 'artist',++ // API Editable+ 'view_count',++ // Date Id+ 'file_scanned_at',+ 'file_modified_at','edited_at',];protected $guarded = ['logical_composite_id'];protected $casts = [- 'date_uploaded' => 'datetime','file_scanned_at' => 'datetime',+ 'file_modified_at' => 'datetime',+'edited_at' => 'datetime','media_type' => MediaType::class,];diff --git a/app/Services/PreviewGeneratorService.php b/app/Services/PreviewGeneratorService.phpindex 75669d57..106263f1 100644--- a/app/Services/PreviewGeneratorService.php+++ b/app/Services/PreviewGeneratorService.php@@ -123,7 +123,7 @@ class PreviewGeneratorService {$isAudio = str_starts_with($videoResource->metadata?->mime_type, 'audio');$thumbnail = $videoResource->metadata->poster_url ?: $folder->series->thumbnail_url ?: $this->defaultThumbnail;- $releaseDate = $this->formatDate($video->metadata->date_released ?: $video->metadata->date_uploaded);+ $releaseDate = $this->formatDate($video->metadata->date_released ?: $video->metadata->file_modified_at);$contentString = $releaseDate . ' • ' . $this->formatDuration($videoResource?->metadata?->duration ?? null);$folderDateUpdated = strtotime($folderResource->series->updated_at);@@ -136,7 +136,7 @@ class PreviewGeneratorService {'is_audio' => $isAudio,'content_string' => $contentString,'release_date' => $releaseDate,- 'upload_date' => $this->formatDate($video->metadata->date_uploaded),+ 'upload_date' => $this->formatDate($video->metadata->file_modified_at),'mime_type' => $video->mime_type,'tags' => $videoResource->video_tags ? array_map(fn ($tag) => $tag->name, $videoResource->video_tags) : null,'studio' => ucfirst($folderResource?->series?->studio ?? $category->name),diff --git a/database/migrations/2026_01_28_041925_remove_date_scanned_from_metadata.php b/database/migrations/2026_01_28_041925_remove_date_scanned_from_metadata.phpindex b8a5633e..085bc8d6 100644--- a/database/migrations/2026_01_28_041925_remove_date_scanned_from_metadata.php+++ b/database/migrations/2026_01_28_041925_remove_date_scanned_from_metadata.php@@ -11,7 +11,7 @@ return new class extends Migration {*/public function up(): void {Schema::table('metadata', function (Blueprint $table) {- $table->dropColumn("date_scanned");+ $table->dropColumn('date_scanned');});}@@ -20,7 +20,7 @@ return new class extends Migration {*/public function down(): void {Schema::table('metadata', function (Blueprint $table) {- $table->date("date_scanned")->nullable();+ $table->date('date_scanned')->nullable();});DB::table('metadata')->whereNotNull('file_scanned_at')->update(['date_scanned' => DB::raw('DATE(file_scanned_at)')]);diff --git a/database/migrations/2026_01_28_173810_add_file_modified_at_to_metadata.php b/database/migrations/2026_01_28_173810_add_file_modified_at_to_metadata.phpnew file mode 100644index 00000000..a8ae2e69--- /dev/null+++ b/database/migrations/2026_01_28_173810_add_file_modified_at_to_metadata.php@@ -0,0 +1,28 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\DB;+use Illuminate\Support\Facades\Schema;++return new class extends Migration {+ /**+ * Run the migrations.+ */+ public function up(): void {+ Schema::table('metadata', function (Blueprint $table) {+ $table->timestampTz('file_modified_at')->nullable(); // TODO: eventually make this nullable when enforced by api (currently you can initiate a metadata when you edit a media item that has not been verified)+ });++ DB::table('metadata')->whereNotNull('date_uploaded')->update(['file_modified_at' => DB::raw("date_uploaded AT TIME ZONE 'UTC'")]);+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void {+ Schema::table('metadata', function (Blueprint $table) {+ $table->dropColumn('file_modified_at');+ });+ }+};diff --git a/database/migrations/2026_01_30_051158_remove_date_uploaded_from_metadata.php b/database/migrations/2026_01_30_051158_remove_date_uploaded_from_metadata.phpnew file mode 100644index 00000000..266359dc--- /dev/null+++ b/database/migrations/2026_01_30_051158_remove_date_uploaded_from_metadata.php@@ -0,0 +1,28 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\DB;+use Illuminate\Support\Facades\Schema;++return new class extends Migration {+ /**+ * Run the migrations.+ */+ public function up(): void {+ Schema::table('metadata', function (Blueprint $table) {+ $table->dropColumn("date_uploaded");+ });+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void {+ Schema::table('metadata', function (Blueprint $table) {+ $table->date("date_uploaded")->nullable();+ });++ DB::table('metadata')->whereNotNull('file_modified_at')->update(['date_uploaded' => DB::raw('DATE(file_modified_at)')]);+ }+};diff --git a/resources/js/components/cards/data/VideoCard.vue b/resources/js/components/cards/data/VideoCard.vueindex 52916775..31450ec3 100644--- a/resources/js/components/cards/data/VideoCard.vue+++ b/resources/js/components/cards/data/VideoCard.vue@@ -148,9 +148,9 @@ const contextMenuItems = computed(() => {<h4class="truncate text-end"- :title="`Date Uploaded: ${toFormattedDate(new Date(videoData.date_uploaded ?? videoData.date + ' GMT'))}\nDate Scanned: ${toFormattedDate(new Date(videoData.date_created))}`"+ :title="`Date Uploaded: ${toFormattedDate(new Date(videoData.file_modified_at ?? videoData.date + ' GMT'))}\nDate Scanned: ${toFormattedDate(new Date(videoData.date_created))}`">- {{ toFormattedDate(new Date(videoData.date_uploaded ?? videoData.date + ' GMT')) }}+ {{ toFormattedDate(new Date(videoData.file_modified_at ?? videoData.date + ' GMT')) }}</h4><span v-if="videoData.video_tags.length" class="flex w-full flex-wrap gap-1 overflow-clip [overflow-clip-margin:4px] sm:hidden" title="Tags">diff --git a/resources/js/components/video/VideoInfoPanel.vue b/resources/js/components/video/VideoInfoPanel.vueindex b1176998..74b270b4 100755--- a/resources/js/components/video/VideoInfoPanel.vue+++ b/resources/js/components/video/VideoInfoPanel.vue@@ -48,7 +48,7 @@ const mediaTypeDescription = computed(() => {const mediaDateDescription = computed(() => {return (- `Date Uploaded: ${toFormattedDate(stateVideo.value.date_uploaded)}` ++ `Date Uploaded: ${toFormattedDate(stateVideo.value.file_modified_at)}` +`\nDate Added: ${toFormattedDate(stateVideo.value.date_created)}` +`\nLast Updated: ${toFormattedDate(stateVideo.value.date_updated)}` +`\nLast Edited: ${toFormattedDate(stateVideo.value.edited_at)}`@@ -198,8 +198,8 @@ onMounted(() => {<li v-if="stateVideo.metadata?.resolution_height"><BadgeTag :label="stateVideo.metadata.resolution_height + 'p'" :class="'meta-badge'" /></li>- <li v-if="stateVideo.date_uploaded">- <BadgeTag :title="mediaDateDescription" :label="toTimeSpan(stateVideo.date_uploaded, '')" :class="'meta-badge'" />+ <li v-if="stateVideo.file_modified_at">+ <BadgeTag :title="mediaDateDescription" :label="toTimeSpan(stateVideo.file_modified_at, '')" :class="'meta-badge'" /></li><li v-if="stateVideo.metadata?.codec">@@ -319,10 +319,10 @@ onMounted(() => {</template></HoverCard></template>- <template v-if="stateVideo.date_uploaded">+ <template v-if="stateVideo.file_modified_at"><p>|</p><p :title="mediaDateDescription" class="truncate text-start text-nowrap">- {{ toTimeSpan(stateVideo.date_uploaded, '') }}+ {{ toTimeSpan(stateVideo.file_modified_at, '') }}</p></template></div>diff --git a/resources/js/contracts/media.ts b/resources/js/contracts/media.tsindex 69f648ae..7635726b 100644--- a/resources/js/contracts/media.ts+++ b/resources/js/contracts/media.ts@@ -69,7 +69,7 @@ export interface MetadataResource {file_size?: number;date_released?: string;date_updated?: string;- date_uploaded?: string;+ file_modified_at?: string;edited_at?: string;};relationships: {@@ -97,7 +97,7 @@ export interface VideoResource {date_created: string;date_released?: string;date_updated?: string;- date_uploaded?: string;+ file_modified_at?: string;edited_at?: string;metadata?: Metadata;subtitles: SubtitleResource[];diff --git a/resources/js/stores/ContentStore.ts b/resources/js/stores/ContentStore.tsindex 16ffcbe2..cc43eddd 100644--- a/resources/js/stores/ContentStore.ts+++ b/resources/js/stores/ContentStore.ts@@ -46,7 +46,7 @@ export const useContentStore = defineStore('Content', () => {video.name,video.title,video.description,- video.date_uploaded,+ video.file_modified_at,video.episode ?? '',video.season ?? '',video.view_count,@@ -71,7 +71,7 @@ export const useContentStore = defineStore('Content', () => {sortCriteria = [{ compareFn: CompareStrategies.episode }];}- if (['date', 'date_released', 'date_uploaded'].includes(videoSort.value.column)) {+ if (['date', 'date_released', 'file_modified_at'].includes(videoSort.value.column)) {sortCriteria[0].compareFn = CompareStrategies.date;}