Skip to content

Commit eaa007d

Browse files
authored
Merge pull request #4707 from Roardom/tmdb-rate-limit-2
(Fix) Occasional tmdb ssl errors break `fetch:meta` command
2 parents d3ddaa4 + d1fe7d3 commit eaa007d

File tree

7 files changed

+27
-6
lines changed

7 files changed

+27
-6
lines changed

app/Console/Commands/FetchMeta.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,13 @@ final public function handle(): void
6868

6969
foreach ($tmdbMovieIds as $id) {
7070
usleep(250_000);
71-
ProcessMovieJob::dispatchSync($id);
72-
$this->info("Movie metadata fetched for tmdb {$id}");
71+
72+
try {
73+
ProcessMovieJob::dispatchSync($id);
74+
$this->info("Movie metadata fetched for tmdb {$id}");
75+
} catch (Exception $e) {
76+
$this->warn("Movie metadata fetch failed for tmdb {$id}: ".$e->getMessage());
77+
}
7378
}
7479

7580
$this->info('Querying all tmdb tv ids');
@@ -85,8 +90,13 @@ final public function handle(): void
8590

8691
foreach ($tmdbTvIds as $id) {
8792
usleep(250_000);
88-
ProcessTvJob::dispatchSync($id);
89-
$this->info("TV metadata fetched for tmdb {$id}");
93+
94+
try {
95+
ProcessTvJob::dispatchSync($id);
96+
$this->info("TV metadata fetched for tmdb {$id}");
97+
} catch (Exception $e) {
98+
$this->warn("TV metadata fetch failed for tmdb {$id}: ".$e->getMessage());
99+
}
90100
}
91101

92102
$this->info('Querying all igdb game ids');
@@ -102,8 +112,13 @@ final public function handle(): void
102112

103113
foreach ($igdbGameIds as $id) {
104114
usleep(250_000);
105-
ProcessIgdbGameJob::dispatchSync($id);
106-
$this->info("Game metadata fetched for igdb {$id}");
115+
116+
try {
117+
ProcessIgdbGameJob::dispatchSync($id);
118+
$this->info("Game metadata fetched for igdb {$id}");
119+
} catch (Exception $e) {
120+
$this->warn("Game metadata fetch failed for igdb {$id}: ".$e->getMessage());
121+
}
107122
}
108123

109124
$this->alert('Meta fetch queueing complete in '.now()->floatDiffInSeconds($start).'s.');

app/Services/Tmdb/Client/Collection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class Collection
5757
public function __construct(int $id)
5858
{
5959
$this->data = Http::acceptJson()
60+
->retry([1000, 5000, 15000])
6061
->withUrlParameters(['id' => $id])
6162
->get('https://api.TheMovieDB.org/3/collection/{id}', [
6263
'api_key' => config('api-keys.tmdb'),

app/Services/Tmdb/Client/Company.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function __construct(int $id)
4242
$this->tmdb = new TMDB();
4343

4444
$this->data = Http::acceptJson()
45+
->retry([1000, 5000, 15000])
4546
->withUrlParameters(['id' => $id])
4647
->get('https://api.TheMovieDB.org/3/company/{id}', [
4748
'api_key' => config('api-keys.tmdb'),

app/Services/Tmdb/Client/Movie.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ class Movie
242242
public function __construct(int $id)
243243
{
244244
$this->data = Http::acceptJson()
245+
->retry([1000, 5000, 15000])
245246
->withUrlParameters(['id' => $id])
246247
->get('https://api.TheMovieDB.org/3/movie/{id}', [
247248
'api_key' => config('api-keys.tmdb'),

app/Services/Tmdb/Client/Network.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class Network
5353
public function __construct(int $id)
5454
{
5555
$this->data = Http::acceptJson()
56+
->retry([1000, 5000, 15000])
5657
->withUrlParameters(['id' => $id])
5758
->get('https://api.TheMovieDB.org/3/network/{id}', [
5859
'api_key' => config('api-keys.tmdb'),

app/Services/Tmdb/Client/Person.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class Person
4646
public function __construct(int $id)
4747
{
4848
$this->data = Http::acceptJson()
49+
->retry([1000, 5000, 15000])
4950
->withUrlParameters(['id' => $id])
5051
->get('https://api.TheMovieDB.org/3/person/{id}', [
5152
'api_key' => config('api-keys.tmdb'),

app/Services/Tmdb/Client/TV.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ class TV
302302
public function __construct(int $id)
303303
{
304304
$this->data = Http::acceptJson()
305+
->retry([1000, 5000, 15000])
305306
->withUrlParameters(['id' => $id])
306307
->get('https://api.TheMovieDB.org/3/tv/{id}', [
307308
'api_key' => config('api-keys.tmdb'),

0 commit comments

Comments
 (0)