miqwit / dedex

A generic efficient DDEX parser. Parse seemlessly the complex DDEX format and transform it into classes easily useable in your PHP project. Supports several versions (3.8.2, 4.1, 4.1.1) and is listed in the official DDEX page: https://kb.ddex.net/display/HBK/Open+Source+Software
MIT License
23 stars 11 forks source link

Uncaught Error: Call to undefined method DedexBundle\Simplifiers\SimpleAlbum::getTracks() #11

Closed nleonar25 closed 2 years ago

nleonar25 commented 2 years ago

Hello, When I use the following code example, I get the Uncaught Error: Call to undefined method DedexBundle\Simplifiers\SimpleAlbum::getTracks()

use DedexBundle\Controller\ErnParserController;
use DedexBundle\Simplifiers\SimpleAlbum;

$xml_path = "tests/samples/with_assets/004_complete/1199119911991.xml";
$parser = new ErnParserController();
$ern = $parser->parse($xml_path);
$album = new SimpleAlbum($ern);

// Then you can access high level property of this album
$release_date = $album->getOriginalReleaseDate();
$artists_at_album_level = $album->getArtists();
$tracks_for_cd_1 = $album->getTracks()[1];

I checked SimpleAlbum class/file, there is no getTracks() method

Thanks

miqwit commented 2 years ago

Will check that soon @nleonar25. Thank you for your interest.

miqwit commented 2 years ago

Hello @nleonar25. I just pushed a fix on master that updates the documentation. The getTracks method has been replaced with getTracksPerCd but I forgot to update the documentation.

Working sample is:

use DedexBundle\Controller\ErnParserController;
use DedexBundle\Simplifiers\SimpleAlbum;

$xml_path = "tests/samples/with_assets/004_complete/1199119911991.xml";
$parser = new ErnParserController();
$ern = $parser->parse($xml_path);
$album = new SimpleAlbum($ern);

// Then you can access high level property of this album
$release_date = $album->getOriginalReleaseDate();
$artists_at_album_level = $album->getArtists();
$tracks_for_cd_1 = $album->getTracksPerCd()[1];

// You can also access exact XML mapping by getting 
// ddex objects at album or track level
$ddex_release = $album->getDdexRelease();
$ddex_release->getReleaseId()[0]->getICPN()->value(); // direct access
$ddex_track = $tracks_for_cd_1[1]->getDdexSoundRecording()->getDuration(); // direct access
nleonar25 commented 2 years ago

Thank you for the update and thank you for putting this library together. It has saved me so much time.

On Sat, Apr 9, 2022, 4:11 AM Mickaël A. @.***> wrote:

Hello @nleonar25 https://github.com/nleonar25. I just pushed a fix on master that updates the documentation. The getTracks method has been replaced with getTracksPerCd but I forgot to update the documentation.

Working sample is:

use DedexBundle\Controller\ErnParserController;use DedexBundle\Simplifiers\SimpleAlbum; $xml_path = "tests/samples/with_assets/004_complete/1199119911991.xml";$parser = new ErnParserController();$ern = $parser->parse($xml_path);$album = new SimpleAlbum($ern); // Then you can access high level property of this album$release_date = $album->getOriginalReleaseDate();$artists_at_album_level = $album->getArtists();$tracks_for_cd_1 = $album->getTracksPerCd()[1]; // You can also access exact XML mapping by getting // ddex objects at album or track level$ddex_release = $album->getDdexRelease();$ddex_release->getReleaseId()[0]->getICPN()->value(); // direct access$ddex_track = $tracks_for_cd_1[1]->getDdexSoundRecording()->getDuration(); // direct access

— Reply to this email directly, view it on GitHub https://github.com/miqwit/dedex/issues/11#issuecomment-1093834642, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYLUIFOY33MFVNL6S36MOW3VEFCTZANCNFSM5RMB2S5A . You are receiving this because you were mentioned.Message ID: @.***>