This commit is contained in:
Lartza
2020-03-10 22:22:20 +02:00
parent 44c7adae1f
commit b2ced96ba4
15 changed files with 166 additions and 121 deletions

View File

@ -24,15 +24,19 @@ type : file
user
'''
def file_item_builder(bot, **kwargs):
return FileItem(bot, kwargs['path'])
def file_item_loader(bot, _dict):
return FileItem(bot, "", _dict)
def file_item_id_generator(**kwargs):
return hashlib.md5(kwargs['path'].encode()).hexdigest()
item_builders['file'] = file_item_builder
item_loaders['file'] = file_item_loader
item_id_generators['file'] = file_item_id_generator
@ -74,7 +78,7 @@ class FileItem(BaseItem):
self.send_client_message(constants.strings('file_missed', file=self.path))
return False
#self.version += 1 # 0 -> 1, notify the wrapper to save me when validate() is visited the first time
# self.version += 1 # 0 -> 1, notify the wrapper to save me when validate() is visited the first time
self.ready = "yes"
return True
@ -153,17 +157,17 @@ class FileItem(BaseItem):
def format_song_string(self, user):
return constants.strings("file_item",
title=self.title,
artist=self.artist if self.artist else '??',
user=user
)
title=self.title,
artist=self.artist if self.artist else '??',
user=user
)
def format_current_playing(self, user):
display = constants.strings("now_playing", item=self.format_song_string(user))
if self.thumbnail:
thumbnail_html = '<img width="80" src="data:image/jpge;base64,' + \
self.thumbnail + '"/>'
display += "<br />" + thumbnail_html
display += "<br />" + thumbnail_html
return display