Skip to content

Commit

Permalink
Add runtime to API
Browse files Browse the repository at this point in the history
  • Loading branch information
PCJones committed Nov 11, 2024
1 parent 72b745f commit 5aa6cd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/v1/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function createTables($db) {
series_id INTEGER,
name TEXT,
aired TEXT,
runtime INTEGER,
season_number INTEGER,
episode_number INTEGER,
FOREIGN KEY(series_id) REFERENCES series_cache(series_id)
Expand Down
5 changes: 4 additions & 1 deletion api/v1/get_show.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function getSeriesData($db, $tvdbId, $apiKey, $debug = false) {
return [
"name" => $episode['name'],
"aired" => $episode['aired'],
"runtime" => $episode['runtime'],
"seasonNumber" => $episode['season_number'],
"episodeNumber" => $episode['episode_number'],
];
Expand Down Expand Up @@ -157,13 +158,14 @@ function fetchAndCacheSeriesData($db, $tvdbId, $apiKey, $debug = false) {
]);

$db->exec("DELETE FROM episodes WHERE series_id = $tvdbId");
$episodesStmt = $db->prepare("INSERT INTO episodes (id, series_id, name, aired, season_number, episode_number) VALUES (:id, :tvdb_id, :name, :aired, :season_number, :episode_number)");
$episodesStmt = $db->prepare("INSERT INTO episodes (id, series_id, name, aired, runtime, season_number, episode_number) VALUES (:id, :tvdb_id, :name, :aired, :runtime, :season_number, :episode_number)");
foreach ($series['episodes'] as $episode) {
$episodesStmt->execute([
'id' => $episode['id'],
'tvdb_id' => $tvdbId,
'name' => $episode['name'],
'aired' => $episode['aired'],
'runtime' => $episode['runtime'],
'season_number' => $episode['seasonNumber'],
'episode_number' => $episode['number']
]);
Expand All @@ -181,6 +183,7 @@ function fetchAndCacheSeriesData($db, $tvdbId, $apiKey, $debug = false) {
return [
"name" => $episode['name'],
"aired" => $episode['aired'],
"runtime" => $episode['runtime'],
"seasonNumber" => $episode['seasonNumber'],
"episodeNumber" => $episode['number'],
];
Expand Down

0 comments on commit 5aa6cd2

Please sign in to comment.