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