getID3
getID3 copied to clipboard
Tag format "id3v2.3" is not allowed on "" files,
trafficstars
The issue here is the error just gives me empty quotes... is there something wrong with my implementation ?
` public function writeMetadata($token) {
require_once base_path('vendor/james-heinrich/getid3/getid3/getid3.php');
$track = Track::where('token', $token)->first();
$content = Storage::disk('s3')->get($track->key);
$tempPath = storage_path('tempfile.mp3');
if ($content === false) {
// Handle error; file download failed
Log::error("Failed to download the file");
return;
}
file_put_contents($tempPath, $content);
$tagwriter = new getid3_writetags;
$tagwriter->filename = $tempPath;
$tagwriter->tagformats = array('id3v2.3');
$TagData = [
'title' => ["The mofo title"],
'artist' => ["Yaldi crew"],
'album' => ["yeer maw's got a boaby"],
'year' => ["1994"],
'genre' => ["grunge pop"],
'composer' => ["yer da"],
// Add more fields as needed
];
$tagwriter->tag_data = $TagData;
// Write tags
if (!$tagwriter->WriteTags()) {
if (is_array($tagwriter->errors)) {
// If errors are in an array, use implode to convert them to a string
echo("Failed to write tags for track {$token}: ".implode(", ", $tagwriter->errors));
} else {
// If it's not an array, log it directly. Might need to convert to string if it's not
echo("Failed to write tags for track {$token}: ".$tagwriter->errors);
}
} else {
echo("wrote tags");
}
Storage::disk('s3')->put($track->key, file_get_contents($tempPath));
// Clean up the temporary file
try {
unlink($tempPath);
} catch (\Exception $e) {
Log::error("Failed to delete the temporary file: ".$e->getMessage());
}
}
`