Skip to content

Instantly share code, notes, and snippets.

@eliottness
Last active November 26, 2025 20:15
Show Gist options
  • Select an option

  • Save eliottness/63c7e4eddbe6befbeebecc7839f97451 to your computer and use it in GitHub Desktop.

Select an option

Save eliottness/63c7e4eddbe6befbeebecc7839f97451 to your computer and use it in GitHub Desktop.
Send Famileo Pictures to Aura Frame
import os
from typing import Generator
import requests
import smtplib
from email.mime.multipart import MIMEMultipart
from email.message import EmailMessage
from datetime import datetime
"""
### .Env content ###
# Please keep being incognito
USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
# Can be found using the developer tools when logged in Famileo
FAMILY_ID="123456"
# Must be an email used bu someone logged in Aura Frame
ORIGIN_EMAIL="test@gmail.com"
# https://help.auraframes.com/hc/en-us/articles/4410731762839-How-to-Send-Photos-via-Email-to-Your-Aura-Frame
DEST_EMAIL="xxxxxxxxxxxxxxxxxx@send.auraframes.com"
# Use your internal SMTP server to send the email
SMTP_HOST="gmail-relay.gmail-relay.svc.cluster.local"
# Famileo login credentials
FAMILEO_USER="test@gmail.com"
FAMILEO_PASSWORD="password123"
"""
# Read .env file alongside the script if it exists
env_file = os.path.join(os.path.dirname(__file__), ".env")
if os.path.exists(env_file):
with open(env_file) as f:
for line in f:
if line.startswith("#") or not line.strip():
continue
key, value = line.strip().split("=", 1)
os.environ[key] = value
USER_AGENT = os.getenv("USER_AGENT")
FAMILY_ID = os.getenv("FAMILY_ID")
ORIGIN_EMAIL = os.getenv("ORIGIN_EMAIL")
DEST_EMAIL = os.getenv("DEST_EMAIL")
SMTP_HOST = os.getenv("SMTP_HOST")
FAMILEO_USER = os.getenv("FAMILEO_USER")
FAMILEO_PASSWORD = os.getenv("FAMILEO_PASSWORD")
def get_login_session(user: str, password: str) -> str:
"""
Get the login session id for Famileo.
"""
response = requests.post(
"https://www.famileo.com/login_check",
headers={
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": USER_AGENT
},
data={
"_username": user,
"_password": password,
}
)
response.raise_for_status()
return response.cookies["PHPSESSID"]
def get_famileo_posts(session_token: str) -> Generator[dict, None, None]:
"""
Get the list of Famileo posts.
"""
now = datetime.now()
base_url = f"https://www.famileo.com/api/families/{FAMILY_ID}/posts"
url = base_url
gazette_date_tz = None
while True:
response = requests.get(
url,
headers={
"accept": "application/json",
"Cookie": f"PHPSESSID={session_token}",
"User-Agent": USER_AGENT
},
)
response.raise_for_status()
wall = response.json()["famillyWall"]
if len(wall) == 0:
raise ValueError("Failed to get posts from Famileo.")
for post in wall:
# If the post is not out yet, skip it
if "gazette_date_tz" not in post or post["gazette_date_tz"] is None:
continue
gazette_post_date = post["gazette_date_tz"]
# If the gazette has not been out for more than 7 days, skip it (Postal delivery time)
if datetime.fromisoformat(gazette_post_date) > now - datetime.timedelta(days=7):
continue
if gazette_date_tz is None:
# We found the gazette we want to access
gazette_date_tz = gazette_post_date
elif gazette_date_tz != gazette_post_date:
# We have reached the next gazette, stop here
raise StopIteration
yield post
# Substract one hour to this last date to avoid getting the same page again
query_param = datetime.fromisoformat(wall[-1]["date_tz"]) - datetime.timedelta(hours=1)
url = f"{base_url}?timestamp={query_param.isoformat()}"
def download_image(url: str) -> bytes:
"""
Download an image from a URL.
"""
response = requests.get(
url,
headers={
"User-Agent": USER_AGENT
},
)
response.raise_for_status()
return response.content
def send_image(image_data: bytes):
"""Send image to Aura Frale via the mail feature.
Args:
image_data (bytes): The image data to send.
"""
msg = EmailMessage()
msg['Subject'] = 'New Famileo Picture' # Not taken into account by Aura Frames
msg['From'] = ORIGIN_EMAIL
msg['To'] = DEST_EMAIL
msg.set_content('New picture from Famileo attached.') # Not taken into account by Aura Frames
msg.add_attachment(image_data, maintype='image', subtype='jpeg')
with smtplib.SMTP(SMTP_HOST) as server:
server.send_message(msg)
def main():
session_token = get_login_session(FAMILEO_USER, FAMILEO_PASSWORD)
for post in get_famileo_posts(session_token):
image_url = post.get("image_2x") or post.get("image")
if not image_url:
print(f"No image found in post {post['wall_post_id']}, skipping.")
image_data = download_image(image_url)
send_image(image_data)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment