Add a block for icecast radios
This commit is contained in:
parent
b0b6400747
commit
29d6eb4e4c
|
@ -10,9 +10,9 @@ from hashlib import md5
|
|||
from .exceptions import ExtractionError
|
||||
|
||||
|
||||
async def get_header(session, url, headerfield=None, *, timeout=5):
|
||||
async def get_header(url, headerfield=None, *, timeout=5):
|
||||
with aiohttp.Timeout(timeout):
|
||||
async with session.head(url) as response:
|
||||
async with aiohttp.ClientSession().head(url) as response:
|
||||
if headerfield:
|
||||
return response.headers.get(headerfield)
|
||||
else:
|
||||
|
@ -276,4 +276,4 @@ class URLPlaylistEntry(BasePlaylistEntry):
|
|||
fmt = "{0[0]}m {0[1]}s".format(length)
|
||||
embed.add_field(name='Duration', value=fmt, inline=False)
|
||||
# And return the embed we created
|
||||
return embed
|
||||
return embed
|
||||
|
|
|
@ -78,8 +78,8 @@ class Playlist(EventEmitter):
|
|||
# unfortunately this is literally broken
|
||||
# https://github.com/KeepSafe/aiohttp/issues/758
|
||||
# https://github.com/KeepSafe/aiohttp/issues/852
|
||||
content_type = await get_header(self.bot.aiosession, info['url'], 'CONTENT-TYPE')
|
||||
|
||||
headers = await get_header(info['url'])
|
||||
content_type = headers.get('Content-Type')
|
||||
except Exception as e:
|
||||
content_type = None
|
||||
|
||||
|
@ -87,6 +87,9 @@ class Playlist(EventEmitter):
|
|||
if content_type.startswith(('application/', 'image/')):
|
||||
if '/ogg' not in content_type: # How does a server say `application/ogg` what the actual fuck
|
||||
raise ExtractionError("Invalid content type \"%s\" for url %s" % (content_type, song_url))
|
||||
if headers.get('ice-audio-info'):
|
||||
raise LiveStreamError("Cannot download from a livestream")
|
||||
|
||||
|
||||
if info.get('is_live', False):
|
||||
raise LiveStreamError("Cannot download from a livestream")
|
||||
|
|
Loading…
Reference in a new issue