diff --git a/mt_clockwheel.py b/mt_clockwheel.py index 221542b..daae644 100644 --- a/mt_clockwheel.py +++ b/mt_clockwheel.py @@ -106,7 +106,20 @@ def build_day(this_date): if verbose: print(' added program:', json.dumps(entry), length) - # TODO: see if playlist_duration is a factor of 24 * 60 * 60 and, if so, duplicate it to fill 24 hours + day_length = 24 * 60 * 60 + if day_length % playlist_duration == 0: + if verbose: + print("looping playlist...") + iterations = (day_length / playlist_duration) + iteration = d["program"] # snapshot of the unit of iteration + looped = [] + if verbose: + print("iteration: ", json.dumps(iteration, indent=4)) + print("iterations: ", iterations) + while iterations > 0: + looped.extend(iteration) + iterations -= 1 + d["program"] = looped playlist = json.dumps(d) if verbose: