Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Commit

Permalink
Check key "document" exists before parsing (#2)
Browse files Browse the repository at this point in the history
Check key "document" exists before parsing
  • Loading branch information
Mte90 committed Aug 22, 2019
2 parents ef320ba + 9691da7 commit 203d84f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
for message in data['messages']:
if 'media' in message:
for term in search:
if re.search(term, message['media']['document']['attributes'][0]['file_name'], re.IGNORECASE):
if 'document' in message['media'] and re.search(term, message['media']['document']['attributes'][0]['file_name'], re.IGNORECASE):
print(' Download ' + message['media']['document']['attributes'][0]['file_name'])
response = urlopen('https://tg.i-c-a.su/media/' + config.get('channel', 'name') + '/' + str(message['id']))
file = open(config.get('channel', 'download') + message['media']['document']['attributes'][0]['file_name'], 'wb')
Expand Down

0 comments on commit 203d84f

Please sign in to comment.