diff --git a/mt_clockwheel.py b/mt_clockwheel.py index 6b047a7..eb9523d 100644 --- a/mt_clockwheel.py +++ b/mt_clockwheel.py @@ -17,7 +17,17 @@ def main(): for single_date in daterange(from_date, to_date): if verbose: print("Processing date", single_date) - build_day(single_date) + daylist = build_day(single_date) + + daylist_path = playlistdir + "/" + channel + "/" + single_date.strftime("%Y") + "/" + single_date.strftime("%m") + "/" + single_date.strftime("%d") + "/" + if not os.path.isdir(daylist_path): + os.makedirs(daylist_path) + daylist_file = single_date.strftime("%Y") + "-" + single_date.strftime("%m") + "-" + single_date.strftime("%d") + ".json" + with open(daylist_path + daylist_file, "w") as file: + file.write(daylist) + + if verbose: + print('wrote playlist file', daylist_path + daylist_file) def parse_config(): global mediadir, playlistdir, channel, verbose, from_date, to_date, playlist_duration @@ -77,8 +87,11 @@ def build_day(this_date): # TODO: see if playlist_duration is a factor of 24 * 60 * 60 and, if so, duplicate it to fill 24 hours + playlist = json.dumps(d) if verbose: - print("playlist json:", json.dumps(d)) + print("playlist json:", playlist) + + return playlist def get_playlist_entry(): entry = {