Skip to content

Commit

Permalink
Merge pull request #1 from juzaweb/feature/paid-movie
Browse files Browse the repository at this point in the history
Feature/paid movie
  • Loading branch information
juzaweb authored Nov 4, 2023
2 parents c75d022 + c1369d2 commit 8097ab6
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 95 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none
- name: Install composer
run: composer create-project juzaweb/juzacms cms "${{ matrix.cms }}"
run: composer create-project juzaweb/cms cms "${{ matrix.cms }}"
- name: Copy .env
run: php -r "copy('.env.testing.example', '.env');"
working-directory: cms
Expand Down
15 changes: 11 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
"juzaweb.com",
"Movie plugin"
],
"description": "MyMo Core Plugin help you easily create movie website. It is a powerful, flexible and User friendly movie & Video Steaming Theme with advance video contents management system. It’s easy to use & install. It has been created to provide unique experience to movie lover & movie site owner. To observe of ISP needed we have made MYMO to use as multipurpose video website. It was created to run with MyMo Theme.",
"description": "Movie Juzaweb Plugin help you easily create movie website. It is a powerful, flexible and User friendly movie & Video Steaming Theme with advance video contents management system. It’s easy to use & install. It has been created to provide unique experience to movie lover & movie site owner. To observe of ISP needed we have made MYMO to use as multipurpose video website. It was created to run with MyMo Theme.",
"extra": {
"juzaweb": {
"name": "Movie Plugin - Easily create movie website",
"domain": "mymo",
"providers": [
"Juzaweb\\Movie\\Providers\\MovieServiceProvider"
],
"name": "Movie plugin",
"domain": "mymo"
]
}
},
"autoload": {
Expand All @@ -24,5 +24,12 @@
"files": [
"src/Helpers/helpers.php"
]
},
"require": {
"juzaweb/subscription": "@dev|^1.0"
},
"require-dev": {
"juzaweb/modules": "^1.0",
"juzaweb/dev-tool": "^1.0"
}
}
2 changes: 1 addition & 1 deletion src/Helpers/TmdbImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* JUZAWEB CMS - The Best CMS for Laravel Project
*
* @package juzaweb/juzacms
* @package juzaweb/cms
* @author Juzaweb Team <admin@juzaweb.com>
* @link https://juzaweb.com
* @license MIT
Expand Down
44 changes: 31 additions & 13 deletions src/Helpers/VideoFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* JUZAWEB CMS - The Best CMS for Laravel Project
*
* @package juzaweb/juzacms
* @package juzaweb/cms
* @author The Anh Dang <dangtheanh16@gmail.com>
* @link https://juzaweb.com/cms
* @license MIT
Expand All @@ -14,7 +14,7 @@

class VideoFile
{
public static function isSourceEmbed($source)
public static function isSourceEmbed($source): bool
{
$embed_source = ['embed', 'youtube', 'vimeo'];

Expand All @@ -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(),
Expand All @@ -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) [
Expand All @@ -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();
Expand Down Expand Up @@ -96,7 +113,7 @@ protected function getVideoUrl($type, $url)
];
}

protected function getVideoUpload()
protected function getVideoUpload(): array
{
if ($this->converted == 1) {
$files = [];
Expand Down Expand Up @@ -169,7 +186,7 @@ protected function getVideoUpload()
];
}

protected function getVideoGoogleDrive()
protected function getVideoGoogleDrive(): array
{
$use_stream = get_config('use_stream', 1);

Expand Down Expand Up @@ -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',
Expand All @@ -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];
}
}
2 changes: 1 addition & 1 deletion src/Http/Controllers/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* JUZAWEB CMS - The Best CMS for Laravel Project
*
* @package juzaweb/juzacms
* @package juzaweb/cms
* @author The Anh Dang <dangtheanh16@gmail.com>
* @link https://juzaweb.com/cms
* @license MIT
Expand Down
7 changes: 4 additions & 3 deletions src/Http/Controllers/Backend/SubtitleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Juzaweb\Movie\Http\Controllers\Backend;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Validator;
use Juzaweb\Movie\Http\Datatables\SubtitleDatatable;
use Juzaweb\CMS\Http\Controllers\BackendController;
Expand Down Expand Up @@ -71,11 +72,11 @@ protected function getTitle($page_type, $file_id)
return trans('mymo::app.subtitle');
}

protected function getDataForForm($model, $page_type, $file_id)
protected function getDataForForm(Model $model, ...$params, $file_id)
{
$data = $this->DataForForm($model, $page_type, $file_id);
$data = $this->DataForForm($model, $params, $file_id);
$file = VideoFile::findOrFail($file_id);
$data['page_type'] = $page_type;
$data['page_type'] = $params;
$data['file_id'] = $file_id;
$data['file'] = $file;
return $data;
Expand Down
10 changes: 3 additions & 7 deletions src/Http/Requests/ReportRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* JUZAWEB CMS - The Best CMS for Laravel Project
*
* @package juzaweb/juzacms
* @package juzaweb/cms
* @author Juzaweb Team <admin@juzaweb.com>
* @link https://juzaweb.com
* @license GNU General Public License v2.0
Expand Down Expand Up @@ -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',
Expand Down
83 changes: 21 additions & 62 deletions src/MovieAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

use Juzaweb\CMS\Abstracts\Action;
use Juzaweb\CMS\Facades\HookAction;
use Juzaweb\Movie\Http\Controllers\AjaxController;
use Juzaweb\Movie\Http\Controllers\Backend\TmdbController;

class MovieAction extends Action
{
public function handle()
public function handle(): void
{
$this->addAction(
Action::INIT_ACTION,
Expand All @@ -27,10 +26,6 @@ public function handle()
Action::INIT_ACTION,
[$this, 'registerResources']
);
$this->addAction(
Action::FRONTEND_CALL_ACTION,
[$this, 'addAjaxTheme']
);
$this->addAction(
'post_type.movies.btn_group',
[$this, 'addImportButton']
Expand All @@ -49,7 +44,7 @@ public function handle()
);
}

public function registerMovie()
public function registerMovie(): void
{
HookAction::registerPostType(
'movies',
Expand All @@ -60,7 +55,7 @@ public function registerMovie()
'supports' => ['tag'],
'metas' => [
'origin_title' => [
'label' => trans('mymo::app.other_name')
'label' => trans('mymo::app.other_name'),
],
'tv_series' => [
'label' => trans('mymo::app.type'),
Expand All @@ -73,6 +68,17 @@ public function registerMovie()
]
],
],
'is_paid' => [
'label' => trans('mymo::app.is_paid'),
'type' => 'select',
'sidebar' => true,
'data' => [
'options' => [
'0' => trans('mymo::app.disabled'),
'1' => trans('mymo::app.enabled'),
]
],
],
'poster' => [
'label' => trans('mymo::app.poster'),
'type' => 'image',
Expand Down Expand Up @@ -120,7 +126,7 @@ public function registerMovie()
);*/
}

public function registerTaxonomies()
public function registerTaxonomies(): void
{
HookAction::registerTaxonomy(
'genres',
Expand Down Expand Up @@ -197,7 +203,7 @@ public function registerTaxonomies()
);
}

public function addSettingForm()
public function addSettingForm(): void
{
HookAction::registerConfig(
[
Expand All @@ -218,53 +224,7 @@ public function addSettingForm()
);
}

public function addAjaxTheme()
{
HookAction::registerFrontendAjax(
'movie-download',
[
'callback' => [AjaxController::class, 'download']
]
);

HookAction::registerFrontendAjax(
'get-player',
[
'callback' => [AjaxController::class, 'getPlayer']
]
);

HookAction::registerFrontendAjax(
'popular-movies',
[
'callback' => [AjaxController::class, 'getPopularMovies']
]
);

HookAction::registerFrontendAjax(
'movies-genre',
[
'callback' => [AjaxController::class, 'getMoviesByGenre']
]
);

HookAction::registerFrontendAjax(
'mymo-filter-form',
[
'callback' => [AjaxController::class, 'getFilterForm'],
]
);

HookAction::registerFrontendAjax(
'movie-report',
[
'callback' => [AjaxController::class, 'report'],
'method' => 'post',
]
);
}

public function registerResources()
public function registerResources(): void
{
HookAction::registerResource(
'servers',
Expand Down Expand Up @@ -370,20 +330,19 @@ public function registerResources()
);
}

public function addImportButton()
public function addImportButton(): void
{
echo '<a href="javascript:void(0)" class="btn btn-primary" data-toggle="modal" data-target="#tmdb-modal">
<i class="fa fa-download"></i> '. trans('mymo::app.add_from_tmdb') .'
</a>';
}

public function addModalImport()
public function addModalImport(): void
{
echo view('mymo::tmdb_import')
->render();
echo view('mymo::tmdb_import')->render();
}

public function addAjaxAdmin()
public function addAjaxAdmin(): void
{
HookAction::registerAdminAjax(
'tmdb-add_movie',
Expand Down
Loading

0 comments on commit 8097ab6

Please sign in to comment.