Upgrade GetID3 (fixes #1040)

This commit is contained in:
Phan An 2019-08-07 15:17:30 +07:00
parent fe9653e09a
commit 5f23f53c8d
4 changed files with 68 additions and 67 deletions

View file

@ -7,10 +7,10 @@ use App\Models\Artist;
use App\Models\Song;
use App\Repositories\SongRepository;
use Exception;
use getID3;
use getid3_lib;
use JamesHeinrich\GetID3\GetID3;
use Illuminate\Contracts\Cache\Repository as Cache;
use InvalidArgumentException;
use JamesHeinrich\GetID3\Utils;
use SplFileInfo;
use Symfony\Component\Finder\Finder;
@ -63,7 +63,7 @@ class FileSynchronizer
private $syncError;
public function __construct(
getID3 $getID3,
GetID3 $getID3,
MediaMetadataService $mediaMetadataService,
HelperService $helperService,
SongRepository $songRepository,
@ -117,17 +117,16 @@ class FileSynchronizer
// Copy the available tags over to comment.
// This is a helper from getID3, though it doesn't really work well.
// We'll still prefer getting ID3v2 tags directly later.
getid3_lib::CopyTagsToComments($info);
$track = $this->getTrackNumberFromInfo($info);
Utils::CopyTagsToComments($info);
$props = [
'artist' => '',
'album' => '',
'albumartist' => '',
'compilation' => false,
'title' => basename($this->filePath, '.'.pathinfo($this->filePath, PATHINFO_EXTENSION)), // default to be file name
'length' => $info['playtime_seconds'],
'track' => (int) $track,
'track' => $this->getTrackNumberFromInfo($info),
'disc' => (int) array_get($info, 'comments.part_of_a_set.0', 1),
'lyrics' => '',
'cover' => array_get($info, 'comments.picture', [null])[0],
@ -327,12 +326,18 @@ class FileSynchronizer
'albumartist' => 'band',
'album' => 'album',
'title' => 'title',
'lyrics' => 'unsynchronised_lyric',
'lyrics' => ['unsychronised_lyric', 'unsynchronised_lyric'],
'compilation' => 'part_of_a_compilation',
];
foreach ($propertyMap as $name => $tag) {
$props[$name] = array_get($info, "tags.id3v2.$tag", [null])[0] ?: array_get($comments, $tag, [''])[0];
foreach ($propertyMap as $name => $tags) {
foreach ((array) $tags as $tag) {
$value = array_get($info, "tags.id3v2.$tag", [null])[0] ?: array_get($comments, $tag, [''])[0];
if ($value) {
$props[$name] = $value;
}
}
// Fixes #323, where tag names can be htmlentities()'ed
if (is_string($props[$name]) && $props[$name]) {

View file

@ -7,7 +7,7 @@
"require": {
"php": ">=7.1.3",
"laravel/framework": "5.8.*",
"james-heinrich/getid3": "^1.9",
"james-heinrich/getid3": "^2.0",
"guzzlehttp/guzzle": "^6.1",
"tymon/jwt-auth": "^0.5.6",
"aws/aws-sdk-php-laravel": "^3.1",
@ -85,5 +85,7 @@
"config": {
"preferred-install": "dist",
"optimize-autoloader": true
}
},
"minimum-stability": "beta",
"prefer-stable": true
}

100
composer.lock generated
View file

@ -1,10 +1,10 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "1a19489422e5398ac1ae54a3c745ec0c",
"content-hash": "866d0e61b814bcbf77879f1052637ae5",
"packages": [
{
"name": "aws/aws-sdk-php",
@ -1006,66 +1006,60 @@
},
{
"name": "james-heinrich/getid3",
"version": "v1.9.17",
"version": "v2.0.0-beta1",
"source": {
"type": "git",
"url": "https://github.com/JamesHeinrich/getID3.git",
"reference": "d2e45f2c4f75cc7443e158757ad2d678e318685d"
"reference": "031fee84c32986e8afaf47d76497bffcfa53f474"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/JamesHeinrich/getID3/zipball/d2e45f2c4f75cc7443e158757ad2d678e318685d",
"reference": "d2e45f2c4f75cc7443e158757ad2d678e318685d",
"url": "https://api.github.com/repos/JamesHeinrich/getID3/zipball/031fee84c32986e8afaf47d76497bffcfa53f474",
"reference": "031fee84c32986e8afaf47d76497bffcfa53f474",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"jakub-onderka/php-parallel-lint": "^0.9 || ^1.0"
"php": ">=5.4.0"
},
"suggest": {
"ext-SimpleXML": "SimpleXML extension is required to analyze RIFF/WAV/BWF audio files (also requires `ext-libxml`).",
"ext-com_dotnet": "COM extension is required when loading files larger than 2GB on Windows.",
"ext-ctype": "ctype extension is required when loading files larger than 2GB on 32-bit PHP (also on 64-bit PHP on Windows) or executing `getid3_lib::CopyTagsToComments`.",
"ext-dba": "DBA extension is required to use the DBA database as a cache storage.",
"ext-exif": "EXIF extension is required for graphic modules.",
"ext-iconv": "iconv extension is required to work with different character sets (when `ext-mbstring` is not available).",
"ext-json": "JSON extension is required to analyze Apple Quicktime videos.",
"ext-libxml": "libxml extension is required to analyze RIFF/WAV/BWF audio files.",
"ext-mbstring": "mbstring extension is required to work with different character sets.",
"ext-mysql": "MySQL extension is required to use the MySQL database as a cache storage (deprecated in PHP 5.5, removed in PHP >= 7.0, use `ext-mysqli` instead).",
"ext-mysqli": "MySQLi extension is required to use the MySQL database as a cache storage.",
"ext-rar": "RAR extension is required for RAR archive module.",
"ext-sqlite3": "SQLite3 extension is required to use the SQLite3 database as a cache storage.",
"ext-xml": "XML extension is required for graphic modules to analyze the XML metadata.",
"ext-zlib": "Zlib extension is required for archive modules and compressed metadata."
"ext-rar": "RAR extension is required for RAR archive module."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9.x-dev"
}
},
"autoload": {
"classmap": [
"getid3/"
]
"psr-4": {
"JamesHeinrich\\GetID3\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-1.0-or-later",
"LGPL-3.0-only",
"MPL-2.0"
"GPL"
],
"description": "PHP script that extracts useful information from popular multimedia file formats",
"homepage": "https://www.getid3.org/",
"authors": [
{
"name": "Craig Duncan",
"role": "Developer",
"email": "git@duncanc.co.uk",
"homepage": "https://github.com/duncan3dc"
},
{
"name": "James Heinrich",
"role": "Developer",
"email": "info@getid3.org",
"homepage": "https://github.com/JamesHeinrich"
}
],
"description": "Extract and write useful information to/from popular multimedia file formats",
"homepage": "http://www.getid3.org/",
"keywords": [
"audio",
"codecs",
"php",
"tags"
"id3",
"metadata",
"tags",
"video"
],
"time": "2019-02-07T17:30:03+00:00"
"time": "2019-05-22T16:33:10+00:00"
},
{
"name": "kylekatarnls/update-helper",
@ -2985,7 +2979,7 @@
},
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
"email": "backendtea@gmail.com"
}
],
"description": "Symfony polyfill for ctype functions",
@ -5606,7 +5600,7 @@
"homepage": "https://nette.org/contributors"
}
],
"description": "? Nette Finder: find files and directories with an intuitive API.",
"description": "🔍 Nette Finder: find files and directories with an intuitive API.",
"homepage": "https://nette.org",
"keywords": [
"filesystem",
@ -5666,7 +5660,7 @@
"homepage": "https://nette.org/contributors"
}
],
"description": "? Nette NEON: encodes and decodes NEON file format.",
"description": "🍸 Nette NEON: encodes and decodes NEON file format.",
"homepage": "http://ne-on.org",
"keywords": [
"export",
@ -6363,18 +6357,18 @@
"authors": [
{
"name": "Arne Blankerts",
"role": "Developer",
"email": "arne@blankerts.de"
"email": "arne@blankerts.de",
"role": "Developer"
},
{
"name": "Sebastian Heuer",
"role": "Developer",
"email": "sebastian@phpeople.de"
"email": "sebastian@phpeople.de",
"role": "Developer"
},
{
"name": "Sebastian Bergmann",
"role": "Developer",
"email": "sebastian@phpunit.de"
"email": "sebastian@phpunit.de",
"role": "Developer"
}
],
"description": "Library for handling version information and constraints",
@ -6978,8 +6972,8 @@
"authors": [
{
"name": "Sebastian Bergmann",
"role": "lead",
"email": "sebastian@phpunit.de"
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
@ -8366,9 +8360,9 @@
}
],
"aliases": [],
"minimum-stability": "stable",
"minimum-stability": "beta",
"stability-flags": [],
"prefer-stable": false,
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": ">=7.1.3",

View file

@ -10,7 +10,7 @@ use App\Models\Song;
use App\Services\FileSynchronizer;
use App\Services\MediaSyncService;
use Exception;
use getID3;
use JamesHeinrich\GetID3\GetID3;
use Illuminate\Foundation\Testing\WithoutMiddleware;
class MediaSyncTest extends TestCase
@ -238,7 +238,7 @@ class MediaSyncTest extends TestCase
/** @test */
public function html_entities_in_tags_are_recognized_and_saved_properly(): void
{
$this->mockIocDependency(getID3::class, [
$this->mockIocDependency(GetID3::class, [
'analyze' => [
'tags' => [
'id3v2' => [