mirror of
https://code.castopod.org/adaures/castopod
synced 2025-04-19 13:01:19 +00:00
refactor: rename audio_file urls to audio urls
This commit is contained in:
parent
e97266c5d4
commit
c1581c1fd4
@ -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+-';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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')) {
|
||||
|
@ -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)),
|
||||
|
@ -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))
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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]));
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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; <?= str_ends_with($theme, 'transparent') ? '--vm-controls-bg: transparent;' : '' ?>"
|
||||
>
|
||||
<vm-audio preload="none">
|
||||
<?php $source = logged_in() ? $episode->audio->file_url : $episode->audio_file_analytics_url .
|
||||
<?php $source = logged_in() ? $episode->audio->file_url : $episode->audio_analytics_url .
|
||||
(isset($_SERVER['HTTP_REFERER'])
|
||||
? '?_from=' .
|
||||
parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST)
|
||||
|
@ -114,7 +114,7 @@
|
||||
imageSrc="<?= $episode->cover->thumbnail_url ?>"
|
||||
title="<?= $episode->title ?>"
|
||||
podcast="<?= $episode->podcast->title ?>"
|
||||
src="<?= $episode->audio_file_web_url ?>"
|
||||
src="<?= $episode->audio_web_url ?>"
|
||||
mediaType="<?= $episode->audio->file_mimetype ?>"
|
||||
playLabel="<?= lang('Common.play_episode_button.play') ?>"
|
||||
playingLabel="<?= lang('Common.play_episode_button.playing') ?>"></play-episode-button>
|
||||
|
@ -19,7 +19,7 @@
|
||||
imageSrc="<?= $episode->cover->thumbnail_url ?>"
|
||||
title="<?= $episode->title ?>"
|
||||
podcast="<?= $episode->podcast->title ?>"
|
||||
src="<?= $episode->audio_file_web_url ?>"
|
||||
src="<?= $episode->audio_web_url ?>"
|
||||
mediaType="<?= $episode->audio->file_mimetype ?>"
|
||||
playLabel="<?= lang('Common.play_episode_button.play') ?>"
|
||||
playingLabel="<?= lang('Common.play_episode_button.playing') ?>"></play-episode-button>
|
||||
|
@ -20,7 +20,7 @@
|
||||
imageSrc="<?= $episode->cover->thumbnail_url ?>"
|
||||
title="<?= $episode->title ?>"
|
||||
podcast="<?= $episode->podcast->title ?>"
|
||||
src="<?= $episode->audio_file_web_url ?>"
|
||||
src="<?= $episode->audio_web_url ?>"
|
||||
mediaType="<?= $episode->audio->file_mimetype ?>"
|
||||
playLabel="<?= lang('Common.play_episode_button.play') ?>"
|
||||
playingLabel="<?= lang('Common.play_episode_button.playing') ?>"></play-episode-button>
|
||||
|
Loading…
x
Reference in New Issue
Block a user