Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Script: write upcoming Tvheadend recording start dates to Synology power scheduler
#!/usr/bin/env python
import datetime, os, json
# Write upcoming Tvheadend recording start dates to Synology power scheduler
# i.e. turn on your Synology so Tvheadend can record.
# Usage: ./ > /etc/power_sched.conf (or use cron)
# location of Tvheadend PVR-schedule files:
# Day-code constants for power scheduler Monday-Sunday:
DAYS = (16908288, 17039360, 17301504, 17825792, 18874368, 20971520, 16842752)
# read in all the recording start dates
start_dates = []
for f in os.listdir(PVR_DIR):
f = open(os.path.join(PVR_DIR,f), 'r')
data =
data = json.loads(data)
# print out config file, with upcoming dates
print '[Power On schedule]'
for date in start_dates:
d = datetime.datetime.fromtimestamp(date)
n =
#print d.isoformat()
day_constant = DAYS[d.weekday()]
time_offset = 256*d.hour + d.minute
time_code = day_constant + time_offset
if d > n: print time_code
print '[Power Off schedule]'

TODO: enkel data voor deze week in rekening brengen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.