From b6672e9e06f7d1e9c911991f7a4f8fad50718051 Mon Sep 17 00:00:00 2001 From: azlux Date: Sun, 3 Jun 2018 23:09:29 +0200 Subject: [PATCH] thumbnail at start --- README.md | 14 -------------- configuration.ini | 1 + mumbleBot.py | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index f0f49a5..7aadfcc 100644 --- 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. diff --git a/configuration.ini b/configuration.ini index 3c6c0c5..bfaefe2 100644 --- a/configuration.ini +++ b/configuration.ini @@ -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
%s help = Command available:
!play_file diff --git a/mumbleBot.py b/mumbleBot.py index 8873bd5..02fc547 100644 --- a/mumbleBot.py +++ b/mumbleBot.py @@ -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 = '' + + 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',