Skip to content
Permalink
Browse files

Handle TMDB 503 error response

  • Loading branch information...
SeinopSys committed Aug 14, 2019
1 parent c467544 commit 85c09dcd8844f4219cfe720e190bd1ee3038609b
@@ -180,7 +180,7 @@ function queryPublic() {
Response::fail('ELASTIC_DOWN');
}
if (isset($_GET['size']) && is_numeric($_GET['size']))
$appearances_per_page = CoreUtils::rangeLimit(intval($_GET['size'], 10), 7, 20);
$appearances_per_page = CoreUtils::rangeLimit(\intval($_GET['size'], 10), 7, 20);
else $appearances_per_page = 7;
$pagination = new Pagination('', $appearances_per_page);
$searching = !empty($_GET['q']) && $_GET['q'] !== '';
@@ -2,32 +2,31 @@
namespace App\Controllers;
use ActiveRecord\Cache;
use ActiveRecord\Table;
use App\Auth;
use App\CGUtils;
use App\CoreUtils;
use App\CSRFProtection;
use App\DB;
use App\DeviantArt;
use App\Models\ShowAppearance;
use App\ShowHelper;
use App\HTTP;
use App\Input;
use App\Logs;
use App\Models\Appearance;
use App\Models\Show;
use App\Models\ShowAppearance;
use App\Models\ShowVideo;
use App\Models\ShowVote;
use App\Pagination;
use App\Permission;
use App\Posts;
use App\Regexes;
use App\Response;
use App\ShowHelper;
use App\Time;
use App\TMDBHelper;
use App\Twig;
use App\VideoProvider;
use App\Models\Show;
use App\Models\ShowVideo;
use GuzzleHttp\Exception\ServerException;
class ShowController extends Controller {
public function index(){
@@ -308,7 +307,7 @@ public function voteApi($params):void {
$table = ShowVote::$table_name;
$vote_count_query = DB::$instance->query(
"SELECT count(*) as value, vote as label FROM $table WHERE show_id = ? GROUP BY vote ORDER BY vote ASC", [$this->show->id]);
"SELECT count(*) as value, vote as label FROM $table WHERE show_id = ? GROUP BY vote ORDER BY vote", [$this->show->id]);
$vote_counts = [];
foreach ($vote_count_query as $row)
$vote_counts[$row['label']] = $row['value'];
@@ -540,9 +539,20 @@ public function brokenVideos($params):void {
public function synopsis($params) {
$this->load_show($params);
try {
$synopses = $this->show->getSynopses();
}
catch (\Throwable $exception){
$message = $exception->getMessage();
if (strpos($message, '503 Service Temporarily Unavailable') !== false) {
Response::fail('The TMDB API is experiencing a temporary outage, synopsis data is currently unavailable.');
}
}
Response::done([
'html' => Twig::$env->render('show/_synopsis.html.twig', [
'current_episode' => $this->show,
'synopses' => $synopses,
'wrap' => false,
'lazyload' => false,
'signed_in' => Auth::$signed_in,
@@ -840,12 +840,6 @@
this.updateTabs();
ColorPicker.getInstance().updatePickingState();
}
closeActiveTabConfirm(){
if (!(this._activeTab instanceof Tab))
return;

this._activeTab.getElement().find('.close').trigger('click');
}
}

const $LevelsChangeForm = $.mk('form','levels-changer').append(
@@ -513,9 +513,14 @@
const { id } = el.dataset;

$.API.get(`/show/${id}/synopsis`,$.mkAjaxHandler(function(){
const $section = $(el).closest('section');
const $el = $(el);
const $section = $el.closest('section');
if (!this.status){
$section.remove();
if (this.message)
$el.replaceWith(
$.mk('div').addClass('notice warn').text(this.message)
);
else $section.remove();
return;
}

@@ -13,7 +13,9 @@
{% if lazyload is not defined or lazyload == true %}
<div class="synopsis-promise{% if current_episode.twoparter %} twoparter{% endif %}" data-id="{{ current_episode.id }}"></div>
{% else %}
{% set synopses = current_episode.synopses %}
{% if synopses is not defined %}
{% set synopses = current_episode.synopses %}
{% endif %}
{% if synopses is not empty %}
{% for i, synopsis in synopses %}
{% set has_image = synopsis.image is defined and synopsis.image %}

0 comments on commit 85c09dc

Please sign in to comment.
You can’t perform that action at this time.