mp4-tag.lisp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. ;;; -*- Mode: Lisp; show-trailing-whitespace: t; Base: 10; indent-tabs: nil; Syntax: ANSI-Common-Lisp; Package: MP4-TAG; -*-
  2. ;;; Copyright (c) 2013, Mark VandenBrink. All rights reserved.
  3. (in-package #:mp4-tag)
  4. ;;; Abstract TAG interface
  5. (defmethod album ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-album+))
  6. (defmethod album-artist ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-album-artist+))
  7. (defmethod artist ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-artist+))
  8. (defmethod comment ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-comment+))
  9. (defmethod composer ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-composer+))
  10. (defmethod copyright ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-copyright+))
  11. (defmethod year ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-year+))
  12. (defmethod encoder ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-encoder+))
  13. (defmethod groups ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-groups+))
  14. (defmethod lyrics ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-lyrics+))
  15. (defmethod title ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-title+))
  16. (defmethod writer ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-writer+))
  17. (defmethod compilation ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-compilation+))
  18. (defmethod disk ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-disk+))
  19. (defmethod tempo ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-tempo+))
  20. (defmethod genre ((me mp4-file-stream))
  21. (let ((genre (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-genre+))
  22. (genre-x (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-genre-x+)))
  23. (assert (not (and genre genre-x)))
  24. (cond
  25. (genre (format nil "~d (~a)" genre (mp3-tag:get-id3v1-genre genre)))
  26. (genre-x (format nil "~d (~a)" genre-x (mp3-tag:get-id3v1-genre genre-x)))
  27. (t "None"))))
  28. (defmethod track ((me mp4-file-stream))
  29. (let ((track (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-track+))
  30. (track-n (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-track-n+)))
  31. (assert (not (and track track-n)))
  32. (if track
  33. track
  34. track-n)))
  35. (defmethod show-tags ((me mp4-file-stream) &key (raw nil))
  36. "Show the tags for an MP4-FILE. If RAW is non-nil, dump the DATA atoms; else show subset of DATA atoms"
  37. (format t "~a~%" (stream-filename me))
  38. (if raw
  39. (progn
  40. (mp4-atom:mp4-show-raw-tag-atoms me)
  41. (if (audio-info me)
  42. (mp4-atom:vpprint (audio-info me) t)))
  43. (let ((album (album me))
  44. (album-artist (album-artist me))
  45. (artist (artist me))
  46. (comment (comment me))
  47. (compilation (compilation me))
  48. (composer (composer me))
  49. (copyright (copyright me))
  50. (disk (disk me))
  51. (encoder (encoder me))
  52. (genre (genre me))
  53. (groups (groups me))
  54. (lyrics (lyrics me))
  55. (tempo (tempo me))
  56. (title (title me))
  57. (track (track me))
  58. (writer (writer me))
  59. (year (year me)))
  60. (if (audio-info me)
  61. (mp4-atom:vpprint (audio-info me) t))
  62. (when album (format t "~&~4talbum: ~a~%" album))
  63. (when album-artist (format t "~4talbum-artist: ~a~%" album-artist))
  64. (when artist (format t "~4tartist: ~a~%" artist))
  65. (when comment (format t "~4tcomment: ~a~%" comment))
  66. (format t "~4tcompilation: ~[no~;yes;unknown~]~%" (if compilation compilation 2))
  67. (when composer (format t "~4tcomposer: ~a~%" composer))
  68. (when copyright (format t "~4tcopyright: ~a~%" copyright))
  69. (when disk (format t "~4tdisk: ~a~%" disk))
  70. (when encoder (format t "~4tencoder: ~a~%" encoder))
  71. (when genre (format t "~4tgenre: ~a~%" genre))
  72. (when groups (format t "~4tgroups: ~a~%" groups))
  73. (when lyrics (format t "~4tlyrics: ~a~%" lyrics))
  74. (when tempo (format t "~4ttempo: ~a~%" tempo))
  75. (when title (format t "~4ttitle: ~a~%" title))
  76. (when track (format t "~4ttrack: ~a~%" track))
  77. (when writer (format t "~4twriter: ~a~%" writer))
  78. (when year (format t "~4tyear: ~a~%" year)))))