Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
columns = shutil.get_terminal_size().columns
sep = "━" if fat else "─"
if not text:
print(sep * columns)
else:
sep_len = (columns - len(text) - 2)
padding = sep_len // 2
printt(sep * padding)
printt(" ", text, " ", bold=fat)
printtln(sep * (padding + (sep_len % 2)))
print_separator("Playing now", fat=True)
printt(_("Title: "))
printtln(video.title, bold=True)
printt(_("Channel: "))
printtln(video.channel.displayname, bold=True)
description = video.description
if DESCRIPTION_ENABLED and description is not None:
columns = shutil.get_terminal_size().columns
lines = description.splitlines()
print_separator(_("Video description"))
for line in lines:
print(wrap.fill(line, width=columns))
print_separator(fat=True)
print()
def print_meta(video: Video) -> None:
def print_separator(text: Optional[str] = None, fat: bool = False) -> None:
columns = shutil.get_terminal_size().columns
sep = "━" if fat else "─"
if not text:
print(sep * columns)
else:
sep_len = (columns - len(text) - 2)
padding = sep_len // 2
printt(sep * padding)
printt(" ", text, " ", bold=fat)
printtln(sep * (padding + (sep_len % 2)))
print_separator("Playing now", fat=True)
printt(_("Title: "))
printtln(video.title, bold=True)
printt(_("Channel: "))
printtln(video.channel.displayname, bold=True)
description = video.description
if DESCRIPTION_ENABLED and description is not None:
columns = shutil.get_terminal_size().columns
lines = description.splitlines()
print_separator(_("Video description"))
for line in lines:
print(wrap.fill(line, width=columns))
print_separator(fat=True)
print()
def print_separator(text: Optional[str] = None, fat: bool = False) -> None:
columns = shutil.get_terminal_size().columns
sep = "━" if fat else "─"
if not text:
print(sep * columns)
else:
sep_len = (columns - len(text) - 2)
padding = sep_len // 2
printt(sep * padding)
printt(" ", text, " ", bold=fat)
printtln(sep * (padding + (sep_len % 2)))
def print_separator(text: Optional[str] = None, fat: bool = False) -> None:
columns = shutil.get_terminal_size().columns
sep = "━" if fat else "─"
if not text:
print(sep * columns)
else:
sep_len = (columns - len(text) - 2)
padding = sep_len // 2
printt(sep * padding)
printt(" ", text, " ", bold=fat)
printtln(sep * (padding + (sep_len % 2)))
def print_separator(text: Optional[str] = None, fat: bool = False) -> None:
columns = shutil.get_terminal_size().columns
sep = "━" if fat else "─"
if not text:
print(sep * columns)
else:
sep_len = (columns - len(text) - 2)
padding = sep_len // 2
printt(sep * padding)
printt(" ", text, " ", bold=fat)
printtln(sep * (padding + (sep_len % 2)))
print_separator("Playing now", fat=True)
printt(_("Title: "))
printtln(video.title, bold=True)
printt(_("Channel: "))
printtln(video.channel.displayname, bold=True)
description = video.description
if DESCRIPTION_ENABLED and description is not None:
columns = shutil.get_terminal_size().columns
lines = description.splitlines()
print_separator(_("Video description"))
for line in lines:
print(wrap.fill(line, width=columns))
print_separator(fat=True)
print()
def print_separator(text: Optional[str] = None, fat: bool = False) -> None:
columns = shutil.get_terminal_size().columns
sep = "━" if fat else "─"
if not text:
print(sep * columns)
else:
sep_len = (columns - len(text) - 2)
padding = sep_len // 2
printt(sep * padding)
printt(" ", text, " ", bold=fat)
printtln(sep * (padding + (sep_len % 2)))
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
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
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
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)