|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Handles movie-related actions |
|
5
|
|
|
* |
|
6
|
|
|
* @author Sam Stenvall <[email protected]> |
|
7
|
|
|
* @copyright Copyright © Sam Stenvall 2013- |
|
8
|
|
|
* @license https://www.gnu.org/licenses/gpl.html The GNU General Public License v3.0 |
|
9
|
|
|
*/ |
|
10
|
|
|
class MovieController extends MediaController |
|
11
|
|
|
{ |
|
12
|
|
|
|
|
13
|
|
|
protected function getSpectatorProhibitedActions() |
|
14
|
|
|
{ |
|
15
|
|
|
return array('getMoviePlaylist'); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Lists all movies in the library, optionally filtered |
|
20
|
|
|
*/ |
|
21
|
|
|
public function actionIndex() |
|
22
|
|
|
{ |
|
23
|
|
|
// Get the appropriate request parameters from the filter |
|
24
|
|
|
$filterForm = new MovieFilterForm(); |
|
25
|
|
|
$movies = VideoLibrary::getMovies($filterForm->buildRequestParameters()); |
|
26
|
|
|
|
|
27
|
|
|
// Redirect to the details page if there's only one result |
|
28
|
|
|
if (count($movies) === 1 && $filterForm->name === $movies[0]->label) |
|
29
|
|
|
$this->redirect(['details', 'id' => $movies[0]->getId()]); |
|
30
|
|
|
|
|
31
|
|
|
$dataProvider = new LibraryDataProvider($movies); |
|
32
|
|
|
$dataProvider->makeSortable(); |
|
33
|
|
|
|
|
34
|
|
|
$this->render('index', [ |
|
35
|
|
|
'dataProvider' => $dataProvider, |
|
36
|
|
|
'filterForm' => $filterForm, |
|
37
|
|
|
]); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Renders a list of recently added movies |
|
43
|
|
|
*/ |
|
44
|
|
|
public function actionRecentlyAdded() |
|
45
|
|
|
{ |
|
46
|
|
|
$movies = VideoLibrary::getRecentlyAddedMovies(); |
|
47
|
|
|
|
|
48
|
|
|
$dataProvider = new LibraryDataProvider($movies); |
|
49
|
|
|
$dataProvider->makeSortable('dateadded DESC'); |
|
50
|
|
|
|
|
51
|
|
|
$this->render('recentlyAdded', array( |
|
52
|
|
|
'dataProvider'=> $dataProvider |
|
53
|
|
|
)); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Shows details and download links for the specified movie |
|
58
|
|
|
* @param int $id the movie ID |
|
59
|
|
|
*/ |
|
60
|
|
|
public function actionDetails($id) |
|
61
|
|
|
{ |
|
62
|
|
|
$movieDetails = VideoLibrary::getMovieDetails($id, array( |
|
63
|
|
|
'genre', |
|
64
|
|
|
'year', |
|
65
|
|
|
'rating', |
|
66
|
|
|
'tagline', |
|
67
|
|
|
'plot', |
|
68
|
|
|
'mpaa', |
|
69
|
|
|
'cast', |
|
70
|
|
|
'director', |
|
71
|
|
|
'imdbnumber', |
|
72
|
|
|
'runtime', |
|
73
|
|
|
'streamdetails', |
|
74
|
|
|
'votes', |
|
75
|
|
|
'art', |
|
76
|
|
|
'thumbnail', |
|
77
|
|
|
'file' |
|
78
|
|
|
)); |
|
79
|
|
|
|
|
80
|
|
|
// Create a data provider for the actors. We only show one row (first |
|
81
|
|
|
// credited only), hence the 6 |
|
82
|
|
|
$actorDataProvider = new CArrayDataProvider( |
|
83
|
|
|
$movieDetails->cast, array( |
|
84
|
|
|
'keyField'=>'name', |
|
85
|
|
|
'pagination'=>array('pageSize'=>6) |
|
86
|
|
|
)); |
|
87
|
|
|
|
|
88
|
|
|
$this->render('details', array( |
|
89
|
|
|
'details'=>$movieDetails, |
|
90
|
|
|
'actorDataProvider'=>$actorDataProvider, |
|
91
|
|
|
)); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Serves a playlist containing the specified movie's files to the browser |
|
96
|
|
|
* @param int $id the movie ID |
|
97
|
|
|
*/ |
|
98
|
|
|
public function actionGetMoviePlaylist($id, $playlistFormat) |
|
99
|
|
|
{ |
|
100
|
|
|
$movieDetails = VideoLibrary::getMovieDetails($id, array( |
|
101
|
|
|
'file', |
|
102
|
|
|
'runtime', |
|
103
|
|
|
'year', |
|
104
|
|
|
'thumbnail', |
|
105
|
|
|
)); |
|
106
|
|
|
|
|
107
|
|
|
$this->log('"%s" streamed "%s"', Yii::app()->user->name, $movieDetails->getDisplayName()); |
|
108
|
|
|
$this->servePlaylist($movieDetails, $playlistFormat); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
} |
|
112
|
|
|
|