~aleteoryx/bcdl

52d35072e68aa23636f869f46eccc7d863c922b0 — Aleteoryx 24 days ago 12521e4 master
use download_type_str instead
1 files changed, 5 insertions(+), 3 deletions(-)

M bcdl.py
M bcdl.py => bcdl.py +5 -3
@@ 168,14 168,15 @@ for i,item in enumerate(items):
	doc = bs4.BeautifulSoup(requests.get(url).text, 'html.parser')
	pagedata = json.loads(doc.find(id='pagedata')['data-blob'])
	for n,dlitem in enumerate(pagedata['download_items']):
		if dlitem['download_type'] == 'a':
		dltype = dlitem['download_type_str'].lower()
		if dltype == 'album':
			filename = clean_filename(f'{dlitem["artist"]} - {dlitem["title"]}')+'.zip'
			for codec in ['flac','alac','aiff-lossless','wav','mp3-320']:
				if codec not in dlitem['downloads']:
					continue
				download = dlitem['downloads'][codec]['url']
				break
		elif dlitem['download_type'] == 't':
		elif dltype == 'track':
			filename = clean_filename(f'{dlitem["artist"]} - {dlitem["title"]}')+'.'
			for codec in ['flac','alac','aiff-lossless','wav','mp3-320']:
				if codec not in dlitem['downloads']:


@@ 184,7 185,8 @@ for i,item in enumerate(items):
				filename += codec.split('-')[0]
				break
		else:
			print(f'Skipping {dlitem["artist"]} - {dlitem["title"]}: unknown type {item["download_type"]}')
			print(f'Skipping {dlitem["artist"]} - {dlitem["title"]}: unknown type {dltype}')
			print(f'You might want to report this to ~aleteoryx!')
			skipped += 1
			continue
		filepath = p.joinpath(filename)