beets icon indicating copy to clipboard operation
beets copied to clipboard

replaygain: Use bytes for filename in GStreamer backend

Open doronbehar opened this issue 4 years ago • 3 comments

Problem

Running this command in verbose (-vv) mode:

$ beet -vv import --copy --flat .

Led to this problem:

Traceback (most recent call last):
  File "/nix/store/b6vrs9bk00356mqzzi3gcypxibm49rvy-beets-1.4.9/lib/python3.7/site-packages/beetsplug/replaygain.py", line 564, in _on_eos
    if not self._set_next_file():
  File "/nix/store/b6vrs9bk00356mqzzi3gcypxibm49rvy-beets-1.4.9/lib/python3.7/site-packages/beetsplug/replaygain.py", line 658, in _set_next_file
    ret = self._set_file()
  File "/nix/store/b6vrs9bk00356mqzzi3gcypxibm49rvy-beets-1.4.9/lib/python3.7/site-packages/beetsplug/replaygain.py", line 641, in _set_file
    self._src.set_property("location", py3_path(syspath(self._file.path)))
TypeError: could not convert '/var/lib/transmission/downloads/Ennio Morricone - The Platinum Collection/split/CD 1/Ennio Morricone - 09 - Il mio nome \udce8 nessuno.flac' to type 'gchararray' when setting property 'GstFileSrc.location'

Here are the file names as ls reports them that trigger the bug:

'Ennio Morricone - 09 - Il mio nome '$'\350'' nessuno.flac'

(I know this is an extreme edge case)

Setup

  • OS: NixOS
  • Python version: 3.7
  • beets version: 1.4.9
  • Turning off plugins made problem go away (yes/no): naturally, turning off replaygain fixes this.
My configuration (output of beet config) is:
lyrics:
    bing_lang_from: []
    sources: google musixmatch
    auto: yes
    bing_client_secret: REDACTED
    bing_lang_to:
    google_API_key: REDACTED
    google_engine_ID: REDACTED
    genius_api_key: REDACTED
    fallback:
    force: no
    local: no
directory: /var/lib/mpd/music-new
library: /var/lib/mpd/music-new/beets.db

musicbrainz:
    pass: REDACTED
    host: musicbrainz.org
    ratelimit: 1
    ratelimit_interval: 1.0
    searchlimit: 10
    user: doronbehar

import:
    write: yes
    copy: yes
    move: no
    link: no
    delete: no
    resume: ask
    incremental: no
    quiet_fallback: skip
    none_rec_action: ask
    timid: no
    autotag: yes
    quiet: no
    singletons: no
    default_action: apply
    languages: []
    detail: no
    flat: no
    group_albums: no
    pretend: no
    search_ids: []
    duplicate_action: ask

clutter: [Thumbs.DB, .DS_Store]
ignore:
- .*
- '*~'
- System Volume Information
- lost+found
ignore_hidden: yes

replace:
    '[\\/]': '-'
    ^\.: _
    '[\x00-\x1f]': _
    '[<>"\?\*\|]': _
    ':': ' -'
    \s+$: ''
    ^\s+: ''
path_sep_replace: _
asciify_paths: no
art_filename: cover
max_filename_length: 0

plugins:
- absubmit
- mbsubmit
- acousticbrainz
- inline
- mbcollection
- chroma
- fromfilename
- info
- duplicates
- edit
- fetchart
- ipfs
- lastgenre
- missing
- mbsync
- mpdstats
- mpdupdate
- lyrics
- playlist
- smartplaylist
- replaygain
- spotify
- import_history
pluginpath: [/var/src/beets-import_history/beetsplug]
threaded: yes
timeout: 5.0
per_disc_numbering: yes
verbose: 0
terminal_encoding:
original_date: no
id3v23: no
va_name: Various Artists

ui:
    terminal_width: 80
    length_diff_thresh: 10.0
    color: yes
    colors:
        text_success: green
        text_warning: yellow
        text_error: red
        text_highlight: red
        text_highlight_minor: lightgray
        action_default: turquoise
        action: blue

match:
    strong_rec_thresh: 0.04
    medium_rec_thresh: 0.25
    rec_gap_thresh: 0.25
    max_rec:
        missing_tracks: medium
        unmatched_tracks: medium
    distance_weights:
        source: 2.0
        artist: 3.0
        album: 3.0
        media: 1.0
        mediums: 1.0
        year: 1.0
        country: 0.5
        label: 0.5
        catalognum: 0.5
        albumdisambig: 0.5
        album_id: 5.0
        tracks: 2.0
        missing_tracks: 0.9
        unmatched_tracks: 0.6
        track_title: 3.0
        track_artist: 2.0
        track_index: 1.0
        track_length: 2.0
        track_id: 5.0
    preferred:
        countries: []
        media: []
        original_year: no
    ignored: []
    required: []
    track_length_grace: 10
    track_length_max: 30

format_item: ${format} % ${albumartist} - ${album} | CD-${disc} | ${track} ${title}
format_album: $album
time_format: '%Y-%m-%d %H:%M:%S'
format_raw_length: no

sort_album: albumartist+ album+
sort_item: artist+ album+ disc+ track+
sort_case_insensitive: yes
item_fields:
    isMultiDisc: "u'yes' if\n    (int(disctotal) > 1) and (disctotal != '')\nelse\n    u''\n"

paths:
    default: $album%aunique{album, albumartist}/%if{$isMultiDisc,CD-$disc/}$track $title
    singleton: $artist - Singles/$title
    comp: $album%aunique{album, albumartist}/%if{$isMultiDisc,CD-$disc/}$track $title
chrome:
    auto: no
ipfs:
    auto: no
    nocopy: no
lastgenre:
    force: no
    source: track
    count: 10
    whitelist: yes
    min_weight: 10
    fallback:
    canonical: no
    auto: yes
    separator: ', '
    prefer_specific: no
absubmit:
    auto: no
    extractor: ''
replaygain:
    backend: gstreamer
    overwrite: no
    auto: yes
    targetlevel: 89
    r128: [Opus]
spotify:
    source_weight: 1.0
    mode: list
    tiebreak: popularity
    show_failures: no
    artist_field: albumartist
    album_field: album
    track_field: title
    region_filter:
    regex: []
    client_id: 4e414367a1d14c75a5c5129a627fcab8
    client_secret: REDACTED
    tokenfile: spotify_token.json
include: [private.yaml]
acousticbrainz:
    auto: yes
    force: no
    tags: []
import_history:
    auto: yes
pathfields: {}
album_fields: {}
mbcollection:
    auto: no
    collection: ''
    remove: no
playlist:
    auto: no
    playlist_dir: .
    relative_to: library
smartplaylist:
    relative_to:
    playlist_dir: .
    auto: yes
    playlists: []
mpd:
    host: a9kVkaZtWC8SievthFNTv7XqP@localhost
    port: 6600
    password: REDACTED
    music_directory: /var/lib/mpd/music-new
    rating: yes
    rating_mix: 0.75
fetchart:
    auto: yes
    minwidth: 0
    maxwidth: 0
    enforce_ratio: no
    cautious: no
    cover_names:
    - cover
    - front
    - art
    - album
    - folder
    sources:
    - filesystem
    - coverart
    - itunes
    - amazon
    - albumart
    google_key: REDACTED
    google_engine: 001442825323518660753:hrh5ch1gjzm
    fanarttv_key: REDACTED
    store_source: no
chroma:
    auto: yes
duplicates:
    album: no
    checksum: ''
    copy: ''
    count: no
    delete: no
    format: ''
    full: no
    keys: []
    merge: no
    move: ''
    path: no
    tiebreak: {}
    strict: no
    tag: ''
edit:
    albumfields: album albumartist
    itemfields: track title artist album
    ignore_fields: id path
mbsubmit:
    format: $track. $title - $artist ($length)
    threshold: medium
missing:
    count: no
    total: no
    album: no

doronbehar avatar Mar 12 '20 08:03 doronbehar

Thanks! Looks like we need to do some sort of conversion—perhaps to bytes—before feeding filenames into the GStreamer backend. In the mean time, you can consider using a different RG backend.

sampsyo avatar Mar 12 '20 18:03 sampsyo

Thanks for the suggestion. I've already worked around that by changing the file names.

doronbehar avatar Mar 12 '20 22:03 doronbehar

I investigated this a little further and it seems like a limitation in the pygobject bindings that it expects properly encoded-utf-8 strings, even when setting properties that don't necessarily impose any requirements on the encoding.

Here's an upstream issue for reference: https://gitlab.gnome.org/GNOME/pygobject/-/issues/616

nagisa avatar Dec 24 '23 18:12 nagisa