diff --git a/create_archive.sh b/create_archive.sh index 46ec122..78ce79e 100755 --- a/create_archive.sh +++ b/create_archive.sh @@ -1,6 +1,8 @@ # reminders of some useful oneliners +for i in *.zip; do echo unzip \"$i\" -d \"${i%.zip}\" ; done + find /home/rizoma/kamizdat_archive/kamizdat.si -iname "*FLAC*.zip" -exec unzip "{}" \; for i in *.zip; do unzip "$i" ; done; diff --git a/create_show.py b/create_show.py index 0059365..866fa55 100755 --- a/create_show.py +++ b/create_show.py @@ -1,5 +1,5 @@ #!/usr/bin/python3 -import os, random, time +import os, fnmatch, random, time from tinytag import TinyTag import datetime @@ -8,76 +8,97 @@ from random import shuffle DATE = datetime.datetime.now().strftime("%Y-%m-%d") total_show_duration = 0 +complete_playlist = [] show_array = [] show_cover = "---" archive = [] +show_name = "THE AND IF" +path = "/home/rob/antena/" + # ///////////////////////////////////////////////// -def create_intro(): - intropath = "/home/rob/antena/texts/clips/u_have_been" +def create_intro(show_array): + intropath = path + "texts/clips/this_is" intro = random.choice(os.listdir(intropath)) - show_array.append(str(os.path.abspath(intropath)) + "/" + str(intro)) + show_array.insert(0, str(os.path.abspath(intropath)) + "/" + str(intro)) def add_to_tracks_played(add_to_played: str): #global complete_tracks_played with open('music/tracks_played.pls', "a") as tracks_played_file: tracks_played_file.write(add_to_played + "\n") -def check_archive(): +def check_archive(track): global archive with open('music/tracks_played.pls') as archive_file: for line in archive_file: archive.append(line) - return archive - -def create_playlist(show_array: list): + if track not in archive: + print("____ TRACK NOT YET PLAYED ... ADDING _____") + return True + else: + print("____ TRACK ALREADY PLAYED _____") + return False + +def load_all_music(): + with open('music/complete_music_archive.pls') as playlist_file: + for line in playlist_file: + complete_playlist.append(line) + print("loaded %s".format(str(len(complete_playlist)))) + return complete_playlist + +def create_show_playlist(show_array: list, complete_playlist:list): + load_all_music() + global total_show_duration global archive - complete_playlist = [] track_count = 0 artist_played = [] - max_track_dur = 12 + max_track_dur = 8 + min_track_dur = 3 - with open('music/complete.pls') as playlist_file: - for line in playlist_file: - complete_playlist.append(line) - - while total_show_duration < 60 * 58: - song = random.choice(random.sample(complete_playlist, len(complete_playlist) )).rstrip() # pick a song + while total_show_duration < 60 * 55: + song = random.choice(random.sample(\ + complete_playlist, len(complete_playlist) )).rstrip() # pick a song track = TinyTag.get(song) # get its metadata # check if the artist not in the played list and the song is less than 8mins - check_archive() - - if track.artist not in artist_played \ - and track.title not in archive \ - and int(track.duration) < max_track_dur * 60: - show_array.append(song.rstrip()) # if 'not in' is true then add the song - artist_played.append(track.artist) # and add the artist to the played list - add_to_tracks_played(track.title) # and write entry to archive file - - track_count += 1 - total_show_duration = total_show_duration + track.duration - else: print("inclusion conditions not met...................... " + str(track)) + if track.artist not in artist_played: + if check_archive(track.title) is True: + if int(track.duration) > min_track_dur * 60: + if int(track.duration) < max_track_dur * 60: + show_array.append(song.rstrip()) # if 'not in' is true then add the song + artist_played.append(track.artist) # and add the artist to the played list + add_to_tracks_played(track.title) # and write entry to archive file + track_count += 1 + total_show_duration = total_show_duration + track.duration + else: print("TRACK TOO SHORT..........." + str(track)) + else: print("TRACK TOO LONG..........." + str(track)) + else: print("SONG PLAYED IN PREVIOUS EPISODE" + str(track)) + else: print("ARTIST ALREADY IN PODCAST" + str(track)) + total_show_duration = timedelta(seconds=round(total_show_duration)) show_array = list(set(show_array)) print("total tracks = " + str(track_count)) print("total duration = " + str(total_show_duration)) return show_array, total_show_duration - - - def find_show_coverart(show_array:list): global show_cover cover = random.choice(show_array) cover = '/'.join(cover.split('/')[:-1]) show_cover = str(cover + "/cover.jpg") - print("cover is ...." + show_cover) + print("THIS WEEKS COVER ART OF THE WEEK is ...." + show_cover) return show_cover +#def create_show_audio(): + def create_web_page(show_array:list): + + dir_path = "shows/" + pattern = "*.html" + show_count = len(fnmatch.filter(os.listdir(dir_path), pattern)) + show_info = [] find_show_coverart(show_array) global total_show_duration @@ -102,21 +123,72 @@ def create_web_page(show_array:list):
" + x + "
" +" \n " ) - file.writelines("