50 lines
1.5 KiB
Python
Executable File
50 lines
1.5 KiB
Python
Executable File
#!/usr/bin/python3
|
|
|
|
import os, random
|
|
from tinytag import TinyTag
|
|
import datetime
|
|
|
|
DATE = datetime.datetime.now().strftime("%Y-%m-%d")
|
|
|
|
playlist_array = []
|
|
show_array = []
|
|
show_info = []
|
|
|
|
# open master playlist
|
|
with open('music/kam/kamizdat_flac.pls') as playlist_file:
|
|
for line in playlist_file:
|
|
playlist_array.append(line)
|
|
|
|
# /////////////////////////////////////////////////
|
|
|
|
# randomly select a number of tracks
|
|
for i in range(15):
|
|
show_array.append(random.choice(playlist_array).rstrip())
|
|
# remove any duplicates
|
|
show_array = list(set(show_array))
|
|
# write the selection as a playlist file
|
|
with open("antena_playlist_" + DATE + ".pls","w") as file:
|
|
file.writelines("\n".join(show_array))
|
|
|
|
# /////////////////////////////////////////////////
|
|
# create a markdown file containing show information
|
|
|
|
total_show_duration = 0
|
|
|
|
for i in show_array:
|
|
track = TinyTag.get(i)
|
|
detail = track.artist + " : " + track.title + \
|
|
" : " + track.album + " : " + str(track.year) + " : " + str(track.duration)
|
|
show_info.append("! " + detail)
|
|
total_show_duration = total_show_duration + track.duration
|
|
|
|
total_show_duration = total_show_duration/60
|
|
|
|
with open("antena_showinfo_" + DATE + ".md","w") as file:
|
|
file.writelines("# SHOW INFO FOR ANTENA " + DATE + "\n")
|
|
file.writelines("Total Playtime excluding fills " + str(total_show_duration) + "\n\n")
|
|
file.writelines("\n".join(show_info))
|
|
|
|
# /////////////////////////////////////////////////
|
|
|