mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-25 14:37:59 +01:00
Merge rPFc0e619aacd75: T357: Added an ID3v1 fallback and added more information to the…
This commit is contained in:
parent
e4ae56885f
commit
a8d7bd1935
2 changed files with 42 additions and 19 deletions
|
@ -58,7 +58,7 @@ class ClassifyMLPMA extends Command
|
||||||
|
|
||||||
$totalTracks = sizeof($tracks);
|
$totalTracks = sizeof($tracks);
|
||||||
|
|
||||||
$fileToStartAt = (int) $this->option('startAt') - 1;
|
$fileToStartAt = (int)$this->option('startAt') - 1;
|
||||||
$this->comment("Skipping $fileToStartAt files..." . PHP_EOL);
|
$this->comment("Skipping $fileToStartAt files..." . PHP_EOL);
|
||||||
|
|
||||||
$tracks = array_slice($tracks, $fileToStartAt);
|
$tracks = array_slice($tracks, $fileToStartAt);
|
||||||
|
@ -90,18 +90,23 @@ class ClassifyMLPMA extends Command
|
||||||
if (Str::contains(Str::lower($track->filename), 'ingram')) {
|
if (Str::contains(Str::lower($track->filename), 'ingram')) {
|
||||||
$this->info('This is an official song remix!');
|
$this->info('This is an official song remix!');
|
||||||
|
|
||||||
list($trackType, $linkedSongIds) = $this->classifyTrack($track->filename, $officialSongs, true);
|
list($trackType, $linkedSongIds) = $this->classifyTrack($track->filename, $officialSongs, true,
|
||||||
|
$parsedTags);
|
||||||
|
|
||||||
|
|
||||||
// If it has "remix" in the name, it's definitely a remix.
|
// If it has "remix" in the name, it's definitely a remix.
|
||||||
} else if (Str::contains(Str::lower($sanitizedTrackTitle), 'remix')) {
|
} else {
|
||||||
|
if (Str::contains(Str::lower($sanitizedTrackTitle), 'remix')) {
|
||||||
$this->info('This is some kind of remix!');
|
$this->info('This is some kind of remix!');
|
||||||
|
|
||||||
list($trackType, $linkedSongIds) = $this->classifyTrack($track->filename, $officialSongs);
|
list($trackType, $linkedSongIds) = $this->classifyTrack($track->filename, $officialSongs, false,
|
||||||
|
$parsedTags);
|
||||||
|
|
||||||
// No idea what this is. Have the pony at the terminal figure it out!
|
// No idea what this is. Have the pony at the terminal figure it out!
|
||||||
} else {
|
} else {
|
||||||
list($trackType, $linkedSongIds) = $this->classifyTrack($track->filename, $officialSongs);
|
list($trackType, $linkedSongIds) = $this->classifyTrack($track->filename, $officialSongs, false,
|
||||||
|
$parsedTags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,7 +138,8 @@ class ClassifyMLPMA extends Command
|
||||||
* @param bool|false $isRemixOfOfficialTrack
|
* @param bool|false $isRemixOfOfficialTrack
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function classifyTrack($filename, $officialSongs, $isRemixOfOfficialTrack = false) {
|
protected function classifyTrack($filename, $officialSongs, $isRemixOfOfficialTrack = false, $tags)
|
||||||
|
{
|
||||||
$trackTypeId = null;
|
$trackTypeId = null;
|
||||||
$linkedSongIds = [];
|
$linkedSongIds = [];
|
||||||
|
|
||||||
|
@ -150,7 +156,8 @@ class ClassifyMLPMA extends Command
|
||||||
if ($isRemixOfOfficialTrack && sizeof($officialSongs) > 1) {
|
if ($isRemixOfOfficialTrack && sizeof($officialSongs) > 1) {
|
||||||
$this->question('Multiple official songs matched! Please enter the ID of the correct one.');
|
$this->question('Multiple official songs matched! Please enter the ID of the correct one.');
|
||||||
|
|
||||||
} else if (sizeof($officialSongs) > 0) {
|
} else {
|
||||||
|
if (sizeof($officialSongs) > 0) {
|
||||||
$this->question('This looks like a remix of an official song!');
|
$this->question('This looks like a remix of an official song!');
|
||||||
$this->question('Press "r" if the match above is right!');
|
$this->question('Press "r" if the match above is right!');
|
||||||
|
|
||||||
|
@ -158,10 +165,15 @@ class ClassifyMLPMA extends Command
|
||||||
$this->question('Exactly what kind of track is this?');
|
$this->question('Exactly what kind of track is this?');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$this->question('If this is a medley, multiple song ID\'s can be separated by commas. ');
|
$this->question('If this is a medley, multiple song ID\'s can be separated by commas. ');
|
||||||
$this->question(' ');
|
$this->question(' ');
|
||||||
$this->question(' ' . $filename . ' ');
|
$this->question(' ' . $filename . ' ');
|
||||||
$this->question(' ');
|
$this->question(' ');
|
||||||
|
$this->question(' Title: ' . $tags['title'] . ' ');
|
||||||
|
$this->question(' Album: ' . $tags['album'] . ' ');
|
||||||
|
$this->question(' Artist: ' . $tags['artist'] . ' ');
|
||||||
|
$this->question(' ');
|
||||||
$this->question(' r = official song remix (accept all "guessed" matches) ');
|
$this->question(' r = official song remix (accept all "guessed" matches) ');
|
||||||
$this->question(' # = official song remix (enter the ID(s) of the show song(s)) ');
|
$this->question(' # = official song remix (enter the ID(s) of the show song(s)) ');
|
||||||
$this->question(' a = show audio remix ');
|
$this->question(' a = show audio remix ');
|
||||||
|
@ -175,7 +187,7 @@ class ClassifyMLPMA extends Command
|
||||||
case 'r':
|
case 'r':
|
||||||
$trackTypeId = TrackType::OFFICIAL_TRACK_REMIX;
|
$trackTypeId = TrackType::OFFICIAL_TRACK_REMIX;
|
||||||
foreach ($officialSongs as $officialSong) {
|
foreach ($officialSongs as $officialSong) {
|
||||||
$linkedSongIds[] = (int) $officialSong->id;
|
$linkedSongIds[] = (int)$officialSong->id;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -199,7 +211,7 @@ class ClassifyMLPMA extends Command
|
||||||
$trackTypeId = TrackType::OFFICIAL_TRACK_REMIX;
|
$trackTypeId = TrackType::OFFICIAL_TRACK_REMIX;
|
||||||
$linkedSongIds = explode(',', $input);
|
$linkedSongIds = explode(',', $input);
|
||||||
$linkedSongIds = array_map(function ($item) {
|
$linkedSongIds = array_map(function ($item) {
|
||||||
return (int) $item;
|
return (int)$item;
|
||||||
}, $linkedSongIds);
|
}, $linkedSongIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,7 +383,18 @@ class ImportMLPMA extends Command
|
||||||
*/
|
*/
|
||||||
protected function getId3Tags($rawTags)
|
protected function getId3Tags($rawTags)
|
||||||
{
|
{
|
||||||
|
if (array_key_exists('id3v2', $rawTags['tags'])) {
|
||||||
$tags = $rawTags['tags']['id3v2'];
|
$tags = $rawTags['tags']['id3v2'];
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (array_key_exists('id3v1', $rawTags['tags'])) {
|
||||||
|
$tags = $rawTags['tags']['id3v1'];
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$tags = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$comment = null;
|
$comment = null;
|
||||||
|
|
||||||
if (isset($tags['comment'])) {
|
if (isset($tags['comment'])) {
|
||||||
|
|
Loading…
Reference in a new issue