mid show CTA insertion
parent
788e0ce382
commit
59e9a079e8
73
mk_show.py
73
mk_show.py
|
@ -73,6 +73,14 @@ def get_intro():
|
|||
#final_playlist.insert(0, str(os.path.abspath(intropath)) + "/" + str(intro))
|
||||
return str(str(intropath) + "/" + str(intro))
|
||||
|
||||
def get_midshow_CTA():
|
||||
|
||||
midshow_path = "audio/midshow_CTA"
|
||||
midshow_CTA = random.choice(os.listdir(midshow_path))
|
||||
#final_playlist.insert(0, str(os.path.abspath(intropath)) + "/" + str(intro))
|
||||
return str(str(midshow_path) + "/" + str(midshow_CTA))
|
||||
|
||||
|
||||
def choose_a_track(conn, episode_number, ):
|
||||
print("adding a track")
|
||||
global episode_duration
|
||||
|
@ -577,60 +585,69 @@ def create_podcast():
|
|||
|
||||
#TODO add track duration counter into this loop to get final duration
|
||||
# metaflac --show-total-samples --show-sample-rate foo.flac | tr '\n' ' ' | awk '{print $1/$2}' -
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# ------------ MAIN SHOW STRUCTURE STARTS HERE --------------------------
|
||||
|
||||
for i in preview: # database >> python list
|
||||
# if its the first track then put the show intro before it
|
||||
# no track intro but yes track outro
|
||||
|
||||
if i[2] == 1:
|
||||
print("adding track intro: " + "{0}/{2}_in.flac".format(fill_path, episode_number, i[2] ))
|
||||
intro = get_intro()
|
||||
final_playlist.insert(0,intro) # insert the intro
|
||||
print("adding track: " + i[10])
|
||||
final_playlist.insert(1, i[10]) # insert the first track
|
||||
print("adding track outro: " + "{0}/{2}_out.flac".format(fill_path, episode_number, i[2] ))
|
||||
final_playlist.insert(0,intro) # insert the intro <---------------
|
||||
final_playlist.insert(1, i[10]) # insert the first track (crossfade happens later)
|
||||
final_playlist.append("{0}/{2}_out.flac".format(fill_path, episode_number, i[2] ))
|
||||
|
||||
elif i[2] == len(preview): # if it's the last track then dont have an outro
|
||||
print("adding track intro: " + "{0}/{2}_in.flac".format(fill_path, episode_number, i[2] ))
|
||||
elif i[2] == len(preview):
|
||||
# if it's the last track then dont have an outro <-----------------
|
||||
final_playlist.append("{0}/{2}_in.flac".format(fill_path, episode_number, i[2] ))
|
||||
print("adding last track intro no outro - the show ends with music : " + i[10])
|
||||
final_playlist.append(i[10])
|
||||
else:
|
||||
|
||||
#TODO insert some call to action filler after a track outro
|
||||
# x 2
|
||||
|
||||
# TODO = episode_number must be zero to get the dummy filler files -
|
||||
print("adding track intro: " + "{0}/{2}_in.flac".format(fill_path, episode_number, i[2] ))
|
||||
# put the intros and outros to rest of tracks <--------------------
|
||||
final_playlist.append("{0}/{2}_in.flac".format(fill_path, episode_number, i[2] ))
|
||||
print("adding track: " + i[10])
|
||||
final_playlist.append(i[10])
|
||||
print("adding track outro: " + "{0}/{2}_out.flac".format(fill_path, episode_number, i[2] ))
|
||||
final_playlist.append("{0}/{2}_out.flac".format(fill_path, episode_number, i[2] ))
|
||||
|
||||
# Insert a midshow CTA between track 6 outro and track 7 intro --------
|
||||
|
||||
final_playlist.insert(24, get_midshow_CTA()) # <-----------------------
|
||||
|
||||
# ------------ MAIN SHOW STRUCTURE ENDS HERE --------------------------
|
||||
|
||||
print('''
|
||||
========================================================================
|
||||
========================================================================
|
||||
{0}
|
||||
========================================================================'''.format(final_playlist))
|
||||
========================================================================'''.format(final_playlist))
|
||||
c = 0
|
||||
for i in final_playlist:
|
||||
c += 1
|
||||
print(c)
|
||||
print(i)
|
||||
|
||||
|
||||
playlist_length = len(final_playlist) / (1000*60)
|
||||
# makes an array of songs and fills as audiosegments
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
# COVERT LIST TO AUDIO SEGMENTS AND DO THE CROSSFADES AND RENDER OUTPUT ETC
|
||||
|
||||
show_playlist = [AudioSegment.from_file(flac_file) for flac_file in final_playlist]
|
||||
|
||||
#playlist = show_playlist[0] # insert intro at head of playlist
|
||||
# FADE IN THE FIRST TRACK
|
||||
|
||||
track1 = show_playlist[1].fade_in(18000) # 18 second fade in to track 1
|
||||
|
||||
# OVERLAY THE FADING IN FIRST TRACK WITH THE SHOW INTRO
|
||||
|
||||
playlist = track1.overlay(show_playlist[0],position= (len(track1)*-1)+50, gain_during_overlay=0)
|
||||
|
||||
#rest = show_playlist[1][len(show_playlist[0]):]
|
||||
#playlist = playlist.append(rest)
|
||||
# JOIN IT ALL TOGETHER - NEED TO BREAK THIS UP IF ANY MORE CROSS FADES NEEDED
|
||||
|
||||
#playlist = playlist.append(show_playlist[1], crossfade=2000) # crossfade first track over intro
|
||||
for track in show_playlist[2:]: # add the rest of the tracks in playlist
|
||||
print(track)
|
||||
playlist = playlist.append(track)
|
||||
|
||||
|
||||
# TODO CLI flag to generate FLAC
|
||||
# save the entire poidcast as FLAC
|
||||
# with open("html/episode/{0}/show.flac".format(episode_number), 'wb') as out_f:
|
||||
# print("FLAC output file opened...writing to file...")
|
||||
|
@ -638,9 +655,15 @@ def create_podcast():
|
|||
# print("FLAC audio file exported...")
|
||||
|
||||
# save the entire poidcast as MP3
|
||||
|
||||
with open("html/episode/{0}/show.mp3".format(episode_number), 'wb') as out_f:
|
||||
print("MP3 output file opened...writing to file...")
|
||||
playlist.export(out_f, format='mp3', tags={'title': str('Uho! Episode #{0} '.format(episode_number)), 'artist': 'https://uho.rizom.si', 'album': 'THE UHO PODCAST', 'comments': 'https://uho.rizom.si'})
|
||||
playlist.export(out_f, format='mp3',\
|
||||
tags={'title': str('Uho! Episode #{0} '.format(episode_number)),\
|
||||
'artist': 'https://uho.rizom.si',\
|
||||
'album': 'THE UHO PODCAST',\
|
||||
'comments': 'https://uho.rizom.si'})
|
||||
|
||||
print("MP3 audio file exported...")
|
||||
|
||||
# TODO duration of final file
|
||||
|
|
Loading…
Reference in New Issue