Open Tom-jm03 opened 6 months ago
I fixed it by replacing the def find_sounds(url): script with:
def find_sounds(url):
res = requests.get(url, headers=HEADERS)
if res.status_code != 200:
print(f'[-] failed to fetch home page with status code {res.status_code}, quitting')
exit(1)
soup = bs4.BeautifulSoup(res.text, 'html.parser')
scripts = soup.find_all('script')
check_if_none(scripts, 'scripts')
target = None
for s in scripts:
if 'var board_data_inline = ' in str(s):
target = s.text.strip()
break
check_if_none(target, 'info script')
start = target.find('var board_data_inline = ') + len('var board_data_inline = ')
end = target.find(';', start)
json_data = target[start:end].strip()
sound_list = json.loads(json_data)
sounds = sound_list['sounds']
res = []
for i in sounds:
res.append({
'id': i['id'],
'title': i['sound_transcript'],
'url': i['sound_file_url']
})
return res
This would be replacing (based on the 101soundboards.py structure) lines: 26 through 115
python311 101soundboards.py https://www.101soundboards.com/boards/105996-drachenlord-soundboard [+] successfully started 64 worker threads Traceback (most recent call last): File "C:\Users\Documents\Python\soundboard_downloader\101soundboards.py", line 177, in
main(args)
File "C:\Users\Documents\Python\soundboard_downloader\101soundboards.py", line 156, in main
sounds = find_sounds(args.URL)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Tom\Documents\Python\soundboard_downloader\101soundboards.py", line 49, in find_sounds
sound_list = json.loads(target[target.find('board_data_preload') + 21:-11])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\AppData\Local\Programs\Python\Python311\Lib\json__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\AppData\Local\Programs\Python\Python311\Lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\AppData\Local\Programs\Python\Python311\Lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 2 (char 1)