Skip to content

Commit

Permalink
Merge pull request #19 from kiwilan/develop
Browse files Browse the repository at this point in the history
v3.0.03
  • Loading branch information
ewilan-riviere authored Oct 31, 2023
2 parents 327e76d + e275719 commit 910de64
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 12 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,15 +501,15 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio

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

[version-src]: https://img.shields.io/packagist/v/kiwilan/php-audio.svg?style=flat-square&colorA=18181B&colorB=777BB4
[version-src]: https://img.shields.io/packagist/v/kiwilan/php-audio.svg?style=flat&colorA=18181B&colorB=777BB4
[version-href]: https://packagist.org/packages/kiwilan/php-audio
[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
[php-version-src]: https://img.shields.io/static/v1?style=flat&label=PHP&message=v8.1&color=777BB4&logo=php&logoColor=ffffff&labelColor=18181b
[php-version-href]: https://www.php.net/
[downloads-src]: https://img.shields.io/packagist/dt/kiwilan/php-audio.svg?style=flat-square&colorA=18181B&colorB=777BB4
[downloads-src]: https://img.shields.io/packagist/dt/kiwilan/php-audio.svg?style=flat&colorA=18181B&colorB=777BB4
[downloads-href]: https://packagist.org/packages/kiwilan/php-audio
[license-src]: https://img.shields.io/github/license/kiwilan/php-audio.svg?style=flat-square&colorA=18181B&colorB=777BB4
[license-src]: https://img.shields.io/github/license/kiwilan/php-audio.svg?style=flat&colorA=18181B&colorB=777BB4
[license-href]: https://github.com/kiwilan/php-audio/blob/main/README.md
[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
[tests-src]: https://img.shields.io/github/actions/workflow/status/kiwilan/php-audio/run-tests.yml?branch=main&label=tests&style=flat&colorA=18181B
[tests-href]: https://packagist.org/packages/kiwilan/php-audio
[codecov-src]: https://codecov.io/gh/kiwilan/php-audio/branch/main/graph/badge.svg?token=4L0D92Z1EZ
[codecov-src]: https://img.shields.io/codecov/c/gh/kiwilan/php-audio/main?style=flat&colorA=18181B&colorB=777BB4
[codecov-href]: https://codecov.io/gh/kiwilan/php-audio
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kiwilan/php-audio",
"description": "PHP package to parse and update audio files metadata, with `JamesHeinrich/getID3`.",
"version": "3.0.02",
"version": "3.0.03",
"keywords": [
"audio",
"php",
Expand Down
2 changes: 1 addition & 1 deletion src/Models/AudioCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ public static function fromId3(?Id3AudioTagV1 $v1, Id3AudioTagV2 $v2): AudioCore
album: $v2->album() ?? $v1->album(),
artist: $v2->artist() ?? $v1->artist(),
albumArtist: $v2->band() ?? null,
comment: $v2->comment() ?? $v1->comment(),
comment: $v2 ? $v2->comment() : $v1->comment(),
composer: $v2->composer() ?? null,
discNumber: $v2->part_of_a_set() ?? null,
genre: $v2->genre() ?? $v1->genre(),
Expand Down
17 changes: 16 additions & 1 deletion src/Models/AudioMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
class AudioMetadata
{
protected function __construct(
protected ?string $path = null,
protected ?int $filesize = null,
protected ?string $extension = null,
protected ?string $dataformat = null,
protected ?string $encoding = null,
protected ?string $mimeType = null,
protected ?float $durationSeconds = null,
Expand All @@ -25,12 +27,15 @@ protected function __construct(

public static function make(Audio $audio): self
{
$path = $audio->getPath();
$reader = $audio->getReader();
$audio = $reader->getAudio();

return new self(
path: $path,
filesize: $reader->getFilesize(),
extension: $audio?->dataformat(),
extension: pathinfo($path, PATHINFO_EXTENSION),
dataformat: $audio?->dataformat(),
encoding: $reader->getEncoding(),
mimeType: $reader->getMimeType(),
durationSeconds: $reader->getPlaytimeSeconds(),
Expand All @@ -45,6 +50,11 @@ public static function make(Audio $audio): self
);
}

public function getPath(): ?string
{
return $this->path;
}

public function getFilesize(): ?int
{
return $this->filesize;
Expand All @@ -55,6 +65,11 @@ public function getExtension(): ?string
return $this->extension;
}

public function getDataformat(): ?string
{
return $this->dataformat;
}

public function getEncoding(): ?string
{
return $this->encoding;
Expand Down
5 changes: 3 additions & 2 deletions tests/AudioTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
$extension = pathinfo($path, PATHINFO_EXTENSION);
$format = AudioFormatEnum::tryFrom($extension);

// ray($audio);
expect($audio)->toBeInstanceOf(Audio::class);
expect($audio->getTitle())->toBe('Introduction');
expect($audio->getArtist())->toBe('Mr Piouf');
Expand All @@ -31,8 +30,10 @@
expect($audio->getExtras())->toBeArray();

$metadata = $audio->getAudio();
expect($metadata->getPath())->toBeString();
expect($metadata->getFilesize())->toBeInt();
expect($metadata->getExtension())->toBeString();
// expect($metadata->getDataformat())->toBeString();
expect($metadata->getEncoding())->toBeString();
expect($metadata->getMimeType())->toBeString();
if ($metadata->getDurationSeconds()) {
Expand Down Expand Up @@ -70,7 +71,7 @@

if ($audio->hasCover()) {
expect($cover)->toBeInstanceOf(AudioCover::class);
expect($cover->getContent())->toBeString();
expect($cover->getContents())->toBeString();
expect($cover->getContents())->toBeString();
expect($cover->getMimeType())->toBeString();
if ($cover->getWidth()) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function addWriterFilesForTests()
MKA,
MKV,
MP3,
MP4,
// MP4,
OGG,
OPUS,
SPX,
Expand Down
53 changes: 53 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Tests

## Docker ubuntu

```bash
docker pull ubuntu:latest
docker run -it --rm ubuntu:latest
```

```bash
cd /home
apt update
apt install -y git software-properties-common
apt install -y flac vorbis-tools
add-apt-repository ppa:ondrej/php
apt update
apt -y install php8.2-fpm php8.2-curl php8.2-xml php8.2-zip
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
```

```bash
git clone -b develop https://github.com/kiwilan/php-audio.git
cd php-audio
/home/composer.phar install
/home/composer.phar test
```

## Docker windows

```bash
docker pull mcr.microsoft.com/windows/server
docker run -it --rm mcr.microsoft.com/windows/servercore:ltsc2019
```

```bash
powershell
```

```powershell
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'))
scoop install git
scoop install php
scoop install composer
```

```bash
git clone -b develop
cd php-audio
composer install
composer test
```

0 comments on commit 910de64

Please sign in to comment.