Sunday, December 17, 2023

Track genres have arrived. But now?

    

                

I would always recommend Plex as a music server in combination with the Plexamp app. 

However, there are some weaknesses. One of them is that it doesn't read the genre tags of the tracks at track level, but only at album level. This means that you cannot distinguish between the piano-accompanied ballad and the dance track on the same album.

Nor can you filter out the occasional Christmas song on an album or, conversely, elegantly add it to a Christmas playlist. 

As a workaround, however, you can use the mood tags, which can be edited at track level and are available for search functions.
If you don't want to do this track by track, the question arises as to whether you can quickly bulk tag the tracks to be tagged with a mood.

Is it christmas? How can I quickly tag many tracks with "christmas"?


You can do this by creating a playlist in the plex web app, for example with all tracks that have the word 'christmas' in the album or track name. You can then use a python script to tag all tracks in the playlist with the mood tag 'Christmas' (as a replacement for the missing genre tag). You can use this script, for example. 

In its latest version, plex recognizes track genres. However, at the moment they can't be edited in the interface. You can edit them in software like mp3tag and refresh the album though. Finally, editing is possible in plex web. Click on the stylo of the track and go to tags. If you don't have genres there, you are either on an older version of plex web or on a local version which has not been updated. 

Where are the track genres to be seen?

You can use the track genres as filters for say, a playlist which excludes some genres like Christmas or Classical Music. Go to library, tracks and you are able to list all tracks who have a particular genre or create playlists and collections using them as filters. 

However, you cannot see the filters in the album view. As a workaround, you can use python code to see and also to modify the genres. Here's some quick and dirty code which offers the missing album view.




Saturday, December 16, 2023

Create your own Radio: Here's how:

   

                

Plexamp is a wonderful companion app to listen to music in your plex library. You can create artist's radios, album mixes, or track radios.

But once you've worked up an appetite, you'll want more: 

You can't create radios in plex web, the sonic proximity to the source tracks can't be determined and you can't combine two tracks or two artists. You also can't rule out the possibility of tracks heard in the last few weeks reappearing, etc. 

But wait, all this can be achieved with a python script.

An example can be found with 'Plex TraxRadio' on my github pages. The script stores in a plex playlist some tracks of the artist the source track comes from and adds sonically similar tracks of a certain distance. I also remove possible duplicates and take into account the rating of the tracks. In the published version, no tracks with a bad rating are included, but unrated tracks are. 

Have no fear...


It should be said again that I am not a professional coder, quite the opposite. Most of it was created in interaction with ChatGPT...

The possibilities with python are almost endless. For example, you could also take into account the genre(s) and much more.... 


Friday, September 15, 2023

Ratings can be exported and saved to the files!

    

                

Ratings can be exported and saved to the files!


Even regular users of plex do not know how ratings they gave to tracks in the music library can be exported and saved in the files. In the past, I have used a workaround which meant to create a playlist with tracks of the same rating, exporting that playlist and import it to a tagger like mp3tag.

While this can be done, there is also the possibility to use a python script which fetches the ratings of the tracks be it in the whole library or just an album or a subset of the library like for example all tracks which were rated in the last week or so.  Once this is working, it is by far a faster method to backup all ratings!

Python is not so difficult as one would expect, especially if you can get mostly helpful hints from chatgpt and the like. For starters you might take a look at some scripts on github. But beware: they usually cannot be used out of the box and must be adapted to your specific use case. 

The wonderful world of filepaths and non-standardized tagging

Under "plex_for_music, you will find two scripts which may serve as a starting point. One is updating the files the ratings of which were updated in plex in the last days, weeks or months, the other takes a different approach and updates all files with plex user ratings in a given range of albums, for example all albums which have A as the first letter in their title. It might be a good idea to start with the latter one to initially update the whole library and then use the former to update from time to time. 

If you take a look at the codes you will see that the first thing you have to do is adapting it to your setting. If there is only one operating system involved, some of the transforming stuff can be deleted. Of course you may have your own folder structure and you have to adapt the script to it. Furthermore, the code to write the rating to the files is specific for the way media monkey works and if you don't use media monkey be aware that other players might take a different approach and change the code accordingly. 

Saturday, July 1, 2023


Backing up album information and the joy of scripting.

In combination with plexamp, plex is a great music server and I cannot find any alternative really working as a substitute for either plex or spotify. 


Different Levels

But you have to accept that plex was not built for music and thus has a different approach than mp3 players like foobar or music organization tools like mediamonkey: It is focussed on the artist and album level. This results in the one major flaw plex has: It is not working well when it comes to compilations. (The reason is obvious: On the artist/album level, compilations do not show the artists on the different tracks and plex will (if id3 tags are properly set) recognize such albums as coming from "Various Artists". )

This difference in approach means that by far not every valuable information in your plex library is mirrored by id3tags in your files: Information such as artist info, similar artists, album reviews, sonically similar albums are on the artist or album level and therefore not reflected in the tags of individual files. 

A loss of that information certainly is tolerable if you have never added anything to what plex automatically has created. But over time, a lot of us added either a missing album review, wrote one on our own or simply changed the Release Date of the record to the date where the recording was actually made (which helps a lot to have consistent decade playlists!)


Backup with scripts is no rocket science

Although plex offers the possibility to backup your database (which is always a good idea), this does not help if you want to access the information outside of plex. And you never know, no software will be there forever, you should never completely rely on proprietary code. 

So this is where scripting comes in. If you want to maintain your metadata well, you can't do without a script or two anyway, but you should run a script for backup purposes at the latest. 

For backing up album reviews and the recording data of albums, I provide the script PlexExportAlbumNFO on github. It runs through all the albums in the library and creates an .nfo file in the folder structure of the hard disk. 

If you are not familiar with python, you can make the script work with a few simple steps. Even for beginners, this is not rocket science and may be feasible with a little research on the internet or in discussion with bing chat. 

And if you're hungry for more, I've provided a number of other scripts for maintaining metadata specifically for music libraries in plex: jackctra/plex_for_music .


Friday, June 16, 2023

Grouping albums by type - how it works... Is it good for anything?




 On the artist page, plex can group regular albums of the artist and in seperate lists, live albums, compilations, EPs and Singles and so forth. You can enable that in settings, under library. 

Admittedly, that looks nice on the artist page but...
... is that all? I haven't found a way in plex itself to use that grouping for filtering any results and the searchbar doesn't look at the album type either. So you would have to add a mood tag like "live" to the album to use that for filtering.   No: Filtering is possible in the album view under format (Album, Single, EP) or type (Compilation, Live, Remix etc.)

Plexamp also can use either the „album formats“ album, single or eps or the album types live, compilation, soundtracks or mixes for filtering and creating playlists. Hence you can use those playlists for further refinement.

So if you are interested in album formats or types, here is how it works:

When scanning the file, Plex uses the MusicBrainz tag "Release Type" for sorting. If you want to do that manually, you can use mp3tag and add a field "RELEASETYPE" to the file's metadata. For live recordings, enter the value "album;live", for compilations "album;compilation". Make sure that the field and the values are EXACTLY spelled like this, otherwise plex would not recognize the tag. 

Plex takes some time for processing, the album poster even vanishes for some time from the artist page. 

NEW: In a newer post, I linked a python script to automate the procedure. 


Saturday, March 11, 2023

  workarounds



Playlists



Merging playlists is not possible by using a direct command. But you can use a workaround:

1. Open Playlist „A“ and put all tracks into the queue for listening (use the 3dots-context menu for that)
2. Open Playlist „B“ and do the same for the tracks in this playlist
3. Now open the queue and create a new playlist. In order to do so, go to the listing symbol in the player first and all tracks will be displayed. Then, use the  symbol in the upper right corner with the plus-sign to create your new merged playlist.

Wednesday, February 1, 2023

Move plex server from Linux/Synology to Windows PC and vice versa



 workarounds

Move a Server without losing Data


  I had my music library on a Synology NAS and was quite happy with it - till I discovered plexamp and its sonic analysis feature which cannot be used on an ARM cpu like mine. I decided to move the server to a powerful windows system, did the sonic analysis there and moved the whole library again to a linux mini pc - including the sonic analysis files. The files themselves are still kept on the NAS.

You have to copy the database and change the path structure like this (steps for moving from a Synology Nas (Server 1) to windows PC (Server2) , if you want to move from windows to linux, the path structure is of course the other way around. 


  1. Set up server 2, create new library pointing at the files on the NAS, start search and cancel immediately after.
  2. Turn off „Empty recycle bin automatically“
  3. Note root path by looking at a file, you need that later on.
  4. Stop both! servers.
  5. Create a Back up to a new folder with file station. The Database is found /var/packages/PlexMediaServer/shares/PlexMediaServer/AppData/Plex Media Server/Plug-in Support/Databases. Don‘t touch original database just in case something goes wrong. Also backup folders metadata and media.
  6. Adjust paths. Use "DB Browser for SQLite" (sqlitebrowser.org), SQLiteSpy is recommended in forums, but it did not work.a) Open the database com.plexamp.plugins.library.db, which can be found in Windows in the folder appdata/local/Plex Media Server/Plug-in Support/Databases. Click on the tab „Browse Data“.b) Then go to the section_locations table and change the root path as required for the new server.c) Change all single entries, because the slashes have to become backslashes. Also the root location is different. For a Music library, you have to go to the section „media_parts“ and there to the column „ file“ Replace slashes with backslashes using the commands update media_parts set file = replace(file, '/', '\');and e.g. update media_parts set file = replace(file, '/drive1', 'D:');.
  7. Save (very important! The UI looks like it automatically saves changes, but it doesn‘t)
  8. Replace .db on server 2. You may also replace Media and metadata which were backed up in step 2. If you have already sonic analysis files, move that folder too. 
  9. Restart server 2 and compare.