Jump to content

selected_aa filenames clarification


Go to solution Solved by maxmp,

Recommended Posts

I'm writing a script to (semi-)automatically embed covert art files from selected_aa into the song files themselves, and I'd like some clarification on how exactly Poweramp selects image files for a track.

It seems as though it first tries to look for an image file with the name

{artist tag content} - {album tag content}.jpg

and if that file isn't found, it looks for the filename

{artist tag content} - {title tag content}.jpg

, ignoring the albumartist field entirely.

I've also noticed the tag contents had leading/trailing whitespace removed, and special characters replaced with underscores. I've found the characters []()&/"\' but I'm not sure if that's all of them.

Is this correct? Or is there more to it? It's hard for me to confirm because I have a lot of files to go through, and there's also some leftover album art that's not in use anymore (from deleted/retagged songs).

Thanks in advance!

Edited by kwyntes
additional info
Link to comment
Share on other sites

Leading/trailing whitespace and many special characters cannot exist in filenames (exactly which ones varies by file system) so to be safe most are replaced with underscore for simplicity. The naming convention was designed to be able to find the images based on the tag text, not really to be reverse-engineered back the other way. But yes, there are also variations for when you are dealing with non-album material, etc. Max could elaborate on the exact logic naming though.

Andre

Link to comment
Share on other sites

Posted (edited)
21 minutes ago, andrewilley said:

Leading/trailing whitespace and many special characters cannot exist in filenames (exactly which ones varies by file system) so to be safe most are replaced with underscore for simplicity.

What I found was that if the artist tag ends in a space, the resulting image filename will still have only a single space before the dash in the filename.

21 minutes ago, andrewilley said:

The naming convention was designed to be able to find the images based on the tag text, not really to be reverse-engineered back the other way.

I'm not trying to reverse-engineer it the other way, I'm trying to do the same thing Poweramp does to find the appropriate images for a given song file.

 

What I've managed to find right now is this, and while it seems to work, I'd like to know if this is actually equivalent to what Poweramp does internally.

SPECIAL_CHARS =
  # windows disallowed
  '<>:"/\\|?*' +
  # found myself
  '()[]&\''
special_chars_rx = f'[{re.escape(SPECIAL_CHARS)}]'

aa_fname_single = f'{re.sub(special_chars_rx, '_', artist_tag).strip()} - {re.sub(special_chars_rx, '_', title_tag).strip()}.jpg'
aa_fname_album  = f'{re.sub(special_chars_rx, '_', artist_tag).strip()} - {re.sub(special_chars_rx, '_', album_tag).strip()}.jpg'

if os.path.isfile(aa_fname_album):
  # embed aa_fname_album into the song file
elif os.path.isfile(aa_fname_single):
  # embed aa_fname_single into the song file
Edited by kwyntes
fix formatting
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...