Skip to main content

A Python API to communicate with Photo Station running on Synology NAS.

Project description

A Python API to communicate with Photo Station running on Synology NAS. Photos and videos are uploaded directly to PhotoStation through its Web API with various metadata including ratings, title, description, and GPS coordinates.

This module uploads original files and lets Synology to process the required thumbnail versions. This works fine with Synology DS916+ but might be too slow with models having slower processors.

Supported features:

  • Login to your shared or personal Photo Station

  • List album contents

  • Create missing albums automatically

  • Add new photos

  • Update metadata of existing photos

  • Update photo binaries based if either timestamp or filesize differs

  • Delete photos

Tested with Synology DS916+ running DSM 6.1 and Photo Station 6.7.1. Should work with older versions too but you mileage may vary.

Installation

pip install photostation

Usage

from photostation import PhotoStationService, SynologyException
import requests

try:
    # login to Photo Station and set up root album
    service = PhotoStationService('https://USERNAME:PASSWORD@xyz.synology.me/photo/webapi/', 'root-album')

    # get reference to album and create it if missing
    album = service.album('2017/05/13', create=True)

    # list album content (subalbums, photos, videos)
    print(album.items)

    # add photo reference inside album
    photo = album.create_item(
        filename = 'testimage.jpg', # original filename
        filetype = 'photo',         # photo or video
        created = 1494603121336,    # timestamp of photo capture
        modified = 1494603121336    # optional timestamp to compare if existing binary has changed
        filesize = 1000,            # optional filesize to compare if existing binary has changed
        title = '',                 # optional title
        description = '',           # optional description
        rating = 0,                 # optional starts from 0 to 5
        latitude = 60,              # optional coordinates for videos
        longitude = 20)             # optional coordinates for videos

    # update metadata of existing photos
    merged = photo.merge()

    if merged:
        print('metadata was updated or already up to date, deleting photo')

        photo.delete()
    else:
        # upload new file
        stream = requests.get('https://dummyimage.com/600x400/000/fff', stream=True)
        photo.save_content(stream)

except SynologyException as se:
    print se.value

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

photostation-0.1.5.tar.gz (7.9 kB view details)

Uploaded Source

File details

Details for the file photostation-0.1.5.tar.gz.

File metadata

File hashes

Hashes for photostation-0.1.5.tar.gz
Algorithm Hash digest
SHA256 3653f272f63488321c0310d0a290f59d4468a98d117c521e174ce801fe5947dc
MD5 bcdb74b9d4eef584cdf02a806325821a
BLAKE2b-256 65e7c619e2e79371ddf1cde348e8fef7cc49ed252efe3e93d5f04d1484625213

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page