Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while downloading Album #65

Closed
brettsloan opened this issue Apr 10, 2022 · 4 comments
Closed

Error while downloading Album #65

brettsloan opened this issue Apr 10, 2022 · 4 comments

Comments

@brettsloan
Copy link

brettsloan commented Apr 10, 2022

EDIT:
Replacing lines 268 - 275
def _contentSoup(self):
soup = getSoup(self.url)
contentSoup = soup.find(id='EchoTopic')
if contentSoup.find('p').string == "No such album":
# The EchoTopic and p exist even if the soundtrack doesn't, so no
# need for error handling here.
raise NonexistentSoundtrackError(self)
return contentSoup

With
def _contentSoup(self):
soup = getSoup(self.url)
contentSoup = soup.find(id='pageContent')
return contentSoup

worked and I've been able to use it properly.
Thank you to kamilkrzyskow for the help!

FIXED
An unexpected error occurred! If it isn't too much to ask, please report to https://github.com/obskyr/khinsider/issues.
Attach the following error message:

Traceback (most recent call last):
File "C:\Users\brett\OneDrive\Desktop\khinsider-master\khinsider.py", line 599, in
sys.exit(doIt())
File "C:\Users\brett\OneDrive\Desktop\khinsider-master\khinsider.py", line 543, in doIt
success = download(soundtrack, outPath, formatOrder=formatOrder, verbose=True)
File "C:\Users\brett\OneDrive\Desktop\khinsider-master\khinsider.py", line 413, in download
return Soundtrack(soundtrackId).download(path, makeDirs, formatOrder, verbose)
File "C:\Users\brett\OneDrive\Desktop\khinsider-master\khinsider.py", line 325, in download
for song in self.songs:
File "C:\Users\brett\OneDrive\Desktop\khinsider-master\khinsider.py", line 149, in lazyVersion
setattr(self, attrName, func(self))
File "C:\Users\brett\OneDrive\Desktop\khinsider-master\khinsider.py", line 288, in songs
table = self._contentSoup.find('table', id='songlist')
File "C:\Users\brett\OneDrive\Desktop\khinsider-master\khinsider.py", line 149, in lazyVersion
setattr(self, attrName, func(self))
File "C:\Users\brett\OneDrive\Desktop\khinsider-master\khinsider.py", line 271, in _contentSoup
if contentSoup.find('p').string == "No such album":
AttributeError: 'NoneType' object has no attribute 'find'

@T-Craig
Copy link

T-Craig commented Apr 10, 2022

Getting the same issue as you. I'm using the code in a program I wrote so it's a little different but same idea. What the issue is, I can't tell. Same error for every album I try, I can only assume something got changed on the kh backend?

  File "D:/Python Projects/khInsider/runner.py", line 33, in <module>
    khinsider.download(soundtrackName, path=path, makeDirs=True, formatOrder=None, verbose=True)
  File "D:\Python Projects\khInsider\khinsider.py", line 413, in download
    return Soundtrack(soundtrackId).download(path, makeDirs, formatOrder, verbose)
  File "D:\Python Projects\khInsider\khinsider.py", line 325, in download
    for song in self.songs:
  File "D:\Python Projects\khInsider\khinsider.py", line 149, in lazyVersion
    setattr(self, attrName, func(self))
  File "D:\Python Projects\khInsider\khinsider.py", line 288, in songs
    table = self._contentSoup.find('table', id='songlist')
  File "D:\Python Projects\khInsider\khinsider.py", line 149, in lazyVersion
    setattr(self, attrName, func(self))
  File "D:\Python Projects\khInsider\khinsider.py", line 271, in _contentSoup
    if contentSoup.find('p').string == "No such album":
AttributeError: 'NoneType' object has no attribute 'find'

@RGPZ
Copy link

RGPZ commented Apr 11, 2022

Chances are it did, do you think the URL for the Khinsider changed?

@kamilkrzyskow
Copy link

kamilkrzyskow commented Apr 11, 2022

I never used this script, too cursed for my liking and I don't download music. However, I helped someone fix this issue.

khinsider/khinsider.py

Lines 270 to 271 in ba98ec5

contentSoup = soup.find(id='EchoTopic')
if contentSoup.find('p').string == "No such album":

Basically replace with:

contentSoup = soup.find(id='pageContent')
if contentSoup.find_all('h2')[0].string == "No such album":

It will not raise an error for valid album IDs, but will break when providing invalid album IDs
That someone checked it with the base example of khinsider.py jumping-flash and it worked.

The solution below wasn't tested and will still raise an error when providing invalid album IDs:

You can technically remove the "No such album" check as it's not a valid check (as it'll never be true):

khinsider/khinsider.py

Lines 268 to 275 in ba98ec5

def _contentSoup(self):
soup = getSoup(self.url)
contentSoup = soup.find(id='EchoTopic')
if contentSoup.find('p').string == "No such album":
# The EchoTopic and p exist even if the soundtrack doesn't, so no
# need for error handling here.
raise NonexistentSoundtrackError(self)
return contentSoup

Basically replace with:

def _contentSoup(self):
    soup = getSoup(self.url)
    contentSoup = soup.find(id='pageContent')
    return contentSoup

OR

def _contentSoup(self):
    return getSoup(self.url).find(id='pageContent')

@ImMalding
Copy link

ImMalding commented Apr 11, 2022

OR

def _contentSoup(self):
    return getSoup(self.url).find(id='pageContent')

This solution worked for me! Thank you so much!

Edit: The solution above wasn't entirely reliable, so I went with the first solution you offered, which seems to be more consistent. Seems to skip album art tho, but thanks regardless

khinsider/khinsider.py

Lines 270 to 271 in ba98ec5

contentSoup = soup.find(id='EchoTopic')
if contentSoup.find('p').string == "No such album":

Basically replace with:

contentSoup = soup.find(id='pageContent')
if contentSoup.find_all('h2')[0].string == "No such album":

@obskyr obskyr closed this as completed in b19ac44 Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants