How to use the ytcc.database.Video.id function in ytcc

To help you get started, we’ve selected a few ytcc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github woefe / ytcc / ytcc / config.py View on Github external
def init_order(self) -> Iterable[Any]:
        col_mapping: Dict[str, Column] = {
            "id": Video.id,
            "date": Video.publish_date,
            "channel": Channel.displayname,
            "title": Video.title,
            "url": Video.yt_videoid,
            "watched": Video.watched
        }
        for key in self._config["YTCC"]["orderBy"].split(","):
            sort_spec = list(map(lambda s: s.strip().lower(), key.split(":")))
            col = sort_spec[0]
            desc = ""

            if len(sort_spec) == 2:
                desc = sort_spec[1]

            column = unpack_or_raise(col_mapping.get(col),
                                     BadConfigException(f"Cannot order by {key.strip()}"))
github woefe / ytcc / ytcc / database.py View on Github external
def add_videos(self, videos: Iterable[Video]) -> None:
        """Add the given videos to the database.

        Already existing videos are silently ignored.

        :param videos: List or other iterable of videos to add.
        """
        for video in videos:
            query = self.session.query(Video.id).filter(Video.yt_videoid == video.yt_videoid)
            if not self.session.query(query.exists()).scalar():
                self.session.add(video)
        self.session.flush()