Giter Site home page Giter Site logo

kiwilan / php-audio Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 0.0 12.59 MB

PHP package to parse and update audio files metadata, with JamesHeinrich/getID3.

License: MIT License

PHP 98.83% Shell 1.17%
audio audiobook id3 id3v1 id3v2 mp3 php flac m4b mkv

php-audio's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

php-audio's Issues

[Bug]: Call to a member function comment() on null

What happened?

It seems that when an .mp3 file only has ID3v2 information and no v1, the following error is generated:

[30-Oct-2023 21:08:56 UTC] PHP Fatal error:  Uncaught Error: Call to a member function comment() on null in site\vendor\kiwilan\php-audio\src\Models\AudioCore.php:430
Stack trace:
#0 sitet\vendor\kiwilan\php-audio\src\Audio.php(395): Kiwilan\Audio\Models\AudioCore::fromId3(NULL, Object(Kiwilan\Audio\Models\Id3AudioTagV2))
#1 site\vendor\kiwilan\php-audio\src\Audio.php(98): Kiwilan\Audio\Audio->parse()
#2 site\upload.php(112): Kiwilan\Audio\Audio::get('site/...')
#3 site\upload.php(407): newMetadata('site/...', 'Miss K8 - Infin...')
#4 {main}
  thrown in site\vendor\kiwilan\php-audio\src\Models\AudioCore.php on line 430

The relevant line is:

comment: $v2->comment() ?? $v1->comment(),

In this case, the function is being called as: fromId3(NULL, Object). Replacing the line with: comment: $v2 ? $v2->comment() : $v1->comment(), works.

How to reproduce the bug

For now I think it happens when a .mp3 file only has only ID3v2 information and no v1.

Package Version

3.0.02

PHP Version

8.2.11

Which operating systems does with happen with?

Windows

Notes

Really nice work, thank you!

[Bug]: Call to a member function format() on false in AudioCore.php:543

What happened?

When trying to parse a specific date I get an error.

[2024-06-03 05:51:03] production.ERROR: Call to a member function format() on false {"exception":"[object] (Error(code: 0): Call to a member function format() on false at /app/vendor/kiwilan/php-audio/src/Models/AudioCore.php:543)
[stacktrace]
#0 /app/vendor/kiwilan/php-audio/src/Audio.php(420): Kiwilan\\Audio\\Models\\AudioCore::fromQuicktime()
#1 /app/vendor/kiwilan/php-audio/src/Audio.php(102): Kiwilan\\Audio\\Audio->parse()

How to reproduce the bug

Try a date that doesn't match the format specified in https://github.com/kiwilan/php-audio/blob/main/src/Models/AudioCore.php#L543

I get this with dates that don't include time like 2024-01-01.

The following snippet can simulate the issue:

$creation_date = '2024-01-01';
$creation_date = date_create_from_format('Y-m-d\TH:i:s\Z', $creation_date);
var_dump($creation_date?->format('Y-m-d\TH:i:s\Z'));

Package Version

v3.0.06

PHP Version

8.3

Which operating systems does with happen with?

Linux

Notes

The date_create_from_format() will return false when it can't parse the date according to the manual. In which case the null safe operator will not work because it's a boolean. I think this is not intended.

Up to now it only happened with quicktime format. Haven't dig the code in order to figure out why is that, so it might make sense to check if there are other snippets that could cause the same issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.