-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from juzaweb/feature/paid-movie
Feature/paid movie
- Loading branch information
Showing
10 changed files
with
79 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
/** | ||
* JUZAWEB CMS - The Best CMS for Laravel Project | ||
* | ||
* @package juzaweb/juzacms | ||
* @package juzaweb/cms | ||
* @author Juzaweb Team <[email protected]> | ||
* @link https://juzaweb.com | ||
* @license MIT | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
/** | ||
* JUZAWEB CMS - The Best CMS for Laravel Project | ||
* | ||
* @package juzaweb/juzacms | ||
* @package juzaweb/cms | ||
* @author The Anh Dang <[email protected]> | ||
* @link https://juzaweb.com/cms | ||
* @license MIT | ||
|
@@ -14,7 +14,7 @@ | |
|
||
class VideoFile | ||
{ | ||
public static function isSourceEmbed($source) | ||
public static function isSourceEmbed($source): bool | ||
{ | ||
$embed_source = ['embed', 'youtube', 'vimeo']; | ||
|
||
|
@@ -29,7 +29,12 @@ public function getFiles(Resource $video): array | |
{ | ||
$url = $video->getMeta('url'); | ||
|
||
return match ($video->getMeta('source')) { | ||
return $this->getFilesBySourceAndUrl($video->getMeta('source'), $url); | ||
} | ||
|
||
public function getFilesBySourceAndUrl(string $source, string $url): array | ||
{ | ||
return match ($source) { | ||
'youtube' => $this->getVideoYoutube($url), | ||
'vimeo' => $this->getVideoVimeo($url), | ||
'upload' => $this->getVideoUpload(), | ||
|
@@ -43,17 +48,29 @@ public function getFiles(Resource $video): array | |
}; | ||
} | ||
|
||
protected function getVideoYoutube($url) | ||
public function getSourceByUrl(string $url): string | ||
{ | ||
$domain = get_domain_by_url($url, true); | ||
|
||
return match ($domain) { | ||
'youtube.com' => 'youtube', | ||
'vimeo.com' => 'vimeo', | ||
'drive.google.com' => 'gdrive', | ||
default => 'mp4', | ||
}; | ||
} | ||
|
||
protected function getVideoYoutube($url): array | ||
{ | ||
return [ | ||
(object) [ | ||
'file' => 'https://www.youtube.com/embed/' . get_youtube_id($url), | ||
'type' => 'mp4', | ||
'type' => 'youtube', | ||
] | ||
]; | ||
} | ||
|
||
protected function getVideoVimeo($url) | ||
protected function getVideoVimeo($url): array | ||
{ | ||
return [ | ||
(object) [ | ||
|
@@ -63,7 +80,7 @@ protected function getVideoVimeo($url) | |
]; | ||
} | ||
|
||
protected function getVideoUrl($type, $url) | ||
protected function getVideoUrl($type, $url): array | ||
{ | ||
/*if (!is_url($url)) { | ||
return $this->getVideoUpload(); | ||
|
@@ -96,7 +113,7 @@ protected function getVideoUrl($type, $url) | |
]; | ||
} | ||
|
||
protected function getVideoUpload() | ||
protected function getVideoUpload(): array | ||
{ | ||
if ($this->converted == 1) { | ||
$files = []; | ||
|
@@ -169,7 +186,7 @@ protected function getVideoUpload() | |
]; | ||
} | ||
|
||
protected function getVideoGoogleDrive() | ||
protected function getVideoGoogleDrive(): array | ||
{ | ||
$use_stream = get_config('use_stream', 1); | ||
|
||
|
@@ -207,7 +224,7 @@ protected function getVideoGoogleDrive() | |
return []; | ||
} | ||
|
||
protected function getVideoGoogleDriveEmbed() | ||
protected function getVideoGoogleDriveEmbed(): array | ||
{ | ||
$files[] = (object) [ | ||
'file' => 'https://drive.google.com/file/d/'. get_google_drive_id($this->url) .'/preview', | ||
|
@@ -217,22 +234,23 @@ protected function getVideoGoogleDriveEmbed() | |
return $files; | ||
} | ||
|
||
protected function generateStreamUrl($path) | ||
protected function generateStreamUrl($path): string | ||
{ | ||
$token = generate_token(basename($path)); | ||
$file = json_encode(['path' => $path]); | ||
$file = \Crypt::encryptString($file); | ||
return $this->getStreamLink($token, $file, basename($path)); | ||
} | ||
|
||
protected function getStreamLink($token, $file, $name) | ||
protected function getStreamLink($token, $file, $name): string | ||
{ | ||
return route('stream.video', [$token, base64_encode($file), $name]); | ||
} | ||
|
||
protected function getExtension() | ||
protected function getExtension(): string | ||
{ | ||
$file_name = basename($this->url); | ||
|
||
return explode('.', $file_name)[count(explode('.', $file_name)) - 1]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
/** | ||
* JUZAWEB CMS - The Best CMS for Laravel Project | ||
* | ||
* @package juzaweb/juzacms | ||
* @package juzaweb/cms | ||
* @author The Anh Dang <[email protected]> | ||
* @link https://juzaweb.com/cms | ||
* @license MIT | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
/** | ||
* JUZAWEB CMS - The Best CMS for Laravel Project | ||
* | ||
* @package juzaweb/juzacms | ||
* @package juzaweb/cms | ||
* @author Juzaweb Team <[email protected]> | ||
* @link https://juzaweb.com | ||
* @license GNU General Public License v2.0 | ||
|
@@ -30,14 +30,10 @@ public function rules(): array | |
], | ||
'post_id' => [ | ||
'required', | ||
Rule::modelExists( | ||
Post::class, | ||
'id', | ||
fn($q) => $q->where('type', 'movies') | ||
), | ||
Rule::modelExists(Post::class), | ||
], | ||
'video_id' => [ | ||
'required', | ||
'nullable', | ||
Rule::modelExists( | ||
Resource::class, | ||
'id', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.