Fix KeyError: 'u'

This commit is contained in:
blank X 2020-12-03 22:08:02 +07:00
parent 48ac10e1db
commit 9fcaaeb6cc
1 changed files with 4 additions and 1 deletions

View File

@ -301,7 +301,10 @@ async def main():
i = random_post.media_metadata[i] i = random_post.media_metadata[i]
if i['status'] == 'valid': if i['status'] == 'valid':
filename = os.path.join(tempdir, str(time.time())) filename = os.path.join(tempdir, str(time.time()))
await _download_file(filename, i['s']['u']) for j in ('u', 'mp4', 'gif'):
if j in i['s']:
await _download_file(filename, i['s'][j])
break
captions.append(f'{text}\n#{a + 1}') captions.append(f'{text}\n#{a + 1}')
files.append(filename) files.append(filename)
url = None url = None