fix thumbnail generation

fix hardcoded paths
a lot of minor fixes
This commit is contained in:
2021-01-21 19:55:42 +00:00
parent aacf387d63
commit 7a62b01027
18 changed files with 62 additions and 121 deletions

View File

@@ -22,21 +22,22 @@ class VideoController extends Controller
* @return Response
*/
public function index(Request $request) {
if($request->has('q')){
$videos = Video::filtered();
if($request->has('q')) {
$needle = trim($request->input('q'));
$videos = $videos->withAnyTagsFuzzy($needle);
return view('index', [
'videos' => Video::filtered()->withAnyTagsFuzzy($needle)
->orderBy('id', 'asc')
->paginate(20)->appends(['q' => $needle]),
'number_of_results' => $videos->get()->count(),
'videos' => $videos->orderBy('id', 'ASC')->paginate(20)->appends(['q' => $needle]),
'categories' => Category::all(),
'q' => $needle,
'q' => $needle
]);
}
return view('index', [
'videos' => Video::filtered()->orderBy('id', 'ASC')->paginate(20),
'categories' => Category::all(),
'number_of_results' => $videos->get()->count(),
'videos' => $videos->orderBy('id', 'ASC')->paginate(20),
'categories' => Category::all()
]);
}
@@ -181,9 +182,11 @@ class VideoController extends Controller
#->back();
#->with('error', 'No video with that ID found');
$sfw = $video->tags->contains(function($key, $tag) {
return $tag->normalized === 'sfw';
});
$sfw = $video->isSfw();
if(!$sfw && !file_exists(public_path() . "/thumbs/blurred/" . substr($video->file, 0, -5) . "_blurred.png"))
$video->blurryThumb();
return view('video', [
'video' => $video,

View File

@@ -38,9 +38,9 @@ Route::group(['prefix' => 'api'], function() {
Route::group(['prefix' => 'comments'], function() {
Route::get('/', 'CommentController@index')->middleware('auth');
Route::get('/{id}', 'CommentController@show')->where('id', '[0-9]+')->middleware('auth');
Route::post('{id}/edit', 'CommentController@update')->where('id', '[0-9]+')->middleware('auth');
Route::post('{id}/delete', 'CommentController@destroy')->where('id', '[0-9]+')->middleware('auth');
Route::post('{id}/restore', 'CommentController@restore')->where('id', '[0-9]+')->middleware('auth');
Route::post('{id}/edit', 'CommentController@update')->where('id', '[0-9]+')->middleware('auth')->middleware('theme');
Route::post('{id}/delete', 'CommentController@destroy')->where('id', '[0-9]+')->middleware('auth')->middleware('theme');
Route::post('{id}/restore', 'CommentController@restore')->where('id', '[0-9]+')->middleware('auth')->middleware('theme');
});
// /api/user
@@ -76,10 +76,10 @@ Route::group(['prefix' => 'api'], function() {
}
return $res;
})->where('id', '[0-9]+')->middleware('auth');
Route::post('{id}/delete', 'VideoController@destroy')->where('id', '[0-9]+');
Route::post('{id}/delete', 'VideoController@destroy')->where('id', '[0-9]+')->middleware('theme');
Route::post('{id}/tag', 'VideoController@tag')->where('id', '[0-9]+');
Route::post('{id}/untag', 'VideoController@untag')->where('id', '[0-9]+');
#Route::post('upload', 'VideoController@store')->middleware('auth');
Route::post('upload', 'VideoController@store')->middleware('auth');
});
#Route::post('upload', 'VideoController@store');
@@ -109,7 +109,7 @@ Route::group(["middleware" => "theme"], function() {
Route::get('index', 'VideoController@index')->middleware('auth');
Route::get('main', 'VideoController@main')->middleware('auth');
Route::post('index/{id}', 'VideoController@update')->middleware('auth');
#Route::get('upload', 'VideoController@create')->middleware('auth');
Route::get('upload', 'VideoController@create')->middleware('auth');
Route::get('categories', 'CategoryController@index')->middleware('auth');
Route::get('webm', function() { return view('webm'); })->middleware('auth');
Route::get('about', function() { return view('about'); })->middleware('auth');

View File

@@ -163,8 +163,8 @@ class Video extends Model
public function tesThumb() {
set_time_limit(9899999999999999);
$dat = $this->file;
#$in = public_path() . "/b"; // webm-input
$in = "/home/w0bm/w0bm/public/b";
$in = public_path() . "/b"; // webm-input
#$in = "/home/w0bm/w0bm/public/b";
$out = public_path() . "/thumbs/beta"; //thumb-output
$tmpdir = str_replace("public", "app/Http/Controllers/tmp", public_path());
@@ -192,7 +192,7 @@ public function blurryThumb() {
set_time_limit(9899999999999999);
$dat = $this->file;
#$in = public_path() . "/b"; // webm-input
$in = "/home/w0bm/w0bm/public/b";
$in = public_path() . "/b";
$out = public_path() . "/thumbs/blurred"; //thumb-output
$tmpdir = str_replace("public", "app/Http/Controllers/tmp", public_path());
@@ -220,28 +220,6 @@ public function blurryThumb() {
}
}
public function createThumbnailStatic() {
$dat = $this->file;
$in = public_path() . "/b"; // webm-input
$out = public_path() . "/thumbs/testing"; //thumb-output
$tmpdir = str_replace("public", "app/Http/Controllers/tmp", public_path());
$name = explode(".", $dat);
array_pop($name);
$name = join(".", $name);
if(!file_exists("{$out}/{$name}.png")) {
$length = round(shell_exec("ffprobe -i {$in}/{$dat} -show_format -v quiet | sed -n 's/duration=//p'"));
for ($i = 1; $i < 10; $i++) {
$act = ($i * 10) * ($length / 100);
$ffmpeg = shell_exec("ffmpeg -ss {$act} -i {$in}/{$dat} -vf \"'select=eq(n\,0)'\" -vf scale=128:128 {$tmpdir}/{$name}_{$i}.png 2>&1");
}
$tmp = shell_exec("convert -delay 27 -loop 0 {$tmpdir}/{$name}_*.png {$out}/{$name}.png 2>&1");
if(@filesize("{$out}/{$name}.png") < 2000)
@unlink("{$out}/{$name}.png");
array_map('unlink', glob("{$tmpdir}/{$name}*.png"));
}
}
public static function getRandom($related = null) {
if ($related) {
$id = $related->videos()->filtered()->countScoped()->count() - 1;
@@ -260,8 +238,8 @@ public function blurryThumb() {
}
public function isSfw() {
return $this->tags->contains(function ($key, $tag) {
$tag->normalized === 'sfw';
return !$this->tags->contains(function ($key, $tag) {
return $tag->normalized === 'nsfw';
});
}

View File

@@ -1143,7 +1143,7 @@ $(function() {
formData.append('file', file);
$('.progress-striped, #upload-stats').css('opacity', 0).slideDown('fast').animate({opacity: 1}, {queue: false, duration: 'fast'});
jqXHR = $.ajax({
url: '/api/upload',
url: '/api/video/upload',
type: 'POST',
data: formData,
processData: false,

View File

@@ -1,7 +1,7 @@
@extends('profilelayout')
@section('content')
<div class="page-header">
<h3 id="index">Index <small>{{ count($videos) }} results</small></h3>
<h3 id="index">Index <small>{{ $number_of_results }} results</small></h3>
<form method="get">
<button type="submit" class="suchbutton"><i style="color:white;" class="fa fa-search"></i></button>
{!! Form::text('q', isset($q) ? $q : null, ['class' => 'suchleiste', 'placeholder' => 'Search w0bm.com']) !!}

View File

@@ -15,21 +15,12 @@
<meta property="og:title" content="@if(isset($video)){{$video->videotitle}}@endif">
@if(auth()->check())<meta property="og:description" content="Tags:@if(isset($video)) {{ $video->getTagListAttribute() }} @endif">@endif
@if(isset($video))
@if(count($video->tags))
@foreach($video->tags as $tag)
@if($tag == 'sfw')
@if($video->isSfw())
<meta property="og:image" content="@if(isset($video))/thumbs/beta/{{str_replace(".webm","",$video->file)}}.png"@endif/>
@elseif($tag == 'nsfw')
@if(file_exists(public_path() . 'thumbs/blurred/{{$video->file}}' . '_blurred.png'))
<meta property="og:image" content="@if(isset($video))/thumbs/blurred/{{str_replace(".webm","",$video->file)}}_blurred.png"@endif/>
@else
{{$video->blurryThumb()}}
<meta property="og:image" content="@if(isset($video))/thumbs/blurred/{{str_replace(".webm","",$video->file)}}_blurred.png"@endif/>
@endif
@endif
@endforeach
@endif
@endif
@if(auth()->check())<meta property="og:video" content="@if(isset($video))/b/{{ $video->file }} @endif">@endif
<meta property="og:url" content="@if(isset($video))/{{ $video->id }}@endif">
<meta property="og:video:type" content="video/webm">

View File

@@ -18,11 +18,10 @@
<div class="main-item">
<a href="/{{$video->id}}">
{{-- MUSS UNBEDINGT NOCH ANGEPASST WERDEN!!! --}}
@if(file_exists('/home/w0bm/w0bm/public/thumbs/beta/'.$thumb.'.png'))
@if(file_exists(public_path() . '/thumbs/beta/'.$thumb.'.png'))
<img src="/thumbs/beta/{{$thumb}}.png">
@else
{{$video->tesThumb()}}
<img src="/thumbs/beta/{{$thumb}}.png">
<img src="/small_404.gif" class="nothumb">
@endif
</a>
</div>

View File

@@ -15,7 +15,6 @@
Help to improve w0bm, click <a href="https://www.strawpoll.me/20512203" target="_blank">here</a>
</div>-->
@if(Auth::check())
<p style="border: 1px solid red; text-align: center;">Shutting down <b><u>9.12.2020</u></b>, all donations refunded! <br> <code>wget -m -np -c -U "blah" -R "index.html*" "https://b.w0bm.com/b/"</code> backup if you like</p>
@include('partials.commentform')
@endif

View File

@@ -2,12 +2,6 @@
@section('content')
@if(auth()->check())
@if(file_exists(public_path() . 'thumbs/beta/{{$video->file}}' . '.png'))
@else
{{$video->tesThumb()}}
@endif
<?php $related = $related ?? null; ?>
<div class="vertical-align">
<div class="wrapper">
@@ -21,7 +15,7 @@
<iframe src="https://w0bm.com/loop/index.html"></iframe>
@else
<video id="video" loop controls preload="auto" crossorigin="anonymous">
<source src="https://b.w0bm.com/b{{ "/" . $video->file }}">
<source src="/b{{ "/" . $video->file }}">
<!-- rip fapple! <source src="//fapple.w0bm.com/{{str_replace(".webm","",$video->file)}}.mp4"> -->
</video>
@endif
@@ -140,7 +134,6 @@
</aside>
@else
{{$video->tesThumb()}}
<div class="centered">
<div class="modal-content col-md-5">
<div class="modal-header">
@@ -159,19 +152,10 @@
</div>
<div class="media not-logged-in">
<div class="media-left">
@if(count($video->tags))
@foreach($video->tags as $tag)
@if($tag == 'sfw')
<img class="media-object" src="@if(isset($video))/thumbs/beta/{{str_replace(".webm","",$video->file)}}.png"@endif">
@elseif($tag == 'nsfw')
@if(file_exists(public_path() . 'thumbs/blurred/{{$video->file}}' . '_blurred.png'))
<img class="media-object" src="@if(isset($video))/thumbs/blurred/{{str_replace(".webm","",$video->file)}}_blurred.png"@endif">
@if($sfw)
<img class="media-object" src="/thumbs/beta/{{str_replace('.webm','',$video->file)}}.png">
@else
{{$video->blurryThumb()}}
<img class="media-object" src="@if(isset($video))/thumbs/blurred/{{str_replace(".webm","",$video->file)}}_blurred.png"@endif">
@endif
@endif
@endforeach
<img class="media-object" src="/thumbs/blurred/{{str_replace('.webm','',$video->file)}}_blurred.png">
@endif
</div>
<div class="media-koerper">

View File

@@ -7,15 +7,13 @@
?>
<div class="main-item">
<a href="/{{$video->id}}">
@if(file_exists('/home/w0bm/w0bm/public/thumbs/beta/'.$thumb.'.png'))
@if(file_exists(public_path() . '/thumbs/beta/'.$thumb.'.png'))
<img src="/thumbs/beta/{{$thumb}}.png">
@else
@else
<img src="/small_404.gif" class="nothumb" />
{{$video->tesThumb()}}
@endif
</a>
</div>
@endif
</a>
</div>
@endforeach
</div>

View File

@@ -5,7 +5,7 @@
<div class="video">
<div class="embed-responsive embed-responsive-16by9">
<video id="video" class="video rounded embed-responsive-item" loop preload="auto" crossorigin="anonymous">
<source src="//b.w0bm.com/b{{ "/" . $video->file }}">
<source src="//w0bm.com/b{{ "/" . $video->file }}">
</video>
</div>
</div>
@@ -19,7 +19,7 @@
<div class="video-wrap embed-responsive embed-responsive-16by9">
<div class="video">
<video id="video" class="video rounded embed-responsive-item" loop preload="auto" crossorigin="anonymous">
<source src="//b.w0bm.com/b{{ "/" . $video->file }}">
<source src="//w0bm.com/b{{ "/" . $video->file }}">
</video>
</div>
</div>
@@ -33,7 +33,7 @@
<iframe src="https://w0bm.com/loop/index.html"></iframe>
@else
<video class="video scrollable" loop id="video">
<source src="//b.w0bm.com/b{{ "/" . $video->file }}">
<source src="//w0bm.com/b{{ "/" . $video->file }}">
</video>
@endif
</div>

View File

@@ -7,12 +7,10 @@
?>
<div class="main-item">
<a href="/{{$video->id}}">
@if(file_exists('/home/w0bm/w0bm/public/thumbs/beta/'.$thumb.'.png'))
@if(file_exists(public_path() . '/thumbs/beta/'.$thumb.'.png'))
<img src="/thumbs/beta/{{$thumb}}.png">
@else
<img src="/small_404.gif" class="nothumb" />
{{$video->tesThumb()}}
@endif
</a>
</div>

View File

@@ -5,7 +5,7 @@
<div class="video">
<div class="embed-responsive embed-responsive-16by9">
<video id="video" class="video rounded embed-responsive-item" loop preload="auto" crossorigin="anonymous">
<source src="@if(env('APP_DEBUG')){{"/b"}}@else{{"//" . (substr($_SERVER["HTTP_HOST"], 0, 3) === "v4." ? "v4." : "") . "b.w0bm.com"}}@endif{{ "/" . $video->file }}">
<source src="@if(env('APP_DEBUG')){{"/b"}}@else{{"//" . (substr($_SERVER["HTTP_HOST"], 0, 3) === "v4." ? "v4." : "") . "w0bm.com"}}@endif{{ "/" . $video->file }}">
</video>
</div>
</div>

View File

@@ -7,12 +7,11 @@
?>
<div class="main-item">
<a href="/{{$video->id}}">
@if(file_exists('/home/w0bm/w0bm/public/thumbs/beta/'.$thumb.'.png'))
@if(file_exists(public_path() . '/thumbs/beta/'.$thumb.'.png'))
<img src="/thumbs/beta/{{$thumb}}.png">
@else
<img src="/small_404.gif" class="nothumb" />
{{$video->tesThumb()}}
@endif
</a>
</div>

View File

@@ -5,7 +5,7 @@
<div class="video">
<div class="embed-responsive embed-responsive-16by9">
<video id="video" class="video rounded embed-responsive-item" loop preload="auto" crossorigin="anonymous">
<source src="@if(env('APP_DEBUG')){{"/b"}}@else{{"//" . (substr($_SERVER["HTTP_HOST"], 0, 3) === "v4." ? "v4." : "") . "b.w0bm.com"}}@endif{{ "/" . $video->file }}">
<source src="@if(env('APP_DEBUG')){{"/b"}}@else{{"//" . (substr($_SERVER["HTTP_HOST"], 0, 3) === "v4." ? "v4." : "") . "w0bm.com"}}@endif{{ "/" . $video->file }}">
</video>
</div>
</div>
@@ -34,5 +34,4 @@
</video>
</div>
@include('video-partials.legacy-videonav')
{{$video->tesThumb()}}
@endsection

View File

@@ -5,7 +5,7 @@
<div class="wrapper">
<div class="embed-responsive embed-responsive-16by9">
<video id="video" loop controls preload="auto" crossorigin="anonymous">
<source src="{{ "//b.w0bm.com/b/" . $video->file }}">
<source src="{{ "//w0bm.com/b/" . $video->file }}">
<!-- rip fapple! <source src="//fapple.w0bm.com/{{str_replace(".webm","",$video->file)}}.mp4"> -->
</video>
@if($video->category->name === 'Anime' || $video->category->name === 'Otomad')

View File

@@ -18,11 +18,10 @@
<div class="main-item">
<a href="/{{$video->id}}">
{{-- MUSS UNBEDINGT NOCH ANGEPASST WERDEN!!! --}}
@if(file_exists('/home/w0bm/w0bm/public/thumbs/beta/'.$thumb.'.png'))
@if(file_exists(public_path() . '/thumbs/beta/'.$thumb.'.png'))
<img src="/thumbs/beta/{{$thumb}}.png">
@else
{{$video->tesThumb()}}
<img src="/thumbs/beta/{{$thumb}}.png">
<img src="/small_404.gif" class="nothumb">
@endif
</a>
</div>

View File

@@ -3,11 +3,6 @@
@if(auth()->check())
@if(file_exists(public_path() . 'thumbs/beta/{{$video->file}}' . '.png'))
@else
{{$video->tesThumb()}}
@endif
<?php $related = $related ?? null; ?>
<div class="vertical-align">
<div class="wrapper">
@@ -21,7 +16,7 @@
<iframe src="https://w0bm.com/loop/index.html"></iframe>
@else
<video id="video" loop controls preload="auto" crossorigin="anonymous">
<source src="//b.w0bm.com/b{{ "/" . $video->file }}">
<source src="//w0bm.com/b{{ "/" . $video->file }}">
<!-- rip fapple! <source src="//fapple.w0bm.com/{{str_replace(".webm","",$video->file)}}.mp4"> -->
</video>
@endif
@@ -140,7 +135,6 @@
</aside>
@else
{{$video->tesThumb()}}
<div class="centered">
<div class="modal-content col-md-5">
<div class="modal-header">