mirror of
https://code.castopod.org/adaures/castopod
synced 2025-06-06 18:31:05 +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 string $title
|
||||||
* @property int $audio_id
|
* @property int $audio_id
|
||||||
* @property Audio $audio
|
* @property Audio $audio
|
||||||
* @property string $audio_file_analytics_url
|
* @property string $audio_analytics_url
|
||||||
* @property string $audio_file_web_url
|
* @property string $audio_web_url
|
||||||
* @property string $audio_file_opengraph_url
|
* @property string $audio_opengraph_url
|
||||||
* @property string|null $description Holds text only description, striped of any markdown or html special characters
|
* @property string|null $description Holds text only description, striped of any markdown or html special characters
|
||||||
* @property string $description_markdown
|
* @property string $description_markdown
|
||||||
* @property string $description_html
|
* @property string $description_html
|
||||||
@ -86,8 +86,6 @@ class Episode extends Entity
|
|||||||
|
|
||||||
protected ?Audio $audio = null;
|
protected ?Audio $audio = null;
|
||||||
|
|
||||||
protected string $audio_url;
|
|
||||||
|
|
||||||
protected string $audio_analytics_url;
|
protected string $audio_analytics_url;
|
||||||
|
|
||||||
protected string $audio_web_url;
|
protected string $audio_web_url;
|
||||||
@ -328,24 +326,17 @@ class Episode extends Entity
|
|||||||
return $this->chapters;
|
return $this->chapters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAudioFileUrl(): string
|
public function getAudioAnalyticsUrl(): string
|
||||||
{
|
|
||||||
helper('media');
|
|
||||||
|
|
||||||
return media_base_url($this->audio->file_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAudioFileAnalyticsUrl(): string
|
|
||||||
{
|
{
|
||||||
helper('analytics');
|
helper('analytics');
|
||||||
|
|
||||||
// remove 'podcasts/' from audio file path
|
// 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(
|
return generate_episode_analytics_url(
|
||||||
$this->podcast_id,
|
$this->podcast_id,
|
||||||
$this->id,
|
$this->id,
|
||||||
$strippedAudioFilePath,
|
$strippedAudioPath,
|
||||||
$this->audio->duration,
|
$this->audio->duration,
|
||||||
$this->audio->file_size,
|
$this->audio->file_size,
|
||||||
$this->audio->header_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 App\Entities\Episode;
|
||||||
use CodeIgniter\Files\File;
|
|
||||||
use JamesHeinrich\GetID3\WriteTags;
|
use JamesHeinrich\GetID3\WriteTags;
|
||||||
|
|
||||||
if (! function_exists('write_audio_file_tags')) {
|
if (! function_exists('write_audio_file_tags')) {
|
||||||
|
@ -202,7 +202,7 @@ if (! function_exists('get_rss_feed')) {
|
|||||||
|
|
||||||
$enclosure->addAttribute(
|
$enclosure->addAttribute(
|
||||||
'url',
|
'url',
|
||||||
$episode->audio_file_analytics_url .
|
$episode->audio_analytics_url .
|
||||||
($serviceSlug === ''
|
($serviceSlug === ''
|
||||||
? ''
|
? ''
|
||||||
: '?_from=' . urlencode($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:width', (string) config('Images')->podcastCoverSizes['large']['width'])
|
||||||
->og('image:height', (string) config('Images')->podcastCoverSizes['large']['height'])
|
->og('image:height', (string) config('Images')->podcastCoverSizes['large']['height'])
|
||||||
->og('locale', $episode->podcast->language_code)
|
->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)
|
->og('audio:type', $episode->audio->file_mimetype)
|
||||||
->meta('article:published_time', $episode->published_at->format(DATE_ISO8601))
|
->meta('article:published_time', $episode->published_at->format(DATE_ISO8601))
|
||||||
->meta('article:modified_time', $episode->updated_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
|
* 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');
|
helper('media');
|
||||||
|
|
||||||
return media_base_url($audioFilePath);
|
return media_base_url($audioPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class EpisodeAnalyticsController extends Controller
|
|||||||
$this->config = config('Analytics');
|
$this->config = config('Analytics');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hit(string $base64EpisodeData, string ...$audioFilePath): RedirectResponse
|
public function hit(string $base64EpisodeData, string ...$audioPath): RedirectResponse
|
||||||
{
|
{
|
||||||
$session = Services::session();
|
$session = Services::session();
|
||||||
$session->start();
|
$session->start();
|
||||||
@ -77,6 +77,6 @@ class EpisodeAnalyticsController extends Controller
|
|||||||
$serviceName,
|
$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(
|
function generate_episode_analytics_url(
|
||||||
int $podcastId,
|
int $podcastId,
|
||||||
int $episodeId,
|
int $episodeId,
|
||||||
string $audioFilePath,
|
string $audioPath,
|
||||||
float $audioFileDuration,
|
float $audioDuration,
|
||||||
int $audioFileSize,
|
int $audioFileSize,
|
||||||
int $audioFileHeaderSize,
|
int $audioFileHeaderSize,
|
||||||
\CodeIgniter\I18n\Time $publicationDate
|
\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
|
// 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 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
|
// - if audio is more than 60s, then take the audio file_header_size + 60s
|
||||||
$audioFileDuration <= 60
|
$audioDuration <= 60
|
||||||
? $audioFileSize
|
? $audioFileSize
|
||||||
: $audioFileHeaderSize +
|
: $audioFileHeaderSize +
|
||||||
floor((($audioFileSize - $audioFileHeaderSize) / $audioFileDuration) * 60),
|
floor((($audioFileSize - $audioFileHeaderSize) / $audioDuration) * 60),
|
||||||
$audioFileSize,
|
$audioFileSize,
|
||||||
$audioFileDuration,
|
$audioDuration,
|
||||||
$publicationDate->getTimestamp(),
|
$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;' : '' ?>"
|
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">
|
<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'])
|
(isset($_SERVER['HTTP_REFERER'])
|
||||||
? '?_from=' .
|
? '?_from=' .
|
||||||
parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST)
|
parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST)
|
||||||
|
@ -114,7 +114,7 @@
|
|||||||
imageSrc="<?= $episode->cover->thumbnail_url ?>"
|
imageSrc="<?= $episode->cover->thumbnail_url ?>"
|
||||||
title="<?= $episode->title ?>"
|
title="<?= $episode->title ?>"
|
||||||
podcast="<?= $episode->podcast->title ?>"
|
podcast="<?= $episode->podcast->title ?>"
|
||||||
src="<?= $episode->audio_file_web_url ?>"
|
src="<?= $episode->audio_web_url ?>"
|
||||||
mediaType="<?= $episode->audio->file_mimetype ?>"
|
mediaType="<?= $episode->audio->file_mimetype ?>"
|
||||||
playLabel="<?= lang('Common.play_episode_button.play') ?>"
|
playLabel="<?= lang('Common.play_episode_button.play') ?>"
|
||||||
playingLabel="<?= lang('Common.play_episode_button.playing') ?>"></play-episode-button>
|
playingLabel="<?= lang('Common.play_episode_button.playing') ?>"></play-episode-button>
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
imageSrc="<?= $episode->cover->thumbnail_url ?>"
|
imageSrc="<?= $episode->cover->thumbnail_url ?>"
|
||||||
title="<?= $episode->title ?>"
|
title="<?= $episode->title ?>"
|
||||||
podcast="<?= $episode->podcast->title ?>"
|
podcast="<?= $episode->podcast->title ?>"
|
||||||
src="<?= $episode->audio_file_web_url ?>"
|
src="<?= $episode->audio_web_url ?>"
|
||||||
mediaType="<?= $episode->audio->file_mimetype ?>"
|
mediaType="<?= $episode->audio->file_mimetype ?>"
|
||||||
playLabel="<?= lang('Common.play_episode_button.play') ?>"
|
playLabel="<?= lang('Common.play_episode_button.play') ?>"
|
||||||
playingLabel="<?= lang('Common.play_episode_button.playing') ?>"></play-episode-button>
|
playingLabel="<?= lang('Common.play_episode_button.playing') ?>"></play-episode-button>
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
imageSrc="<?= $episode->cover->thumbnail_url ?>"
|
imageSrc="<?= $episode->cover->thumbnail_url ?>"
|
||||||
title="<?= $episode->title ?>"
|
title="<?= $episode->title ?>"
|
||||||
podcast="<?= $episode->podcast->title ?>"
|
podcast="<?= $episode->podcast->title ?>"
|
||||||
src="<?= $episode->audio_file_web_url ?>"
|
src="<?= $episode->audio_web_url ?>"
|
||||||
mediaType="<?= $episode->audio->file_mimetype ?>"
|
mediaType="<?= $episode->audio->file_mimetype ?>"
|
||||||
playLabel="<?= lang('Common.play_episode_button.play') ?>"
|
playLabel="<?= lang('Common.play_episode_button.play') ?>"
|
||||||
playingLabel="<?= lang('Common.play_episode_button.playing') ?>"></play-episode-button>
|
playingLabel="<?= lang('Common.play_episode_button.playing') ?>"></play-episode-button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user