Skip to content

A self-hosted media server and file management system

pint

aminnausin84fad0987b0c
diff --git a/app/Http/Controllers/DirectoryController.php b/app/Http/Controllers/DirectoryController.php
index 708b304e..be3bc14f 100755
--- a/app/Http/Controllers/DirectoryController.php
+++ b/app/Http/Controllers/DirectoryController.php
@@ -317,7 +317,7 @@ class DirectoryController extends Controller {
}
public static function setupBatch($chain, Task $task) {
- return Bus::batch($chain)->progress(function (Batch $batch) use ($task) {
+ return Bus::batch($chain)->progress(function (Batch $batch) {
// $task->refresh();
// $task->update([
// 'sub_tasks_pending' => $batch->pendingJobs,
diff --git a/app/Jobs/EmbedUidInMetadata.php b/app/Jobs/EmbedUidInMetadata.php
index 7cc9787c..5c5a052f 100644
--- a/app/Jobs/EmbedUidInMetadata.php
+++ b/app/Jobs/EmbedUidInMetadata.php
@@ -25,7 +25,9 @@ class EmbedUidInMetadata implements ShouldQueue {
protected $uid;
protected $taskId;
+
protected $subTaskId;
+
protected $startedAt;
/**
diff --git a/app/Jobs/IndexFiles.php b/app/Jobs/IndexFiles.php
index 0b1ee074..e6e27972 100755
--- a/app/Jobs/IndexFiles.php
+++ b/app/Jobs/IndexFiles.php
@@ -235,7 +235,8 @@ class IndexFiles implements ShouldBeUnique, ShouldQueue {
Storage::put('dataCache.json', json_encode($dataCache, JSON_UNESCAPED_SLASHES));
// dump('Categories | Folders | Videos | Data | SQL | DataCache', $directories, $subDirectories, $files, $data, $dbOut, $dataCache);
dump('Categories | Folders | Videos | Changes | SQL ', $directories, ['count' => count($subDirectories['data']['folderStructure'])], ['count' => count($files['data']['videoStructure'])], $data, $dbOut);
- return "Changed " . count($data['categories']) . " libraries, " . count($data['folders']) . " folders and " . count($data['videos']) . " Videos. \n\n$dbOut";
+
+ return 'Changed ' . count($data['categories']) . ' libraries, ' . count($data['folders']) . ' folders and ' . count($data['videos']) . " Videos. \n\n$dbOut";
} catch (\Throwable $th) {
dump($th);
throw new \Exception('Unable to index files, ' . $th->getMessage());
@@ -288,7 +289,7 @@ class IndexFiles implements ShouldBeUnique, ShouldQueue {
$data['next_ID'] = $currentID;
$data['categoryStructure'] = $current;
- SubTask::where('id', $this->subTaskId)->update(['summary' => 'Generated ' . count($changes) . ' Library Changes', 'progress' => 10]);
+ SubTask::where('id', $this->subTaskId)->update(['summary' => 'Generated ' . count($changes) . ' Library Changes', 'progress' => 10]);
return ['categoryChanges' => $changes, 'data' => $data];
}
@@ -366,7 +367,7 @@ class IndexFiles implements ShouldBeUnique, ShouldQueue {
$data['next_ID'] = $currentID;
$data['folderStructure'] = $current;
- SubTask::where('id', $this->subTaskId)->update(['summary' => 'Generated ' . count($changes) . ' Folder Changes', 'progress' => 30]);
+ SubTask::where('id', $this->subTaskId)->update(['summary' => 'Generated ' . count($changes) . ' Folder Changes', 'progress' => 30]);
return ['folderChanges' => $changes, 'data' => $data, 'cost' => $cost, 'seriesChanges' => $seriesChanges];
}
@@ -486,7 +487,8 @@ class IndexFiles implements ShouldBeUnique, ShouldQueue {
$data['next_ID'] = $currentID;
$data['videoStructure'] = $current;
- SubTask::where('id', $this->subTaskId)->update(['summary' => 'Generated ' . count($changes) . ' Video Changes', 'progress' => 80]);
+ SubTask::where('id', $this->subTaskId)->update(['summary' => 'Generated ' . count($changes) . ' Video Changes', 'progress' => 80]);
+
return ['videoChanges' => $changes, 'data' => $data, 'cost' => $cost, 'updatedFolderStructure' => $foldersCopy, 'metadataChanges' => $metadataChanges];
}
diff --git a/app/Jobs/VerifyFiles.php b/app/Jobs/VerifyFiles.php
index 1d50dbc1..180aa231 100755
--- a/app/Jobs/VerifyFiles.php
+++ b/app/Jobs/VerifyFiles.php
@@ -183,7 +183,7 @@ class VerifyFiles implements ShouldQueue {
$changes['season'] = count($season) == 1 ? (int) $season[0] : $audioMetadata['season'] ?? null;
}
- if (is_null($metadata->title) && !str_starts_with($mime_type, 'audio')) {
+ if (is_null($metadata->title) && ! str_starts_with($mime_type, 'audio')) {
$newTitle = count($season) == 1 ? 'S' . $season[0] : '';
$newTitle .= count($episode) == 1 ? 'E' . $episode[0] : '';
@@ -218,7 +218,7 @@ class VerifyFiles implements ShouldQueue {
// dump($video->name);
}
$index += 1;
- SubTask::where('id', $this->subTaskId)->update(['progress' => (int) (($index / count($this->videos)) * 100)]);
+ SubTask::where('id', $this->subTaskId)->update(['progress' => (int) (($index / count($this->videos)) * 100)]);
// dump($metadata->toArray());
}
@@ -298,15 +298,14 @@ class VerifyFiles implements ShouldQueue {
$metadata = $this->getFileMetadata($filePath);
}
-
$description = $metadata['tags']['artist'] ?? '';
$description = ($description ? ($description . ' - ') : '') . ($metadata['tags']['album'] ?? '');
$season = $metadata['tags']['disc'] ?? null;
$episode = $metadata['tags']['track'] ?? null;
+
return ['description' => $description === '' ? null : $description, 'season' => $season, 'episode' => $episode];
}
-
private function getPathUrl($path) {
/**
* @disregard P1013 Undefined method but it actually exists
@@ -321,14 +320,14 @@ class VerifyFiles implements ShouldQueue {
$coverGenerated = $this->extractAlbumArt($filePath, $coverArtPath);
if ($coverGenerated) {
Storage::disk('public')->put($coverArtPath, $coverGenerated);
+
return $this->getPathUrl($coverArtPath);
}
}
+
return null;
}
-
-
private function extractAlbumArt($filePath, $outputPath) {
try {
//code...'ffmpeg',
diff --git a/app/Jobs/VerifyFolders.php b/app/Jobs/VerifyFolders.php
index 6d892bac..772ebc5a 100644
--- a/app/Jobs/VerifyFolders.php
+++ b/app/Jobs/VerifyFolders.php
@@ -102,7 +102,7 @@ class VerifyFolders implements ShouldQueue {
}
$index += 1;
- SubTask::where('id', $this->subTaskId)->update(['progress' => (int) (($index / count($this->folders)) * 100)]);
+ SubTask::where('id', $this->subTaskId)->update(['progress' => (int) (($index / count($this->folders)) * 100)]);
// dump($series->toArray());
} catch (\Throwable $th) {