fix(lrts): can not download audio for the count less than pagesize

This commit is contained in:
Riceball LEE 2020-12-27 15:45:21 +08:00
parent e37836a40b
commit 9432ce3c71
No known key found for this signature in database
GPG Key ID: 10F15E84852CB868

View File

@ -40,20 +40,18 @@ def lrts_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
'Referer': url 'Referer': url
} }
items = [] items = []
if (total_count > page_size): for page in range(first_page, last_page):
for page in range(first_page, last_page): page_url = 'http://www.lrts.me/ajax/book/%s/%s/%s' % (book_no, page, page_size)
page_url = 'http://www.lrts.me/ajax/book/%s/%s/%s' % (book_no, page, page_size) response_content = json.loads(post_content(page_url, headers))
response_content = json.loads(post_content(page_url, headers)) if response_content['status'] != 'success':
if response_content['status'] != 'success': raise AssertionError("got the page failed: %s" % (page_url))
raise AssertionError("got the page failed: %s" % (page_url)) data = response_content['data']['data']
data = response_content['data']['data'] if data:
if data: for i in data:
for i in data: i['resName'] = parse.unquote(i['resName'])
i['resName'] = parse.unquote(i['resName']) items.extend(data)
items.extend(data) else:
else: break
break
headers = { headers = {
'Referer': 'http://www.lrts.me/playlist' 'Referer': 'http://www.lrts.me/playlist'
} }
@ -61,7 +59,6 @@ def lrts_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
for item in items: for item in items:
i_url = 'http://www.lrts.me/ajax/path/4/%s/%s' % (item['fatherResId'], item['resId']) i_url = 'http://www.lrts.me/ajax/path/4/%s/%s' % (item['fatherResId'], item['resId'])
response_content = json.loads(post_content(i_url, headers)) response_content = json.loads(post_content(i_url, headers))
logging.debug(response_content)
if response_content['status'] == 'success' and response_content['data']: if response_content['status'] == 'success' and response_content['data']:
item['ok'] = True item['ok'] = True
item['url'] = response_content['data'] item['url'] = response_content['data']