def _is_old(self, video: Video) -> bool: TealPrint.verbose(f"🚦 Is the video old?", push_indent=True) old_date = datetime.now().astimezone() - timedelta( days=config.general.max_days_back) video_date = datetime.strptime(video.date, "%Y-%m-%dT%H:%M:%S%z") if video_date >= old_date: TealPrint.verbose(f"🟢 Video is new", color=LogColors.passed) TealPrint.pop_indent() return False else: TealPrint.verbose(f"🔴 Video is old", color=LogColors.filtered) TealPrint.pop_indent() return True
def _matches_any_exclude(self, channel: Channel, video: Video) -> bool: title = video.title.lower() TealPrint.verbose(f"🚦 Check exclude filter", push_indent=True) if len(channel.excludes) == 0: TealPrint.verbose(f"🟢 Pass: no exclude filter", color=LogColors.passed) TealPrint.pop_indent() return False for filter in channel.excludes: filter = filter.lower() if re.search(filter, title): TealPrint.verbose(f"🔴 Matched filter: {filter}", color=LogColors.filtered) TealPrint.pop_indent() return True else: TealPrint.verbose(f"🟡 Didn't match filter: {filter}", color=LogColors.no_match) TealPrint.verbose(f"🟢 Didn't match any exclude filter", color=LogColors.passed) TealPrint.pop_indent() return False
def execute(self, channels: List[Channel]) -> None: for channel in channels: TealPrint.info(channel.name, color=LogColors.header, push_indent=True) videos = self.repo.get_latest_videos(channel) if len(videos) == 0: TealPrint.info( f"🦘 Skipping {channel.name}, no new matching videos to download", color=LogColors.skipped) for video in videos: TealPrint.verbose(f"🎞 {video.title}", color=LogColors.header, push_indent=True) # Skip downloaded videos if self.repo.has_downloaded(video): TealPrint.verbose( f"🟠Skipping {video.title}, already downloaded", color=LogColors.skipped) TealPrint.pop_indent() continue # Filter out if self._filter_video(channel, video): TealPrint.verbose(f"🔴 Video was filtered out", color=LogColors.filtered) TealPrint.pop_indent() continue TealPrint.verbose(f"🟢 Video passed all filters", color=LogColors.passed) TealPrint.verbose(f"🔽 Downloading...") download_path = self.repo.download(video) if download_path is None: TealPrint.warning(f"⚠Couldn't download {video.title}") TealPrint.pop_indent() continue TealPrint.verbose( f"🎞 Starting rendering, this may take a while...") out_path = self._get_out_filepath(channel, video) rendered = self.repo.render(video, download_path, out_path, channel.speed) if not rendered: TealPrint.warning(f"⚠Couldn't render {video.title}") TealPrint.pop_indent() continue self.repo.set_as_downloaded(channel, video) TealPrint.info( f"✔ Video {video.title} downloaded successfully ➡ {out_path}" ) TealPrint.pop_indent() TealPrint.pop_indent()