Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaygain: Check for R128 tags fails on opus files when values are missing #2615

Closed
gandalf3 opened this issue Jun 28, 2017 · 12 comments
Closed
Labels
bug bugs that are confirmed and actionable

Comments

@gandalf3
Copy link

Problem

I enabled the replaygain plugin and attempted to compute tags for an album.
Output:

% beet -vv replaygain -a 'Brandenburg Concerti'
user configuration: /home/gandalf3/.config/beets/config.yaml
data directory: /home/gandalf3/.config/beets
plugin paths: 
Sending event: pluginload
library database: /home/gandalf3/data/music.db
library directory: /home/gandalf3/music
Sending event: library_opened
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/beets/dbcore/db.py", line 336, in __getattr__
    return self[key]
  File "/usr/lib/python3.6/site-packages/beets/dbcore/db.py", line 243, in __getitem__
    raise KeyError(key)
KeyError: 'r128_item_gain'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/beet", line 11, in <module>
    load_entry_point('beets==1.4.5', 'console_scripts', 'beet')()
  File "/usr/lib/python3.6/site-packages/beets/ui/__init__.py", line 1256, in main
    _raw_main(args)
  File "/usr/lib/python3.6/site-packages/beets/ui/__init__.py", line 1243, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/lib/python3.6/site-packages/beetsplug/replaygain.py", line 1010, in func
    self.handle_album(album, write)
  File "/usr/lib/python3.6/site-packages/beetsplug/replaygain.py", line 900, in handle_album
    if not self.album_requires_gain(album):
  File "/usr/lib/python3.6/site-packages/beetsplug/replaygain.py", line 859, in album_requires_gain
    for item in album.items()]) or \
  File "/usr/lib/python3.6/site-packages/beetsplug/replaygain.py", line 859, in <listcomp>
    for item in album.items()]) or \
  File "/usr/lib/python3.6/site-packages/beets/dbcore/db.py", line 338, in __getattr__
    raise AttributeError(u'no such field {0!r}'.format(key))
AttributeError: no such field 'r128_item_gain'

Setup

  • OS: Archlinux
  • Python version: 3.6.1
  • beets version: 1.4.5
  • Turning off plugins made problem go away (yes/no): well, yes, but the functionality in question also went away ;)

My configuration (output of beet config) is:

directory: ~/music
library: ~/data/music.db

plugins: mpdstats chroma edit smartplaylist info replaygain
smartplaylist:
    playlist_dir: ~/.config/mpd/playlists
    playlists: [{name: all.m3u, query: ''}, {name: baroque.m3u, query: 'genre:baroque'}]
    relative_to:
    auto: yes
replaygain:
    auto: no
    backend: bs1770gain
    overwrite: no
    targetlevel: 89
    r128: [Opus]
    chunk_at: 5000
    method: replaygain

import:
    copy: no
    write: no
chroma:
    auto: yes
mpd:
    music_directory: /home/gandalf3/music
    rating: yes
    rating_mix: 0.75
    host: localhost
    port: 6600
    password: REDACTED
edit:
    albumfields: album albumartist
    itemfields: track title artist album
    ignore_fields: id path
@sampsyo sampsyo added the bug bugs that are confirmed and actionable label Jun 29, 2017
@sampsyo sampsyo changed the title Calculating ReplayGain/R128 tags fails replaygain: Check for R128 tags fails when values are missing Jun 29, 2017
@sampsyo
Copy link
Member

sampsyo commented Jun 29, 2017

Thank you for the report! It looks like this was a regression introduced in #2560. @autrimpo, would you mind taking a look? We may need to turn item.r128_item_gain into item.get('r128_item_gain') to avoid crashing when the value is missing.

@autrimpo
Copy link
Contributor

Sure, I'll look at it next week.

@autrimpo
Copy link
Contributor

autrimpo commented Jul 3, 2017

I couldn't reproduce the issue, could you post some more info about the files? I assume they were imported into the db before the 1.4.5 release. What format are they in?
I tried both Python 2 and 3 and the results were the same, however my distro has only Python 3.5. Maybe it's a 3.6 specific bug?

@bb010g
Copy link

bb010g commented Jul 3, 2017

I've got the same issue on import. Running master on Arch with Python 3.6.1-1.

@gandalf3
Copy link
Author

gandalf3 commented Jul 3, 2017

The files I tested are all .opus files. Sure enough, it seems to work if I analyze an album with only .ogg files.

@gandalf3 gandalf3 changed the title replaygain: Check for R128 tags fails when values are missing replaygain: Check for R128 tags fails on opus files when values are missing Jul 3, 2017
@autrimpo
Copy link
Contributor

autrimpo commented Jul 4, 2017

I'm still unable to reproduce the issue.
Here's what I did:

  1. Checkout the 1.4.3 tag from the repo
  2. Import an album with Opus files (with replaygain set to auto: no)
  3. Check the file metadata if they contain any replaygain/R128 tags (they do not)
  4. beet -vv replaygain -a 'album:THEALBUM' with the 1.4.5 version of beets

I found an issue with the logic in the handle_album function, the condition on lines 906-907 is missing a not so it falsely throws exceptions, but with that fixed, the replaygain command runs fine.

I'm going to set up an Arch VM and try reproduce the bug there.

@sampsyo
Copy link
Member

sampsyo commented Jul 4, 2017

I also haven't been able to directly reproduce the crash, but I think I do see the problem: it should be r128_track_gain, not r128_item_gain, on that line. 😃

autrimpo added a commit to autrimpo/beets that referenced this issue Jul 4, 2017
@autrimpo
Copy link
Contributor

autrimpo commented Jul 4, 2017

I've created a new branch r128-#2615 where I've pushed the possible fix, could you clone it and see if it works, since I can't reproduce the bug?

@gandalf3
Copy link
Author

gandalf3 commented Jul 5, 2017

@autrimpo I can confirm this fixes it for me, thanks!

@gandalf3 gandalf3 closed this as completed Jul 5, 2017
@bb010g
Copy link

bb010g commented Jul 5, 2017

@gandalf3 Could you leave this issue open until it's fixed in the beetbox repository (that is, #2623 is merged)?

@gandalf3 gandalf3 reopened this Jul 6, 2017
sampsyo added a commit that referenced this issue Jul 7, 2017
fixes issue #2615 - wrong r128 tag being accessed
@sampsyo sampsyo closed this as completed in e742f86 Jul 7, 2017
@ibrokemypie
Copy link

Getting this issue still on beets version 1.4.5
Python version 3.6.2
plugins: absubmit, acousticbrainz, chroma, edit, embedart, fetchart, info, lyrics, mbsync, missing, mpdstats, mpdupdate, replaygain

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/beets/dbcore/db.py", line 336, in __getattr__
    return self[key]
  File "/usr/lib/python3.6/site-packages/beets/dbcore/db.py", line 243, in __getitem__
    raise KeyError(key)
KeyError: 'r128_item_gain'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/beet", line 11, in <module>
    load_entry_point('beets==1.4.5', 'console_scripts', 'beet')()
  File "/usr/lib/python3.6/site-packages/beets/ui/__init__.py", line 1256, in main
    _raw_main(args)
  File "/usr/lib/python3.6/site-packages/beets/ui/__init__.py", line 1243, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/lib/python3.6/site-packages/beets/ui/commands.py", line 934, in import_func
    import_files(lib, paths, query)
  File "/usr/lib/python3.6/site-packages/beets/ui/commands.py", line 911, in import_files
    session.run()
  File "/usr/lib/python3.6/site-packages/beets/importer.py", line 325, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/lib/python3.6/site-packages/beets/util/pipeline.py", line 445, in run_parallel
    six.reraise(exc_info[0], exc_info[1], exc_info[2])
  File "/usr/lib/python3.6/site-packages/six.py", line 693, in reraise
    raise value
  File "/usr/lib/python3.6/site-packages/beets/util/pipeline.py", line 312, in run
    out = self.coro.send(msg)
  File "/usr/lib/python3.6/site-packages/beets/util/pipeline.py", line 194, in coro
    func(*(args + (task,)))
  File "/usr/lib/python3.6/site-packages/beets/importer.py", line 1435, in plugin_stage
    func(session, task)
  File "/usr/lib/python3.6/site-packages/beets/plugins.py", line 124, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/beetsplug/replaygain.py", line 998, in imported
    self.handle_album(task.album, False)
  File "/usr/lib/python3.6/site-packages/beetsplug/replaygain.py", line 900, in handle_album
    if not self.album_requires_gain(album):
  File "/usr/lib/python3.6/site-packages/beetsplug/replaygain.py", line 859, in album_requires_gain
    for item in album.items()]) or \
  File "/usr/lib/python3.6/site-packages/beetsplug/replaygain.py", line 859, in <listcomp>
    for item in album.items()]) or \
  File "/usr/lib/python3.6/site-packages/beets/dbcore/db.py", line 338, in __getattr__
    raise AttributeError(u'no such field {0!r}'.format(key))
AttributeError: no such field 'r128_item_gain'

@autrimpo
Copy link
Contributor

autrimpo commented Oct 9, 2017

AFAIK that's because 1.4.5 was released before the fix was merged. (Jun 20 vs Jul 7)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs that are confirmed and actionable
Projects
None yet
Development

No branches or pull requests

5 participants