Skip to content

Commit 910de64

Browse files
Merge pull request #19 from kiwilan/develop
v3.0.03
2 parents 327e76d + e275719 commit 910de64

File tree

7 files changed

+81
-12
lines changed

7 files changed

+81
-12
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -501,15 +501,15 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
501501

502502
[<img src="https://user-images.githubusercontent.com/48261459/201463225-0a5a084e-df15-4b11-b1d2-40fafd3555cf.svg" height="120rem" width="100%" />](https://github.com/kiwilan)
503503

504-
[version-src]: https://img.shields.io/packagist/v/kiwilan/php-audio.svg?style=flat-square&colorA=18181B&colorB=777BB4
504+
[version-src]: https://img.shields.io/packagist/v/kiwilan/php-audio.svg?style=flat&colorA=18181B&colorB=777BB4
505505
[version-href]: https://packagist.org/packages/kiwilan/php-audio
506-
[php-version-src]: https://img.shields.io/static/v1?style=flat-square&label=PHP&message=v8.1&color=777BB4&logo=php&logoColor=ffffff&labelColor=18181b
506+
[php-version-src]: https://img.shields.io/static/v1?style=flat&label=PHP&message=v8.1&color=777BB4&logo=php&logoColor=ffffff&labelColor=18181b
507507
[php-version-href]: https://www.php.net/
508-
[downloads-src]: https://img.shields.io/packagist/dt/kiwilan/php-audio.svg?style=flat-square&colorA=18181B&colorB=777BB4
508+
[downloads-src]: https://img.shields.io/packagist/dt/kiwilan/php-audio.svg?style=flat&colorA=18181B&colorB=777BB4
509509
[downloads-href]: https://packagist.org/packages/kiwilan/php-audio
510-
[license-src]: https://img.shields.io/github/license/kiwilan/php-audio.svg?style=flat-square&colorA=18181B&colorB=777BB4
510+
[license-src]: https://img.shields.io/github/license/kiwilan/php-audio.svg?style=flat&colorA=18181B&colorB=777BB4
511511
[license-href]: https://github.com/kiwilan/php-audio/blob/main/README.md
512-
[tests-src]: https://img.shields.io/github/actions/workflow/status/kiwilan/php-audio/run-tests.yml?branch=main&label=tests&style=flat-square&colorA=18181B
512+
[tests-src]: https://img.shields.io/github/actions/workflow/status/kiwilan/php-audio/run-tests.yml?branch=main&label=tests&style=flat&colorA=18181B
513513
[tests-href]: https://packagist.org/packages/kiwilan/php-audio
514-
[codecov-src]: https://codecov.io/gh/kiwilan/php-audio/branch/main/graph/badge.svg?token=4L0D92Z1EZ
514+
[codecov-src]: https://img.shields.io/codecov/c/gh/kiwilan/php-audio/main?style=flat&colorA=18181B&colorB=777BB4
515515
[codecov-href]: https://codecov.io/gh/kiwilan/php-audio

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "kiwilan/php-audio",
33
"description": "PHP package to parse and update audio files metadata, with `JamesHeinrich/getID3`.",
4-
"version": "3.0.02",
4+
"version": "3.0.03",
55
"keywords": [
66
"audio",
77
"php",

src/Models/AudioCore.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ public static function fromId3(?Id3AudioTagV1 $v1, Id3AudioTagV2 $v2): AudioCore
427427
album: $v2->album() ?? $v1->album(),
428428
artist: $v2->artist() ?? $v1->artist(),
429429
albumArtist: $v2->band() ?? null,
430-
comment: $v2->comment() ?? $v1->comment(),
430+
comment: $v2 ? $v2->comment() : $v1->comment(),
431431
composer: $v2->composer() ?? null,
432432
discNumber: $v2->part_of_a_set() ?? null,
433433
genre: $v2->genre() ?? $v1->genre(),

src/Models/AudioMetadata.php

+16-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
class AudioMetadata
88
{
99
protected function __construct(
10+
protected ?string $path = null,
1011
protected ?int $filesize = null,
1112
protected ?string $extension = null,
13+
protected ?string $dataformat = null,
1214
protected ?string $encoding = null,
1315
protected ?string $mimeType = null,
1416
protected ?float $durationSeconds = null,
@@ -25,12 +27,15 @@ protected function __construct(
2527

2628
public static function make(Audio $audio): self
2729
{
30+
$path = $audio->getPath();
2831
$reader = $audio->getReader();
2932
$audio = $reader->getAudio();
3033

3134
return new self(
35+
path: $path,
3236
filesize: $reader->getFilesize(),
33-
extension: $audio?->dataformat(),
37+
extension: pathinfo($path, PATHINFO_EXTENSION),
38+
dataformat: $audio?->dataformat(),
3439
encoding: $reader->getEncoding(),
3540
mimeType: $reader->getMimeType(),
3641
durationSeconds: $reader->getPlaytimeSeconds(),
@@ -45,6 +50,11 @@ public static function make(Audio $audio): self
4550
);
4651
}
4752

53+
public function getPath(): ?string
54+
{
55+
return $this->path;
56+
}
57+
4858
public function getFilesize(): ?int
4959
{
5060
return $this->filesize;
@@ -55,6 +65,11 @@ public function getExtension(): ?string
5565
return $this->extension;
5666
}
5767

68+
public function getDataformat(): ?string
69+
{
70+
return $this->dataformat;
71+
}
72+
5873
public function getEncoding(): ?string
5974
{
6075
return $this->encoding;

tests/AudioTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
$extension = pathinfo($path, PATHINFO_EXTENSION);
1010
$format = AudioFormatEnum::tryFrom($extension);
1111

12-
// ray($audio);
1312
expect($audio)->toBeInstanceOf(Audio::class);
1413
expect($audio->getTitle())->toBe('Introduction');
1514
expect($audio->getArtist())->toBe('Mr Piouf');
@@ -31,8 +30,10 @@
3130
expect($audio->getExtras())->toBeArray();
3231

3332
$metadata = $audio->getAudio();
33+
expect($metadata->getPath())->toBeString();
3434
expect($metadata->getFilesize())->toBeInt();
3535
expect($metadata->getExtension())->toBeString();
36+
// expect($metadata->getDataformat())->toBeString();
3637
expect($metadata->getEncoding())->toBeString();
3738
expect($metadata->getMimeType())->toBeString();
3839
if ($metadata->getDurationSeconds()) {
@@ -70,7 +71,7 @@
7071

7172
if ($audio->hasCover()) {
7273
expect($cover)->toBeInstanceOf(AudioCover::class);
73-
expect($cover->getContent())->toBeString();
74+
expect($cover->getContents())->toBeString();
7475
expect($cover->getContents())->toBeString();
7576
expect($cover->getMimeType())->toBeString();
7677
if ($cover->getWidth()) {

tests/Pest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function addWriterFilesForTests()
8585
MKA,
8686
MKV,
8787
MP3,
88-
MP4,
88+
// MP4,
8989
OGG,
9090
OPUS,
9191
SPX,

tests/README.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Tests
2+
3+
## Docker ubuntu
4+
5+
```bash
6+
docker pull ubuntu:latest
7+
docker run -it --rm ubuntu:latest
8+
```
9+
10+
```bash
11+
cd /home
12+
apt update
13+
apt install -y git software-properties-common
14+
apt install -y flac vorbis-tools
15+
add-apt-repository ppa:ondrej/php
16+
apt update
17+
apt -y install php8.2-fpm php8.2-curl php8.2-xml php8.2-zip
18+
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
19+
php composer-setup.php
20+
php -r "unlink('composer-setup.php');"
21+
```
22+
23+
```bash
24+
git clone -b develop https://github.com/kiwilan/php-audio.git
25+
cd php-audio
26+
/home/composer.phar install
27+
/home/composer.phar test
28+
```
29+
30+
## Docker windows
31+
32+
```bash
33+
docker pull mcr.microsoft.com/windows/server
34+
docker run -it --rm mcr.microsoft.com/windows/servercore:ltsc2019
35+
```
36+
37+
```bash
38+
powershell
39+
```
40+
41+
```powershell
42+
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh'))
43+
scoop install git
44+
scoop install php
45+
scoop install composer
46+
```
47+
48+
```bash
49+
git clone -b develop
50+
cd php-audio
51+
composer install
52+
composer test
53+
```

0 commit comments

Comments
 (0)