iheanyi / bandcamp-dl

Simple python script to download Bandcamp albums

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError when no tracks listed

machawk1 opened this issue · comments

Python version:
Python 3.7.0

Bandcamp-dl version:
bandcamp-dl 0.0.8-12

Bancamp-dl options:
bandcamp-dl --artist=eradicator --album=its-your-right

url:
https://eradicator.bandcamp.com/track/its-your-right

options:

Describe the issue:

On albums without a track listing but just displaying a single track to-be-played, I receive an exception:

Traceback (most recent call last):
  File "/usr/local/bin/bandcamp-dl", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/bandcamp_dl/__main__.py", line 93, in main
    album = bandcamp.parse(url, True, arguments['--embed-lyrics'], arguments['--debug'])
  File "/usr/local/lib/python3.7/site-packages/bandcamp_dl/bandcamp.py", line 40, in parse
    bandcamp_json = BandcampJSON(self.soup, debugging).generate()
  File "/usr/local/lib/python3.7/site-packages/bandcamp_dl/bandcampjson.py", line 25, in generate
    self.js_to_json()
  File "/usr/local/lib/python3.7/site-packages/bandcamp_dl/bandcampjson.py", line 50, in js_to_json
    self.get_js()
  File "/usr/local/lib/python3.7/site-packages/bandcamp_dl/bandcampjson.py", line 37, in get_js
    self.js_data = self.body.find("script", {"src": False}, text=re.compile(self.target)).string
AttributeError: 'NoneType' object has no attribute 'string'

Other albums and artists without this characteristic (one track) seem to work without issue. Potentially related to the above and #113: I receive a similar Error when running bandcamp-dl without any options:

$ bandcamp-dl
Traceback (most recent call last):
  File "/usr/local/bin/bandcamp-dl", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/bandcamp_dl/__main__.py", line 93, in main
    album = bandcamp.parse(url, True, arguments['--embed-lyrics'], arguments['--debug'])
  File "/usr/local/lib/python3.7/site-packages/bandcamp_dl/bandcamp.py", line 40, in parse
    bandcamp_json = BandcampJSON(self.soup, debugging).generate()
  File "/usr/local/lib/python3.7/site-packages/bandcamp_dl/bandcampjson.py", line 25, in generate
    self.js_to_json()
  File "/usr/local/lib/python3.7/site-packages/bandcamp_dl/bandcampjson.py", line 50, in js_to_json
    self.get_js()
  File "/usr/local/lib/python3.7/site-packages/bandcamp_dl/bandcampjson.py", line 37, in get_js
    self.js_data = self.body.find("script", {"src": False}, text=re.compile(self.target)).string
AttributeError: 'NoneType' object has no attribute 'string'

Its possible something changed again, last time they made having a user-agent a requirement, hopefully its something simple this time too.

According to bandcamp this is listed as a track not an album (as shown buy its /track/its-your-right url)

It may be that when a single track is uploaded for an album bandcamp now automatically sticks it on a single track page now, not sure if it did that before.

So not really a bug but it might be nice if I add something to do a quick check by generating a /track/ url and seeing if it exists if the album url fails.

commented

Python version:
Python 3.8.5

Bandcamp-dl version:
bandcamp-dl 0.0.8-12

url:
https://parentsnz.bandcamp.com/album/parents

Issue:

No options used. Get the same issue on all types of tracks/albums. Might be related.

Traceback (most recent call last):
  File "/home/username/.local/bin/bandcamp-dl", line 8, in <module>
    sys.exit(main())
  File "/home/username/.local/lib/python3.8/site-packages/bandcamp_dl/__main__.py", line 93, in main
    album = bandcamp.parse(url, True, arguments['--embed-lyrics'], arguments['--debug'])
  File "/home/username/.local/lib/python3.8/site-packages/bandcamp_dl/bandcamp.py", line 40, in parse
    bandcamp_json = BandcampJSON(self.soup, debugging).generate()
  File "/home/username/.local/lib/python3.8/site-packages/bandcamp_dl/bandcampjson.py", line 25, in generate
    self.js_to_json()
  File "/home/username/.local/lib/python3.8/site-packages/bandcamp_dl/bandcampjson.py", line 50, in js_to_json
    self.get_js()
  File "/home/username/.local/lib/python3.8/site-packages/bandcamp_dl/bandcampjson.py", line 37, in get_js
    self.js_data = self.body.find("script", {"src": False}, text=re.compile(self.target)).string
AttributeError: 'NoneType' object has no attribute 'string'

Works in current version, was likely fixed by others changes to locating the page data.