Beatport Plugin issue

Hi. Having trouble getting Beatport plugin working. Get the same problem on three different distros. Eager to get it working as most of my library is electronic dance music :slightly_smiling_face:

Have installed required requests and requests_oauthlib libraries.

‘beet version’ gives:

beets version 1.6.0
Python version 3.10.4
plugins: copyartifacts, deezer, discogs, embedart, fetchart, inline, lastgenre, random, zero

The instructions say ‘The first time you run the import command after enabling the plugin, it will ask you to authorize with Beatport by visiting the site in a browser. On the site you will be asked to enter your username and password to authorize beets to query the Beatport API.’

Instead get the following error:

beet import Music
Traceback (most recent call last):
File “/home/nglha/.local/lib/python3.8/site-packages/beetsplug/beatport.py”, line 290, in setup
with open(self._tokenfile()) as f:
FileNotFoundError: [Errno 2] No such file or directory: ‘/home/nglha/.config/beets/beatport_token.json’

During handling of the above exception, another exception occurred:

beet import Music
Traceback (most recent call last):
File “/home/nglha/.local/lib/python3.8/site-packages/beetsplug/beatport.py”, line 290, in setup
with open(self._tokenfile()) as f:
FileNotFoundError: [Errno 2] No such file or directory: ‘/home/nglha/.config/beets/beatport_token.json’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py”, line 485, in wrap_socket
cnx.do_handshake()
File “/usr/lib/python3/dist-packages/OpenSSL/SSL.py”, line 1915, in do_handshake
self._raise_ssl_error(self._ssl, result)
File “/usr/lib/python3/dist-packages/OpenSSL/SSL.py”, line 1639, in _raise_ssl_error
raise SysCallError(errno, errorcode.get(errno))
OpenSSL.SSL.SysCallError: (104, ‘ECONNRESET’)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/urllib3/connectionpool.py”, line 665, in urlopen
httplib_response = self._make_request(
File “/usr/lib/python3/dist-packages/urllib3/connectionpool.py”, line 376, in _make_request
self._validate_conn(conn)
File “/usr/lib/python3/dist-packages/urllib3/connectionpool.py”, line 996, in validate_conn
conn.connect()
File “/usr/lib/python3/dist-packages/urllib3/connection.py”, line 366, in connect
self.sock = ssl_wrap_socket(
File "/usr/lib/python3/dist-packages/urllib3/util/ssl
.py", line 370, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File “/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py”, line 491, in wrap_socket
raise ssl.SSLError(“bad handshake: %r” % e)
ssl.SSLError: (“bad handshake: SysCallError(104, ‘ECONNRESET’)”,)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/requests/adapters.py”, line 439, in send
resp = conn.urlopen(
File “/usr/lib/python3/dist-packages/urllib3/connectionpool.py”, line 719, in urlopen
retries = retries.increment(
File “/usr/lib/python3/dist-packages/urllib3/util/retry.py”, line 436, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘oauth-api.beatport.com’, port=443): Max retries exceeded with url: /identity/1/oauth/request-token (Caused by SSLError(SSLError(“bad handshake: SysCallError(104, ‘ECONNRESET’)”)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/nglha/.local/bin/beet”, line 8, in
sys.exit(main())
File “/home/nglha/.local/lib/python3.8/site-packages/beets/ui/init.py”, line 1285, in main
_raw_main(args)
File “/home/nglha/.local/lib/python3.8/site-packages/beets/ui/init.py”, line 1272, in _raw_main
subcommand.func(lib, suboptions, subargs)
File “/home/nglha/.local/lib/python3.8/site-packages/beets/ui/commands.py”, line 973, in import_func
import_files(lib, paths, query)
File “/home/nglha/.local/lib/python3.8/site-packages/beets/ui/commands.py”, line 943, in import_files
session.run()
File “/home/nglha/.local/lib/python3.8/site-packages/beets/importer.py”, line 337, in run
plugins.send(‘import_begin’, session=self)
File “/home/nglha/.local/lib/python3.8/site-packages/beets/plugins.py”, line 488, in send
result = handler(**arguments)
File “/home/nglha/.local/lib/python3.8/site-packages/beets/plugins.py”, line 145, in wrapper
return func(*args, **kwargs)
File “/home/nglha/.local/lib/python3.8/site-packages/beetsplug/beatport.py”, line 294, in setup
token, secret = self.authenticate(c_key, c_secret)
File “/home/nglha/.local/lib/python3.8/site-packages/beetsplug/beatport.py”, line 305, in authenticate
url = auth_client.get_authorize_url()
File “/home/nglha/.local/lib/python3.8/site-packages/beetsplug/beatport.py”, line 93, in get_authorize_url
self.api.fetch_request_token(
File “/home/nglha/.local/lib/python3.8/site-packages/requests_oauthlib/oauth1_session.py”, line 287, in fetch_request_token
token = self._fetch_token(url, **request_kwargs)
File “/home/nglha/.local/lib/python3.8/site-packages/requests_oauthlib/oauth1_session.py”, line 365, in _fetch_token
r = self.post(url, **request_kwargs)
File “/usr/lib/python3/dist-packages/requests/sessions.py”, line 581, in post
return self.request(‘POST’, url, data=data, json=json, **kwargs)
File “/usr/lib/python3/dist-packages/requests/sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “/usr/lib/python3/dist-packages/requests/sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “/usr/lib/python3/dist-packages/requests/adapters.py”, line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host=‘oauth-api.beatport.com’, port=443): Max retries exceeded with url: /identity/1/oauth/request-token (Caused by SSLError(SSLError(“bad handshake: SysCallError(104, ‘ECONNRESET’)”)))

It appears to be looking for a ‘beatport_token.json’ file but there is no mention of this on the plugin page.

The relevant error is actually the last one in the chain: the SSLError. This kind of thing is terribly annoying to debug but usually indicates either intermittent network problems our out-of-date OpenSSL or certificates packages.

2 Likes