beets icon indicating copy to clipboard operation
beets copied to clipboard

convert: An invalid destination path can arise when auto-converting an item with missing metadata

Open 2V3EvG4LMJFdRe opened this issue 2 years ago • 6 comments

Problem

Running this command in verbose (-vv) mode:

$ beet -vv import /Volumes/Media/Audio/WAV/Nintendo\ 3DS/Let\'s\ Golf\ 3D 

Led to this problem:

...
Sending event: item_removed
Sending event: database_change
Sending event: item_removed
Sending event: database_change
Sending event: database_change
Sending event: album_removed
Sending event: item_removed
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/beets/util/__init__.py", line 462, in copy
    shutil.copyfile(path, dest)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/shutil.py", line 264, in copyfile
    with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: b'//00 .mp3'

Error: Permission denied while copying /var/folders/4y/96gd8p814dq0mlqc24_6_bq00000gn/T/tmpgi8z7mpl.mp3 to //00 .mp3

Here's a link to the music files that trigger the bug (if relevant): https://mega.nz/file/ONlnCbqY#HpmD5t5GwBRiG01i3Fr-RmSOpgSWviYyDUheFd5PNWw

Setup

  • OS: macOS
  • Python version: 3.9.5
  • beets version: 1.6.1
  • Turning off plugins made problem go away (yes/no): wold have to turn off conversion plugin which defeats the purpose since I do want these WAV converted to mp3, which otherwise works will other files (FLAC typically)

My configuration (output of beet config) is:

plugins: fetchart embedart lyrics discogs spotify convert bpmanalyser
autotag: yes
ignore_hidden: yes
original_date: yes
languages: en
va_name: Compilation
directory: ~/Downloads/
import:
    copy: yes
    write: yes
    move: no
convert:
    auto: yes
    quiet: yes
    delete_originals: no
    format: mp3
    mp3:
      command: ffmpeg -i $source -q:a 0 -map_metadata 0 $dest
      extension: mp3
discogs:
    user_token: yhRjvGwdihHSyuSMebbwfkDCovmrNHkodhTEdOuk
fetchart:
    auto: yes
    sources: fanarttv itunes amazon coverart albumart
    fanarttv_key: redacted
embedart: 
    auto: yes
    maxwidth: 1000
    remove_art_file: yes
lyrics:
    auto: yes
    force: yes
    import.write: yes
    sources: genius
    google_API_key: redacted
bpmanalyser:
  auto: yes
  dry-run: no
  write: yes
  threads: 2
  force: yes
  quiet: yes
replace:
    'featuring': 'feat\.'
    '’': "'"
    '[“”]': '"'
    '[…]': '...'
    '[-]': '-'
    '[−]': '-'
    '[—]': '-'
    '[Ⅰ]': I
    '[Ⅱ]': II

2V3EvG4LMJFdRe avatar Aug 31 '23 05:08 2V3EvG4LMJFdRe

Might help to get mediainfo and run that on it.

RollingStar avatar Sep 02 '23 17:09 RollingStar

They're just game format files that I converted into audio with foobar2000 a while ago. They play fine on Preview through Finder. You know of an alternative to Mediainfo? Seems to cost a buck 😅

2V3EvG4LMJFdRe avatar Sep 12 '23 09:09 2V3EvG4LMJFdRe

It should be free? https://mediaarea.net/en/MediaInfo/Download

Could also run ffmpeg -i

on it and copy the output. There may be a way to have ffmpeg show more info.

RollingStar avatar Sep 12 '23 17:09 RollingStar

Hmm, this one looks tricky, some observations:

  • The convert plugin is involved: What fails is not directly the copy of the WAV file, but of the transcoded temporary file.
  • The destination path is invalid. So, my guess would be that there's no or invalid metadata in the files, and that leads to us generating an invalid output path. There's a chance that this is Mac-specific.

wisp3rwind avatar Sep 12 '23 18:09 wisp3rwind

(Thanks for the tip on mediainfo)

You're right, the files have no metadata on them and it fails because of it - it seems obvious although I can't quite confirm it because I have no way to edit the metadata. How about some change to make the converter default to the file name for the path if no metadata is found? File name example: PartyPackTitle_2Mix.44.wav

2V3EvG4LMJFdRe avatar Sep 14 '23 03:09 2V3EvG4LMJFdRe

You're right, the files have no metadata on them and it fails because of it - it seems obvious although I can't quite confirm it because I have no way to edit the metadata. How about some change to make the converter default to the file name for the path if no metadata is found? File name example: PartyPackTitle_2Mix.44.wav

Yes, absolutely, beets should do something more reasonable than just crash in this case!

wisp3rwind avatar Sep 14 '23 22:09 wisp3rwind