Skip to content

Commit

Permalink
Fix mkv video metadata and thumbnail.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekmo committed Mar 4, 2019
1 parent 472d668 commit d28f7d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions telegram_upload/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ def get_file_attributes(file):
mime = get_file_mime(file)
if mime == 'video':
metadata = video_metadata(file)
video_meta = metadata
meta_groups = metadata._MultipleMetadata__groups
if not metadata.has('width') and meta_groups:
video_meta = meta_groups[next(filter(lambda x: x.startswith('video'), meta_groups._key_list))]
attrs.append(DocumentAttributeStreamVideo(
(0, metadata.get('duration').seconds)[metadata.has('duration')],
(0, metadata.get('width'))[metadata.has('width')],
(0, metadata.get('height'))[metadata.has('height')]
(0, video_meta.get('width'))[video_meta.has('width')],
(0, video_meta.get('height'))[video_meta.has('height')]
))
return attrs

Expand Down
1 change: 1 addition & 0 deletions telegram_upload/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ def get_video_thumb(file, output=None, width=90):
'-vframes', '1',
output,
], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
p.communicate()
if not p.returncode and os.path.lexists(file):
return output

0 comments on commit d28f7d4

Please sign in to comment.