Skip to content

Commit

Permalink
Merge pull request #15 from wells/v1.1.6-dev
Browse files Browse the repository at this point in the history
v1.1.6 dev
  • Loading branch information
wells authored Mar 17, 2017
2 parents 9dd7627 + 1d3ecb7 commit 0bf8f2f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
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

0 comments on commit 0bf8f2f

Please sign in to comment.