Skip to content

Commit

Permalink
adds content_id attribute (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
pinkywafer authored Dec 17, 2021
1 parent c5eb6bb commit 7084c59
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ key | type | description
### Attributes

* url: URL of the most recent video
* content_id: the content ID (useful for sending to certain media players)
* published: The time and date the video was published
* stars: The 'stars' recieved on youtube. (This is all reactions both 👍 and 👎 combined)
* views: the number of video views
Expand Down
3 changes: 3 additions & 0 deletions custom_components/youtube/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def __init__(self, channel_id, name, session):
self._name = name
self.channel_id = channel_id
self.url = None
self.content_id = None
self.published = None
self.channel_live = False
self.channel_image = None
Expand All @@ -85,6 +86,7 @@ async def async_update(self):
else:
_LOGGER.debug('%s - Skipping live check', self._name)
self.url = url
self.content_id = url.split('?v=')[1]
self.published = info.split('<published>')[2].split('</')[0]
thumbnail_url = info.split(
'<media:thumbnail url="')[1].split('"')[0]
Expand Down Expand Up @@ -121,6 +123,7 @@ def icon(self):
def extra_state_attributes(self):
"""Attributes."""
return {'url': self.url,
'content_id': self.content_id,
'published': self.published,
'stars': self.stars,
'views': self.views,
Expand Down
1 change: 1 addition & 0 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ key | type | description
### Attributes
* url: URL of the most recent video
* content_id: the content ID (useful for sending to certain media players)
* published: The time and date the video was published
* stars: The 'stars' recieved on youtube. (This is all reactions both 👍 and 👎 combined)
* views: the number of video views
Expand Down

0 comments on commit 7084c59

Please sign in to comment.