gtronset/beets-filetote

Crash when re-importing library

Closed this issue · 7 comments

arogl commented

I found your plugin a few days ago and have enabled so trying to reimport the library items that were imported as-is.

Some of these have extras of lrc and pdf files

Error from pip install:

beet imp -L "data_source::^$"
Traceback (most recent call last):
  File "C:\Python3\Scripts\beet-script.py", line 33, in <module>
    sys.exit(load_entry_point('beets', 'console_scripts', 'beet')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "i:\git\beets\beets\ui\__init__.py", line 1301, in main
    _raw_main(args)
  File "i:\git\beets\beets\ui\__init__.py", line 1288, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "i:\git\beets\beets\ui\commands.py", line 1034, in import_func
    import_files(lib, paths, query)
  File "i:\git\beets\beets\ui\commands.py", line 974, in import_files
    session.run()
  File "i:\git\beets\beets\importer.py", line 342, in run
    plugins.send('import_begin', session=self)
  File "i:\git\beets\beets\plugins.py", line 488, in send
    result = handler(**arguments)
             ^^^^^^^^^^^^^^^^^^^^
  File "i:\git\beets\beets\plugins.py", line 145, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python3\Lib\site-packages\beetsplug\filetote.py", line 94, in _register_session_settings
    self.paths = os.path.expanduser(session.paths[0])
                                    ~~~~~~~~~~~~~^^^
IndexError: list index out of range

Error from git install:

beet -vvv imp -L "data_source::^$" 
user configuration: C:\Users\<username>\AppData\Roaming\beets\config.yaml
data directory: C:\Users\<username>\AppData\Roaming\beets
plugin paths: C:\Users\<username>\AppData\Roaming\beets\beetsplug
inline: adding item field first_artist
inline: adding item field date
inline: adding album field date
lastgenre: Loading canonicalization tree i:\git\beets\beetsplug\lastgenre\genres-tree.yaml
Sending event: pluginload
library database: C:\Users\<username>l\AppData\Roaming\beets\library.db
library directory: I:\Music
Sending event: library_opened
Sending event: import_begin
Traceback (most recent call last):
  File "C:\Python3\Scripts\beet-script.py", line 33, in <module>
    sys.exit(load_entry_point('beets', 'console_scripts', 'beet')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "i:\git\beets\beets\ui\__init__.py", line 1301, in main
    _raw_main(args)
  File "i:\git\beets\beets\ui\__init__.py", line 1288, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "i:\git\beets\beets\ui\commands.py", line 1034, in import_func
    import_files(lib, paths, query)
  File "i:\git\beets\beets\ui\commands.py", line 974, in import_files
    session.run()
  File "i:\git\beets\beets\importer.py", line 342, in run
    plugins.send('import_begin', session=self)
  File "i:\git\beets\beets\plugins.py", line 488, in send
    result = handler(**arguments)
             ^^^^^^^^^^^^^^^^^^^^
  File "i:\git\beets\beets\plugins.py", line 145, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python3\Lib\site-packages\beetsplug\filetote.py", line 100, in _register_session_settings
    self.filetote.session.import_path = os.path.expanduser(session.paths[0])
                                                           ~~~~~~~~~~~~~^^^
IndexError: list index out of range

Config relevant for filetote:

paths:
  ext:.pdf: %upper{%asciify{%left{$first_artist,1}}}/$first_artist/($year) $album%aunique{}/$album - 00 - $artist - $title
  paired_ext:.lrc: %upper{%asciify{%left{$first_artist,1}}}/$first_artist/($year) $album%aunique{}/$artist - $track - $title.rc

filetote:
  pairing:
    enabled: true
    pairing_only: true
    extensions: ".lrc"
  extensions: .pdf

Hi @arogl ! Thank you for providing all the details here. I think I see the issue, let me work on it a bit. My personal needs hadn't resulted in me testing with reimporting using searches, so a couple of assumptions in the plugin need to be changed. I'll ping you once I have an update 😄

@arogl I was wrong about my previous guess, so, unfortunately, this is still eluding me. For your library (library directory: I:\Music), is this just a different drive or is it a network share?

arogl commented

The library directory is on a different drive, not a network share.

I can try some debugging later today/tonight to help out

@arogl were you able to get past this and/or is this still an issue?

arogl commented

I can work around by doing beet ls -ap mn_albumid::^$ and then import per line

@arogl This is fixed in #126, set to be included in the next release. There was a bug when importing with a query that is now resolved.

The release with this fix is now out, please us v0.4.6.