library.parse_uri can't handle browse URIs

library.parse_uri will raise an exception when it tries to parse the second element of any URI that doesn't have an integer at that index, for example:

funkwhale:directory:artists:by-name
ERROR    2021-08-11 23:16:55,713 [18375:Core-6] mopidy.core.library
  FunkwhaleBackend backend caused an exception.
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/mopidy/core/library.py", line 17, in _backend_error_handling
    yield
  File "/usr/lib/python3.9/site-packages/mopidy/core/library.py", line 217, in lookup
    result = future.get()
  File "/home/erin/virtualenvs/mopidy/lib/python3.9/site-packages/pykka/_threading.py", line 55, in get
    raise exc_value
  File "/home/erin/virtualenvs/mopidy/lib/python3.9/site-packages/pykka/_actor.py", line 186, in _actor_loop
    response = self._handle_receive(envelope.message)
  File "/home/erin/virtualenvs/mopidy/lib/python3.9/site-packages/pykka/_actor.py", line 286, in _handle_receive
    return callee(*message.args, **message.kwargs)
  File "/home/erin/mopidy-funkwhale/mopidy_funkwhale/library.py", line 378, in lookup
    type, id = parse_uri(uri)
  File "/home/erin/mopidy-funkwhale/mopidy_funkwhale/library.py", line 387, in parse_uri
    id = int(parts[1])
ValueError: invalid literal for int() with base 10: 'artists'

The similar error mentioned in #16 (closed) is likely a result of viewing the browse root directory, which has the uri funkwhale:directory, which is shorter than expected.

library.browse returns working URIs like funkwhale:albums:123 when a directory actually has contents, but frontends such as Iris call library.lookup when browsing any directory URI. While this doesn't appear to actually break anything in Iris it results in a lot of log spam.

For what it's worth, mopidy-spotify rejects these sort of lookups as well, just with a nicer single line error message

I've fixed this locally and will be creating a merge request soon.

Edited by Erin