Skip to content
Permalink
Browse files

add failed message for youtube

  • Loading branch information...
kabel2 committed Aug 5, 2017
1 parent fb418fc commit 901319a7ef083e77ba83a4b8c58d039cf23c1b77
Showing with 57 additions and 18 deletions.
  1. +27 −16 app/Http/Requests/UploadFileToConvert.php
  2. +1 −1 public/css/app.css
  3. +1 −1 public/js/form.js
  4. +28 −0 resources/assets/js/stepbystepform.js
@@ -27,45 +27,54 @@ public function authorize()
public function rules()
{
return [
'url' => 'nullable|string|max:255',
'limit' => 'required|integer',
'sound' => 'required|string|max:2',
'autoResolution' => 'nullable|string|max:2',
'file' => 'nullable|mimes:webm,mp4,mkv,mov,avi,wmv,flv,3gp,gif',
'url' => 'nullable|string|max:255',
'limit' => 'required|integer',
'sound' => 'required|string|max:2',
'autoResolution' => 'nullable|string|max:2',
'file' => 'nullable|mimes:webm,mp4,mkv,mov,avi,wmv,flv,3gp,gif',
];
}
/**
* Configure the validator instance.
*
* @param \Illuminate\Validation\Validator $validator
* @param \Illuminate\Validation\Validator $validator
* @return void
*/
public function withValidator($validator)
{
$validator->after(function ($validator) {
$data = (object) $validator->getData();
$data = (object)$validator->getData();
if ($data->url) {
if (! $this->validateRemoteFile($data->url)) {
if (!$this->validateRemoteFile($data->url)) {
$validator->errors()->add('url', 'Bitte eine richtige URL angeben!');
}
}
if ($data->youtube) {
if (! Youtube::getVideoInfo(Youtube::parseVidFromURL($data->youtube))) {
$validator->errors()->add('youtube', 'Diese Youtube Adresse ist nicht gültig');
} elseif (strtotime(Youtube::getVideoInfo(Youtube::parseVidFromURL($data->youtube))->contentDetails->duration) > (40 * 60)) {
$validator->errors()->add('youtube', 'Dieses Youtube Video ist zu lang!');
if (preg_match('/(http\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+/', $data->youtube) != false) {
if (!Youtube::getVideoInfo(Youtube::parseVidFromURL($data->youtube))) {
$validator->errors()->add('youtube', 'Diese Youtube Adresse ist nicht gültig');
} elseif (strtotime(Youtube::getVideoInfo(Youtube::parseVidFromURL($data->youtube))->contentDetails->duration) > (40 * 60)) {
$validator->errors()->add('youtube', 'Dieses Youtube Video ist zu lang!');
}
} else {
$validator->errors()->add('youtube', 'Bitte eine richtige URL angeben!');
}
}
if ($data->cutstart && $data->cutend && $data->cutstart > $data->cutend) {
$validator->errors()->add('cutstart', 'Der Start des Videos kann nicht nach dem Ende sein!');
}
if (!$data->limit) {
$validator->errors()->add('limitnull', 'Gib mindestens 1Mb an!');
}
});
}
private function YTDurationToSeconds($time)
private
function YTDurationToSeconds($time)
{
$duration = new DateInterval($time);
@@ -78,17 +87,18 @@ private function YTDurationToSeconds($time)
* @param $url
* @return bool
*/
private function validateRemoteFile($url)
private
function validateRemoteFile($url)
{
$data = Curl::to($url)->allowRedirect()->withOption('NOBODY', true)->withOption('HEADER', true)->get();
if ($data) {
if (preg_match('/^HTTP\/1\.[01] (\d\d\d)/', $data, $matches)) {
$status = (int) $matches[1];
$status = (int)$matches[1];
}
if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {
$contentLength = (int) $matches[1];
$contentLength = (int)$matches[1];
}
if (preg_match('/Content-Type: (\w+\/\w+)/', $data, $matches)) {
@@ -121,5 +131,6 @@ private function validateRemoteFile($url)
}
return false;
}
}

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more.

@@ -46,6 +46,13 @@ $(function() {
{
$('#full').fadeOut();
$.each(data, function(index, element) {
if(typeof (element.youtube) !== 'undefined') {
$(this).queue(function(){
$ctr.addClass("ul slider-ul-active").removeClass("clip slider-clip-active");
$(this).dequeue();
alert(element.youtube);
});
}
if(typeof (element.url) !== 'undefined') {
$(this).queue(function(){
$ctr.addClass("ul slider-ul-active").removeClass("clip slider-clip-active");
@@ -60,6 +67,27 @@ $(function() {
alert(element.file);
});
}
else if(typeof (element.limitnull) !== 'undefined') {
$(this).queue(function(){
$ctr.addClass("size slider-size-active").removeClass("clip slider-clip-active");
$(this).dequeue();
alert(element.limit);
});
}
else if(typeof (element.sound) !== 'undefined') {
$(this).queue(function(){
$ctr.addClass("sound slider-sound-active").removeClass("clip slider-clip-active");
$(this).dequeue();
alert(element.sound);
});
}
else if(typeof (element.autoResolution) !== 'undefined') {
$(this).queue(function(){
$ctr.addClass("res slider-res-active").removeClass("clip slider-clip-active");
$(this).dequeue();
alert(element.autoResolution);
});
}
});
}
});

0 comments on commit 901319a

Please sign in to comment.
You can’t perform that action at this time.