mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-06-17 18:46:40 +00:00
Fix hachoir don't close files by itself (#875)
This commit is contained in:
parent
baedd10110
commit
dfcf414111
@ -414,9 +414,8 @@ class UploadMethods(MessageParseMethods, UserMethods):
|
||||
os.path.basename(file))
|
||||
}
|
||||
if utils.is_audio(file) and hachoir:
|
||||
m = hachoir.metadata.extractMetadata(
|
||||
hachoir.parser.createParser(file)
|
||||
)
|
||||
with hachoir.parser.createParser(file) as parser:
|
||||
m = hachoir.metadata.extractMetadata(parser)
|
||||
attr_dict[types.DocumentAttributeAudio] = \
|
||||
types.DocumentAttributeAudio(
|
||||
voice=voice_note,
|
||||
@ -430,9 +429,8 @@ class UploadMethods(MessageParseMethods, UserMethods):
|
||||
|
||||
if not force_document and utils.is_video(file):
|
||||
if hachoir:
|
||||
m = hachoir.metadata.extractMetadata(
|
||||
hachoir.parser.createParser(file)
|
||||
)
|
||||
with hachoir.parser.createParser(file) as parser:
|
||||
m = hachoir.metadata.extractMetadata(parser)
|
||||
doc = types.DocumentAttributeVideo(
|
||||
round_message=video_note,
|
||||
w=m.get('width') if m.has('width') else 0,
|
||||
|
Loading…
Reference in New Issue
Block a user