Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting metadata from audio resources #10151

Open
jsilland opened this issue Aug 5, 2022 · 3 comments
Open

Extracting metadata from audio resources #10151

jsilland opened this issue Aug 5, 2022 · 3 comments

Comments

@jsilland
Copy link

jsilland commented Aug 5, 2022

I would like to extend Hugo's resource handling to add first-class support for audio files (mp3 / aac / flac), including the ability to extract text metadata (artist / album / etc…) as well as cover art. Hugo currently special-cases image resources and provides APIs to operate on the content of an image and to extract EXIF data; I would like to add an equivalent resource type to similarly allow extracting metadata from audio files.

My primary use case is to embed audio content on my website without having to duplicate the files' existing metadata in the declaration of a page resource — this would greatly reduce the toil associated with publishing new audio content over time. I don't foresee a need to manipulate or access the audio content itself, just the metadata which is accessible as part of those file formats.

I am happy to put work into making this happen — I am comfortable writing Go and there are existing native libraries to perform the tag parsing, e.g. https://github.com/dhowden/tag. I have seen the recent addition to the contribution guide mentioning not wanting to accept patches for additional features; I'd be happy to trade one or few bugfixes in order to land this one. Either way, please let me know if this seems like a reasonable addition to Hugo, either now or in the future.

@jsilland
Copy link
Author

FYI I now have a working prototype of this at 9513ea2 — it's very early but it seems to work okay, and includes support for turning cover art into proper Hugo image resources. The following template gets rendered as expected:

<ul>
  {{ $audioResources := $.Page.Resources.ByType "audio" }} 
  {{ range $index, $audioFile := $audioResources }}
    <li>
      {{ with $audioFile.AudioTags }}
        <a href="{{ $audioFile.RelPermalink }}">
          {{ .Artist }}
          {{ with .Art }}
            <img src="{{ .RelPermalink }}" />
          {{ end }}
        </a>
      {{ end }}
    </li>
  {{ end }}
</ul>

My next step is to clean up the code and write tests — this is not ready for review at this time but I wanted to share the progress

@rthinkel
Copy link

This is awesome, has there been any further progress with it? I'd love to be able to implement this feature on my site. Thank you for your work!

Copy link

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@github-actions github-actions bot added the Stale label Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants