Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.1.6 dev #15

Merged
merged 1 commit into from
Mar 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ APP_KEY=SomeRandomStringThatIsLongEnough
APP_TIMEZONE="UTC"
APP_URL="http://airflix.local"

AIRFLIX_EXTENSIONS_VIDEO=m4v
AIRFLIX_EXTENSIONS_VIDEO="m4v, mp4"
TMDB_API_KEY=ApplyForAnApiKey

DB_HOST=localhost
Expand Down
23 changes: 22 additions & 1 deletion Airflix/Episode.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function getFileNameAttribute()
{
return 'S'.sprintf('%02d', $this->season_number).
'E'.sprintf('%02d', $this->episode_number).'.'.
config('airflix.extensions.video');
$this->getFileExtension();
}

/**
Expand All @@ -132,6 +132,27 @@ public function getHasFileAttribute()
->exists($this->file_path);
}

/**
* Get the movie's file extension.
*
* @return string
*/
protected function getFileExtension()
{
$filePath = '/downloads/episodes/'.
$this->folder_name.'/'.
$this->folder_name.'.';

foreach(config('airflix.extensions.video') as $extension)
{
if(Storage::disk('public')->exists($filePath.$extension)) {
return $extension;
}
}

return 'm4v';
}

/**
* Get the episode's still path.
*
Expand Down
23 changes: 22 additions & 1 deletion Airflix/Movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function getBackdropUrlAttribute()
public function getFileNameAttribute()
{
return $this->folder_name.'.'.
config('airflix.extensions.video');
$this->getFileExtension();
}

/**
Expand All @@ -139,6 +139,27 @@ public function getHasFileAttribute()
->exists($this->file_path);
}

/**
* Get the movie's file extension.
*
* @return string
*/
protected function getFileExtension()
{
$filePath = '/downloads/movies/'.
$this->folder_name.'/'.
$this->folder_name.'.';

foreach(config('airflix.extensions.video') as $extension)
{
if(Storage::disk('public')->exists($filePath.$extension)) {
return $extension;
}
}

return 'm4v';
}

/**
* Get the movie's poster URl.
*
Expand Down
7 changes: 6 additions & 1 deletion config/airflix.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
],

'extensions' => [
'video' => env('AIRFLIX_EXTENSIONS_VIDEO', 'm4v'),
'video' => array_map('trim',
array_filter(
explode(',', env('AIRFLIX_EXTENSIONS_VIDEO', 'm4v, mp4')),
'strlen'
)
),
],

'per_page' => 100,
Expand Down