diff --git a/app/Entities/Episode.php b/app/Entities/Episode.php index 80286775..1b1c0e0f 100644 --- a/app/Entities/Episode.php +++ b/app/Entities/Episode.php @@ -39,9 +39,9 @@ use RuntimeException; * @property string $title * @property int $audio_id * @property Audio $audio - * @property string $audio_file_analytics_url - * @property string $audio_file_web_url - * @property string $audio_file_opengraph_url + * @property string $audio_analytics_url + * @property string $audio_web_url + * @property string $audio_opengraph_url * @property string|null $description Holds text only description, striped of any markdown or html special characters * @property string $description_markdown * @property string $description_html @@ -86,8 +86,6 @@ class Episode extends Entity protected ?Audio $audio = null; - protected string $audio_url; - protected string $audio_analytics_url; protected string $audio_web_url; @@ -328,24 +326,17 @@ class Episode extends Entity return $this->chapters; } - public function getAudioFileUrl(): string - { - helper('media'); - - return media_base_url($this->audio->file_path); - } - - public function getAudioFileAnalyticsUrl(): string + public function getAudioAnalyticsUrl(): string { helper('analytics'); // remove 'podcasts/' from audio file path - $strippedAudioFilePath = substr($this->getAudio()->file_path, 9); + $strippedAudioPath = substr($this->getAudio()->file_path, 9); return generate_episode_analytics_url( $this->podcast_id, $this->id, - $strippedAudioFilePath, + $strippedAudioPath, $this->audio->duration, $this->audio->file_size, $this->audio->header_size, @@ -353,14 +344,14 @@ class Episode extends Entity ); } - public function getAudioFileWebUrl(): string + public function getAudioWebUrl(): string { - return $this->getAudioFileAnalyticsUrl() . '?_from=-+Website+-'; + return $this->getAudioAnalyticsUrl() . '?_from=-+Website+-'; } - public function getAudioFileOpengraphUrl(): string + public function getAudioOpengraphUrl(): string { - return $this->getAudioFileAnalyticsUrl() . '?_from=-+Open+Graph+-'; + return $this->getAudioAnalyticsUrl() . '?_from=-+Open+Graph+-'; } /** diff --git a/app/Helpers/id3_helper.php b/app/Helpers/id3_helper.php index be6ae69f..8b36879f 100644 --- a/app/Helpers/id3_helper.php +++ b/app/Helpers/id3_helper.php @@ -9,7 +9,6 @@ declare(strict_types=1); */ use App\Entities\Episode; -use CodeIgniter\Files\File; use JamesHeinrich\GetID3\WriteTags; if (! function_exists('write_audio_file_tags')) { diff --git a/app/Helpers/rss_helper.php b/app/Helpers/rss_helper.php index 1a85bb7f..d26cf756 100644 --- a/app/Helpers/rss_helper.php +++ b/app/Helpers/rss_helper.php @@ -202,7 +202,7 @@ if (! function_exists('get_rss_feed')) { $enclosure->addAttribute( 'url', - $episode->audio_file_analytics_url . + $episode->audio_analytics_url . ($serviceSlug === '' ? '' : '?_from=' . urlencode($serviceSlug)), diff --git a/app/Helpers/seo_helper.php b/app/Helpers/seo_helper.php index ea6f4993..33e4c2ff 100644 --- a/app/Helpers/seo_helper.php +++ b/app/Helpers/seo_helper.php @@ -104,7 +104,7 @@ if (! function_exists('get_episode_metatags')) { ->og('image:width', (string) config('Images')->podcastCoverSizes['large']['width']) ->og('image:height', (string) config('Images')->podcastCoverSizes['large']['height']) ->og('locale', $episode->podcast->language_code) - ->og('audio', $episode->audio_file_opengraph_url) + ->og('audio', $episode->audio_opengraph_url) ->og('audio:type', $episode->audio->file_mimetype) ->meta('article:published_time', $episode->published_at->format(DATE_ISO8601)) ->meta('article:modified_time', $episode->updated_at->format(DATE_ISO8601)) diff --git a/modules/Analytics/Config/Analytics.php b/modules/Analytics/Config/Analytics.php index b4ffd795..578d8262 100644 --- a/modules/Analytics/Config/Analytics.php +++ b/modules/Analytics/Config/Analytics.php @@ -28,12 +28,12 @@ class Analytics extends BaseConfig /** * get the full audio file url * - * @param string|string[] $audioFilePath + * @param string|string[] $audioPath */ - public function getAudioFileUrl(string | array $audioFilePath): string + public function getAudioUrl(string | array $audioPath): string { helper('media'); - return media_base_url($audioFilePath); + return media_base_url($audioPath); } } diff --git a/modules/Analytics/Controllers/EpisodeAnalyticsController.php b/modules/Analytics/Controllers/EpisodeAnalyticsController.php index 167c5d84..3a97bd82 100644 --- a/modules/Analytics/Controllers/EpisodeAnalyticsController.php +++ b/modules/Analytics/Controllers/EpisodeAnalyticsController.php @@ -48,7 +48,7 @@ class EpisodeAnalyticsController extends Controller $this->config = config('Analytics'); } - public function hit(string $base64EpisodeData, string ...$audioFilePath): RedirectResponse + public function hit(string $base64EpisodeData, string ...$audioPath): RedirectResponse { $session = Services::session(); $session->start(); @@ -77,6 +77,6 @@ class EpisodeAnalyticsController extends Controller $serviceName, ); - return redirect()->to($this->config->getAudioFileUrl(['podcasts', ...$audioFilePath])); + return redirect()->to($this->config->getAudioUrl(['podcasts', ...$audioPath])); } } diff --git a/modules/Analytics/Helpers/analytics_helper.php b/modules/Analytics/Helpers/analytics_helper.php index 026e6554..d6433d87 100644 --- a/modules/Analytics/Helpers/analytics_helper.php +++ b/modules/Analytics/Helpers/analytics_helper.php @@ -45,8 +45,8 @@ if (! function_exists('generate_episode_analytics_url')) { function generate_episode_analytics_url( int $podcastId, int $episodeId, - string $audioFilePath, - float $audioFileDuration, + string $audioPath, + float $audioDuration, int $audioFileSize, int $audioFileHeaderSize, \CodeIgniter\I18n\Time $publicationDate @@ -61,16 +61,16 @@ if (! function_exists('generate_episode_analytics_url')) { // bytes_threshold: number of bytes that must be downloaded for an episode to be counted in download analytics // - if audio is less than or equal to 60s, then take the audio file_size // - if audio is more than 60s, then take the audio file_header_size + 60s - $audioFileDuration <= 60 + $audioDuration <= 60 ? $audioFileSize : $audioFileHeaderSize + - floor((($audioFileSize - $audioFileHeaderSize) / $audioFileDuration) * 60), + floor((($audioFileSize - $audioFileHeaderSize) / $audioDuration) * 60), $audioFileSize, - $audioFileDuration, + $audioDuration, $publicationDate->getTimestamp(), ), ), - $audioFilePath, + $audioPath, ); } } diff --git a/themes/cp_app/embed.php b/themes/cp_app/embed.php index fcc375d2..7a3e3836 100644 --- a/themes/cp_app/embed.php +++ b/themes/cp_app/embed.php @@ -41,7 +41,7 @@ style="--vm-player-box-shadow:0; --vm-player-theme: hsl(var(--color-accent-base)); --vm-control-focus-color: hsl(var(--color-accent-contrast)); --vm-control-spacing: 4px; --vm-menu-item-focus-bg: hsl(var(--color-background-highlight)); --vm-control-icon-size: 24px; " > - audio->file_url : $episode->audio_file_analytics_url . + audio->file_url : $episode->audio_analytics_url . (isset($_SERVER['HTTP_REFERER']) ? '?_from=' . parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST) diff --git a/themes/cp_app/episode/_layout.php b/themes/cp_app/episode/_layout.php index 631082e6..0f81cd59 100644 --- a/themes/cp_app/episode/_layout.php +++ b/themes/cp_app/episode/_layout.php @@ -114,7 +114,7 @@ imageSrc="cover->thumbnail_url ?>" title="title ?>" podcast="podcast->title ?>" - src="audio_file_web_url ?>" + src="audio_web_url ?>" mediaType="audio->file_mimetype ?>" playLabel="" playingLabel=""> diff --git a/themes/cp_app/episode/_partials/card.php b/themes/cp_app/episode/_partials/card.php index 3b29f8ec..f024d232 100644 --- a/themes/cp_app/episode/_partials/card.php +++ b/themes/cp_app/episode/_partials/card.php @@ -19,7 +19,7 @@ imageSrc="cover->thumbnail_url ?>" title="title ?>" podcast="podcast->title ?>" - src="audio_file_web_url ?>" + src="audio_web_url ?>" mediaType="audio->file_mimetype ?>" playLabel="" playingLabel=""> diff --git a/themes/cp_app/episode/_partials/preview_card.php b/themes/cp_app/episode/_partials/preview_card.php index 9e69012d..bba7ab1b 100644 --- a/themes/cp_app/episode/_partials/preview_card.php +++ b/themes/cp_app/episode/_partials/preview_card.php @@ -20,7 +20,7 @@ imageSrc="cover->thumbnail_url ?>" title="title ?>" podcast="podcast->title ?>" - src="audio_file_web_url ?>" + src="audio_web_url ?>" mediaType="audio->file_mimetype ?>" playLabel="" playingLabel="">