beets icon indicating copy to clipboard operation
beets copied to clipboard

Plugin to generate NFO files, especially for Kodi

Open OmgImAlexis opened this issue 9 years ago • 25 comments

It'd be great to see an option for NFO files being written for artists and albums which would mean the MBID can be saved as well as other details. This helps with things like KODI, Plex, etc. and would also help with beets and updating music libraries even if the database file is deleted.

For an example of the NFO files have a look at what KODI accepts. Most other platforms that use NFO files for music either use the same format as KODI or an extended format which uses KODI's as a base.

http://kodi.wiki/view/NFO_files/Music http://kodi.wiki/view/Music_tagging (go down to "6 NFO files")

OmgImAlexis avatar Jan 24 '17 09:01 OmgImAlexis

+1000000000000 And there is no other software which can do this for music. And maybe in the future artist artwork, thumbs, backgrounds from https://fanart.tv/music-fanart/ for ex. can be fetched too?

akyag avatar Jan 24 '17 10:01 akyag

@akyag: there's already a fanart.tv backend for the fetchart plugin, so that part is done

ghost avatar Jan 24 '17 11:01 ghost

@akyag : sorry, i thought we did have fanart.tv already, but this implies not so https://github.com/beetbox/beets/issues/889

ghost avatar Jan 24 '17 11:01 ghost

Ah, so these are little XML files containing metadata? Seems like a fine request.

sampsyo avatar Jan 24 '17 13:01 sampsyo

Hi, @sampsyo! Where can we store .nfo files? I think I can implement this feature.

tigranl avatar Mar 04 '17 20:03 tigranl

Cool! I actually don't know where Kodi expects them to be... perhaps in the album directory (album.path in beets)?

sampsyo avatar Mar 04 '17 20:03 sampsyo

Another one question. I assume it should be a plugin?

tigranl avatar Mar 04 '17 20:03 tigranl

Yeah, totally—integrations with specific other software count as narrow enough use cases that they should be plugins.

sampsyo avatar Mar 04 '17 21:03 sampsyo

Hi @tigranl. I'm also interested in implementing this feature. If you have already started something in a repo would you mind sharing so maybe we can collaborate on this? Also, do you think this kind of feature would be more useful as a CLI command, or as part of the importing process?

bajosoto avatar Mar 06 '17 17:03 bajosoto

And to your question, it's two kinds of file. artist.nfo goes in the artist folder and album.nfo in the album one. Also, according to the wiki, "Both album.nfo and artist.nfo files can contain the MusicBrainz tag or simply contain a URL to the correct page on the MusicBrainz website". Maybe this would be a much simpler approach than generating the xml structure?

bajosoto avatar Mar 06 '17 18:03 bajosoto

@bajosoto I just started, I'll make a PR soon. I think it would be more appropriate as part of the importing process.

tigranl avatar Mar 06 '17 18:03 tigranl

Yeah, using just a URL would simplify everything.

tigranl avatar Mar 06 '17 18:03 tigranl

Ok, thanks. I have a very, very simple and rough (but working!) implementation of a plugin here that generates the .nfo file for albums (no artists yet) as part of the import process like you mentioned. I am aware I'm doing a second call to music brainz that could (and should) be spared since this is already part of the import process, but I'm not quite sure of how can I pull the data that is already in the task in commands.py (the url is already fetched there) all the way into my plugin. It's probably a silly question, but I'm a beginner with python and any input or feedback would be much appreciated. :D

bajosoto avatar Mar 06 '17 20:03 bajosoto

Cool, thanks for getting this started!

It's actually pretty simple to get the ID out of the album object. You can just use album.mb_albumid to get the MBID that has been assigned to the album after matching.

If you're curious about the full set of fields that are available on album, it's here.

sampsyo avatar Mar 07 '17 00:03 sampsyo

How did I miss that..? Thanks @sampsyo. I'll improve it tomorrow :bowtie:

bajosoto avatar Mar 07 '17 00:03 bajosoto

It might be a good idea to use 'import' event, so it will work with singletones as well.

tigranl avatar Mar 07 '17 12:03 tigranl

how would it work for singletons? one nfo for every single track?

akyag avatar Mar 07 '17 16:03 akyag

Yep.

tigranl avatar Mar 07 '17 17:03 tigranl

https://gist.github.com/tigranl/79652e7dfac1d6216c1c0a2d0bbf696f

tigranl avatar Mar 07 '17 18:03 tigranl

Hey @tigranl, from what I see in the KODI wiki, there seems to be no template for singletons so these would probably not be recognized by it (perhaps this works in Plex or others?). Nevertheless they can be generated. I believe using the item_imported event would be a good idea, alongside album_import since it's not called during album imports from what I understand from the documentation. @sampsyo, is there any way to fetch the album artist path from within the plugin based on the path configuration?

bajosoto avatar Mar 12 '17 18:03 bajosoto