mirror of
https://github.com/UiO-Gaming/ShiteMusicBot.git
synced 2026-11-07 06:44:29 +01:00
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
14 lines
406 B
Python
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
|