Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup prints #19

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions examples/test_extract.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
import krec
import argparse
from pathlib import Path


"""
Extract KRec data from an MKV file and optionally save it to a new file.

Usage:
# Just extract and view
python examples/test_extract.py input.mkv -v

# Extract and save
python examples/test_extract.py input.mkv -o output.krec -v
"""

import argparse
import logging
from pathlib import Path

import colorlogging

import krec


def main(args):
print(f"Extracting from: {args.input_file}")
logging.info("Extracting from: %s", args.input_file)

try:
extracted_krec = krec.extract_from_video(args.input_file, verbose=args.verbose)
print("Extraction successful")
print(f"Extracted KRec has {len(extracted_krec)} frames")
logging.info("Extraction successful")
logging.info("Extracted KRec has %d frames", len(extracted_krec))

if args.output_file:
output_path = Path(args.output_file)
extracted_krec.save(str(output_path))
print(f"Saved to: {output_path}")
logging.info("Saved to: %s", output_path)

except Exception as e:
print(f"Error: {e}")
return 1

return 0
logging.error("Error: %s", e)


if __name__ == "__main__":
Expand All @@ -38,5 +41,7 @@ def main(args):
parser.add_argument("-o", "--output-file", type=str, help="Output KRec file path (optional)")
parser.add_argument("-v", "--verbose", action="store_true", help="Enable verbose output")

colorlogging.configure()

args = parser.parse_args()
exit(main(args))
main(args)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
colorlogging
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
version: str = version_re.group(1)


with open("requirements.txt") as f:
requirements: list[str] = f.read().splitlines()

class RustBuildExt(build_ext):
def run(self) -> None:
# Generate the stub file
Expand Down Expand Up @@ -60,6 +63,7 @@ def run(self) -> None:
),
],
setup_requires=["setuptools-rust"],
install_requires=requirements,
zip_safe=False,
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down