telegram: Improve metadata shown for audio and recording/voice media,
patch 50155e1ef1b508f47640d4f570da84407efac9cb
Author: E. Bosch <presidev@AT@gmail.com>
Date: Fri Dec 15 00:00:44 CET 2023
* telegram: Improve metadata shown for audio and recording/voice media,
and get filename from them
hunk ./telegram.py 731
- attrib_file = attrib_video = filename = None
+ attrib_file = attrib_av = filename = None
hunk ./telegram.py 735
- if isinstance(x, tgty.DocumentAttributeVideo):
- attrib_video = x
+ if isinstance(x, tgty.DocumentAttributeVideo) or isinstance(x, tgty.DocumentAttributeAudio):
+ attrib_av = x
hunk ./telegram.py 741
- return size, h_size, attrib_video, filename
+ return size, h_size, attrib_av, filename
hunk ./telegram.py 759
- elif message.audio: media_type = 'audio'
- elif message.voice: media_type = 'rec'
+ elif message.audio:
+ size, h_size, attrib_audio, filename = scan_doc_attributes(message.media.document)
+ dur = get_human_duration(attrib_audio.duration) if attrib_audio else ''
+ per = attrib_audio.performer or ''
+ tit = attrib_audio.title or ''
+ theme = ',{}/{}'.format(per, tit) if per or tit else ''
+ media_type = 'audio:{},{}{}'.format(h_size, dur, theme)
+ elif message.voice:
+ size, _, attrib_audio, filename = scan_doc_attributes(message.media.document)
+ dur = get_human_duration(attrib_audio.duration) if attrib_audio else ''
+ media_type = 'rec:{}'.format(dur)
hunk ./utils.py 133
- if s > 0: res += str(s) + 's'
+ if s > 0 or duration < 60: res += str(s) + 's'