mirror of
https://github.com/devfake/flox.git
synced 2024-11-15 06:32:34 +01:00
Show current movies in theatre (#82)
* start with "now playing" movies * display current route * display route in header * update production files * fix test and create refresh mock
This commit is contained in:
parent
771b3d6d33
commit
e6c13acde7
@ -29,6 +29,11 @@
|
|||||||
return $this->tmdb->trending();
|
return $this->tmdb->trending();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function current()
|
||||||
|
{
|
||||||
|
return $this->tmdb->current();
|
||||||
|
}
|
||||||
|
|
||||||
public function upcoming()
|
public function upcoming()
|
||||||
{
|
{
|
||||||
return $this->tmdb->upcoming();
|
return $this->tmdb->upcoming();
|
||||||
|
@ -104,8 +104,7 @@
|
|||||||
public function upcoming()
|
public function upcoming()
|
||||||
{
|
{
|
||||||
$cache = Cache::remember('upcoming', $this->untilEndOfDay(), function() {
|
$cache = Cache::remember('upcoming', $this->untilEndOfDay(), function() {
|
||||||
// There is no 'EN' region in TMDb.
|
$region = getRegion($this->translation);
|
||||||
$region = strtolower($this->translation) == 'en' ? 'us' : $this->translation;
|
|
||||||
|
|
||||||
$response = $this->requestTmdb($this->base . '/3/movie/upcoming', [
|
$response = $this->requestTmdb($this->base . '/3/movie/upcoming', [
|
||||||
'region' => $region,
|
'region' => $region,
|
||||||
@ -117,6 +116,26 @@
|
|||||||
return $this->filterItems($cache);
|
return $this->filterItems($cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search TMDb for current playing movies in our region.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function current()
|
||||||
|
{
|
||||||
|
$cache = Cache::remember('current', $this->untilEndOfDay(), function() {
|
||||||
|
$region = getRegion($this->translation);
|
||||||
|
|
||||||
|
$response = $this->requestTmdb($this->base . '/3/movie/now_playing', [
|
||||||
|
'region' => $region,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return collect($this->createItems($response, 'movie'));
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->filterItems($cache);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search TMDb for current popular movies and tv shows.
|
* Search TMDb for current popular movies and tv shows.
|
||||||
*
|
*
|
||||||
|
@ -19,3 +19,9 @@
|
|||||||
{
|
{
|
||||||
return str_slug($title) != '' ? str_slug($title) : 'no-slug-available';
|
return str_slug($title) != '' ? str_slug($title) : 'no-slug-available';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// There is no 'EN' region in TMDb.
|
||||||
|
function getRegion($translation)
|
||||||
|
{
|
||||||
|
return strtolower($translation) == 'en' ? 'us' : $translation;
|
||||||
|
}
|
@ -14,6 +14,7 @@
|
|||||||
Route::get('/suggestions/{tmdbID}/{mediaType}', 'TMDBController@suggestions');
|
Route::get('/suggestions/{tmdbID}/{mediaType}', 'TMDBController@suggestions');
|
||||||
Route::get('/trending', 'TMDBController@trending');
|
Route::get('/trending', 'TMDBController@trending');
|
||||||
Route::get('/upcoming', 'TMDBController@upcoming');
|
Route::get('/upcoming', 'TMDBController@upcoming');
|
||||||
|
Route::get('/current', 'TMDBController@current');
|
||||||
|
|
||||||
Route::patch('/refresh-all', 'ItemController@refreshAll');
|
Route::patch('/refresh-all', 'ItemController@refreshAll');
|
||||||
Route::get('/settings', 'SettingController@settings');
|
Route::get('/settings', 'SettingController@settings');
|
||||||
|
@ -58,6 +58,7 @@
|
|||||||
public function it_should_import_a_backup_file()
|
public function it_should_import_a_backup_file()
|
||||||
{
|
{
|
||||||
$this->createStorageDownloadsMock();
|
$this->createStorageDownloadsMock();
|
||||||
|
$this->createRefreshAllMock();
|
||||||
$this->callImport('export.json');
|
$this->callImport('export.json');
|
||||||
|
|
||||||
$this->assertCount(4, Item::all());
|
$this->assertCount(4, Item::all());
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Services\IMDB;
|
use App\Services\IMDB;
|
||||||
|
use App\Services\Models\ItemService;
|
||||||
use App\Services\Storage;
|
use App\Services\Storage;
|
||||||
use App\Services\TMDB;
|
use App\Services\TMDB;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
@ -31,6 +32,12 @@
|
|||||||
$mock->shouldReceive('downloadImages')->andReturn(null);
|
$mock->shouldReceive('downloadImages')->andReturn(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createRefreshAllMock()
|
||||||
|
{
|
||||||
|
$mock = $this->mock(ItemService::class);
|
||||||
|
$mock->shouldReceive('refreshAll')->andReturn(null);
|
||||||
|
}
|
||||||
|
|
||||||
public function createTmdbEpisodeMock()
|
public function createTmdbEpisodeMock()
|
||||||
{
|
{
|
||||||
// Mock this to avoid unknown requests to TMDb (get seasons and then get episodes for each season)
|
// Mock this to avoid unknown requests to TMDb (get seasons and then get episodes for each season)
|
||||||
|
@ -73,7 +73,7 @@
|
|||||||
const path = this.$route.path;
|
const path = this.$route.path;
|
||||||
const released = new Date(this.localItem.released * 1000);
|
const released = new Date(this.localItem.released * 1000);
|
||||||
|
|
||||||
if(path == '/upcoming') {
|
if(path === '/upcoming' || path === '/current') {
|
||||||
return this.formatLocaleDate(released);
|
return this.formatLocaleDate(released);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<main :class="{'display-suggestions': path == 'suggestions'}">
|
<main :class="{'display-suggestions': path === 'suggestions'}">
|
||||||
<div class="wrap-content" v-if=" ! loading">
|
<div class="wrap-content" v-if=" ! loading">
|
||||||
<div class="items-wrap">
|
<div class="items-wrap">
|
||||||
<Item v-for="(item, index) in items"
|
<Item v-for="(item, index) in items"
|
||||||
@ -52,12 +52,12 @@
|
|||||||
this.path = this.$route.name;
|
this.path = this.$route.name;
|
||||||
|
|
||||||
switch(this.path) {
|
switch(this.path) {
|
||||||
case 'trending':
|
|
||||||
return this.initTrending();
|
|
||||||
case 'suggestions':
|
case 'suggestions':
|
||||||
return this.initSuggestions();
|
return this.initSuggestions();
|
||||||
|
case 'trending':
|
||||||
case 'upcoming':
|
case 'upcoming':
|
||||||
return this.initUpcoming();
|
case 'current':
|
||||||
|
return this.initContent(this.path);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -67,26 +67,17 @@
|
|||||||
|
|
||||||
this.setPageTitle(this.lang('suggestions for') + ' ' + this.$route.query.name);
|
this.setPageTitle(this.lang('suggestions for') + ' ' + this.$route.query.name);
|
||||||
|
|
||||||
http(`${config.api}/suggestions/${tmdbID}/${type}`).then(value => {
|
http(`${config.api}/suggestions/${tmdbID}/${type}`).then(response => {
|
||||||
this.items = value.data;
|
this.items = response.data;
|
||||||
this.SET_LOADING(false);
|
this.SET_LOADING(false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
initTrending() {
|
initContent(path) {
|
||||||
this.setPageTitle(this.lang('trending'));
|
this.setPageTitle(this.lang(path));
|
||||||
|
|
||||||
http(`${config.api}/trending`).then(value => {
|
http(`${config.api}/${path}`).then(response => {
|
||||||
this.items = value.data;
|
this.items = response.data;
|
||||||
this.SET_LOADING(false);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
initUpcoming() {
|
|
||||||
this.setPageTitle(this.lang('upcoming'));
|
|
||||||
|
|
||||||
http(`${config.api}/upcoming`).then(value => {
|
|
||||||
this.items = value.data;
|
|
||||||
this.SET_LOADING(false);
|
this.SET_LOADING(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
<ul class="site-nav">
|
<ul class="site-nav">
|
||||||
<li><router-link to="/trending">{{ lang('trending') }}</router-link></li>
|
<li><router-link to="/trending">{{ lang('trending') }}</router-link></li>
|
||||||
|
<li><router-link to="/current">{{ lang('current') }}</router-link></li>
|
||||||
<li><router-link to="/upcoming">{{ lang('upcoming') }}</router-link></li>
|
<li><router-link to="/upcoming">{{ lang('upcoming') }}</router-link></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ export default new Router({
|
|||||||
{ path: '/suggestions', component: TMDBContent, name: 'suggestions' },
|
{ path: '/suggestions', component: TMDBContent, name: 'suggestions' },
|
||||||
{ path: '/trending', component: TMDBContent, name: 'trending' },
|
{ path: '/trending', component: TMDBContent, name: 'trending' },
|
||||||
{ path: '/upcoming', component: TMDBContent, name: 'upcoming' },
|
{ path: '/upcoming', component: TMDBContent, name: 'upcoming' },
|
||||||
|
{ path: '/current', component: TMDBContent, name: 'current' },
|
||||||
|
|
||||||
{ path: '*', component: Content }
|
{ path: '*', component: Content }
|
||||||
]
|
]
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
"url-loader": "^0.5.7",
|
"url-loader": "^0.5.7",
|
||||||
"vue-html-loader": "^1.2.3",
|
"vue-html-loader": "^1.2.3",
|
||||||
"vue-loader": "^9.5.1",
|
"vue-loader": "^9.5.1",
|
||||||
|
"vue-loader": "^9.9.5",
|
||||||
"webpack": "^1.13.2"
|
"webpack": "^1.13.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
"trending": "الأكثر رواجا",
|
"trending": "الأكثر رواجا",
|
||||||
"upcoming": "المقبلة",
|
"upcoming": "المقبلة",
|
||||||
|
"current": "Current",
|
||||||
"tv": "تلفاز",
|
"tv": "تلفاز",
|
||||||
"movies": "أفلام",
|
"movies": "أفلام",
|
||||||
"last seen": "آخر المشاهدة",
|
"last seen": "آخر المشاهدة",
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
"trending": "Trender",
|
"trending": "Trender",
|
||||||
"upcoming": "Kommende",
|
"upcoming": "Kommende",
|
||||||
|
"current": "Current",
|
||||||
"tv": "TV",
|
"tv": "TV",
|
||||||
"movies": "Movies",
|
"movies": "Movies",
|
||||||
"last seen": "Sidst set",
|
"last seen": "Sidst set",
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
"trending": "Beliebt",
|
"trending": "Beliebt",
|
||||||
"upcoming": "Kommend",
|
"upcoming": "Kommend",
|
||||||
|
"current": "Aktuell",
|
||||||
"tv": "TV",
|
"tv": "TV",
|
||||||
"movies": "Filme",
|
"movies": "Filme",
|
||||||
"last seen": "Zuletzt gesehen",
|
"last seen": "Zuletzt gesehen",
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
"trending": "Τάσεις",
|
"trending": "Τάσεις",
|
||||||
"upcoming": "Προσεχείς",
|
"upcoming": "Προσεχείς",
|
||||||
|
"current": "Current",
|
||||||
"tv": "TV",
|
"tv": "TV",
|
||||||
"movies": "Ταινίες",
|
"movies": "Ταινίες",
|
||||||
"last seen": "Τελευταία προβολή",
|
"last seen": "Τελευταία προβολή",
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
"trending": "Trending",
|
"trending": "Trending",
|
||||||
"upcoming": "Upcoming",
|
"upcoming": "Upcoming",
|
||||||
|
"current": "Current",
|
||||||
"tv": "TV",
|
"tv": "TV",
|
||||||
"movies": "Movies",
|
"movies": "Movies",
|
||||||
"last seen": "Last seen",
|
"last seen": "Last seen",
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
"trending": "Popular",
|
"trending": "Popular",
|
||||||
"upcoming": "Próximamente",
|
"upcoming": "Próximamente",
|
||||||
|
"current": "Current",
|
||||||
"tv": "TV",
|
"tv": "TV",
|
||||||
"movies": "Películas",
|
"movies": "Películas",
|
||||||
"last seen": "Última vista",
|
"last seen": "Última vista",
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
"trending": "Tendances",
|
"trending": "Tendances",
|
||||||
"upcoming": "Prochainement",
|
"upcoming": "Prochainement",
|
||||||
|
"current": "Current",
|
||||||
"tv": "Séries TV",
|
"tv": "Séries TV",
|
||||||
"movies": "Films",
|
"movies": "Films",
|
||||||
"last seen": "Dernier film/épisode vu",
|
"last seen": "Dernier film/épisode vu",
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
"trending": "Trending",
|
"trending": "Trending",
|
||||||
"upcoming": "Aankomende",
|
"upcoming": "Aankomende",
|
||||||
|
"current": "Current",
|
||||||
"tv": "TV",
|
"tv": "TV",
|
||||||
"movies": "Films",
|
"movies": "Films",
|
||||||
"last seen": "Laatst gezien",
|
"last seen": "Laatst gezien",
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user