Closed brettsloan closed 2 years ago
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'
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.
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):
https://github.com/obskyr/khinsider/blob/ba98ec5b4feefe8abf2551c8d404d4e1b2257a43/khinsider.py#L268-L275
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
Basically replace with:
contentSoup = soup.find(id='pageContent') if contentSoup.find_all('h2')[0].string == "No such album":
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
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'