From 1331316f6ee7621c0b0ea432549d628b059b5246 Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Wed, 29 Nov 2023 21:03:25 -0500 Subject: [PATCH] Update blink paths --- scripts/blink-check | 2 +- scripts/blink-fetch | 35 +++++++++++++++++++++++------------ scripts/blink-timelapse | 2 +- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/scripts/blink-check b/scripts/blink-check index af9eef4..d43188e 100755 --- a/scripts/blink-check +++ b/scripts/blink-check @@ -11,7 +11,7 @@ def main() -> int: # Handle program arguments ap = argparse.ArgumentParser(prog='blink-check', description='Check on a running blink-fetch cron task') ap.add_argument("hostname", help="[user@]hostname[:port] for SSH") - ap.add_argument("--image-dir", help="Remote directory containing fetched images", default="/tmp/blink") + ap.add_argument("--image-dir", help="Remote directory containing fetched images", default="/home/ewpratten/Pictures/blink") ap.add_argument("--camera-id", help="Camera ID", default="155295") ap.add_argument("--show-latest", "--show", "-s", help="Download and display the latest image (if possible)", action="store_true") ap.add_argument('-v', '--verbose', help='Enable verbose logging', action='store_true') diff --git a/scripts/blink-fetch b/scripts/blink-fetch index 31d9312..c98c163 100755 --- a/scripts/blink-fetch +++ b/scripts/blink-fetch @@ -14,11 +14,13 @@ from pathlib import Path logger = logging.getLogger(__name__) + def decdeg2dms(dd): mult = -1 if dd < 0 else 1 - mnt,sec = divmod(abs(dd)*3600, 60) - deg,mnt = divmod(mnt, 60) - return mult*deg, mult*mnt, mult*sec + mnt, sec = divmod(abs(dd) * 3600, 60) + deg, mnt = divmod(mnt, 60) + return mult * deg, mult * mnt, mult * sec + async def main() -> int: # Handle program arguments @@ -28,12 +30,18 @@ async def main() -> int: ap.add_argument("--username", help="Blink username", required=True) ap.add_argument("--password", help="Blink password") ap.add_argument("--camera-id", help="Camera ID", default="155295") - ap.add_argument("--output-dir", help="Output directory", default="/tmp/blink") - ap.add_argument("--no-2fa", help="Don't try to get 2FA credentials", action="store_true") + ap.add_argument("--output-dir", help="Output directory", default="~/Pictures/blink") + ap.add_argument( + "--no-2fa", help="Don't try to get 2FA credentials", action="store_true" + ) ap.add_argument("--no-exif", help="Don't write EXIF data", action="store_true") ap.add_argument("--exif-camera", help="Camera name", default="Blink Mini") - ap.add_argument("--exif-latitude", "--exif-lat", help="Camera latitude (Decimal Degrees)") - ap.add_argument("--exif-longitude", "--exif-lng", help="Camera longitude (Decimal Degrees)") + ap.add_argument( + "--exif-latitude", "--exif-lat", help="Camera latitude (Decimal Degrees)" + ) + ap.add_argument( + "--exif-longitude", "--exif-lng", help="Camera longitude (Decimal Degrees)" + ) ap.add_argument( "-v", "--verbose", help="Enable verbose logging", action="store_true" ) @@ -50,7 +58,9 @@ async def main() -> int: args.password = getpass.getpass(prompt="Blink Password: ") # Authenticate with Blink servers - auth = Auth({"username": args.username, "password": args.password}, no_prompt=args.no_2fa) + auth = Auth( + {"username": args.username, "password": args.password}, no_prompt=args.no_2fa + ) blink = Blink() blink.auth = auth await blink.start() @@ -72,8 +82,9 @@ async def main() -> int: # Create the output directory if it doesn't exist now = datetime.now() - out_file = Path( - f"{args.output_dir}/camera_{args.camera_id}.{now.strftime('%Y%m%d_%H%M%S')}.jpg" + out_file = ( + Path(args.output_dir).expanduser() + / f"camera_{args.camera_id}.{now.strftime('%Y%m%d_%H%M%S')}.jpg" ) out_file.parent.mkdir(parents=True, exist_ok=True) @@ -88,7 +99,7 @@ async def main() -> int: # Set the camera type image.model = args.exif_camera - + # If the user provided a latitude and longitude, set it # if args.exif_latitude and args.exif_longitude: # image.gps_latitude = decdeg2dms(float(args.exif_latitude)) @@ -98,7 +109,7 @@ async def main() -> int: # Set the timestamp image.datetime_original = now.strftime(exif.DATETIME_STR_FORMAT) - + # Write the EXIF data back to the file logger.info("Writing EXIF data") with open(out_file, "wb") as f: diff --git a/scripts/blink-timelapse b/scripts/blink-timelapse index a1e0c4a..0e202b2 100755 --- a/scripts/blink-timelapse +++ b/scripts/blink-timelapse @@ -16,7 +16,7 @@ def main() -> int: description="Generates timelapses from blink image captures", ) ap.add_argument("--camera-id", help="Camera ID", default="155295") - ap.add_argument("--image-dir", help="Image directory", default="/tmp/blink") + ap.add_argument("--image-dir", help="Image directory", default="~/Pictures/blink") ap.add_argument( "--output-dir", help="Output directory", default="~/Videos/BlinkTimelapse" )