Check if a file exists, read metadata. Closes #15
This commit is contained in:
parent
e538c3c9fb
commit
f7ab210b8a
@ -20,6 +20,7 @@ import util
|
|||||||
import base64
|
import base64
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
from mutagen.easyid3 import EasyID3
|
||||||
|
|
||||||
|
|
||||||
class MumbleBot:
|
class MumbleBot:
|
||||||
@ -321,6 +322,11 @@ class MumbleBot:
|
|||||||
def download_music(self, url):
|
def download_music(self, url):
|
||||||
url_hash = hashlib.md5(url.encode()).hexdigest()
|
url_hash = hashlib.md5(url.encode()).hexdigest()
|
||||||
path = var.config.get('bot', 'tmp_folder') + url_hash + ".%(ext)s"
|
path = var.config.get('bot', 'tmp_folder') + url_hash + ".%(ext)s"
|
||||||
|
mp3 = path.replace(".%(ext)s", ".mp3")
|
||||||
|
if os.path.isfile(mp3):
|
||||||
|
audio = EasyID3(mp3)
|
||||||
|
video_title = audio["title"]
|
||||||
|
else:
|
||||||
ydl_opts = {
|
ydl_opts = {
|
||||||
'format': 'bestaudio/best',
|
'format': 'bestaudio/best',
|
||||||
'outtmpl': path,
|
'outtmpl': path,
|
||||||
@ -343,7 +349,7 @@ class MumbleBot:
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
return path.replace(".%(ext)s", ".mp3"), video_title
|
return mp3, video_title
|
||||||
|
|
||||||
def loop(self):
|
def loop(self):
|
||||||
raw_music = ""
|
raw_music = ""
|
||||||
|
@ -4,3 +4,4 @@ flask
|
|||||||
youtube-dl
|
youtube-dl
|
||||||
python-magic
|
python-magic
|
||||||
Pillow
|
Pillow
|
||||||
|
mutagen
|
||||||
|
Loading…
x
Reference in New Issue
Block a user