#5565 -- Update available metadata tags for ffprobe.
This commit is contained in:
parent
f5e075012c
commit
197c3ab2aa
|
@ -6,6 +6,7 @@ namespace App\Controller\Admin;
|
|||
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Media\Enums\MetadataTags;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
final class CustomFieldsAction
|
||||
|
@ -23,72 +24,7 @@ final class CustomFieldsAction
|
|||
title: __('Custom Fields'),
|
||||
props: [
|
||||
'listUrl' => (string)$router->fromHere('api:admin:custom_fields'),
|
||||
'autoAssignTypes' => [
|
||||
'album' => __('Album'), // TAL, TALB
|
||||
'album_artist_sort_order' => __('Album Artist Sort Order'), // TS2, TSO2
|
||||
'album_sort_order' => __('Album Sort Order'), // TSA, TSOA
|
||||
'artist' => __('Artist'), // TP1, TPE1
|
||||
'band' => __('Band'), // TP2, TPE2
|
||||
'bpm' => __('Bpm'), // TBP, TBPM
|
||||
'comment' => __('Comment'), // COM, COMM
|
||||
'commercial_information' => __('Commercial Information'), // WCM, WCOM
|
||||
'composer' => __('Composer'), // TCM, TCOM
|
||||
'composer_sort_order' => __('Composer Sort Order'), // TSC, TSOC
|
||||
'conductor' => __('Conductor'), // TP3, TPE3
|
||||
'content_group_description' => __('Content Group Description'), // TIT1, TT1
|
||||
'copyright' => __('Copyright'), // WCOP, WCP
|
||||
'copyright_message' => __('Copyright Message'), // TCOP, TCR
|
||||
'encoded_by' => __('Encoded By'), // TEN, TENC
|
||||
'encoder_settings' => __('Encoder Settings'), // TSS, TSSE
|
||||
'encoding_time' => __('Encoding Time'), // TDEN
|
||||
'file_owner' => __('File Owner'), // TOWN
|
||||
'file_type' => __('File Type'), // TFLT, TFT
|
||||
'genre' => __('Genre'), // TCO, TCON
|
||||
'initial_key' => __('Initial Key'), // TKE, TKEY
|
||||
'internet_radio_station_name' => __('Internet Radio Station Name'), // TRSN
|
||||
'internet_radio_station_owner' => __('Internet Radio Station Owner'), // TRSO
|
||||
'involved_people_list' => __('Involved People List'), // IPL, IPLS, TIPL
|
||||
'isrc' => __('ISRC'), // TRC, TSRC
|
||||
'language' => __('Language'), // TLA, TLAN
|
||||
'length' => __('Length'), // TLE, TLEN
|
||||
'linked_information' => __('Linked Information'), // LINK, LNK
|
||||
'lyricist' => __('Lyricist'), // TEXT, TXT
|
||||
'media_type' => __('Media Type'), // TMED, TMT
|
||||
'mood' => __('Mood'), // TMOO
|
||||
'music_cd_identifier' => __('Music CD Identifier'), // MCDI, MCI
|
||||
'musician_credits_list' => __('Musician Credits List'), // TMCL
|
||||
'original_album' => __('Original Album'), // TOAL, TOT
|
||||
'original_artist' => __('Original Artist'), // TOA, TOPE
|
||||
'original_filename' => __('Original Filename'), // TOF, TOFN
|
||||
'original_lyricist' => __('Original Lyricist'), // TOL, TOLY
|
||||
'original_release_time' => __('Original Release Time'), // TDOR
|
||||
'original_year' => __('Original Year'), // TOR, TORY
|
||||
'part_of_a_compilation' => __('Part Of A Compilation'), // TCMP, TCP
|
||||
'part_of_a_set' => __('Part Of A Set'), // TPA, TPOS
|
||||
'performer_sort_order' => __('Performer Sort Order'), // TSOP, TSP
|
||||
'playlist_delay' => __('Playlist Delay'), // TDLY, TDY
|
||||
'produced_notice' => __('Produced Notice'), // TPRO
|
||||
'publisher' => __('Publisher'), // TPB, TPUB
|
||||
'recording_time' => __('Recording Time'), // TDRC
|
||||
'release_time' => __('Release Time'), // TDRL
|
||||
'remixer' => __('Remixer'), // TP4, TPE4
|
||||
'set_subtitle' => __('Set Subtitle'), // TSST
|
||||
'subtitle' => __('Subtitle'), // TIT3, TT3
|
||||
'tagging_time' => __('Tagging Time'), // TDTG
|
||||
'terms_of_use' => __('Terms Of Use'), // USER
|
||||
'title' => __('Title'), // TIT2, TT2
|
||||
'title_sort_order' => __('Title Sort Order'), // TSOT, TST
|
||||
'track_number' => __('Track Number'), // TRCK, TRK
|
||||
'unsynchronised_lyric' => __('Unsynchronised Lyric'), // ULT, USLT
|
||||
'url_artist' => __('URL Artist'), // WAR, WOAR
|
||||
'url_file' => __('URL File'), // WAF, WOAF
|
||||
'url_payment' => __('URL Payment'), // WPAY
|
||||
'url_publisher' => __('URL Publisher'), // WPB, WPUB
|
||||
'url_source' => __('URL Source'), // WAS, WOAS
|
||||
'url_station' => __('URL Station'), // WORS
|
||||
'url_user' => __('URL User'), // WXX, WXXX
|
||||
'year' => __('Year'), // TYE, TYER
|
||||
],
|
||||
'autoAssignTypes' => MetadataTags::getNames(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
namespace App\Media\Enums;
|
||||
|
||||
enum MetadataTags: string
|
||||
{
|
||||
case Album = 'album'; // TAL, TALB
|
||||
case Artist = 'artist'; // TP1, TPE1
|
||||
case Bpm = 'bpm'; // TBP, TBPM
|
||||
case Comment = 'comment'; // COM, COMM
|
||||
case Composer = 'composer'; // TCM, TCOM
|
||||
case Copyright = 'copyright'; // WCOP, WCP
|
||||
case EncodedBy = 'encoded_by'; // TEN, TENC
|
||||
case Genre = 'genre'; // TCO, TCON
|
||||
case Isrc = 'isrc'; // TRC, TSRC
|
||||
case Title = 'title'; // TIT2, TT2
|
||||
case Year = 'year'; // TYE, TYER
|
||||
|
||||
// Other possible metadata tags that may not be pulled by FFProbe
|
||||
case AlbumArtist = 'album_artist';
|
||||
case AlbumArtistSortOrder = 'album_artist_sort_order'; // TS2, TSO2
|
||||
case AlbumSortOrder = 'album_sort_order'; // TSA, TSOA
|
||||
case Band = 'band'; // TP2, TPE2
|
||||
case CommercialInformation = 'commercial_information'; // WCM, WCOM
|
||||
case ComposerSortOrder = 'composer_sort_order'; // TSC, TSOC
|
||||
case Conductor = 'conductor'; // TP3, TPE3
|
||||
case ContentGroupDescription = 'content_group_description'; // TIT1, TT1
|
||||
case CopyrightMessage = 'copyright_message'; // TCOP, TCR
|
||||
case EncoderSettings = 'encoder_settings'; // TSS, TSSE
|
||||
case EncodingTime = 'encoding_time'; // TDEN
|
||||
case FileOwner = 'file_owner'; // TOWN
|
||||
case FileType = 'file_type'; // TFLT, TFT
|
||||
case InitialKey = 'initial_key'; // TKE, TKEY
|
||||
case InternetRadioStationName = 'internet_radio_station_name'; // TRSN
|
||||
case InternetRadioStationOwner = 'internet_radio_station_owner'; // TRSO
|
||||
case InvolvedPeopleList = 'involved_people_list'; // IPL, IPLS, TIPL
|
||||
case Language = 'language'; // TLA, TLAN
|
||||
case Length = 'length'; // TLE, TLEN
|
||||
case LinkedInformation = 'linked_information'; // LINK, LNK
|
||||
case Lyricist = 'lyricist'; // TEXT, TXT
|
||||
case MediaType = 'media_type'; // TMED, TMT
|
||||
case Mood = 'mood'; // TMOO
|
||||
case MusicCdIdentifier = 'music_cd_identifier'; // MCDI, MCI
|
||||
case MusicianCreditsList = 'musician_credits_list'; // TMCL
|
||||
case OriginalAlbum = 'original_album'; // TOAL, TOT
|
||||
case OriginalArtist = 'original_artist'; // TOA, TOPE
|
||||
case OriginalFilename = 'original_filename'; // TOF, TOFN
|
||||
case OriginalLyricist = 'original_lyricist'; // TOL, TOLY
|
||||
case OriginalReleaseTime = 'original_release_time'; // TDOR
|
||||
case OriginalYear = 'original_year'; // TOR, TORY
|
||||
case PartOfACompilation = 'part_of_a_compilation'; // TCMP, TCP
|
||||
case PartOfASet = 'part_of_a_set'; // TPA, TPOS
|
||||
case PerformerSortOrder = 'performer_sort_order'; // TSOP, TSP
|
||||
case PlaylistDelay = 'playlist_delay'; // TDLY, TDY
|
||||
case ProducedNotice = 'produced_notice'; // TPRO
|
||||
case Publisher = 'publisher'; // TPB, TPUB
|
||||
case RecordingTime = 'recording_time'; // TDRC
|
||||
case ReleaseTime = 'release_time'; // TDRL
|
||||
case Remixer = 'remixer'; // TP4, TPE4
|
||||
case SetSubtitle = 'set_subtitle'; // TSST
|
||||
case Subtitle = 'subtitle'; // TIT3, TT3
|
||||
case TaggingTime = 'tagging_time'; // TDTG
|
||||
case TermsOfUse = 'terms_of_use'; // USER
|
||||
case TitleSortOrder = 'title_sort_order'; // TSOT, TST
|
||||
case TrackNumber = 'track_number'; // TRCK, TRK
|
||||
case UnsynchronisedLyric = 'unsynchronised_lyric'; // ULT, USLT
|
||||
case UrlArtist = 'url_artist'; // WAR, WOAR
|
||||
case UrlFile = 'url_file'; // WAF, WOAF
|
||||
case UrlPayment = 'url_payment'; // WPAY
|
||||
case UrlPublisher = 'url_publisher'; // WPB, WPUB
|
||||
case UrlSource = 'url_source'; // WAS, WOAS
|
||||
case UrlStation = 'url_station'; // WORS
|
||||
case UrlUser = 'url_user'; // WXX, WXXX
|
||||
|
||||
public static function getNames(): array
|
||||
{
|
||||
return [
|
||||
self::Album->value => __('Album'),
|
||||
self::Artist->value => __('Artist'),
|
||||
self::Bpm->value => __('BPM'),
|
||||
self::Comment->value => __('Comment'),
|
||||
self::Composer->value => __('Composer'),
|
||||
self::Copyright->value => __('Copyright'),
|
||||
self::EncodedBy->value => __('Encoded By'),
|
||||
self::Genre->value => __('Genre'),
|
||||
self::Isrc->value => __('ISRC'),
|
||||
self::Title->value => __('Title'),
|
||||
self::Year->value => __('Year'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getTag(string $value): ?self
|
||||
{
|
||||
$value = str_replace('-', '_', strtolower($value));
|
||||
|
||||
$tag = self::tryFrom($value);
|
||||
if (null !== $tag) {
|
||||
return $tag;
|
||||
}
|
||||
|
||||
$aliases = [
|
||||
'date' => self::Year,
|
||||
'encoder' => self::EncodedBy,
|
||||
];
|
||||
|
||||
return $aliases[$value] ?? null;
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace App\Media\Metadata;
|
||||
|
||||
use App\Event\Media\ReadMetadata;
|
||||
use App\Media\Enums\MetadataTags;
|
||||
use App\Media\Metadata;
|
||||
use App\Media\MimeType;
|
||||
use App\Utilities\Arrays;
|
||||
|
@ -89,19 +90,32 @@ final class Reader
|
|||
continue;
|
||||
}
|
||||
|
||||
foreach ($tagSet as $tagName => $tagContents) {
|
||||
if (!empty($tagContents) && !isset($metaTags[$tagName])) {
|
||||
$tagValue = $tagContents;
|
||||
if (is_array($tagValue)) {
|
||||
// Skip pictures
|
||||
if (isset($tagValue['data'])) {
|
||||
continue;
|
||||
}
|
||||
$flatValue = Arrays::flattenArray($tagValue);
|
||||
$tagValue = implode(', ', $flatValue);
|
||||
}
|
||||
foreach ($tagSet as $tagName => $tagValue) {
|
||||
if (empty($tagValue)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$metaTags[strtolower((string)$tagName)] = $this->cleanUpString((string)$tagValue);
|
||||
$tagEnum = MetadataTags::getTag((string)$tagName);
|
||||
if (null === $tagEnum) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($tagValue)) {
|
||||
// Skip pictures
|
||||
if (isset($tagValue['data'])) {
|
||||
continue;
|
||||
}
|
||||
$flatValue = Arrays::flattenArray($tagValue);
|
||||
$tagValue = implode(', ', $flatValue);
|
||||
}
|
||||
|
||||
$tagValue = $this->cleanUpString((string)$tagValue);
|
||||
|
||||
$tagName = $tagEnum->value;
|
||||
if (isset($metaTags[$tagName])) {
|
||||
$metaTags[$tagName] .= ', ' . $tagValue;
|
||||
} else {
|
||||
$metaTags[$tagName] = $tagValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue