Pint
This commit is contained in:
@@ -2,11 +2,9 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Jobs\GetFileSizeFromCDN;
|
||||
use App\Models\Downloads;
|
||||
use App\Models\Episode;
|
||||
|
||||
use App\Jobs\GetFileSizeFromCDN;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DownloadService
|
||||
@@ -14,10 +12,10 @@ class DownloadService
|
||||
public function createOrUpdateDownloads(Request $request, Episode $episode, int $index): void
|
||||
{
|
||||
$downloadTypes = [
|
||||
'episodedlurl' => 'FHD',
|
||||
'episodedlurlinterpolated' => 'FHDi',
|
||||
'episodedlurl4k' => 'UHD',
|
||||
'downloadUHDi' => 'UHDi',
|
||||
'episodedlurl' => 'FHD',
|
||||
'episodedlurlinterpolated' => 'FHDi',
|
||||
'episodedlurl4k' => 'UHD',
|
||||
'downloadUHDi' => 'UHDi',
|
||||
];
|
||||
|
||||
foreach ($downloadTypes as $inputField => $type) {
|
||||
@@ -25,9 +23,9 @@ class DownloadService
|
||||
if ($request->filled($fieldName)) {
|
||||
$download = Downloads::updateOrCreate([
|
||||
'episode_id' => $episode->id,
|
||||
'type' => $type,
|
||||
'type' => $type,
|
||||
], [
|
||||
'url' => $request->input($fieldName),
|
||||
'url' => $request->input($fieldName),
|
||||
]);
|
||||
|
||||
// Dispatch Job to get File Size from CDN
|
||||
|
||||
@@ -5,14 +5,12 @@ namespace App\Services;
|
||||
use App\Models\Episode;
|
||||
use App\Models\Hentai;
|
||||
use App\Models\Studios;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
use Intervention\Image\Laravel\Facades\Image;
|
||||
use Illuminate\Support\Str;
|
||||
use Intervention\Image\Encoders\WebpEncoder;
|
||||
use Intervention\Image\Laravel\Facades\Image;
|
||||
|
||||
class EpisodeService
|
||||
{
|
||||
@@ -24,6 +22,7 @@ class EpisodeService
|
||||
|
||||
if (is_numeric($lastPart) && $lastPart < 1000) {
|
||||
$slugParts[array_key_last($slugParts)] = 's'.$lastPart;
|
||||
|
||||
return implode('-', $slugParts);
|
||||
}
|
||||
|
||||
@@ -31,16 +30,15 @@ class EpisodeService
|
||||
}
|
||||
|
||||
public function createEpisode(
|
||||
Request $request,
|
||||
Request $request,
|
||||
Hentai $hentai,
|
||||
int $episodeNumber,
|
||||
?Studios $studio = null,
|
||||
?Episode $referenceEpisode = null
|
||||
): Episode
|
||||
{
|
||||
$episode = new Episode();
|
||||
): Episode {
|
||||
$episode = new Episode;
|
||||
$episode->title = $referenceEpisode->title ?? $request->input('title');
|
||||
$episode->title_search = preg_replace("/[^A-Za-z0-9 ]/", '', $episode->title);
|
||||
$episode->title_search = preg_replace('/[^A-Za-z0-9 ]/', '', $episode->title);
|
||||
$episode->title_jpn = $referenceEpisode->title_jpn ?? $request->input('title_jpn');
|
||||
$episode->slug = "{$hentai->slug}-{$episodeNumber}";
|
||||
$episode->hentai_id = $hentai->id;
|
||||
@@ -96,7 +94,6 @@ class EpisodeService
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function createOrUpdateCover(Request $request, Episode $episode, string $slug, int $episodeNumber): void
|
||||
{
|
||||
if (! $request->hasFile("episodecover{$episodeNumber}")) {
|
||||
@@ -111,7 +108,7 @@ class EpisodeService
|
||||
// Encode and save cover image
|
||||
Image::read($request->file("episodecover{$episodeNumber}")->getRealPath())
|
||||
->cover(268, 394)
|
||||
->encode(new WebpEncoder())
|
||||
->encode(new WebpEncoder)
|
||||
->save(Storage::disk('public')->path($episode->cover_url));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,29 +5,25 @@ namespace App\Services;
|
||||
use App\Models\Episode;
|
||||
use App\Models\Gallery;
|
||||
use App\Models\Hentai;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
use Intervention\Image\Laravel\Facades\Image;
|
||||
use Intervention\Image\Encoders\WebpEncoder;
|
||||
use Intervention\Image\Laravel\Facades\Image;
|
||||
|
||||
class GalleryService
|
||||
{
|
||||
|
||||
public function createOrUpdateGallery(Request $request, Hentai $hentai, Episode $episode, int $episodeNumber, bool $override = false): void
|
||||
{
|
||||
$galleryInputNumber = $override ? 1 : $episodeNumber;
|
||||
|
||||
if($request->hasFile('episodegallery'.$galleryInputNumber)) {
|
||||
if ($request->hasFile('episodegallery'.$galleryInputNumber)) {
|
||||
|
||||
$this->deleteOldGallery($episode);
|
||||
|
||||
$this->createGalleryFolder($hentai);
|
||||
|
||||
$counter = 0;
|
||||
foreach($request->file('episodegallery'.$galleryInputNumber) as $file) {
|
||||
foreach ($request->file('episodegallery'.$galleryInputNumber) as $file) {
|
||||
$gallery = $this->createGallery($hentai, $episode, $episodeNumber, $counter);
|
||||
$this->saveGalleryImage($gallery, $file);
|
||||
$counter += 1;
|
||||
@@ -45,7 +41,7 @@ class GalleryService
|
||||
|
||||
private function createGallery(Hentai $hentai, Episode $episode, int $episodeNumber, int $counter): Gallery
|
||||
{
|
||||
$gallery = new Gallery();
|
||||
$gallery = new Gallery;
|
||||
$gallery->hentai_id = $hentai->id;
|
||||
$gallery->episode_id = $episode->id;
|
||||
$gallery->image_url = "/images/hentai/{$hentai->slug}/gallery-ep-{$episodeNumber}-{$counter}.webp";
|
||||
@@ -59,12 +55,12 @@ class GalleryService
|
||||
{
|
||||
Image::read($sourceImage->getRealPath())
|
||||
->cover(1920, 1080)
|
||||
->encode(new WebpEncoder())
|
||||
->encode(new WebpEncoder)
|
||||
->save(Storage::disk('public')->path($gallery->image_url));
|
||||
|
||||
Image::read($sourceImage->getRealPath())
|
||||
->cover(960, 540)
|
||||
->encode(new WebpEncoder())
|
||||
->encode(new WebpEncoder)
|
||||
->save(Storage::disk('public')->path($gallery->thumbnail_url));
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ class MatrixRegistrationService
|
||||
// Get nonce from Synapse
|
||||
$nonceResponse = Http::get("$server/_synapse/admin/v1/register");
|
||||
|
||||
if (!$nonceResponse->ok()) {
|
||||
throw new \Exception("Could not fetch nonce from Matrix.");
|
||||
if (! $nonceResponse->ok()) {
|
||||
throw new \Exception('Could not fetch nonce from Matrix.');
|
||||
}
|
||||
|
||||
$nonce = $nonceResponse->json()['nonce'];
|
||||
@@ -23,10 +23,10 @@ class MatrixRegistrationService
|
||||
// Generate MAC
|
||||
$mac = hash_hmac(
|
||||
'sha1',
|
||||
$nonce . "\0" .
|
||||
$username . "\0" .
|
||||
$password . "\0" .
|
||||
"notadmin",
|
||||
$nonce."\0".
|
||||
$username."\0".
|
||||
$password."\0".
|
||||
'notadmin',
|
||||
$secret
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user