From d131b5934855e2d3215067c2e3ade80f097789a7 Mon Sep 17 00:00:00 2001 From: Jonathan Flueren <11487762+JonOfUs@users.noreply.github.com> Date: Wed, 6 Oct 2021 16:41:19 +0200 Subject: [PATCH] Align episode upload format to gpodder-api 'started', 'position' and 'total' are optional and 'timestamp' is in 'Y-m-d\TH:i:s' format --- lib/Controller/EpisodeActionController.php | 13 ------------- lib/Core/EpisodeAction/EpisodeActionReader.php | 7 ++++--- lib/Core/EpisodeAction/EpisodeActionSaver.php | 3 +-- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/lib/Controller/EpisodeActionController.php b/lib/Controller/EpisodeActionController.php index 8e139f1..bf638bd 100644 --- a/lib/Controller/EpisodeActionController.php +++ b/lib/Controller/EpisodeActionController.php @@ -84,17 +84,4 @@ class EpisodeActionController extends Controller { public function filterEpisodesFromRequestParams(array $data): array { return array_filter($data, "is_numeric", ARRAY_FILTER_USE_KEY); } - - /** - * @param int|null $since - * - * @return DateTime - */ - private function createDateTimeFromTimestamp(?int $since): DateTime { - return ($since !== null) - ? (new \DateTime)->setTimestamp($since) - : (new \DateTime('-1 week')); - } - - } diff --git a/lib/Core/EpisodeAction/EpisodeActionReader.php b/lib/Core/EpisodeAction/EpisodeActionReader.php index 2fb22db..40e6ce0 100644 --- a/lib/Core/EpisodeAction/EpisodeActionReader.php +++ b/lib/Core/EpisodeAction/EpisodeActionReader.php @@ -19,10 +19,11 @@ class EpisodeActionReader $episodeAction["episode"], $episodeAction["action"], $episodeAction["timestamp"], - $episodeAction["started"], - $episodeAction["position"], - $episodeAction["total"], + $episodeAction["started"] ?? -1, + $episodeAction["position"] ?? -1, + $episodeAction["total"] ?? -1, $episodeAction["guid"] ?? null, + null ); } diff --git a/lib/Core/EpisodeAction/EpisodeActionSaver.php b/lib/Core/EpisodeAction/EpisodeActionSaver.php index 482293f..1b2261b 100644 --- a/lib/Core/EpisodeAction/EpisodeActionSaver.php +++ b/lib/Core/EpisodeAction/EpisodeActionSaver.php @@ -56,8 +56,7 @@ class EpisodeActionSaver private function convertTimestampToUnixEpoch(string $timestamp): string { - return \DateTime::createFromFormat('D F d H:i:s T Y', $timestamp) - ->setTimezone(new DateTimeZone('UTC')) + return \DateTime::createFromFormat('Y-m-d\TH:i:s', $timestamp) ->format("U"); }