From 06bf639cfc3bcac49bbeb232387c5faadbb37245 Mon Sep 17 00:00:00 2001 From: Jenny Date: Thu, 8 Jul 2021 19:01:54 +0100 Subject: [PATCH] Remove un-needed html unescape (#40) html.parser.HTMLParser().unescape() moved to html.unescape() in python 3.9 Removed instead as it is not required. closes #39 --- custom_components/youtube/sensor.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/custom_components/youtube/sensor.py b/custom_components/youtube/sensor.py index 4e120ab..26b84f4 100644 --- a/custom_components/youtube/sensor.py +++ b/custom_components/youtube/sensor.py @@ -5,7 +5,6 @@ https://github.com/custom-components/youtube """ -import html import logging import async_timeout import voluptuous as vol @@ -40,8 +39,7 @@ async def async_setup_platform( async with async_timeout.timeout(10, loop=hass.loop): response = await session.get(url) info = await response.text() - name = html.parser.HTMLParser().unescape( - info.split('')[1].split('</')[0]) + name = info.split('<title>')[1].split('</')[0] except Exception: # pylint: disable=broad-except name = None @@ -80,8 +78,7 @@ async def async_update(self): if exp < self.expiry: return self.expiry = exp - title = html.parser.HTMLParser().unescape( - info.split('<title>')[2].split('</')[0]) + title = info.split('<title>')[2].split('</')[0] url = info.split('<link rel="alternate" href="')[2].split('"/>')[0] if self.live or url != self.url: self.stream, self.live, self.stream_start = await is_live(url, self._name, self.hass, self.session)