Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if defined? VagrantPlugins::HostsUpdater
config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
end

config.vm.provision 'ffmpeg', type: 'shell', inline: 'apt install -y ffmpeg'
end
9 changes: 8 additions & 1 deletion app/SongComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,16 @@ protected function createOrUpdate(array $metadata, string $file): array
Storage::disk()->makeDirectory('public/songs/' . $song->id);
}

// Store song image.
File::move($file, storage_path('app/public/songs') . "/{$song->id}/{$song->id}-{$songDetails->id}.zip");
Storage::disk()->put("public/songs/{$song->id}/{$song->id}-{$songDetails->id}.{$songData['coverType']}", base64_decode($songData['coverData']));

// Convert for preview.
Storage::disk()->put("public/songs/{$song->id}/tempPreview", base64_decode($songData['songPreviewData']));
$previewTempPath = storage_path("app/public/songs/{$song->id}/tempPreview");
$previewOutPath = storage_path("app/public/songs/{$song->id}/preview.mp3");
exec("(ffmpeg -i {$previewTempPath} {$previewOutPath}; rm ${previewTempPath}) > /dev/null &");

return [
'status' => static::SONG_CREATED,
'key' => $song->id . '-' . $songDetails->id,
Expand Down Expand Up @@ -448,4 +455,4 @@ protected function updateCache(array $song)
}
}

}
}
8 changes: 7 additions & 1 deletion app/UploadParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,15 @@ function map($v)
}

$hashBase = '';
$hasSongPreviewData = false;
foreach ($info['difficultyLevels'] as $difficultyLevel) {

if ($this->zipHasFile($difficultyLevel['audioPath']) && $this->zipHasFile($difficultyLevel['jsonPath'])) {
if (!$hasSongPreviewData) {
$songData['songPreviewData'] = base64_encode($this->readFromZip($difficultyLevel['audioPath']));
$hasSongPreviewData = true;
}

$songData['difficultyLevels'][$difficultyLevel['difficulty']] = [
'difficulty' => $difficultyLevel['difficulty'],
'rank' => $difficultyLevel['difficultyRank'],
Expand Down Expand Up @@ -290,4 +296,4 @@ protected function closeZip()
$this->zipFile = null;
}
}
}
}