Merge pull request #2886 from Roardom/similar-refresh

(Add) Refresh torrent metadata button
This commit is contained in:
HDVinnie
2023-07-12 20:31:01 -04:00
committed by GitHub
5 changed files with 63 additions and 5 deletions
@@ -17,6 +17,7 @@ use App\Models\Category;
use App\Models\Movie;
use App\Models\Torrent;
use App\Models\Tv;
use App\Services\Tmdb\TMDBScraper;
use MarcReichel\IGDBLaravel\Models\Game;
use MarcReichel\IGDBLaravel\Models\PlatformLogo;
@@ -100,4 +101,25 @@ class SimilarTorrentController extends Controller
'igdb' => $igdb ?? null,
]);
}
public function update(Category $category, int $tmdbId)
{
if ($tmdbId !== 0) {
$tmdbScraper = new TMDBScraper();
switch (true) {
case $category->movie_meta:
$tmdbScraper->movie($tmdbId);
break;
case $category->tv_meta:
$tmdbScraper->tv($tmdbId);
break;
}
}
return to_route('torrents.similar', ['category_id' => $category->id, 'tmdb' => $tmdbId])
->withSuccess('Metadata update queued successfully');
}
}
+16 -5
View File
@@ -158,27 +158,38 @@
padding: 0;
}
.meta__dropdown > li:first-child > a {
.meta__dropdown > li > form {
display: contents;
}
.meta__dropdown > li:first-child > a,
.meta__dropdown > li:first-child > form > button {
border-radius: 6px 6px 0 0;
}
.meta__dropdown > li:last-child > a {
.meta__dropdown > li:last-child > a,
.meta__dropdown > li:last-child > form > button {
border-radius: 0 0 6px 6px;
}
.meta__dropdown > li:only-child > a {
.meta__dropdown > li:only-child > a,
.meta__dropdown > li:only-child > form > button {
border-radius: 6px;
}
.meta__dropdown > li > a {
.meta__dropdown > li > a,
.meta__dropdown > li > form > button {
padding: 18px 18px 18px 28px;
min-width: 180px;
display: block;
color: var(--meta-dropdown-fg);
background: transparent;
font-size: 14px;
text-align: left;
}
.meta__dropdown > li > a:hover {
.meta__dropdown > li > a:hover,
.meta__dropdown > li > form > button:hover {
background: var(--meta-dropdown-hover-bg);
color: var(--meta-dropdown-hover-fg);
}
@@ -44,6 +44,18 @@
Request similar
</a>
</li>
@if ($meta?->id && auth()->user()->group->is_modo)
<li>
<form
action="{{ route('torrents.similar.update', ['category' => $category, 'tmdbId' => $meta->id]) }}"
method="post"
>
@csrf
@method('PATCH')
<button>Update Metadata</button>
</form>
</li>
@endif
</ul>
</div>
<ul class="meta__ids">
@@ -44,6 +44,18 @@
Request similar
</a>
</li>
@if ($meta?->id && auth()->user()->group->is_modo)
<li>
<form
action="{{ route('torrents.similar.update', ['category' => $category, 'tmdbId' => $meta->id]) }}"
method="post"
>
@csrf
@method('PATCH')
<button>Update Metadata</button>
</form>
</li>
@endif
</ul>
</div>
<ul class="meta__ids">
+1
View File
@@ -206,6 +206,7 @@ Route::middleware('language')->group(function (): void {
Route::get('/download/{id}', [App\Http\Controllers\TorrentDownloadController::class, 'store'])->name('download');
Route::post('/{id}/reseed', [App\Http\Controllers\ReseedController::class, 'store'])->name('reseed');
Route::get('/similar/{category_id}.{tmdb}', [App\Http\Controllers\SimilarTorrentController::class, 'show'])->name('torrents.similar');
Route::patch('/similar/{category}.{tmdbId}', [App\Http\Controllers\SimilarTorrentController::class, 'update'])->name('torrents.similar.update')->middleware('modo');
});
Route::prefix('torrent')->group(function (): void {