From 3301bf3ff6383d51ae8dbab411636428ee9569f9 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 24 Feb 2018 17:40:12 +0100 Subject: [PATCH] Fix voice notes default filename being "None - None.oga" --- telethon/telegram_client.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 3e7918d2..3f341099 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -1622,18 +1622,27 @@ class TelegramClient(TelegramBareClient): file_size = document.size + kind = 'document' possible_names = [] for attr in document.attributes: if isinstance(attr, DocumentAttributeFilename): possible_names.insert(0, attr.file_name) elif isinstance(attr, DocumentAttributeAudio): - possible_names.append('{} - {}'.format( - attr.performer, attr.title - )) + kind = 'audio' + if attr.performer and attr.title: + possible_names.append('{} - {}'.format( + attr.performer, attr.title + )) + elif attr.performer: + possible_names.append(attr.performer) + elif attr.title: + possible_names.append(attr.title) + elif attr.voice: + kind = 'voice' file = self._get_proper_filename( - file, 'document', utils.get_extension(document), + file, kind, utils.get_extension(document), date=date, possible_names=possible_names )