Answer the question
In order to leave comments, you need to log in
How can I create a link to download a telegram file?
Here is all the data I have:
[{'_': 'Message', 'id': 799, 'peer_id': {'_': 'PeerChannel', 'channel_id': 1195851415}, 'date': datetime.datetime(2021, 5, 25, 18, 16, 29, tzinfo=datetime.timezone.utc), 'message': '', 'out': True, 'mentioned': False, 'media_unread': False, 'silent': True, 'post': True, 'from_scheduled': False, 'legacy': False, 'edit_hide': False, 'pinned': False, 'from_id': None, 'fwd_from': None, 'via_bot_id': None, 'reply_to': None, 'media': {'_': 'MessageMediaDocument', 'document': {'_': 'Document', 'id': 5289805549955714500, 'access_hash': 6708206575358420852, 'file_reference': b'\x04GG>\x97\x00\x00\x03\x1f`\xad?\x1a\xc1\xbc\x8c\xba%\x82J\xa9\xa8\xd4\xa7\xd2\xa1\xd29\xde', 'date': datetime.datetime(2021, 5, 25, 18, 16, 29, tzinfo=datetime.timezone.utc), 'mime_type': 'video/mp4', 'size': 4058427, 'dc_id': 2, 'attributes': [{'_': 'DocumentAttributeVideo', 'duration': 10, 'w': 576, 'h': 1024, 'round_message': False, 'supports_streaming': True}], 'thumbs': [{'_': 'PhotoStrippedSize', 'type': 'i', 'bytes': b'\x01(\x16\xc9g\xdc1\xb5G\xd0S)\xeb\x19\xcf\xcc\x08\xfaR\xf9c=[\x1f\xee\xff\x00\xf5\xe9\xd9\xf6\x0b\xa2:)\xc5\x0ex\x07\x14Q\xca\xc5tXQV\x1fo\x97\x8d\xc4\xfau\xac\xfd\xed\xebG\x98\xff\x00\xde5\xa4\xa6\x9bD\xa8\xb4Nh\xa8\x0c\x8c\x7f\x8a\x8a\xafj\x83\x94e\x14QX\x16\x14QE\x00\x7f'}, {'_': 'PhotoSize', 'type': 'm', 'location': {'_': 'FileLocationToBeDeprecated', 'volume_id': 200281400252, 'local_id': 16815}, 'w': 180, 'h': 320, 'size': 7162}], 'video_thumbs': []}, 'ttl_seconds': None}, 'reply_markup': None, 'entities': [], 'views': 1, 'forwards': 0, 'replies': None, 'edit_date': None, 'post_author': 'Adrian', 'grouped_id': None, 'restriction_reason': [], 'ttl_period': None}]
Answer the question
In order to leave comments, you need to log in
The link will not work, but you can take the file through the client API. Request from telethon, so we use it.
location = types.InputDocumentFileLocation(id=5289805549955714500, access_hash=6708206575358420852, file_reference=b'\x04GG>\x97\x00\x00\x03\x1f`\xad?\x1a\xc1\xbc\x8c\xba%\x82J\xa9\xa8\xd4\xa7\xd2\xa1\xd29\xde', thumb_size='100')
with open('result.mp4', 'wb') as f:
client.download_file(input_location=location, file=f)
with open('result.mp4', 'wb') as f:
msg.download_media(file=f)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question