mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 04:35:24 +00:00
Fix send_audio
not working as expected (#23)
This commit is contained in:
parent
13070fe748
commit
83a89e79de
@ -197,10 +197,13 @@ class SendAudio:
|
||||
try:
|
||||
if isinstance(audio, str):
|
||||
if os.path.isfile(audio):
|
||||
mime_type = self.guess_mime_type(audio) or "audio/mpeg"
|
||||
if mime_type == "audio/ogg":
|
||||
mime_type = "audio/opus"
|
||||
thumb = await self.save_file(thumb)
|
||||
file = await self.save_file(audio, progress=progress, progress_args=progress_args)
|
||||
media = raw.types.InputMediaUploadedDocument(
|
||||
mime_type=self.guess_mime_type(audio) or "audio/mpeg",
|
||||
mime_type=mime_type,
|
||||
file=file,
|
||||
thumb=thumb,
|
||||
attributes=[
|
||||
@ -219,10 +222,13 @@ class SendAudio:
|
||||
else:
|
||||
media = utils.get_input_media_from_file_id(audio, FileType.AUDIO)
|
||||
else:
|
||||
mime_type = self.guess_mime_type(file_name or audio.name) or "audio/mpeg"
|
||||
if mime_type == "audio/ogg":
|
||||
mime_type = "audio/opus"
|
||||
thumb = await self.save_file(thumb)
|
||||
file = await self.save_file(audio, progress=progress, progress_args=progress_args)
|
||||
media = raw.types.InputMediaUploadedDocument(
|
||||
mime_type=self.guess_mime_type(file_name or audio.name) or "audio/mpeg",
|
||||
mime_type=mime_type,
|
||||
file=file,
|
||||
thumb=thumb,
|
||||
attributes=[
|
||||
|
@ -176,9 +176,12 @@ class SendVoice:
|
||||
try:
|
||||
if isinstance(voice, str):
|
||||
if os.path.isfile(voice):
|
||||
mime_type = self.guess_mime_type(voice) or "audio/ogg"
|
||||
if mime_type == "audio/mpeg":
|
||||
mime_type = "audio/ogg"
|
||||
file = await self.save_file(voice, progress=progress, progress_args=progress_args)
|
||||
media = raw.types.InputMediaUploadedDocument(
|
||||
mime_type=self.guess_mime_type(voice) or "audio/mpeg",
|
||||
mime_type=mime_type,
|
||||
file=file,
|
||||
attributes=[
|
||||
raw.types.DocumentAttributeAudio(
|
||||
@ -195,9 +198,12 @@ class SendVoice:
|
||||
else:
|
||||
media = utils.get_input_media_from_file_id(voice, FileType.VOICE)
|
||||
else:
|
||||
mime_type = self.guess_mime_type(voice.name) or "audio/ogg"
|
||||
if mime_type == "audio/mpeg":
|
||||
mime_type = "audio/ogg"
|
||||
file = await self.save_file(voice, progress=progress, progress_args=progress_args)
|
||||
media = raw.types.InputMediaUploadedDocument(
|
||||
mime_type=self.guess_mime_type(voice.name) or "audio/mpeg",
|
||||
mime_type=mime_type,
|
||||
file=file,
|
||||
attributes=[
|
||||
raw.types.DocumentAttributeAudio(
|
||||
|
Loading…
Reference in New Issue
Block a user