argparser command line functionality added

main
Rob Canning 2024-01-26 00:25:50 +01:00
parent 1af505cef5
commit f498383f79
7 changed files with 298 additions and 168 deletions

View File

@ -1,4 +1,10 @@
# antena
# uho
usage examples:
./mk_show.py --episode 2 --date 2024-03-11 --playlist keep --web --art --mp3
./mk_show.py --episode 2 --insert_fill --top_tail
Generative radio show of contemporary Slovenian independent music for Mariborski radio študent - MARŠ. Scripted using Liquidsoap and assorted other scripting glue, bash, python...

Binary file not shown.

View File

@ -93,31 +93,36 @@
<div class="row align-items-center justify-content-center text-center">
<div class="col-md-8" data-aos="fade-up" data-aos-delay="400">
<h2 class="text-white font-weight-light mb-2 display-4">{{show_name}} | Episode #{{episode_number}} </h2>
<div class="text-white mb-3"><span class="text-white-opacity-05"><small>{{episode_author}} <span class="sep">/</span> {{episode_date}} <span class="sep">/</span> {{episode_dur}}</small></span></div>
</div>
</div>
</div>
</div>
<div class="text-white mb-3"><span class="text-white-opacity-05"> Hosted by: {{episode_author}} | First broadcast:{{episode_date}} | Total running time: {{episode_duration}}</small></span></div>
</div>
</div>
</div>
</div>
<div class="container site-section">
<div class="container site-section">
<div class="player mb-5">
<audio id="player2" preload="none" controls style="max-width: 100%">
<source src="show.mp3" type="audio/mp3">
</audio>
</div>
<div class="text-white mb-4"><span class="text-white">Presented by: {{episode_author}} / Zavod Rizoma | {{episode_date}}</span>
</div>
<div class="row justify-content-center">
<div class="col-md-12">
<h2>{{show_name}} | Episode #{{episode_number}} | {{episode_date}}</h2>
<em>Total playtime: {{episode_duration}} | Show presented by: {{show_author}}</em>
<div class="player mb-5">
<audio id="player2" preload="none" controls style="max-width: 100%">
<source src="show.mp3" type="audio/mp3">
</audio>
</div>
<em>Playtime: {{episode_duration}} | Show presented by: {{episode_author}} | First broadcast: {{episode_date}} | {{show_url}}</em>
<!-- {% for track in episode_playlist[0:] %} -->
<!-- <p><b> {{track}} </b> </p> -->
<!-- {% endfor %} -->
<table class="table table-striped">
<img src="{{episode_image}}" width="500"/>
<!-- <img src="{{episode_image}}" width="500"/> TODO MAKE THIS PRETTY -->
<!-- <TD class="c1"><IMG src="favicon.ico"></TD> -->
<TD class="c0"><b>#</b></TD>
<TD class="c1"><b>TRACK</b></TD>
@ -144,8 +149,13 @@
<!-- </item> -->
</TR>
{% endfor %}
</table>
</table>
<div class="row align-items-center justify-content-center text-center">
<p><a href="../../index.html" class="btn btn-primary btn-sm py-3 px-4 small">Back to Episode List</a></p>
</div>
</div>
</div>
@ -162,7 +172,6 @@
<p>{{about_show}}</p>
</div>
</div>
<div class="col-lg-4 mb-5 mb-lg-0">
@ -186,7 +195,7 @@
<div class="row">
<div class="col-md-12">
<h3 class="footer-heading mb-4">Follow Us</h3>
<h3 class="footer-heading mb-4">Follow {{show_name}}</h3>
<div>
<a href="#" class="pl-0 pr-3"><span class="icon-facebook"></span></a>
@ -201,20 +210,20 @@
<div class="col-lg-4 mb-5 mb-lg-0">
<div class="mb-5">
<h3 class="footer-heading mb-2">Subscribe Newsletter</h3>
<p>Contact us at: info@zavodrizoma.si.</p>
<!-- <div class="mb-5"> -->
<!-- <h3 class="footer-heading mb-2">Subscribe Newsletter</h3> -->
<!-- <p>Contact us at: uho.podcast@gmail.com.</p> -->
<form action="#" method="post">
<div class="input-group mb-3">
<input type="text" class="form-control border-secondary text-white bg-transparent" placeholder="Enter Email" aria-label="Enter Email" aria-describedby="button-addon2">
<div class="input-group-append">
<button class="btn btn-primary" type="button" id="button-addon2">Send</button>
</div>
</div>
</form>
<!-- <\!-- <form action="#" method="post"> -\-> -->
<!-- <\!-- <div class="input-group mb-3"> -\-> -->
<!-- <\!-- <input type="text" class="form-control border-secondary text-white bg-transparent" placeholder="Enter Email" aria-label="Enter Email" aria-describedby="button-addon2"> -\-> -->
<!-- <\!-- <div class="input-group-append"> -\-> -->
<!-- <\!-- <button class="btn btn-primary" type="button" id="button-addon2">Send</button> -\-> -->
<!-- <\!-- </div> -\-> -->
<!-- <\!-- </div> -\-> -->
<!-- <\!-- </form> -\-> -->
</div>
<!-- </div> -->
</div>

View File

@ -1,4 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{show_name}}</title>
@ -7,7 +8,6 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:200,300,400,700,900">
<link rel="stylesheet" href="fonts/icomoon/style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/magnific-popup.css">
<link rel="stylesheet" href="css/jquery-ui.css">
@ -80,7 +80,6 @@
</ul>
</nav>
</div>
</div>
@ -88,22 +87,29 @@
</header>
<div class="site-blocks-cover overlay" style="background-image: url({{episode_image}});" data-aos="fade" data-stellar-background-ratio="0.5">
<div class="site-blocks-cover overlay" style="background-image: url(episode/{{episode_number}}/{{episode_image}});" data-aos="fade" data-stellar-background-ratio="0.5">
<div class="container">
<div class="row align-items-center justify-content-center text-center">
<div class="col-md-8" data-aos="fade-up" data-aos-delay="400">
<h2 class="text-white font-weight-light mb-2 display-4">Latest Episode: # {{episode_number}}</h2>
<div class="text-white mb-4"><span class="text-white"><b>This week music from: {{episode_artists}}</b></span></div>
<div class="text-white mb-4"><span class="text-white-opacity-05"><small>{{episode_author}} / Zavod Rizoma | 16 September 2017 | 1:30:20</small></span></div>
<p><a href="episode/{{episode_number}}/index.html" class="btn btn-primary btn-sm py-3 px-4 small">Episode Details and Player</a></p>
<div class="col-md-12" data-aos="fade-up" data-aos-delay="400">
<h2 class="text-white font-weight-light mb-2 display-4">{{show_name}}</h2>
<p class="text-white font-weight-light">{{about_show}}</p>
<h4 class="text-white font-weight-light mb-2 display-4">Latest Episode: # {{episode_number}}</h4>
<p class="text-white font-weight-light">This week music from: {{episode_artists}}</p>
<div class="player">
<p><a href="episode/{{episode_number}}/index.html" class="btn btn-primary btn-sm py-3 px-4 small">Episode Details and Player</a></p>
<div class="text-white mb-4"><span class="text-white">Presented by: {{episode_author}} / Zavod Rizoma | {{episode_date}}</span>
<div class="player">
<audio id="player2" preload="none" controls style="max-width: 100%">
<source src="episode/{{episode_number}}/show.mp3" type="audio/mp3">
</audio>
</div>
</div>
<p class="text-white font-weight-light">{{show_url}}</p>
</div>
</div>
</div>
@ -121,7 +127,7 @@
{% for episode in episodes %}
<div class="d-block d-md-flex podcast-entry bg-white mb-5" data-aos="fade-up">
<div class="image" style="background-image: url('episode/{{episode.episode_number}}/img/cover.png');"></div>
<div class="image" style="background-image: url('episode/{{episode.episode_number}}/{{episode_image}}');"></div>
<div class="text">
<h3 class="font-weight-light"><a href="episode/{{episode.episode_number}}/index.html">Episode: # {{episode.episode_number}} </a></h3>
@ -264,7 +270,7 @@
<div class="row">
<div class="col-lg-4">
<div class="mb-5">
<h3 class="footer-heading mb-4">About {{show_name}}</h3>
<h3 class="footer-heading mb-4">About The {{show_name}} Podcast</h3>
<p>{{about_show}}</p>
</div>
@ -329,47 +335,65 @@
<div class="row">
<div class="col-md-12">
<h3 class="footer-heading mb-4">Follow Us</h3>
<h3 class="footer-heading mb-4">Follow Us on Social Media</h3>
We are on most of the social media platforms, please follow us and tell your friends about the podcast!
<div>
<a href="#" class="pl-0 pr-3"><span class="icon-facebook"></span></a>
<a href="#" class="pl-3 pr-3"><span class="icon-twitter"></span></a>
<a href="#" class="pl-3 pr-3"><span class="icon-instagram"></span></a>
<a href="#" class="pl-3 pr-3"><span class="icon-linkedin"></span></a>
<a href="https://www.facebook.com/profile.php?id=61555936138715" class="pl-0 pr-3"><span class="icon-facebook"></span></a>
<a href="https://twitter.com/uho_podcast" class="pl-3 pr-3"><span class="icon-twitter"></span></a>
<a href="https://www.instagram.com/uho.podcast" class="pl-3 pr-3"><span class="icon-instagram"></span></a>
<a href="https://www.youtube.com/@uho.podcast" class="pl-3 pr-3"><span class="icon-youtube"></span></a>
<a href="https://soundcloud.com/uho-podcast" class="pl-3 pr-3"><span class="icon-soundcloud"></span></a>
</div>
</div>
<p></p>
<p></p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h3 class="footer-heading mb-4">Support us on Patreon</h3>
<div>
<a href="https://www.patreon.com/bePatron?u=116340955">Become a Patreon member! Support the show financially, for as little as 5 euros/dollars/pounds a month </a>
</div>
</div>
</div>
</div>
<!-- <div class="col-lg-4 mb-5 mb-lg-0"> -->
<!-- <div class="mb-5"> -->
<!-- <h3 class="footer-heading mb-4">Watch Video</h3> -->
<!-- <div class="block-16"> -->
<!-- <figure> -->
<!-- <img src="images/img_1.jpg" alt="Image placeholder" class="img-fluid rounded"> -->
<!-- <a href="https://vimeo.com/channels/staffpicks/93951774" class="play-button popup-vimeo"><span class="icon-play"></span></a> -->
<!-- </figure> -->
<!-- </div> -->
</div>
<div class="col-lg-4 mb-5 mb-lg-0">
<div class="mb-5">
<h3 class="footer-heading mb-2">Subscribe Newsletter</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit minima minus odio.</p>
<form action="#" method="post">
<div class="input-group mb-3">
<input type="text" class="form-control border-secondary text-white bg-transparent" placeholder="Enter Email" aria-label="Enter Email" aria-describedby="button-addon2">
<div class="input-group-append">
<button class="btn btn-primary" type="button" id="button-addon2">Send</button>
</div>
</div>
</form>
<h3 class="footer-heading mb-4">Subscribe to Podcast RSS Feed</h3>
<div class="block-16">
<figure>
<a href="{{show_url}}/{{show_rss}}">
<img src="episode/1/img/cover0.png" alt="podcast" class="img-fluid rounded">
</a>
</figure>
<a href="{{show_url}}/{{show_rss}}">{{show_url}}/{{show_rss}}</a>
</div>
You can also subscribe to our RSS feed via Soundcloud <a href="https://soundcloud.com/uho-podcast" class="pl-3 pr-3"><span class="icon-soundcloud"></span></a> or Youtube <a href="https://www.youtube.com/@uho.podcast" class="pl-3 pr-3"><span class="icon-youtube"></span></a>
</div>
<!-- <div class="mb-5"> -->
<!-- <h3 class="footer-heading mb-2">Subscribe Newsletter</h3> -->
<!-- <form action="#" method="post"> -->
<!-- <div class="input-group mb-3"> -->
<!-- <input type="text" class="form-control border-secondary text-white bg-transparent" placeholder="Enter Email" aria-label="Enter Email" aria-describedby="button-addon2"> -->
<!-- <div class="input-group-append"> -->
<!-- <button class="btn btn-primary" type="button" id="button-addon2">Send</button> -->
<!-- </div> -->
<!-- </div> -->
<!-- </form> -->
<!-- </div> -->
</div>
</div>

View File

@ -1,5 +0,0 @@
path="/home/rob/antena/music"
find $path -iname "*.flac" | sort | shuf > \
playlists/complete_music_archive.pls

View File

@ -69,7 +69,7 @@ def database_create_episodes_table(conn):
Column("id", "INT", nullable=True),
Column("episode", "INT", nullable=True),
Column("track_number", "INT", nullable=True),
Column("date", 'DATETIME', nullable=True),
Column("date", "VARCHAR(120)", nullable=True),
Column("album", "VARCHAR(200)", nullable=True),
Column("track", "VARCHAR(120)", nullable=True),
Column("artist", "VARCHAR(120)", nullable=True),

View File

@ -11,23 +11,37 @@ import sqlite3, json
import subprocess
import uuid
from pypika import Query, Table, Field, Column
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--date", help="Show Date")
parser.add_argument("-e", "--episode", help="Episode Number", type=int)
parser.add_argument("-p", "--playlist", help="new, keep or edit", default="keep")
parser.add_argument("-m", "--mp3", action="store_true")
parser.add_argument("-w", "--web", action="store_true")
parser.add_argument("-a", "--art", action="store_true")
parser.add_argument("-i", "--insert_fills", action="store_true")
parser.add_argument("-t", "--top_tail", action="store_true")
args = parser.parse_args()
#from mk_web import *
path = "/home/rob/antena/"
show_name = "The_SLO_Indie"
show_short_description = "An eclectic selection of independent and experimental music from Slovenia. \
Published weekly by The Rizoma Institute. Hosted and compiled by Rob Canning. \
Broadcast in Slovenia on FM by Mariborski radio student - MARŠ"
show_name = "UhO"
show_url = "https://uho.rizom.si"
show_rss = "podcast_rss.xml"
show_email = "uho.podcast@gmail.com"
episode_author="Rob Canning"
episode_number = int(sys.argv[1])
input_date = sys.argv[2]
show_short_description = '''The UhO! podcast presents an eclectic selection of independent music from Slovenia. The show aims to deliver as broad a range of genres as possible; banging techno, sludge, math rock, contemporary classical, doom, free improvisation, noise music, field recordings, ambient, drone....etc etc... whatever the genre, you can be sure you are listening to the latest and most inovative music on offer in this part of the world. Hosted and compiled by Rob Canning, the show is published weekly by Zavod Rizoma and is broadcast in Slovenia on FM by mariborski radio študent: MARŠ. It as also available as a podcast. Use our RSS feed or search for UhO Podcast where ever you subscribe to podcasts'''
episode_number = args.episode
input_date = args.date
episode_date = datetime.datetime.now().strftime("%Y-%m-%d")
episode_duration = 0
episode_playlist = []
show_cover = ""
archive = []
artists_played = []
#artists_played = []
artist_abreviated = []
web_path = "/home/rob/antena/html/episode/{0}/img".format(episode_number)
@ -41,19 +55,17 @@ else: os.makedirs(web_path)
# /////////////////////////////////////////////////
def set_episode_date(input_date):
# second CLI argument is showdate in YYYY-MM-DD
global episode_date
date_str = input_date
date_format = '%Y-%m-%d'
episode_date = str(datetime.datetime.strptime(date_str, date_format))
#return episode_date
print(episode_date)
d = input_date.split("-")
episode_date = datetime.date(int(d[0]),int(d[1]),int(d[2])).strftime("%A, %d %B, %Y")
return episode_date
def create_intro(episode_playlist):
def create_intro():
intropath = path + "audio/texts/clips/this_is"
intro = random.choice(os.listdir(intropath))
episode_playlist.insert(0, str(os.path.abspath(intropath)) + "/" + str(intro))
#final_playlist.insert(0, str(os.path.abspath(intropath)) + "/" + str(intro))
def check_archive(track_path):
@ -67,19 +79,43 @@ def check_archive(track_path):
print('Track has been played on a previous episode', [track_path, data[0]])
return False
#TODO limit number of KM Compilations in new function
def check_for_KM_compilation(track_album):
"TODO fix me"
# check if album is played already on this episode - maybe last 2 episodes >= or similar
cursor = conn.cursor()
q = 'SELECT * FROM EPISODES WHERE album = "{0}" AND EPISODE = {1} '.format(track_album,episode_number, "lubski" )
#q = "SELECT album FROM EPISODES WHERE instr(album, 'Klubski') AND episode = '{1}' ".format(track_album,episode_number )
cursor.execute(q)
data=cursor.fetchone()
if data is None:
return True # no previous play record found... the track can be added3
else:
print('Klubski Maraton compilation already featured this episode!?', [track_album, data])
return False
def check_album(track_album):
# check if album is played already on this episode - maybe last 2 episodes >= or similar
cursor = conn.cursor()
cursor.execute("SELECT * FROM EPISODES WHERE album = ? AND episode = ?", (track_album,episode_number))
data=cursor.fetchone()
#print(data)
if data is None:
return True # no previous play record found... the track can be added
else:
print('Album already featured on this episode ? ?', [track_album, data[0]])
return False
def check_artist(track_artist):
# check if artist is played already on this episode - maybe last 2 episodes >= or similar
cursor = conn.cursor()
cursor.execute("SELECT * FROM EPISODES WHERE artist = ? AND episode = ?", (track_artist,episode_number))
@ -91,14 +127,13 @@ def check_artist(track_artist):
print('ARTIST already featured on this episode:', [track_artist, data[0]])
return False
def playlist_replace_track(conn, episode_number, track_to_replace):
def playlist_replace_track(conn, episode_playlist, episode_number, track_to_replace):
cursor = conn.cursor()
cursor.execute("SELECT * FROM MUSIC_LIBRARY ORDER BY RANDOM() LIMIT 1 ;")
r = cursor.fetchone() # FETCH A NEW TRACK FROM THE DATABASE
print('new suggestion================================' + str(r))
print('new suggestion ================================' + str(r))
song = str(r[9])
track_label = str(r[1])
@ -128,17 +163,20 @@ def playlist_replace_track(conn, episode_playlist, episode_number, track_to_repl
#for i in preview:
# print('{0} : {1} {2} {3} {4} \n'.format(i[2], i[4], i[5], i[6], i[7],))
def create_episode_playlist(conn, episode_playlist: list, episode_number):
episode_duration = 0
# -----------------------------------------------------------------------------
def create_episode_playlist(conn, episode_number):
global episode_duration
global archive
track_number = 0
track_count = 0
global artists_played
max_track_dur = 9
max_track_dur = 10
min_track_dur = 2
set_episode_date(input_date)
# first clear the sqlite table rows for the episode
cursor = conn.cursor()
cursor.execute('DELETE FROM EPISODES WHERE episode = {0}'.format(episode_number))
@ -163,53 +201,44 @@ def create_episode_playlist(conn, episode_playlist: list, episode_number):
# SOME LOGIC TO SEE IF WE ALLOW THAT TRACK OR NOT
# TODO here we need to append to DB not the static file
# if track_artist not in artists_played:
if check_album(track_album) is True and check_artist(track_artist) is True:
if check_album(track_album) is True \
and check_artist(track_artist) is True \
and check_for_KM_compilation(track_album) is True:
if check_archive(track_path) is True:
if track_duration > min_track_dur * 60:
if int(track_duration) < max_track_dur * 60:
episode_playlist.append(song.rstrip()) # if 'not in' is true then add the song
art = string=re.sub("\(.*?\)","",track_artist)
# shorten verbose artist names such as trojnik Trojnik (Cene Resnik, Tomaž Grom, Vid Drašler)
art = string=re.sub("and","&",art)
artist_abreviated.append(art)
artists_played.append(track_artist) # and add the artist to the played list
#add_to_tracks_played(track_path) # and write entry to archive file
if not track_year: # where missing metadata give a dummy value
track_year = "0000"
e = Table('EPISODES')
track_number = track_count
id = str(uuid.uuid4())
q = e.insert(id, episode_number, track_number, episode_date,\
q = e.insert(id, episode_number, track_number, str(episode_date),\
track_album, track_title, track_artist, \
track_duration,track_genre, track_year, \
track_path, track_label, track_comment)
track_path, track_label, track_comment)
cursor.execute(str(q))
conn.commit()
# print("sqlite: Episode track successfully inserted into SHOW table");
track_count += 1;
episode_duration = episode_duration + track_duration
# else: print("TRACK TOO SHORT..........." )
# else: print("TRACK TOO SHORT..........." )
# else: print("TRACK TOO LONG..........." )
# else: print("SONG PLAYED IN PREVIOUS EPISODE" )
#else: print("ARTIST ALREADY IN PODCAST")
#TODO am i happy with track selection? change an entry ? add a specific entry? to replace
# preview and modify option -TODO move to its own function
modify_playlist(conn, episode_playlist, episode_number)
modify_playlist(conn, episode_number, episode_duration)
#TODO maybe episode duration needs fixing after new track insertion
# -----------------------------------------------------------------------------
# TODO shuffle playlist order as an option
def modify_playlist(conn, episode_playlist, episode_number):
def modify_playlist(conn, episode_number, episode_duration):
cursor = conn.cursor()
cursor.execute('SELECT * FROM EPISODES WHERE EPISODE=?', [episode_number])
@ -231,7 +260,7 @@ def modify_playlist(conn, episode_playlist, episode_number):
if user_input == 'y':
print("action")
create_episode_playlist(conn, episode_playlist, episode_number)
create_episode_playlist(conn, episode_number)
elif user_input == 'p':
# preview a track --------------------------------------
preview_track = input("which track would you like to preview [0-12]:")
@ -246,19 +275,18 @@ def modify_playlist(conn, episode_playlist, episode_number):
print("ok groovy choice then...")
else:
input("do the db replace logic")
playlist_replace_track(conn, episode_playlist, episode_number, preview_track)
playlist_replace_track(conn, episode_number, preview_track)
elif user_input == 's':
print("the logic to shuffle the existing playlist order")
else:
print("Goodbye happy DJ")
print(">>>>>>>>>>>>>>>>>> Goodbye Happy DJ !!!!!!!!!!!!!!")
episode_duration = timedelta(seconds=round(episode_duration))
print("Total Duration = {0}".format(episode_duration))
return user_input
# episode_duration = timedelta(seconds=round(episode_duration))
# print("Total Tracks = {0} \nTotal Duration = {1}".format(track_count, episode_duration))
# ----------------------------------------------------------------------
def combine_images(columns, space, images, variants:int):
global show_cover
@ -335,19 +363,32 @@ def combine_images(columns, space, images, variants:int):
im.text((30, h2_baseline + (h2_spc*4)), "{0}"\
.format(' | '.join(artist_abreviated[9:12])), (255,255,255), font=mf_h2)
im.text((1540,1888), ''' http://{0}.rizom.si '''\
.format(show_name, episode_date,episode_number), fill="white", font=mf_h4)
im.text((1540,1888), '''{0} '''\
.format(show_url, show_name, episode_date,episode_number), fill="white", font=mf_h4)
show_cover = 'img/cover{2}.png'.format(episode_number,episode_date, variants)
background.save("html/" + "episode/{0}/{1}".format(episode_number, show_cover))
#convert -delay 100 -loop 0 html/episode/2/img/show_cover_2024-01-12* animatedGIF.gif
return show_cover
def create_show_coverart(episode_playlist, variants):
# -------------------------------------------------------------------------------
def create_show_coverart(variants):
final_playlist = []
cursor = conn.cursor()
cursor.execute('SELECT path FROM EPISODES WHERE EPISODE=?', [episode_number])
preview = cursor.fetchall()
for i in preview: # database >> python list
final_playlist.append(i[0])
show_cover_jpgs = []
# in the directory containing songs find jpg and pngs containing string "cover"
for dir in episode_playlist:
for dir in final_playlist:
path = pathlib.Path(dir).parent
for file in os.listdir(path):
for p in [".png", ".jpg", ".jpeg"]:
@ -388,8 +429,10 @@ def create_animated_gif():
img.save(fp=fp_out, format='GIF', append_images=imgs,
save_all=True, duration=200, loop=0)
def create_podcast(episode_playlist: list):
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
def create_podcast():
print('''------------------------
creating show audio
@ -398,11 +441,21 @@ def create_podcast(episode_playlist: list):
from glob import glob
from pydub import AudioSegment
playlist_songs = [AudioSegment.from_file(flac_file) for flac_file in episode_playlist]
print(playlist_songs)
# grab the conpleted playlist from the database
final_playlist = []
cursor = conn.cursor()
cursor.execute('SELECT path FROM EPISODES WHERE EPISODE=?', [episode_number])
preview = cursor.fetchall()
for i in preview: # database >> python list
final_playlist.append(i[0])
playlist_songs = [AudioSegment.from_file(flac_file) for flac_file in final_playlist]
#TODO intro is not here anymore change index
show_intro = playlist_songs[0]
# first_song = playlist_songs[0].fade_in(0) # only fadein if used over show intro - currently not used
# intro_and_first = first_song.overlay(show_intro)
first_three_blurb = playlist_songs[0]
second_three_blurb = playlist_songs[0]
final_songs_blurb = playlist_songs[0]
@ -462,10 +515,12 @@ def create_podcast(episode_playlist: list):
print("MP3 audio file exported...")
### ------------------------------------------------------------
def create_html_homepage_from_template(episode_playlist):
def create_html_homepage_from_template():
# TODO "on this weeks show" variants fed to html from list here
from jinja2 import Template, Environment, FileSystemLoader
set_episode_date(input_date)
env = Environment(loader=FileSystemLoader('html/templates'))
homepage_template = env.get_template('homepage.jinja')
@ -521,26 +576,31 @@ def create_html_homepage_from_template(episode_playlist):
track_genre = str(t[8])
track_year = str(t[9])
#TODO remove single quptes not working in episode_artists
#TODO remove single quptes not working in episode_artists
# populate the jinja html template for the EPISODE
#''.join(random.choice((str.upper,str.lower))(x) for x in show_name)
output_from_parsed_template = homepage_template.render(\
show_name=''.join(random.choice((str.upper,str.lower))(x) for x in show_name), \
episodes=episodes, episode_author="Rob Canning",\
episode_duration=episode_duration, episode_number=episode_number, \
episode_artists=str(episode_artists[episode_number]).strip("[").strip("]").strip("\'").strip("'"), \
about_show=show_short_description, episode_playlist=episode_playlist, \
episode_image="episode/{0}/img/cover0.png".format(episode_number))
show_name=show_name, show_url=show_url, show_rss=show_rss, \
episodes=episodes, episode_author=episode_author,\
episode_date=episode_date,\
episode_duration=episode_duration, episode_number=episode_number, \
episode_artists=str(episode_artists[episode_number])\
.strip("[").strip("]").strip('\'').strip('\''), \
about_show=show_short_description, \
episode_image="img/cover0.png".format(episode_number))
with open("html/index.html".format(episode_number), "w") as episode_page:
episode_page.write(output_from_parsed_template)
def create_html_episode_from_template(episode_playlist, episode_number):
def create_html_episode_from_template(episode_number, episode_duration):
from jinja2 import Template, Environment, FileSystemLoader
set_episode_date(input_date)
env = Environment(loader=FileSystemLoader('html/templates'))
episode_template = env.get_template('episode.jinja')
playlist_table = []
# maybe a jinja2 template loop here instead
@ -576,10 +636,11 @@ def create_html_episode_from_template(episode_playlist, episode_number):
playlist_table.append(playlist_entry)
# populate the jinja html template for the EPISODE
output_from_parsed_template = episode_template.render(\
show_name=show_name, episode_author="Rob Canning",\
episode_number=episode_number, episode_duration=episode_duration, \
show_name=show_name, episode_author=episode_author,\
episode_number=episode_number, show_url=show_url, show_rss=show_rss,\
episode_duration=timedelta(seconds=round(episode_duration)), \
episode_date=episode_date, about_show=show_short_description, \
episode_playlist=playlist_table, \
episode_image="img/cover0.png".format(episode_number))
@ -587,35 +648,70 @@ def create_html_episode_from_template(episode_playlist, episode_number):
with open("html/episode/{0}/index.html".format(episode_number), "w") as episode_page:
episode_page.write(output_from_parsed_template)
def create_RSS_XML_from_template():
from jinja2 import Template, Environment, FileSystemLoader
set_episode_date(input_date)
env = Environment(loader=FileSystemLoader('html/templates'))
rss_template = env.get_template('show_RSS.jinja.xml')
output_from_parsed_template = \
rss_template.render(\
show_name=show_name, \
episode_number=int(episode_number), episode_author="Rob Canning",\
episode_duration=episode_duration, about_show=show_short_description, \
episode_number=int(episode_number), episode_author=episode_author, \
show_url=show_url,\
episode_duration=timedelta(seconds=round(episode_duration)),\
about_show=show_short_description, \
episode_image="img/cover0.png".format(episode_number))
with open("html/show_rss.xml".format(episode_number), "w") as rss_page:
rss_page.write(output_from_parsed_template)
def main():
set_episode_date(input_date)
# while create_episode_playlist(conn, episode_playlist, episode_number) != 'y':
# create_episode_playlist(conn, episode_playlist, episode_number)
create_episode_playlist(conn, episode_playlist, episode_number)
create_show_coverart(episode_playlist, 4) #episode_duration = 100
#create_animated_gif()
create_intro(episode_playlist)
create_html_episode_from_template(episode_playlist, episode_number)
create_html_homepage_from_template(episode_playlist)
create_RSS_XML_from_template()
conn.close()
create_podcast(episode_playlist)
# playlist options
if args.playlist == "new":
print("creating new playlist >>>>> database ")
create_episode_playlist(conn, episode_number)
elif args.playlist=="keep":
print("working with playlist from database... ")
elif args.playlist=="edit":
print("edit the playlist...")
modify_playlist(conn, episode_number, episode_duration)
else:
print("not creating new show....")
if args.insert_fills == True:
print("inserting voice fills......")
if args.top_tail == True:
print("inserting intro and outro......")
# output options
if args.mp3 == True:
print("creating MP3 audio output......")
create_intro()
create_podcast()
else:
print("not creating audio output......")
if args.web == True:
print("creating html......")
#create_animated_gif()
create_html_episode_from_template(episode_number, episode_duration)
create_html_homepage_from_template()
create_RSS_XML_from_template()
if args.art == True:
print("creating artwork for socials ......")
create_show_coverart(4) #episode_duration = 100
#create_animated_gif()
conn.close()
main()