Added indications when there are audio, video, photos or gifvs in media attachments

This commit is contained in:
Manuel Cortez 2022-11-09 09:09:37 -06:00
parent d71d3695eb
commit c0654658b5
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
3 changed files with 23 additions and 5 deletions

View File

@ -304,13 +304,13 @@ class BaseBuffer(base.Buffer):
original_date = arrow.get(self.session.db[self.name][self.buffer.list.get_selected()].created_at)
ts = original_date.humanize(locale=languageHandler.getLanguage())
self.buffer.list.list.SetItem(self.buffer.list.get_selected(), 2, ts)
# if self.session.settings['sound']['indicate_audio'] and utils.is_audio(toot):
# self.session.sound.play("audio.ogg")
# if self.session.settings['sound']['indicate_img'] and utils.is_media(toot):
# self.session.sound.play("image.ogg")
if self.session.settings['sound']['indicate_audio'] and utils.is_audio_or_video(toot):
self.session.sound.play("audio.ogg")
if self.session.settings['sound']['indicate_img'] and utils.is_image(toot):
self.session.sound.play("image.ogg")
# can_share = self.can_share()
# pub.sendMessage("toggleShare", shareable=can_share)
# self.buffer.retweet.Enable(can_share)
# self.buffer.boost.Enable(can_share)
def audio(self, url='', *args, **kwargs):
if sound.URLPlayer.player.is_playing():

View File

@ -20,6 +20,8 @@ input_device = string(default="Default")
output_device = string(default="Default")
session_mute = boolean(default=False)
current_soundpack = string(default="default")
indicate_audio = boolean(default=True)
indicate_img = boolean(default=True)
[other_buffers]
timelines = list(default=list())

View File

@ -18,3 +18,19 @@ def find_item(item, listItems):
if item.reblog != None and item.reblog.id == listItems[i].id:
return i
return None
def is_audio_or_video(toot):
if toot.reblog != None:
return is_audio_or_video(toot.reblog)
# Checks firstly for Mastodon native videos and audios.
for media in toot.media_attachments:
if media["type"] == "video" or media["type"] == "audio":
return True
def is_image(toot):
if toot.reblog != None:
return is_audio_or_video(toot.reblog)
# Checks firstly for Mastodon native videos and audios.
for media in toot.media_attachments:
if media["type"] == "gifv" or media["type"] == "image":
return True