1
Fork 0
mirror of https://github.com/Steffo99/bbbdl.git synced 2024-11-22 07:44:18 +00:00

Add colored output

This commit is contained in:
Steffo 2020-11-04 17:17:47 +01:00
parent 6b69b60eb3
commit e796c2958f
3 changed files with 21 additions and 7 deletions

View file

@ -25,9 +25,9 @@ def download(input_url, output_file, overwrite=False, verbose_ffmpeg=False):
if not overwrite and os.path.exists(output_file): if not overwrite and os.path.exists(output_file):
raise click.ClickException(f"Output file already exists: {output_file}") raise click.ClickException(f"Output file already exists: {output_file}")
click.echo(f"Downloading: {input_url} -> {output_file}", err=True)
meeting = Meeting.from_url(input_url) meeting = Meeting.from_url(input_url)
click.secho(f"Downloading: {input_url} -> {output_file}", err=True, fg="green")
streams = compose_lesson(meeting) streams = compose_lesson(meeting)
output = ffmpeg.output(*streams, output_file) output = ffmpeg.output(*streams, output_file)
@ -46,10 +46,10 @@ def download(input_url, output_file, overwrite=False, verbose_ffmpeg=False):
@click.pass_context @click.pass_context
def sync(ctx: click.Context, file=None, remote_file=None, overwrite=False, verbose_ffmpeg=False): def sync(ctx: click.Context, file=None, remote_file=None, overwrite=False, verbose_ffmpeg=False):
if file: if file:
click.echo(f"Syncing from local file: {file.name}", err=True) click.secho(f"Syncing from local file: {file.name}", err=True, bold=True, bg="white", fg="black")
j = json.load(file) j = json.load(file)
elif remote_file: elif remote_file:
click.echo(f"Syncing from remote file: {remote_file}", err=True) click.secho(f"Syncing from remote file: {remote_file}", err=True, bold=True)
j = requests.get(remote_file).json() j = requests.get(remote_file).json()
else: else:
raise click.ClickException("No JSON file was specified.") raise click.ClickException("No JSON file was specified.")
@ -58,9 +58,9 @@ def sync(ctx: click.Context, file=None, remote_file=None, overwrite=False, verbo
try: try:
ctx.invoke(download, input_url=input_url, output_file=output_file, overwrite=overwrite, verbose_ffmpeg=verbose_ffmpeg) ctx.invoke(download, input_url=input_url, output_file=output_file, overwrite=overwrite, verbose_ffmpeg=verbose_ffmpeg)
except click.ClickException: except click.ClickException:
click.echo(f"Skipped: {input_url} -> {output_file}", err=True) click.secho(f"Skipped: {input_url} -> {output_file}", err=True, fg="cyan")
except requests.HTTPError as e: except requests.HTTPError as e:
click.echo(f"Not available: {input_url} -> HTTP {e.response.status_code}") click.secho(f"Not available: {input_url} -> HTTP {e.response.status_code}", err=True, fg="yellow")
if __name__ == "__main__": if __name__ == "__main__":

15
poetry.lock generated
View file

@ -39,6 +39,14 @@ category = "main"
optional = false optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]]
name = "colorama"
version = "0.4.4"
description = "Cross-platform colored terminal text."
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]] [[package]]
name = "ffmpeg-python" name = "ffmpeg-python"
version = "0.2.0" version = "0.2.0"
@ -126,7 +134,7 @@ socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7,<2.0)"]
[metadata] [metadata]
lock-version = "1.0" lock-version = "1.0"
python-versions = "^3.8" python-versions = "^3.8"
content-hash = "8658967e9571ffdc038fe220a009684044442d130b1da057b7a099aa4af53244" content-hash = "dfac38187ca5aaf0c35d805a4d1a237b208f4f0883270961a27041816554796b"
[metadata.files] [metadata.files]
beautifulsoup4 = [ beautifulsoup4 = [
@ -146,6 +154,10 @@ click = [
{file = "click-7.1.2-py2.py3-none-any.whl", hash = "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc"}, {file = "click-7.1.2-py2.py3-none-any.whl", hash = "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc"},
{file = "click-7.1.2.tar.gz", hash = "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a"}, {file = "click-7.1.2.tar.gz", hash = "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a"},
] ]
colorama = [
{file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"},
{file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"},
]
ffmpeg-python = [ ffmpeg-python = [
{file = "ffmpeg-python-0.2.0.tar.gz", hash = "sha256:65225db34627c578ef0e11c8b1eb528bb35e024752f6f10b78c011f6f64c4127"}, {file = "ffmpeg-python-0.2.0.tar.gz", hash = "sha256:65225db34627c578ef0e11c8b1eb528bb35e024752f6f10b78c011f6f64c4127"},
{file = "ffmpeg_python-0.2.0-py3-none-any.whl", hash = "sha256:ac441a0404e053f8b6a1113a77c0f452f1cfc62f6344a769475ffdc0f56c23c5"}, {file = "ffmpeg_python-0.2.0-py3-none-any.whl", hash = "sha256:ac441a0404e053f8b6a1113a77c0f452f1cfc62f6344a769475ffdc0f56c23c5"},
@ -188,6 +200,7 @@ lxml = [
{file = "lxml-4.6.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:e65c221b2115a91035b55a593b6eb94aa1206fa3ab374f47c6dc10d364583ff9"}, {file = "lxml-4.6.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:e65c221b2115a91035b55a593b6eb94aa1206fa3ab374f47c6dc10d364583ff9"},
{file = "lxml-4.6.1-cp38-cp38-win32.whl", hash = "sha256:d6f8c23f65a4bfe4300b85f1f40f6c32569822d08901db3b6454ab785d9117cc"}, {file = "lxml-4.6.1-cp38-cp38-win32.whl", hash = "sha256:d6f8c23f65a4bfe4300b85f1f40f6c32569822d08901db3b6454ab785d9117cc"},
{file = "lxml-4.6.1-cp38-cp38-win_amd64.whl", hash = "sha256:573b2f5496c7e9f4985de70b9bbb4719ffd293d5565513e04ac20e42e6e5583f"}, {file = "lxml-4.6.1-cp38-cp38-win_amd64.whl", hash = "sha256:573b2f5496c7e9f4985de70b9bbb4719ffd293d5565513e04ac20e42e6e5583f"},
{file = "lxml-4.6.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:098fb713b31050463751dcc694878e1d39f316b86366fb9fe3fbbe5396ac9fab"},
{file = "lxml-4.6.1-cp39-cp39-manylinux1_i686.whl", hash = "sha256:1d87936cb5801c557f3e981c9c193861264c01209cb3ad0964a16310ca1b3301"}, {file = "lxml-4.6.1-cp39-cp39-manylinux1_i686.whl", hash = "sha256:1d87936cb5801c557f3e981c9c193861264c01209cb3ad0964a16310ca1b3301"},
{file = "lxml-4.6.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:2d5896ddf5389560257bbe89317ca7bcb4e54a02b53a3e572e1ce4226512b51b"}, {file = "lxml-4.6.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:2d5896ddf5389560257bbe89317ca7bcb4e54a02b53a3e572e1ce4226512b51b"},
{file = "lxml-4.6.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:9b06690224258db5cd39a84e993882a6874676f5de582da57f3df3a82ead9174"}, {file = "lxml-4.6.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:9b06690224258db5cd39a84e993882a6874676f5de582da57f3df3a82ead9174"},

View file

@ -15,6 +15,7 @@ beautifulsoup4 = "^4.9.3"
requests = "^2.24.0" requests = "^2.24.0"
ffmpeg-python = "^0.2.0" ffmpeg-python = "^0.2.0"
lxml = "^4.6.1" lxml = "^4.6.1"
colorama = "^0.4.4"
[tool.poetry.scripts] [tool.poetry.scripts]
bbbdl = 'bbbdl.__main__:main' bbbdl = 'bbbdl.__main__:main'