Skip to content

Commit

Permalink
fix: fixed replace option not working properly (#767)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrch authored Dec 12, 2024
1 parent d343094 commit af1d86f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions app/Actions/Models/Wiki/Video/Audio/BackfillAudioAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ protected function replaceRelatedAudio(): bool
protected function getAudio(): ?Audio
{
// Allow bypassing of source video derivation
$sourceVideo = $this->deriveSourceVideo()
? $this->getSourceVideo($this->replaceRelatedAudio() ? '<' : '>')
: $this->getModel();
if ($this->replaceRelatedAudio()) {
$sourceVideo = $this->getSourceVideo('<');
} elseif ($this->deriveSourceVideo()) {
$sourceVideo = $this->getSourceVideo();
} else {
$sourceVideo = $this->getModel();
}

// It's possible that the video is not attached to any themes, exit early.
if ($sourceVideo === null) {
Expand All @@ -177,7 +181,7 @@ protected function getAudio(): ?Audio
// When uploading a BD version we should get the parent audio of a WEB version and
// move the file overwriting the content later. Therefore, the old model is not deleted.
if ($this->replaceRelatedAudio() && $audio instanceof Audio) {
$moveAction = new MoveAudioAction($audio, $this->getModel()->path());
$moveAction = new MoveAudioAction($audio, Str::replace('webm', 'ogg', $this->getModel()->path()));

$storageResults = $moveAction->handle();

Expand All @@ -196,7 +200,10 @@ protected function getAudio(): ?Audio

// Finally, extract audio from the source video
if ($audio === null || $this->overwriteAudio() || $this->replaceRelatedAudio()) {
Log::info("Extracting Audio from Video '{$sourceVideo->getName()}'");

if ($this->replaceRelatedAudio()) {
$sourceVideo = $this->getModel();
}

return $this->extractAudio($sourceVideo);
}
Expand Down

0 comments on commit af1d86f

Please sign in to comment.