parser.add_argument('--camera', "-c", help='Camera: icc / idc', default="idc")
parser.add_argument('--textsize', "-t", help='Text size: default 40', default="40")
args = parser.parse_args()
InSightMission = InSightAPI(af=args.camera, per_page="400")
json_request = InSightMission.make_request()
metadata_images = InSightMission.get_images_metadata(json_request, InSightMission.get_count(json_request))
images = []
metadata = []
filenames = []
for index, image in enumerate(metadata_images):
	images.append(image["url"])
	metadata.append(image["title"])
	filenames.append("images/IMG_" + str(index) + ".png")

metadata.reverse()
if os.path.exists("images"):
	shutil.rmtree("images")
utils.download_image(images, "images/", order="sequential")
for index, i in enumerate(filenames):
	cmd = ["convert",i,"-pointsize",args.textsize,"-fill","white","-undercolor","'#00000080'","-gravity","South","-annotate","+0+5",metadata[index],i]	
	p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
	out, err = p.communicate()
          
scale = ""
if not args.size == None:
	scale = "-vf scale=" + args.size
p = subprocess.Popen("ffmpeg -y -f image2 -framerate " + args.fps + " -i images/IMG_%d.png " + scale + " " + args.output, shell=True)
out, err = p.communicate()

#shutil.rmtree("images")
### Gets X number of images from InSight Mars Lander from NASA.gov

### Args:
### n = number of images starting from the current one backwards
### out = output directory

import argparse

from insightmars import InSightAPI, utils
InSightMission = InSightAPI(per_page="400")

parser = argparse.ArgumentParser()
parser.add_argument("--number",
                    "-n",
                    type=int,
                    help='Number of images to download',
                    required=True)
parser.add_argument('--output', "-o", help='Output directory', required=True)
parser.add_argument('--sort', "-s", help='Sort by: sol / sequential', type=str)
args = parser.parse_args()

json_request = InSightMission.make_request()
all_images = InSightMission.get_count(json_request)
print("InSight Photo Downloader")
print("Number of images available: %d" % all_images)
print("Number of images to download: %d" % args.number)
images = InSightMission.get_images(json_request, args.number)
utils.download_image(images, args.output, args.sort)
Esempio n. 3
0
from insightmars import InSightAPI, utils
import os
import time

#import twutils
import logging

InSightMission = InSightAPI()
json_request = InSightMission.make_request()

if not os.path.exists("images"):
    os.makedirs("images")
logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO)
while True:
    time.sleep(5)  #1800 = 30min
    if len(os.listdir('images')) == 0:
        logging.info("populating 1st img")
        utils.download_image(InSightMission.get_latest(json_request))
    current_imageid = InSightMission.get_images_metadata(json_request,
                                                         1)[0]["imageid"]
    if not os.listdir('images')[0].replace(".PNG", "") == current_imageid:
        logging.info("downloading new img + tweeting it.....")
        utils.download_image(InSightMission.get_latest(json_request))
        #tweet
        cmd = ["python", "tweet.py", current_imageid + ".PNG"]
        subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)