beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.88k stars 1.82k forks source link

sqlite3.InterfaceError: Error binding parameter 6 - probably unsupported type. #3388

Closed allesmi closed 5 years ago

allesmi commented 5 years ago

I got an error from sqlite3 while importing more music. The album in question matched with a candidate from Spotify. On accepting the candidate the exception below is thrown.

Problem

Running this command in verbose (-vv) mode:

$ beet -c config.yaml -vv import import/

Led to this problem:

overlaying configuration: config.yaml
user configuration: /home/amiller/.config/beets/config.yaml
data directory: /home/amiller/.config/beets
plugin paths: 
Sending event: pluginload
library database: /home/amiller/Music/beets-test/library/library.db
library directory: /home/amiller/Music/beets-test/library
Sending event: library_opened
Sending event: import_begin
Import of the directory:
/home/amiller/Music/beets-test/import
was interrupted. Resume (Y/n)? n
/usr/lib/python3.7/site-packages/mutagen/apev2.py:35: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import MutableSequence
Sending event: import_task_created
Sending event: import_task_start
Looking up: /home/amiller/Music/beets-test/import/Pieces_Of_A_Pensive_State_Of_Mind-Missin_You-EP
Tagging Pieces Of A Pensive State Of Mind - Missin' You
No album ID found.
Search terms: Pieces Of A Pensive State Of Mind - Missin' You
Album might be VA: False
Searching for MusicBrainz releases with: {'release': "missin' you", 'artist': 'pieces of a pensive state of mind', 'tracks': '4'}
Requesting MusicBrainz release feba06b6-179e-4be5-b0ab-de7a860dbfde
primary MB release type: album
Sending event: albuminfo_received
Candidate: A State of Mind - Platypus Funk (feba06b6-179e-4be5-b0ab-de7a860dbfde)
Computing track assignment...
...done.
Success. Distance: 0.85
Requesting MusicBrainz release 225b514f-575f-4bea-bece-997b1d682f70
primary MB release type: single
Sending event: albuminfo_received
Candidate: A State of Mind - Like a Dream (225b514f-575f-4bea-bece-997b1d682f70)
Computing track assignment...
...done.
Success. Distance: 0.77
Requesting MusicBrainz release aff430a9-2409-4a3c-a2f2-84cbe312baa4
primary MB release type: single
Sending event: albuminfo_received
Candidate: A State of Mind - One Step Beyond / Sensuality (aff430a9-2409-4a3c-a2f2-84cbe312baa4)
Computing track assignment...
...done.
Success. Distance: 0.77
Requesting MusicBrainz release 813bbe8f-8f92-4ecc-a8a3-24cb71d98e6c
primary MB release type: single
Sending event: albuminfo_received
Candidate: A State of Mind - Like a Dream (813bbe8f-8f92-4ecc-a8a3-24cb71d98e6c)
Computing track assignment...
...done.
Success. Distance: 0.77
Requesting MusicBrainz release d1147aed-3c44-4648-b32d-ffc58e155396
primary MB release type: single
Sending event: albuminfo_received
Candidate: A State of Mind - Black Horse (d1147aed-3c44-4648-b32d-ffc58e155396)
Computing track assignment...
...done.
Success. Distance: 0.81
spotify: Searching Spotify for 'album:Missin' You artist:Pieces Of A Pensive State Of Mind'
spotify: Found 1 results from Spotify for 'album:Missin' You artist:Pieces Of A Pensive State Of Mind'
spotify: Searching for album 0wAAFt3jqYMp1LUhlYY5YY
Sending event: albuminfo_received
Candidate: Pieces Of A Pensive State Of Mind - Missin' You EP (2019 Remaster) (0wAAFt3jqYMp1LUhlYY5YY)
Computing track assignment...
...done.
Success. Distance: 0.11
Evaluating 6 candidates.

/home/amiller/Music/beets-test/import/Pieces_Of_A_Pensive_State_Of_Mind-Missin_You-EP (4 items)
Sending event: before_choose_candidate
Correcting tags from:
    Pieces Of A Pensive State Of Mind - Missin' You
To:
    Pieces Of A Pensive State Of Mind - Missin' You EP (2019 Remaster)
URL:
    https://open.spotify.com/album/0wAAFt3jqYMp1LUhlYY5YY
(Similarity: 89.1%) (year, album, source, tracks) (Spotify, [1994], U-TRAX)
 * Missin' You (2019 Remaster)                       -> Missin' You - 2019 Remaster (source)
 * Missin' You (Awax Reorganisation) (2019 Remaster) -> Missin' You (Awax Reorganisation) - 2019 Remaster (source)
 * Echoic (2019 Remaster)                            -> Echoic - 2019 Remaster (source)
 * Channel Pressure (2019 Remaster)                  -> Channel Pressure - 2019 Remaster (source)
[A]pply, More candidates, Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort? 
Sending event: import_task_choice
Sending event: import_task_apply
0 of 4 items replaced
Traceback (most recent call last):
  File "/home/amiller/.local/bin/beet", line 11, in <module>
    load_entry_point('beets==1.4.9', 'console_scripts', 'beet')()
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/ui/__init__.py", line 1253, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/ui/commands.py", line 955, in import_func
    import_files(lib, paths, query)
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/ui/commands.py", line 925, in import_files
    session.run()
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/importer.py", line 331, in run
    pl.run_sequential()
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/util/pipeline.py", line 389, in run_sequential
    list(self.pull())
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/util/pipeline.py", line 466, in pull
    out = coro.send(msg)
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/util/pipeline.py", line 171, in coro
    task = func(*(args + (task,)))
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/importer.py", line 1420, in user_query
    apply_choice(session, task)
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/importer.py", line 1491, in apply_choice
    task.add(session.lib)
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/importer.py", line 756, in add
    self.album = lib.add_album(self.imported_items())
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/library.py", line 1350, in add_album
    album.add(self)
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/library.py", line 355, in add
    super(LibModel, self).add(lib)
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/dbcore/db.py", line 581, in add
    self.store()
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/library.py", line 1210, in store
    super(Album, self).store(fields)
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/library.py", line 347, in store
    super(LibModel, self).store(fields)
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/dbcore/db.py", line 510, in store
    tx.mutate(query, subvars)
  File "/home/amiller/.local/lib/python3.7/site-packages/beets/dbcore/db.py", line 832, in mutate
    cursor = self.db._connection().execute(statement, subvals)
sqlite3.InterfaceError: Error binding parameter 6 - probably unsupported type.

I think the problem is somehow related to the data we get from Spotify. Enabling the discogs plugin and applying a match from there does not throw the exception. Note the brackets around the year in the line of the Spotify candidate: (Similarity: 89.1%) (year, album, source, tracks) (Spotify, [1994], U-TRAX). Other candidates shown after hitting [M]ore Candidates did not show them. I queried the Spotify API manually and the response does not contain brackets.

Here's a link to the music files that trigger the bug (if relevant): https://open.spotify.com/album/0wAAFt3jqYMp1LUhlYY5YY

Setup

My configuration (output of beet config) is:

directory: ~/Music/beets-test/library
library: ~/Music/beets-test/library/library.db

plugins: [spotify]

import:
    copy: yes
    write: yes
threaded: no
spotify:
    source_weight: 0.1
    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
sampsyo commented 5 years ago

Wow; that's bad! It seems like someone will need to reproduce this problem and examine exactly what all the types are that we're getting from the Spotify plugin. One of them is clearly not being converted in the way we expect. @rhlahuja, perhaps you'd like to take a look?

Meanwhile, do you happen to notice anything different between this album and others that you tag using Spotify that don't trigger the same problem?

rhlahuja commented 5 years ago

This is due to a bug fixed in https://github.com/beetbox/beets/pull/3343 -- that PR properly assigns the year for year-only release dates returned by the Spotify API (which I've confirmed is the case with 0wAAFt3jqYMp1LUhlYY5YY).

Using the latest beets 1.5.0 off master instead of 1.4.9 should resolve it.

sampsyo commented 5 years ago

Excellent; thanks for confirming.