@@ -216,13 +216,25 @@ private function parse(): self
216216
217217 $ this ->type = match ($ this ->extension ) {
218218 'aac ' => null ,
219+ 'aif ' => 'id3 ' ,
220+ 'aifc ' => 'id3 ' ,
221+ 'aiff ' => 'id3 ' ,
219222 'flac ' => 'vorbiscomment ' ,
220223 'm4a ' => 'quicktime ' ,
221224 'm4b ' => 'quicktime ' ,
225+ 'm4v ' => 'quicktime ' ,
226+ 'mka ' => 'matroska ' ,
227+ 'mkv ' => 'matroska ' ,
222228 'mp3 ' => 'id3 ' ,
223229 'mp4 ' => 'quicktime ' ,
230+ 'ogg ' => 'vorbiscomment ' ,
231+ 'opus ' => 'vorbiscomment ' ,
232+ 'spx ' => 'vorbiscomment ' ,
233+ 'tta ' => 'ape ' ,
224234 'wav ' => 'id3 ' ,
235+ 'webm ' => 'matroska ' ,
225236 'wma ' => 'asf ' ,
237+ 'wv ' => 'ape ' ,
226238 default => null ,
227239 };
228240
@@ -232,21 +244,7 @@ private function parse(): self
232244 }
233245
234246 if ($ this ->type === 'id3 ' ) {
235- $ v1 = $ tags ->id3v1 ();
236- $ v2 = $ tags ->id3v2 ();
237-
238- $ year = $ v2 ?->year() ?? $ v1 ?->year();
239- $ this ->title = $ v2 ?->title() ?? $ v1 ?->title();
240- $ this ->artist = $ v2 ?->artist() ?? $ v1 ?->artist();
241- $ this ->album = $ v2 ?->album() ?? $ v1 ?->album();
242- $ this ->genre = $ v2 ?->genre() ?? $ v1 ?->genre();
243- $ this ->year = $ year ? (int ) $ year : null ;
244- $ this ->trackNumber = $ v2 ?->track_number() ?? $ v1 ?->track_number();
245- $ this ->comment = $ v2 ?->comment() ?? $ v1 ?->comment();
246- $ this ->albumArtist = $ v2 ?->band() ?? null ;
247- $ this ->composer = $ v2 ?->composer() ?? null ;
248- $ this ->discNumber = $ v2 ?->part_of_a_set() ?? null ;
249- $ this ->isCompilation = $ v2 ?->part_of_a_compilation() ?? false ;
247+ $ this ->parseId3 ($ tags );
250248 $ this ->isValid = true ;
251249 }
252250
@@ -256,37 +254,22 @@ private function parse(): self
256254 }
257255
258256 if ($ this ->type === 'vorbiscomment ' ) {
259- $ vorbis = $ tags ->vorbiscomment ();
260-
261- $ this ->title = $ vorbis ->title ();
262- $ this ->artist = $ vorbis ->artist ();
263- $ this ->album = $ vorbis ->album ();
264- $ this ->genre = $ vorbis ->genre ();
265- $ this ->trackNumber = $ vorbis ->tracknumber ();
266- $ this ->comment = $ vorbis ->comment ();
267- $ this ->albumArtist = $ vorbis ->albumartist ();
268- $ this ->composer = $ vorbis ->composer ();
269- $ this ->discNumber = $ vorbis ->discnumber ();
270- $ this ->isCompilation = $ vorbis ->compilation ();
271- $ this ->year = (int ) $ vorbis ->date ();
272- $ this ->encoding = $ vorbis ->encoder ();
273- $ this ->comment = $ vorbis ->description ();
257+ $ this ->parseVorbisComment ($ tags );
274258 $ this ->isValid = true ;
275259 }
276260
277261 if ($ this ->type === 'asf ' ) {
278- $ asf = $ tags ->asf ();
279-
280- $ this ->title = $ asf ->title ();
281- $ this ->artist = $ asf ->artist ();
282- $ this ->album = $ asf ->album ();
283- $ this ->albumArtist = $ asf ->albumartist ();
284- $ this ->composer = $ asf ->composer ();
285- $ this ->discNumber = $ asf ->partofset ();
286- $ this ->genre = $ asf ->genre ();
287- $ this ->trackNumber = $ asf ->track_number ();
288- $ this ->year = (int ) $ asf ->year ();
289- $ this ->encoding = $ asf ->encodingsettings ();
262+ $ this ->parseAsf ($ tags );
263+ $ this ->isValid = true ;
264+ }
265+
266+ if ($ this ->type === 'matroska ' ) {
267+ $ this ->parseMatroska ($ tags );
268+ $ this ->isValid = true ;
269+ }
270+
271+ if ($ this ->type === 'ape ' ) {
272+ $ this ->parseApe ($ tags );
290273 $ this ->isValid = true ;
291274 }
292275
@@ -304,6 +287,48 @@ private function parse(): self
304287 return $ this ;
305288 }
306289
290+ private function parseId3 (Id3AudioTag $ tags ): self
291+ {
292+ $ v1 = $ tags ->id3v1 ();
293+ $ v2 = $ tags ->id3v2 ();
294+
295+ $ year = $ v2 ?->year() ?? $ v1 ?->year();
296+ $ this ->title = $ v2 ?->title() ?? $ v1 ?->title();
297+ $ this ->artist = $ v2 ?->artist() ?? $ v1 ?->artist();
298+ $ this ->album = $ v2 ?->album() ?? $ v1 ?->album();
299+ $ this ->genre = $ v2 ?->genre() ?? $ v1 ?->genre();
300+ $ this ->year = $ year ? (int ) $ year : null ;
301+ $ this ->trackNumber = $ v2 ?->track_number() ?? $ v1 ?->track_number();
302+ $ this ->comment = $ v2 ?->comment() ?? $ v1 ?->comment();
303+ $ this ->albumArtist = $ v2 ?->band() ?? null ;
304+ $ this ->composer = $ v2 ?->composer() ?? null ;
305+ $ this ->discNumber = $ v2 ?->part_of_a_set() ?? null ;
306+ $ this ->isCompilation = $ v2 ?->part_of_a_compilation() ?? false ;
307+
308+ return $ this ;
309+ }
310+
311+ private function parseVorbisComment (Id3AudioTag $ tags ): self
312+ {
313+ $ vorbis = $ tags ->vorbiscomment ();
314+
315+ $ this ->title = $ vorbis ->title ();
316+ $ this ->artist = $ vorbis ->artist ();
317+ $ this ->album = $ vorbis ->album ();
318+ $ this ->genre = $ vorbis ->genre ();
319+ $ this ->trackNumber = $ vorbis ->tracknumber ();
320+ $ this ->comment = $ vorbis ->comment ();
321+ $ this ->albumArtist = $ vorbis ->albumartist ();
322+ $ this ->composer = $ vorbis ->composer ();
323+ $ this ->discNumber = $ vorbis ->discnumber ();
324+ $ this ->isCompilation = $ vorbis ->compilation ();
325+ $ this ->year = (int ) $ vorbis ->date ();
326+ $ this ->encoding = $ vorbis ->encoder ();
327+ $ this ->comment = $ vorbis ->description ();
328+
329+ return $ this ;
330+ }
331+
307332 private function parseQuicktime (Id3AudioTag $ tags ): self
308333 {
309334 $ quicktime = $ tags ->quicktime ();
@@ -349,4 +374,62 @@ private function parseQuicktime(Id3AudioTag $tags): self
349374
350375 return $ this ;
351376 }
377+
378+ private function parseAsf (Id3AudioTag $ tags ): self
379+ {
380+ $ asf = $ tags ->asf ();
381+
382+ $ this ->title = $ asf ->title ();
383+ $ this ->artist = $ asf ->artist ();
384+ $ this ->album = $ asf ->album ();
385+ $ this ->albumArtist = $ asf ->albumartist ();
386+ $ this ->composer = $ asf ->composer ();
387+ $ this ->discNumber = $ asf ->partofset ();
388+ $ this ->genre = $ asf ->genre ();
389+ $ this ->trackNumber = $ asf ->track_number ();
390+ $ this ->year = (int ) $ asf ->year ();
391+ $ this ->encoding = $ asf ->encodingsettings ();
392+
393+ return $ this ;
394+ }
395+
396+ private function parseMatroska (Id3AudioTag $ tags ): self
397+ {
398+ $ matroska = $ tags ->matroska ();
399+
400+ $ this ->title = $ matroska ->title ();
401+ $ this ->album = $ matroska ->album ();
402+ $ this ->artist = $ matroska ->artist ();
403+ $ this ->albumArtist = $ matroska ->album_artist ();
404+ $ this ->comment = $ matroska ->comment ();
405+ $ this ->composer = $ matroska ->composer ();
406+ $ this ->discNumber = $ matroska ->disc ();
407+ $ this ->genre = $ matroska ->genre ();
408+ $ this ->isCompilation = $ matroska ->compilation ();
409+ $ this ->trackNumber = $ matroska ->part_number ();
410+ $ this ->year = (int ) $ matroska ->date ();
411+ $ this ->encoding = $ matroska ->encoder ();
412+
413+ return $ this ;
414+ }
415+
416+ private function parseApe (Id3AudioTag $ tags ): self
417+ {
418+ $ ape = $ tags ->ape ();
419+
420+ $ this ->album = $ ape ->album ();
421+ $ this ->artist = $ ape ->artist ();
422+ $ this ->albumArtist = $ ape ->album_artist ();
423+ $ this ->comment = $ ape ->comment ();
424+ $ this ->composer = $ ape ->composer ();
425+ $ this ->discNumber = $ ape ->disc ();
426+ $ this ->genre = $ ape ->genre ();
427+ $ this ->isCompilation = $ ape ->compilation ();
428+ $ this ->title = $ ape ->title ();
429+ $ this ->trackNumber = $ ape ->track ();
430+ $ this ->year = (int ) $ ape ->date ();
431+ $ this ->encoding = $ ape ->encoder ();
432+
433+ return $ this ;
434+ }
352435}
0 commit comments