How to use the ytcc.database.Video 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 / test / test_database.py View on Github external
def init_db():
    insert_list = [
        Video(yt_videoid="0", title="title1", description="description1", publisher="id_publisher1", publish_date=1488286166,
              watched=False),
        Video(yt_videoid="0", title="title1", description="description1", publisher="id_publisher1", publish_date=1488286167,
              watched=False),
        Video(yt_videoid="1", title="title2", description="description1", publisher="id_publisher1", publish_date=1488286168,
              watched=False),
        Video(yt_videoid="1", title="title2", description="description2", publisher="id_publisher2", publish_date=1488286170,
              watched=False),
        Video(yt_videoid="2", title="title3", description="description3", publisher="id_publisher2", publish_date=1488286171,
              watched=False)
    ]
    db = Database(":memory:")
    db.add_channel(Channel(displayname="publisher1", yt_channelid="id_publisher1"))
    db.add_channel(Channel(displayname="publisher2", yt_channelid="id_publisher2"))
    db.add_channel(Channel(displayname="publisher3", yt_channelid="id_publisher3"))
    db.add_videos(insert_list)
    return db
github woefe / ytcc / test / test_ytcc.py View on Github external
publisher="UCsLiV4WJfkTEHH0b9PmRklw", publish_date=1488345630.0, watched=True),
            Video(yt_videoid="7mckB-NdKWY", title="tmpiM62pN", description="",
                 publisher="UCsLiV4WJfkTEHH0b9PmRklw", publish_date=1488345565.0, watched=False),
            Video(yt_videoid="RmRPt93uAsQ", title="tmpIXBgjd", description="",
                 publisher="UCsLiV4WJfkTEHH0b9PmRklw", publish_date=1488344217.0, watched=False),
            Video(yt_videoid="nDPy3RyKdrg", title="tmpwA0TjG", description="",
                 publisher="UCsLiV4WJfkTEHH0b9PmRklw", publish_date=1488343000.0, watched=False),
            Video(yt_videoid="L0_F805qUIM", title="tmpKDOkro", description="",
                 publisher="UCxexYYtOetqikZqriLuTS-g", publish_date=1488344253.0, watched=True),
            Video(yt_videoid="lXWrdlDEzQs", title="tmpEvCR4s", description="",
                 publisher="UCxexYYtOetqikZqriLuTS-g", publish_date=1488343152.0, watched=True),
            Video(yt_videoid="cCnXsCQNkr8", title="tmp1rpsWK", description="",
                 publisher="UCxexYYtOetqikZqriLuTS-g", publish_date=1488343046.0, watched=True),
            Video(yt_videoid="rSxVs0XeQa4", title="tmpc5Y2pd", description="",
                 publisher="UCxexYYtOetqikZqriLuTS-g", publish_date=1488342015.0, watched=False),
            Video(yt_videoid="gQAsWrGfsrw", title="tmpn1M1Oa", description="",
                 publisher="UCxexYYtOetqikZqriLuTS-g", publish_date=1488341324.0, watched=False),
        ]
        self.db_conn.session.execute("delete from video")
        self.db_conn.session.execute("delete from channel")
        self.db_conn.add_channel(Channel(displayname="Webdriver Torso", yt_channelid="UCsLiV4WJfkTEHH0b9PmRklw"))
        self.db_conn.add_channel(Channel(displayname="Webdriver YPP", yt_channelid="UCxexYYtOetqikZqriLuTS-g"))
        self.db_conn.add_videos(insert_list)
        self.video = self.db_conn.session.query(Video).filter(Video.title == "tmpIXBgjd").one()
        self.video_id = self.video.id
github woefe / ytcc / test / test_database.py View on Github external
def init_db():
    insert_list = [
        Video(yt_videoid="0", title="title1", description="description1", publisher="id_publisher1", publish_date=1488286166,
              watched=False),
        Video(yt_videoid="0", title="title1", description="description1", publisher="id_publisher1", publish_date=1488286167,
              watched=False),
        Video(yt_videoid="1", title="title2", description="description1", publisher="id_publisher1", publish_date=1488286168,
              watched=False),
        Video(yt_videoid="1", title="title2", description="description2", publisher="id_publisher2", publish_date=1488286170,
              watched=False),
        Video(yt_videoid="2", title="title3", description="description3", publisher="id_publisher2", publish_date=1488286171,
              watched=False)
    ]
    db = Database(":memory:")
    db.add_channel(Channel(displayname="publisher1", yt_channelid="id_publisher1"))
    db.add_channel(Channel(displayname="publisher2", yt_channelid="id_publisher2"))
    db.add_channel(Channel(displayname="publisher3", yt_channelid="id_publisher3"))
    db.add_videos(insert_list)
    return db
github woefe / ytcc / test / test_database.py View on Github external
def test_resolve_video_id(self):
        db = init_db()
        video = db.resolve_video_id(1)
        expected = Video(id=1, yt_videoid="0", title="title1", description="description1", publisher="id_publisher1",
                         publish_date=1488286166.0, watched=False)

        self.eq_video(video, expected)
github woefe / ytcc / test / test_database.py View on Github external
def test_mark_watched(self):
        db = init_db()
        for video in db.resolve_video_ids([2, 3]):
            video.watched = True
        videos = db.session.query(Video).filter(Video.watched == False).all()
        expected = Video(id=1, yt_videoid="0", title="title1", description="description1", publisher="id_publisher1",
                         publish_date=1488286166.0, watched=False)
        self.assertEqual(len(videos), 1)
        self.eq_video(videos[0], expected)
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()}"))
            column = column.collate("NOCASE")
            yield column.desc() if desc == "desc" else column