Skip to content
Permalink
Browse files

Check key "document" exists before parsing (#2)

Check key "document" exists before parsing
  • Loading branch information...
Mte90 committed Aug 22, 2019
2 parents ef320ba + 9691da7 commit 203d84f6ad1c739fc0be8a74cf3dc36d6dde8973
Showing with 1 addition and 1 deletion.
  1. +1 −1 downloader.py
@@ -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')

0 comments on commit 203d84f

Please sign in to comment.
You can’t perform that action at this time.