alfem/telegram-download-daemon

Error with DocumentAttributeVideo

Closed this issue · 1 comments

Hi, first thank you for sharing, great job with this project!
I faced an error when message contains a DocumentAttributeVideo instead of a DocumentAttributeFilename

This is the stacktrace:

NewMessage.Event(original_update=UpdateNewChannelMessage(message=Message(id=34, to_id=PeerChannel(channel_id=1424057180), date=datetime.datetime(2020, 9, 13, 3, 17, 31, tzinfo=datetime.timezone.utc), message='2020 (subtitulada)', out=True, mentioned=False, media_unread=False, silent=False, post=True, from_scheduled=False, legacy=False, edit_hide=False, from_id=None, fwd_from=MessageFwdHeader(date=datetime.datetime(2020, 9, 4, 20, 32, 14, tzinfo=datetime.timezone.utc), from_id=None, from_name=None, channel_id=1286109059, channel_post=363, post_author='Girohens', saved_from_peer=None, saved_from_msg_id=None, psa_type=None), via_bot_id=None, reply_to_msg_id=None, media=MessageMediaDocument(document=Document(id=5085077086159241436, access_hash=-3834822399060811738, file_reference=b'\x04T\xe1c\\x00\x00\x00"]\x8fK\x86\xe3\x8at\xc4W\xc8\xca\x15\xc8*\x9c\xa8\xcf\x95\xd8', date=datetime.datetime(2020, 9, 4, 20, 31, 40, tzinfo=datetime.timezone.utc), mime_type='video/mp4', size=1059123240, dc_id=1, attributes=[DocumentAttributeVideo(duration=6908, w=1280, h=536, round_message=False, supports_streaming=True)], thumbs=[PhotoStrippedSize(type='i', bytes=b'\x01\x11(\xc5\xa2\x8a(\x00\xa2\x8a(\x00\xa2\x8a(\x00\xa2\x8a(\x00\xa2\x8a(\x00\xa2\x8a(\x03'), PhotoSize(type='m', location=FileLocationToBeDeprecated(volume_id=107831094, local_id=19068), w=320, h=134, size=1108)], video_thumbs=[]), ttl_seconds=None), reply_markup=None, entities=[], views=1, edit_date=None, post_author=None, grouped_id=None, restriction_reason=[]), pts=35, pts_count=1), pattern_match=None, message=Message(id=34, to_id=PeerChannel(channel_id=1424057180), date=datetime.datetime(2020, 9, 13, 3, 17, 31, tzinfo=datetime.timezone.utc), message='2020 (subtitulada)', out=True, mentioned=False, media_unread=False, silent=False, post=True, from_scheduled=False, legacy=False, edit_hide=False, from_id=None, fwd_from=MessageFwdHeader(date=datetime.datetime(2020, 9, 4, 20, 32, 14, tzinfo=datetime.timezone.utc), from_id=None, from_name=None, channel_id=1286109059, channel_post=363, post_author='Girohens', saved_from_peer=None, saved_from_msg_id=None, psa_type=None), via_bot_id=None, reply_to_msg_id=None, media=MessageMediaDocument(document=Document(id=5085077086159241436, access_hash=-3834822399060811738, file_reference=b'\x04T\xe1c\\x00\x00\x00"]\x8fK\x86\xe3\x8at\xc4W\xc8\xca\x15\xc8*\x9c\xa8\xcf\x95\xd8', date=datetime.datetime(2020, 9, 4, 20, 31, 40, tzinfo=datetime.timezone.utc), mime_type='video/mp4', size=1059123240, dc_id=1, attributes=[DocumentAttributeVideo(duration=6908, w=1280, h=536, round_message=False, supports_streaming=True)], thumbs=[PhotoStrippedSize(type='i', bytes=b'\x01\x11(\xc5\xa2\x8a(\x00\xa2\x8a(\x00\xa2\x8a(\x00\xa2\x8a(\x00\xa2\x8a(\x00\xa2\x8a(\x03'), PhotoSize(type='m', location=FileLocationToBeDeprecated(volume_id=107831094, local_id=19068), w=320, h=134, size=1108)], video_thumbs=[]), ttl_seconds=None), reply_markup=None, entities=[], views=1, edit_date=None, post_author=None, grouped_id=None, restriction_reason=[]))
[ERROR/2020-09-12 22:17:31,552]telethon.client.updates:Unhandled exception on handler
Traceback (most recent call last):
File "telegram-download-daemon.py", line 103, in handler
filename=getFilename(event)
File "telegram-download-daemon.py", line 83, in getFilename
return next(x for x in event.media.document.attributes if isinstance(x, DocumentAttributeFilename)).file_name
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/telethon/client/updates.py", line 443, in _dispatch_update
await callback(event)
RuntimeError: coroutine raised StopIteration

I will try to solve it but I'm very unfamiliar with python!

alfem commented

As PR #23 includes many assorted changes I finally cherry picked the right ones to fix the video issue.

Thanks!