Skip to content

Commit

Permalink
In VideosMonitor overwrite record_got_updated() implementation
Browse files Browse the repository at this point in the history
In order to avoid inflating db with nearly identical variations of the same record, changes in 'published_text' field are ignored.
  • Loading branch information
user committed Apr 6, 2024
1 parent 8262341 commit caf3baf
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions avtdl/plugins/youtube/youtube_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
from avtdl.core.monitors import PagedFeedMonitor, PagedFeedMonitorConfig, PagedFeedMonitorEntity
from avtdl.core.plugins import Plugins
from avtdl.plugins.filters.filters import EmptyFilterConfig
from avtdl.plugins.youtube.common import NextPageContext, get_innertube_context, get_session_index, handle_consent, prepare_next_page_request
from avtdl.plugins.youtube.feed_info import AuthorInfo, VideoRendererInfo, get_video_renderers, parse_owner_info, parse_video_renderer
from avtdl.plugins.youtube.common import NextPageContext, get_innertube_context, get_session_index, handle_consent, \
prepare_next_page_request
from avtdl.plugins.youtube.feed_info import AuthorInfo, VideoRendererInfo, get_video_renderers, parse_owner_info, \
parse_video_renderer


@Plugins.register('channel', Plugins.kind.ASSOCIATED_RECORD)
Expand Down Expand Up @@ -208,6 +210,15 @@ def _parse_entries(self, owner_info: Optional[AuthorInfo], video_renderers: List
def get_record_id(self, record: YoutubeVideoRecord) -> str:
return record.video_id

def record_got_updated(self, record: YoutubeVideoRecord, entity: VideosMonitorEntity) -> bool:
excluded_fields = {'published_text'}
stored_record = self.load_record(record, entity)
if stored_record is None:
return False
record_dump = record.model_dump(exclude=excluded_fields)
stored_record_dump = stored_record.model_dump(exclude=excluded_fields)
return record_dump != stored_record_dump


@Plugins.register('filter.channel', Plugins.kind.ACTOR_CONFIG)
class ChannelFilterConfig(EmptyFilterConfig):
Expand Down

0 comments on commit caf3baf

Please sign in to comment.