diff --git a/index.html b/index.html index 921131e..ebfad3e 100755 --- a/index.html +++ b/index.html @@ -23,5 +23,7 @@

The full catalog of still images should be seen at http://telescopium.local/stills/.

+ +

Telescopium's ip address is ip addr goes here.

diff --git a/make_a_gif.py b/make_a_gif.py new file mode 100644 index 0000000..aed46b4 --- /dev/null +++ b/make_a_gif.py @@ -0,0 +1,26 @@ +#!/bin/python3 +import os +from datetime import datetime + +def make_it(): + #filter out and sort to get only the frames we want (noon frames from the last two weeks) + files = os.listdir("/var/www/html/stills/") + twoweeks = [] + now = datetime.now() + for fi in files: + f = "/var/www/html/stills/" + fi + dt = datetime.fromtimestamp(os.stat(f).st_mtime) + if (now-dt).days < 16 and dt.hour < 13 and dt.hour > 10: + twoweeks.append(f) + frames = sorted(twoweeks, key=lambda f: os.stat(f).st_mtime) + + with open("/var/www/html/framelist.txt", "w+") as framelist: + framelist.write("".join(["file '" + f + "'\n" for f in frames])) + + #make the actual gif + print(f"ffmpeg -r 7 -f concat -safe 0 -i /var/www/html/framelist.txt -c copy -s 1280x720 -vcodec libx264 /var/www/html/twoweeks.mp4") + print(f"convert -delay 14 -loop 0 -dispose previous {' '.join(frames)} /var/www/html/animation.gif") + + +if __name__ == "__main__": + make_it() diff --git a/take_a_still.py b/take_a_still.py index a80cf01..c697587 100644 --- a/take_a_still.py +++ b/take_a_still.py @@ -1,7 +1,9 @@ #!/bin/python3 import os import shutil +import socket from bs4 import BeautifulSoup +from datetime import datetime index_filename = "/var/www/html/index.html" @@ -15,6 +17,15 @@ filename = "/stills/" + os.popen("date +%+4Y-%m-%d-%Hh%Mm.jpg").read().strip() os.system("libcamera-jpeg -o /var/www/html" + filename) +import make_a_gif +make_a_gif.make_it() + +# figgure out our local ip address +s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +s.connect(("8.8.8.8", 80)) +ip_address = s.getsockname()[0] +s.close() + #make sure that the index shows the latest one soup = None @@ -26,5 +37,7 @@ with open(index_filename, "r") as the_file: latest_image['src'] = filename + soup.find(id="ip_address").string = ip_address + with open(index_filename, "w") as the_file: the_file.write(str(soup)) diff --git a/telescopium.service b/telescopium.service index e4e6968..6531e2d 100644 --- a/telescopium.service +++ b/telescopium.service @@ -8,4 +8,4 @@ ExecStart=python /home/shoofle/telescopium/take_a_still.py User=shoofle [Install] -WantedBy=multi-user.target +WantedBy = multi-user.target diff --git a/work_log b/work_log index 3d419cc..17f37a3 100644 --- a/work_log +++ b/work_log @@ -19,3 +19,10 @@ added a listing for autoindexing the folder /var/www/html/stills/ with location made a python script to take a picture, plus a systemd service and timer to take pictures daily! they need to be symlinked into /etc/systemd/system/ finally realized i never did `systemctl enable telescopium.timer --now` so the timer never started which is why my daily task hasn't been running. remedied. + +telescopium physical has been installed in its place in the rear window. also i made it so that it prints its current ip address in the webpage. + +gonna try and make it so it converts the latest month of images into a gif, at a rate of one week per second? hopefully just using imagemagick. +update: i am deep in the bowels of imagemagick and ffmpeg trying in vain to get this to work + +fixed the unrelated issue where it was taking a picture every time the system rebooted. it's because i had the telescopium service enabled in addition to the timer; i disabled the service and made sure only the timer was enabled