]> git.0d.be Git - botaradio.git/commitdiff
thumbnail at start
authorazlux <github@azlux.fr>
Sun, 3 Jun 2018 21:09:29 +0000 (23:09 +0200)
committerazlux <github@azlux.fr>
Sun, 3 Jun 2018 21:09:29 +0000 (23:09 +0200)
README.md
configuration.ini
mumbleBot.py

index f0f49a506059adaf0992ba8e846b5a2431850bb4..7aadfccfb61f4e28e983a4af5e59be562c876fa5 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,19 +1,5 @@
 # botamusique
 
-**Info:**
-
-> This is a fork of the official repository (located [here](https://github.com/azlux/botamusique)).
-We are working on various features for our own version of the bot. However, we will
-regularly merge upstream changes and will also create pull requests to merge back our
-features to the upstream repo at some point.
-
-The remainder of this readme is from the original repo.
-Note that the ToDo list at the end of the Readme is **outdated** and **not applicable** for this repository.
-
----
-
-[Version Française ici](README.fr.md)
-
 ======
 
 Botamusique is a mumble bot which goal is to allow users to listen music together with its audio output.
index 3c6c0c57c27a9c052796188fbfe74660fe0ab446..bfaefe233a31d88ad7cfd1d0cf5ab989f87c9dd9 100644 (file)
@@ -48,6 +48,7 @@ bad_url = Bad URL asked
 multiple_matches = Track not found! Possible candidates:
 queue_contents = The next items in the queue are:
 queue_empty = No more music in the playlist!
+now_playing = Now playing %s<br />%s
 
 help = Command available:
        <br />!play_file <path>
index 8873bd5b88d198fbe6add7d0061ab595a79e643d..02fc547e822ead930dde5809ef87100a66939423 100644 (file)
@@ -20,6 +20,10 @@ import youtube_dl
 import media
 import logging
 import util
+import base64
+from PIL import Image
+from io import BytesIO
+
 
 class MumbleBot:
     def __init__(self, args):
@@ -248,6 +252,16 @@ class MumbleBot:
             path, title = self.download_music(url)
             var.current_music[1] = url
 
+            im = Image.open(var.config.get('bot', 'tmp_folder') + hashlib.md5(url.encode()).hexdigest() + '.jpg')
+            im.thumbnail((100, 100), Image.ANTIALIAS)
+            buffer = BytesIO()
+            im.save(buffer, format="JPEG")
+            thumbnail_base64 = base64.b64encode(buffer.getvalue())
+            thumbnail_html = '<img - src="data:image/PNG;base64,' + thumbnail_base64.decode() + '"/>'
+
+            logging.debug(thumbnail_html)
+            self.send_msg_channel(var.config.get('strings', 'now_playing') % (title, thumbnail_html))
+
         elif var.current_music[0] == "file":
             path = var.config.get('bot', 'music_folder') + var.current_music[1]
             title = var.current_music[1]
@@ -277,6 +291,7 @@ class MumbleBot:
             'format': 'bestaudio/best',
             'outtmpl': path,
             'noplaylist': True,
+            'writethumbnail': True,
             'postprocessors': [{
                 'key': 'FFmpegExtractAudio',
                 'preferredcodec': 'mp3',