thumbnail at start
This commit is contained in:
parent
d91178dc68
commit
b6672e9e06
14
README.md
14
README.md
@ -1,19 +1,5 @@
|
|||||||
# botamusique
|
# 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.
|
Botamusique is a mumble bot which goal is to allow users to listen music together with its audio output.
|
||||||
|
@ -48,6 +48,7 @@ bad_url = Bad URL asked
|
|||||||
multiple_matches = Track not found! Possible candidates:
|
multiple_matches = Track not found! Possible candidates:
|
||||||
queue_contents = The next items in the queue are:
|
queue_contents = The next items in the queue are:
|
||||||
queue_empty = No more music in the playlist!
|
queue_empty = No more music in the playlist!
|
||||||
|
now_playing = Now playing %s<br />%s
|
||||||
|
|
||||||
help = Command available:
|
help = Command available:
|
||||||
<br />!play_file <path>
|
<br />!play_file <path>
|
||||||
|
15
mumbleBot.py
15
mumbleBot.py
@ -20,6 +20,10 @@ import youtube_dl
|
|||||||
import media
|
import media
|
||||||
import logging
|
import logging
|
||||||
import util
|
import util
|
||||||
|
import base64
|
||||||
|
from PIL import Image
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
|
||||||
class MumbleBot:
|
class MumbleBot:
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
@ -248,6 +252,16 @@ class MumbleBot:
|
|||||||
path, title = self.download_music(url)
|
path, title = self.download_music(url)
|
||||||
var.current_music[1] = 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":
|
elif var.current_music[0] == "file":
|
||||||
path = var.config.get('bot', 'music_folder') + var.current_music[1]
|
path = var.config.get('bot', 'music_folder') + var.current_music[1]
|
||||||
title = var.current_music[1]
|
title = var.current_music[1]
|
||||||
@ -277,6 +291,7 @@ class MumbleBot:
|
|||||||
'format': 'bestaudio/best',
|
'format': 'bestaudio/best',
|
||||||
'outtmpl': path,
|
'outtmpl': path,
|
||||||
'noplaylist': True,
|
'noplaylist': True,
|
||||||
|
'writethumbnail': True,
|
||||||
'postprocessors': [{
|
'postprocessors': [{
|
||||||
'key': 'FFmpegExtractAudio',
|
'key': 'FFmpegExtractAudio',
|
||||||
'preferredcodec': 'mp3',
|
'preferredcodec': 'mp3',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user