Files
ShiteMusicBot/cogs/utils/RoxUtils.py
T
Roxedus 7cf4111925 .gitignore
added IDE and tests folder
bot.py
	PEP8
cogs/music.py
	added thumbnails to now playing, and when song is added to queue
cogs/utils/RoxUtils.py
	added function to fetch thumbnail url
		youtube		= OK
		soundcloud		= OK
requirements.txt
	added bs4, and requests requirements
2019-01-09 00:08:16 +01:00

14 lines
406 B
Python

import requests
from bs4 import BeautifulSoup as BS
def thumbnailer(self, identifier, uri):
thumbnail_url = ""
if "youtube" in uri:
thumbnail_url = f"https://img.youtube.com/vi/{identifier}/0.jpg"
return thumbnail_url
elif "soundcloud" in uri:
thumbnail_url = BS(requests.get(uri).text, "html.parser").find("meta", property="twitter:image")["content"]
return thumbnail_url
else:
return None