Skip to content

Instantly share code, notes, and snippets.

@ameliaikeda
Created September 12, 2014 02:41
Show Gist options
  • Save ameliaikeda/184c87fb945b36b66d0c to your computer and use it in GitHub Desktop.
Save ameliaikeda/184c87fb945b36b66d0c to your computer and use it in GitHub Desktop.
For being such a messy library, this is actually quite clean...
<?php
use GetId3\Write\Id3v2 as TagWriter;
trait TagTrait {
public function writeTags(Track $song = null) {
if (is_null($song)) $song = $this;
$writer = new TagWriter;
$writer->majorversion = 4; // write ID3v2.4 tags
$writer->filename = $song->file_path;
$writer->tag_data = [
"title" => $song->title,
"artist" => $song->artist,
"album" => $song->album,
"internet_radio_station_name" => "R/a/dio <https://r-a-d.io>",
"internet_radio_station_owner" => "R/a/dio <[email protected]>",
"tracknumber" => $song->id,
"comment" => $song->tags,
];
return $writer->WriteID3v2();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment