mt_clockwheel/mt_clockwheel.py

69 lines
2.4 KiB
Python
Raw Normal View History

2023-08-25 11:36:58 -04:00
import argparse
import datetime
import json
import os
# globals
mediadir = "/var/lib/ffplayout/tv-media"
playlistdir = "/var/lib/ffplayout/playlists"
channel = "newellijaytelevision"
verbose = False
from_date = datetime.date.today()
to_date = datetime.date.today()
def main():
parse_config()
2023-08-25 11:49:39 -04:00
for single_date in daterange(from_date, to_date):
if verbose:
print("Processing date", single_date)
build_day(single_date)
2023-08-25 11:36:58 -04:00
def parse_config():
global mediadir, playlistdir, channel, verbose, from_date, to_date
parser = argparse.ArgumentParser(
prog="mt_clockwheel",
description="a simple clockwheel playlist generator for ffplayout",
epilog="brought to you by your friends at Mountain Town Technology and Community Media Network"
)
parser.add_argument('-d', '--directory', dest='mediadir', help='root directory for media library')
parser.add_argument('-p', '--playlists', dest='playlistdir', help='root directory for playlists')
parser.add_argument('-c', '--channel', dest='channel', help='channel name to generate playlists for')
parser.add_argument('-v', '--verbose', action='store_true', help='provide verbose output logging')
parser.add_argument('-f', '--from', dest='from_date', help='first date to generate playlist for')
parser.add_argument('-t', '--to', dest='to_date', help='last date to generate playlist for')
args = parser.parse_args()
if args.verbose:
verbose = True
if args.mediadir:
mediadir = args.mediadir
if args.playlistdir:
playlistdir = args.playlistdir
if args.channel:
channel = args.channel
if args.from_date:
2023-08-25 11:49:39 -04:00
from_date = datetime.datetime.strptime(args.from_date, "%Y-%m-%d").date()
2023-08-25 11:36:58 -04:00
if args.to_date:
2023-08-25 11:49:39 -04:00
to_date = datetime.datetime.strptime(args.to_date, "%Y-%m-%d").date()
2023-08-25 11:36:58 -04:00
if verbose:
print("Arguments parsed, config:")
print("mediadir:", mediadir)
print("playlistdir:", playlistdir)
print("channel:", channel)
print("from_date:", from_date)
print("to_date:", to_date)
2023-08-25 11:49:39 -04:00
def build_day(this_date):
# todo
pass
# generator function to yield single dates from a date range
def daterange(start_date, end_date):
for n in range(int((end_date - start_date).days) + 1): # adding 1 to make the range inclusive
yield start_date + datetime.timedelta(n)
2023-08-25 11:36:58 -04:00
if __name__ == "__main__":
main()