regosen / get_cover_art

Batch cover art downloader and embedder for audio files
MIT License
76 stars 7 forks source link

Unable to download when album tag ends with [Disc 1] #2

Closed pidiggy closed 3 years ago

pidiggy commented 3 years ago

First thanks for creating this module as I'm using to covert my google music to what my synology Audio Station requires...

Ran into the following issue when it tried to download album art for my Billy Joel two set CD...

tags/metadata in mp3 file given to finder.scan_file was: 'ID3TagV2': {'artist': 'Billy Joel', 'album': 'The Essential Billy Joel [Disc 1]', 'song': 'Piano Man', 'track': '1/18', 'genre': 'Rock', 'composer': 'Billy Joel', 'year': '2001'}

Output from finder.scan_file(): ERROR encountered downloading for The Essential Billy Joel [Disc 1]

Perhaps the de-slug routine could be updated to chop off the "[Disc 1]" and allow the search in the apple web site to work.

regosen commented 3 years ago

Hi pidiggy. I began investigating this, but it seems that as of today I can no longer download anything. It looks like Apple Music had changed their search result contents to the extent that even the search results don't appear in the source. I'm not sure how to fix this with my current script.

Are you experiencing this error for the rest of your library as well?

pidiggy commented 3 years ago

That bites. I have not run against my whole collection yet... Just a few files I thought might be tricky... Was planning to just download them manually from discogs.com... album art is really all I need at this point.Thanks again for posting this module.

Sent from Yahoo Mail on Android

On Sun, Nov 29, 2020 at 5:58 PM, Rego Sennotifications@github.com wrote:

Hi pidiggy. I began investigating this, but it seems that as of today I can no longer download anything. It looks like Apple Music had changed their search result contents to the extent that even the search results don't appear in the source. I'm not sure how to fix this with my current script.

Are you experiencing this error for the rest of your library as well?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

regosen commented 3 years ago

Update: I'm able to get the images through a slightly different query now. Stay tuned, I should have a fix in the next couple of days.

regosen commented 3 years ago

Ok, I believe I have fixed both this issue and accounted for the Apple Music changes. Can you try again with the latest version of this script?

pidiggy commented 3 years ago

I'll retry this also this weekend and give feedback. Thanks.

regosen commented 3 years ago

Just checking in, have you had a chance to try out the changes?

pidiggy commented 3 years ago

Sorry took me awhile but just got around to testing it out.

My goals (required for Synology Audio Station player): For each song: a) Create artist directory if doesn't already exists. b) Create Album directory if doesn't already exists c) Always get album artwork if available and place into Album dir if doesn't exist d) If no artwork in song and "song" artwork available, embed into mp3 file. e) Rename album cover art work as "cover.jpg" as Synology Audio Station requires).

So trying to get this module to resolve c-d above.

I tried all four combinations of test/force args to CoverFinder with new get-cover-art-1.3.6 C1: 'test': True, 'force': True, C2: 'test': False, 'force': True, C3: 'test': False, 'force': False, C4: 'test': True, 'force': False,

Maybe I should have clarified goal "d)" above. Combo' C2 downloaded but also overwrote the existing "song" art-work with album cover art-work (1999.mp3 had artwork embedded). Combo C3 skipped both on 1999.mp3 but "Piano Man.mp3" that had no embedded art-work, downloaded the album cover but then also embedded the same album cover art-work instead of embedding the "song" art-work. Is this because it didn't find the "song" art-work?

Does your tool try to find the "song" art-work or just get the album cover art-work? Ideally it would try to get "song" art-work and if none found reference the "force" (or new arg), to then optionally insert the cover as song art-work.

Now C1 gets me the album cover for each but when I try C4 it skips the cover when a song has embedded art-work and both C2 and C3 overwrites the existing "song" artwork. So only way I know to get my desired behavior would be to perform C1 then perform C3 on a copy of mp3 file in /tmp dir first. Then extract the embedded art-work from temp file and if same as album cover skip otherwise assume it got the "song" artwork and overwrite the target destination mp3 file.

Example output using C3 inputs: finder = CoverFinder({'verbose': True, 'test': False, 'force': False, 'dest': album_dir})

` (mte) pidiggy@n5110:~/mypy$ ./mp32dsa.py mp3 input files from: ./gmin/

Fleetwood Mac - The Very Best of Fleetwood(005)(1).mp3 : {'artist': 'Fleetwood Mac', 'band': 'Fleetwood Mac', 'album': 'The Very Best of Fleetwood Mac [Reprise] Disc 1', 'song': 'Rhiannon [Single Version]', 'track': '5/0', 'genre': 'Rock', 'composer': 'Stevie Nicks', 'year': '2002'}

Prince - The Very Best of Prince - 1999.mp3 : {'artist': 'Prince', 'band': 'Prince', 'album': 'The Very Best of Prince', 'song': '1999', 'track': '2/0', 'genre': 'Soul And R&B', 'composer': 'Prince', 'year': '2001'}

Billy Joel - The Essential Billy Joel [Dis(002).mp3 : {'artist': 'Billy Joel', 'album': 'The Essential Billy Joel [Disc 1]', 'song': "You're My Home", 'track': '2/18', 'genre': 'Rock', 'composer': 'Billy Joel', 'year': '2001'}

Billy Joel - The Essential Billy Joel [Dis(001)(1).mp3 : {'artist': 'Billy Joel', 'album': 'The Essential Billy Joel [Disc 1]', 'song': 'Piano Man', 'track': '1/18', 'genre': 'Rock', 'composer': 'Billy Joel', 'year': '2001'}

Song Count 4 TargetOut: /home/pidiggy/mypy/./sast/

Creating: /home/pidiggy/mypy/./sast/Fleetwood Mac Creating: /home/pidiggy/mypy/./sast/Fleetwood Mac/The Very Best of Fleetwood Mac Already Has Art: True CoverFinder args: {'verbose': True, 'test': False, 'force': False, 'dest': '/home/pidiggy/mypy/./sast/Fleetwood Mac/The Very Best of Fleetwood Mac'} Skipping existing embedded artwork for /home/pidiggy/mypy/sast/Fleetwood Mac/The Very Best of Fleetwood Mac/Fleetwood Mac - The Very Best of Fleetwood Mac Reprise Disc 1.jpg Song: /home/pidiggy/mypy/./sast/Fleetwood Mac/The Very Best of Fleetwood Mac/Rhiannon [Single Version].mp3 Done

Creating: /home/pidiggy/mypy/./sast/Prince Creating: /home/pidiggy/mypy/./sast/Prince/The Very Best of Prince Already Has Art: True CoverFinder args: {'verbose': True, 'test': False, 'force': False, 'dest': '/home/pidiggy/mypy/./sast/Prince/The Very Best of Prince'} Skipping existing embedded artwork for /home/pidiggy/mypy/sast/Prince/The Very Best of Prince/Prince - The Very Best of Prince.jpg Song: /home/pidiggy/mypy/./sast/Prince/The Very Best of Prince/1999.mp3 Done

Creating: /home/pidiggy/mypy/./sast/Billy Joel Creating: /home/pidiggy/mypy/./sast/Billy Joel/The Essential Billy Joel Already Has Art: False CoverFinder args: {'verbose': True, 'test': False, 'force': False, 'dest': '/home/pidiggy/mypy/./sast/Billy Joel/The Essential Billy Joel'} Downloaded cover art: /home/pidiggy/mypy/sast/Billy Joel/The Essential Billy Joel/Billy Joel - The Essential Billy Joel Disc 1.jpg Embedding art into /home/pidiggy/mypy/./sast/Billy Joel/The Essential Billy Joel/You're My Home.mp3 Song: /home/pidiggy/mypy/./sast/Billy Joel/The Essential Billy Joel/You're My Home.mp3 Done

Already Has Art: False CoverFinder args: {'verbose': True, 'test': False, 'force': False, 'dest': '/home/pidiggy/mypy/./sast/Billy Joel/The Essential Billy Joel'} Skipping existing download for /home/pidiggy/mypy/sast/Billy Joel/The Essential Billy Joel/Billy Joel - The Essential Billy Joel Disc 1.jpg Embedding art into /home/pidiggy/mypy/./sast/Billy Joel/The Essential Billy Joel/Piano Man.mp3 Song: /home/pidiggy/mypy/./sast/Billy Joel/The Essential Billy Joel/Piano Man.mp3 Done `

Thanks again for creating this tool!!

pidiggy commented 3 years ago

Now I have assumed that there is artwork for every individual song in an album or single... If this is not the case maybe asking for your tool to find unique art-work per song is out of scope... or too complicated/complex since dependent on the database you can query to obtain that info... I would not ask you to spend more of your time on this... Maybe someone can offer help or point to a database that makes it easy to locate unique art-work per song...that is different than album cover art. Regards, -pidpiddle

pidiggy commented 3 years ago

Forgot to mention using C1 gets cover artwork for all of my test mp3 songs but NOT for "Rhiannon [Single Version].mp3". Actual none of the combo' C[1-4] also does not produce a download of the cover art work (should if force=True, IMO).

Perhaps it didn't find one. In this case could CoverFinder emit a message that it wasn't able to retrieve the cover artwork?

regosen commented 3 years ago

You're welcome, and thanks for all this feedback!

Album vs song: This script ignores the song name and assumes a 1:1 relationship between album and artwork. In my library I personally have albums named "miscellaneous" where I didn't bother with complete albums (but still wanted to lump the artist's songs together to avoid awkward navigations in Apple's Music app). This script doesn't help with those, because if I could only use artist and song title, Apple's search API would often (usually, in my experience) have multiple results and no way to determine which album art to use. It doesn't sound exactly like your situation, but if similar then I would recommend a tool like Metadatics that gives you a GUI and a way to choose from the multiple matches.

"message that it wasn't able to retrieve the cover artwork": did you fail to get such a message even with verbose set to True?

Or maybe I didn't get my head around your use case. The stdout of the tool looks correct based on your commandline parameters and the "already has artwork" values you stated.

pidiggy commented 3 years ago

Using C1 on Prince 1999.mp3, which has artwork embedded still gets me the cover artwork for album... which is ideal since they are different artworks

Creating: /home/pidiggy/./sast/Prince Creating: /home/pidiggy/./sast/Prince/The Very Best of Prince Already Has Art: True CoverFinder args: {'verbose': True, 'test': True, 'force': True, 'dest': '/home/pidiggy/./sast/Prince/The Very Best of Prince'} Downloaded cover art: /home/pidiggy/sast/Prince/The Very Best of Prince/Prince - The Very Best of Prince.jpg Song: /home/pidiggy/./sast/Prince/The Very Best of Prince/1999.mp3 Done

However, using C1 on Rhiannon [Single Version].mp3, which also has artwork embedded does NOT get the cover artwork for album... Creating: /home/pidiggy/./sast/Fleetwood Mac Creating: /home/pidiggy/./sast/Fleetwood Mac/The Very Best of Fleetwood Mac Already Has Art: True CoverFinder args: {'verbose': True, 'test': True, 'force': True, 'dest': '/home/pidiggy/./sast/Fleetwood Mac/The Very Best of Fleetwood Mac'} Song: /home/pidiggy/./sast/Fleetwood Mac/The Very Best of Fleetwood Mac/Rhiannon [Single Version].mp3 Done

So ideally it could emit warning (even better return a True/False flag) when it failed or success... S if it does not emit log file "Downloaded cover art:*" I'll have to assume it failed.

BTW I get the following error when executing "mp3tags = MP3File(fpath)" statement on another Prince mp3 file. Any ideas on how to workaround the error... or perhaps I'll have to use a "try:/exeption:" block to skip processings these files that have issue decoding the tags inside... Suspect same error will appear when I eventually call finder = CoverFinder(cf_args), finder.scan_file(outmp3f)...

Prince _ the Revolution - The Very Best of(007).mp3 Traceback (most recent call last): File "/tmp/mte/lib/python3.6/site-packages/mp3_tagger/id3.py", line 129, in _unpack_bytes val = self.bytes_.decode() UnicodeDecodeError: 'utf-8' codec can't decode byte 0x98 in position 1: invalid start byte

Thanks.

regosen commented 3 years ago

Regarding mp3tags = MP3File(fpath) I don't see anything called MP3File(...) in this repo, did you mean line 8 in meta_mp3.py: self.audio = MP3(path, ID3=ID3)? If so, I could wrap that in a try-except block.

Nevertheless, the relevant code from scan_file() is already wrapped in its own try-except block, which should print ERROR: failed to process ....

Would you mind emailing me the file that caused the exception? My email is listed in my profile.

regosen commented 3 years ago

I just posted a new version of the script (1.3.7) that expands the scope of --force. Can you try again with the updated script?

Someone else was able to email me a file, and I helped resolve their issue. If you still have problems, please email me a file that fails, that will enable me to help you more effectively.

pidiggy commented 3 years ago

Instead of using MP3File which get_cover_art uses and failed on some mp3 files, I now use "eyed3" which is able to open those that failed. I still call CoverFinder to see if I can get the artwork and now I see it does emit failure message when it fails.

Creating: /home/test/./sast/Naked Eyes Creating: /home/test/./sast/Naked Eyes/Sounds of the Eighties: 1983 Song Has Art: True CoverFinder args: {'verbose': True, 'test': True, 'force': True, 'dest': '/home/test/./sast/Naked Eyes/Sounds of the Eighties: 1983'} Failed to find matching artist (various artists) and album (sounds of the eighties: 1983) Song: /home/test/./sast/Naked Eyes/Sounds of the Eighties: 1983/Always Something There to Remind Me.mp3 None Done

Now my next challenge is to get the artwork for the "original" album that a song was released like the one above when its from a CD I bought that is a mix of several... As you can imagine, the artwork for "various artists" is the same for every song which is NOT useful when displayed on player.

So now I need to find the "original" album name given artist and song title... but can't find an easy way... I can or course google it... but scraping for the output is extra work I was hoping to avoid... Any ideas for getting that album name?

regosen commented 3 years ago

I see what you mean. Unfortunately this script is not intended for that purpose. "Always Something There To Remind Me" by Naked Eyes was on several of their releases. Even if you only care about the "original" release, that song was originally released on the UK "Burning Bridges" album, the US "Naked Eyes" album (with different artwork and slightly different tracklisting), and as a single. A good tool to determine this would still warrant some kind of user interface to let you choose among these. This script is not that tool.

Taking a step back, this conversation has turned into something very different from the original issue, which I fixed. Do you mind if I close this issue? Feel free to open a separate issue if you still think this script should address this new use case.

regosen commented 3 years ago

Closing because the latest version of the script chops off [Disc 1] etc when searching for matches. Thanks for all your investigations!

Please open new issues for any requests unrelated to this.