mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-25 14:37:59 +01:00
Merge rPFf4f97acd9fc0: T357: Validate the length of a year correctly.
This commit is contained in:
parent
9468ced8c4
commit
616b6e9ccf
1 changed files with 22 additions and 38 deletions
|
@ -179,21 +179,17 @@ class ImportMLPMA extends Command
|
|||
|
||||
if ($taggedYear !== null && $modifiedDate->year === $taggedYear) {
|
||||
$releasedAt = $modifiedDate;
|
||||
} else {
|
||||
if ($taggedYear !== null && (string)$taggedYear !== 4) {
|
||||
$this->error('This track\'s tagged year makes no sense! Using the track\'s last modified date...');
|
||||
$releasedAt = $modifiedDate;
|
||||
} else {
|
||||
if ($taggedYear !== null && $modifiedDate->year !== $taggedYear) {
|
||||
$this->error('Release years don\'t match! Using the tagged year...');
|
||||
$releasedAt = Carbon::create($taggedYear);
|
||||
} elseif ($taggedYear !== null && (string)Str::length($taggedYear) !== 4) {
|
||||
$this->error('This track\'s tagged year makes no sense! Using the track\'s last modified date...');
|
||||
$releasedAt = $modifiedDate;
|
||||
} elseif ($taggedYear !== null && $modifiedDate->year !== $taggedYear) {
|
||||
$this->error('Release years don\'t match! Using the tagged year...');
|
||||
$releasedAt = Carbon::create($taggedYear);
|
||||
|
||||
} else {
|
||||
// $taggedYear is null
|
||||
$this->error('This track isn\'t tagged with its release year! Using the track\'s last modified date...');
|
||||
$releasedAt = $modifiedDate;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// $taggedYear is null
|
||||
$this->error('This track isn\'t tagged with its release year! Using the track\'s last modified date...');
|
||||
$releasedAt = $modifiedDate;
|
||||
}
|
||||
|
||||
// This is later used by the classification/publishing script to determine the publication date.
|
||||
|
@ -281,18 +277,14 @@ class ImportMLPMA extends Command
|
|||
if ($image['image_mime'] === 'image/png') {
|
||||
$extension = 'png';
|
||||
|
||||
} elseif ($image['image_mime'] === 'image/jpeg') {
|
||||
$extension = 'jpg';
|
||||
|
||||
} elseif ($image['image_mime'] === 'image/gif') {
|
||||
$extension = 'gif';
|
||||
|
||||
} else {
|
||||
if ($image['image_mime'] === 'image/jpeg') {
|
||||
$extension = 'jpg';
|
||||
|
||||
} else {
|
||||
if ($image['image_mime'] === 'image/gif') {
|
||||
$extension = 'gif';
|
||||
|
||||
} else {
|
||||
$this->error('Unknown cover art format!');
|
||||
}
|
||||
}
|
||||
$this->error('Unknown cover art format!');
|
||||
}
|
||||
|
||||
// write temporary image file
|
||||
|
@ -393,23 +385,15 @@ class ImportMLPMA extends Command
|
|||
*/
|
||||
protected function getId3Tags($rawTags)
|
||||
{
|
||||
if (array_key_exists('tags', $rawTags) &&
|
||||
array_key_exists('id3v2', $rawTags['tags'])
|
||||
) {
|
||||
if (array_key_exists('tags', $rawTags) && array_key_exists('id3v2', $rawTags['tags'])) {
|
||||
$tags = $rawTags['tags']['id3v2'];
|
||||
|
||||
} elseif (array_key_exists('tags', $rawTags) && array_key_exists('id3v1', $rawTags['tags'])) {
|
||||
$tags = $rawTags['tags']['id3v1'];
|
||||
} else {
|
||||
if (
|
||||
array_key_exists('tags', $rawTags) &&
|
||||
array_key_exists('id3v1', $rawTags['tags'])
|
||||
) {
|
||||
$tags = $rawTags['tags']['id3v1'];
|
||||
|
||||
} else {
|
||||
$tags = [];
|
||||
}
|
||||
$tags = [];
|
||||
}
|
||||
|
||||
|
||||
$comment = null;
|
||||
|
||||
if (isset($tags['comment'])) {
|
||||
|
|
Loading…
Reference in a new issue