From 06c1a4fa4383eae401352c11ce21098235d7000c Mon Sep 17 00:00:00 2001 From: user Date: Mon, 11 Mar 2024 03:43:40 +0300 Subject: [PATCH] Add video_author field to YoutubeChatRecord Regenerate PLUGINS.md --- PLUGINS.md | 3 ++- avtdl/plugins/youtube/youtube_chat.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/PLUGINS.md b/PLUGINS.md index 1c6550f..0905595 100644 --- a/PLUGINS.md +++ b/PLUGINS.md @@ -1,5 +1,5 @@ - + ## Description and configuration of available plugins ### Table of content: @@ -657,6 +657,7 @@ Youtube chat message * `color`: message header color (RGB integer), if present. * `video_id`: video_id of the video chat message was sent to. * `video_title`: title of the video chat message was sent to. +* `video_author`: name of the channel where the video chat message was sent to is published. * `uid`: unique id of the message. * `action`: internal name of message type. Used for debug purposes. * `renderer`: internal name of message format. Used for debug purposes. diff --git a/avtdl/plugins/youtube/youtube_chat.py b/avtdl/plugins/youtube/youtube_chat.py index 87231c2..c2defe9 100644 --- a/avtdl/plugins/youtube/youtube_chat.py +++ b/avtdl/plugins/youtube/youtube_chat.py @@ -45,6 +45,8 @@ class YoutubeChatRecord(Record): """video_id of the video chat message was sent to""" video_title: str = '' """title of the video chat message was sent to""" + video_author: str = '' + """name of the channel where the video chat message was sent to is published""" uid: str """unique id of the message""" @@ -112,6 +114,7 @@ class ChatPageContext(NextPageContext): continuation_url: Optional[str] = None base_update_interval: float = 120 done: bool = False + video_author: str = '' video_title: str = '' video_id: str = '' @@ -167,6 +170,7 @@ async def get_records(self, entity: YoutubeChatMonitorEntity, session: aiohttp.C records = Parser().run_parsers(new_actions) for record in records: record.video_id = entity.context.video_id + record.video_author = entity.context.video_author record.video_title = entity.context.video_title new_update_interval = self._new_update_interval(entity, len(records)) # entity.update_interval gets updated by self.request() @@ -197,6 +201,7 @@ async def _get_first(self, entity: YoutubeChatMonitorEntity, session: aiohttp.Cl entity.context.video_id = info.video_id entity.context.video_title = info.title + entity.context.video_author = info.author message = find_one(initial_page, '$..conversationBar.conversationBarRenderer.availabilityMessage.messageRenderer.text') if message is not None: