2017 © Pedro PelĂĄez
 

library metadata

Metadata library for PHP

image

gravitymedia/metadata

Metadata library for PHP

  • Tuesday, July 12, 2016
  • by pCoLaSD
  • Repository
  • 2 Watchers
  • 2 Stars
  • 39 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Metadata

Metadata library for PHP, (*1)

Packagist Downloads License Build Code Quality Coverage PHP Dependencies, (*2)

Requirements

This library has the following requirements:, (*3)

  • PHP 5.4+

Installation

Install composer in your project:, (*4)

$ curl -s https://getcomposer.org/installer | php

Create a composer.json file in your project root:, (*5)

{
    "require": {
        "gravitymedia/metadata": "dev-master"
    }
}

Install via composer:, (*6)

$ php composer.phar install

Usage

Currently reading and writing of ID3 (v1 and v2) metadata is supported. The support for more metadata formats will be available soon., (*7)

CLI

This library contains a useful CLI script. You may export and import the metadata to/from YAML files. More export/import formats will be available soon., (*8)

ID3 v1

require 'vendor/autoload.php';

use GravityMedia\Metadata\SplFileInfo;

// create new metadata aware file info object
$file = new SplFileInfo('/path/to/input/file.mp3');

// get ID3 v1 metadata
$metadata = $file->getMetadata();
$tag = $metadata->getId3v1Tag();

// dump tag info
var_dump($tag);

// update ID3 v1 metadata
$tag
    ->setTitle('New title')
    ->setArtist('An other artist')
    ->setAlbum('The album title')
    ->setYear(2014)
    ->setComment('This tag was written by metadata library')
    ->setTrack(1)
    ->save();

// dump updated tag info
var_dump($metadata->getId3v1Tag());

// remove ID3 v1 metadata
$tag->remove();

ID3 v2

require 'vendor/autoload.php';

use GravityMedia\Metadata\SplFileInfo;

// create new metadata aware file info object
$file = new SplFileInfo('/path/to/input/file.mp3');

// get ID3 v2 metadata
$metadata = $file->getMetadata();
$tag = $metadata->getId3v2Tag();

// dump tag info
var_dump($tag);

// update ID3 v2 metadata
$tag
    ->setTitle('New title')
    ->setArtist('An other artist')
    ->setAlbum('The album title')
    ->setYear(2014)
    ->setComment('This tag was written by metadata library')
    ->setTrack(1)
    ->save();

// dump updated tag info
var_dump($metadata->getId3v2Tag());

// remove ID3 v2 metadata
$tag->remove();

The Versions