obskyr / khinsider

A script for khinsider mass downloads. Get video game soundtracks quickly and easily! Also a Python interface.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error while downloading Album

brettsloan opened this issue · comments

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'

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'
commented

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

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')

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":