starting social media bot function
parent
cc587f60b3
commit
38a399c8f9
BIN
database/show.db
BIN
database/show.db
Binary file not shown.
|
@ -4,8 +4,8 @@
|
|||
<title>{{show_name}}</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel="icon" type="image/x-icon" href="images/favicon.ico">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:200,300,400,700,900">
|
||||
<link rel="icon" type="image/x-icon" href="../../images/favicon.ico">
|
||||
<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">
|
||||
|
@ -90,8 +90,10 @@
|
|||
<div class="site-blocks-cover overlay inner-page-cover" style="background-image: url({{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">
|
||||
<div class="col-md-8" style="background-color: rgba(0,0,0,0.5)" data-aos="fade-up" data-aos-delay="400">
|
||||
<h2 style="background-color: black;" class="text-white font-weight-light mb-2 display-4">{{show_name}} | Episode #{{episode_number}} </h2>
|
||||
<p class="text-white font-weight-light">Latest Episode: #{{episode_number}} with music from: {{episode_artists}}</p>
|
||||
|
||||
<div class="text-white mb-3"><span class="text-white" style="color: white; background-color: black;" > Hosted by: {{episode_author}} | First broadcast: {{episode_date}} | <br> Total running time: {{episode_duration}}</small></span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -269,7 +271,7 @@
|
|||
<div class="block-16">
|
||||
<figure>
|
||||
<a href="{{show_url}}/{{show_rss}}">
|
||||
<img src="episode/1/img/cover0.jpeg" alt="podcast" class="img-fluid rounded">
|
||||
<img src="/images/podcast-main.jpeg" alt="podcast" class="img-fluid rounded">
|
||||
</a>
|
||||
"P", palette=Image.ADAPTIVE, colors=256</figure>
|
||||
<a href="{{show_url}}/{{show_rss}}">{{show_url}}/{{show_rss}}</a>
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
<h2 class="tex font-weight-light mb-2 display-4">The Podcast {{show_name}}!</h2>
|
||||
<p class="tex font-weight-light mb-2 display-4">The best alternative music from Slovenia, every week.</p>
|
||||
|
||||
<!-- <p class="text-white font-weight-light" style="color: white; background-color: black;" >Latest Episode: #{{episode_number}} with music from: {{episode_artists}}</p> -->
|
||||
<p class="text-white font-weight-light" >Latest Episode: #{{episode_number}} with music from: {{episode_artists}}</p>
|
||||
|
||||
<p><a href="episode/{{episode_number}}/index.html" class="btn btn-primary btn-sm py-3 px-4 small">Episode #{{episode_number}} Details and Player</a></p>
|
||||
<div class="text-white mb-4"><span class="text-white">Presented by: {{episode_author}} / Zavod Rizoma | {{episode_date}}</span>
|
||||
|
|
|
@ -58,7 +58,7 @@ def database_create(conn):
|
|||
⠀⠀⠀⠀⠻⣿⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⣿⠟⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
''');
|
||||
|
||||
#TODO meta idea about uho and soundwave in the above ascii
|
||||
def database_create_episodes_table(conn):
|
||||
# the show database
|
||||
|
||||
|
@ -77,7 +77,10 @@ def database_create_episodes_table(conn):
|
|||
Column("year", 'DATETIME', nullable=True),
|
||||
Column("path", "VARCHAR(120)", nullable=False),
|
||||
Column("label", "VARCHAR(120)", nullable=False),
|
||||
Column("comment", "VARCHAR(120)", nullable=False))\
|
||||
Column("comment", "VARCHAR(120)", nullable=False),
|
||||
Column("episode_total_dur", "VARCHAR(120)", nullable=False),
|
||||
Column("episode_artists", "VARCHAR(120)", nullable=False),
|
||||
Column("something_else", "VARCHAR(120)", nullable=False))\
|
||||
.unique("id") \
|
||||
.primary_key("id")
|
||||
|
||||
|
|
158
mk_show.py
158
mk_show.py
|
@ -24,6 +24,7 @@ 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("-s", "--socials", action="store_true")
|
||||
parser.add_argument("-i", "--insert_fills", action="store_true")
|
||||
parser.add_argument("-t", "--top_tail", action="store_true")
|
||||
|
||||
|
@ -52,7 +53,8 @@ artist_abreviated = []
|
|||
episode_artists = []
|
||||
|
||||
# sqlite database connection
|
||||
conn = sqlite3.connect("database/show.db")
|
||||
# TODO make this a input vaiable for testing db and live db
|
||||
conn = sqlite3.connect("database/uho_music.db")
|
||||
|
||||
web_path = "{0}/html/episode/{1}/img".format(path, episode_number)
|
||||
if not os.path.exists(web_path):
|
||||
|
@ -124,10 +126,11 @@ def choose_a_track(conn, episode_number, ):
|
|||
|
||||
if int(track_duration) < max_track_dur * 60:
|
||||
# TODO put in a function
|
||||
art = string=re.sub("\(.*?\)","",track_artist)
|
||||
#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)
|
||||
#art = string=re.sub("and","&",art)
|
||||
#artist_abreviated.append(art)
|
||||
#print(artist_abreviated)
|
||||
if not track_year: # where missing metadata give a dummy value
|
||||
track_year = "0000"
|
||||
|
||||
|
@ -138,7 +141,7 @@ def choose_a_track(conn, episode_number, ):
|
|||
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()
|
||||
track_count += 1;
|
||||
|
@ -292,7 +295,7 @@ def playlist_add_track(conn, episode_number, episode_duration):
|
|||
|
||||
modify_playlist(conn, episode_number, episode_duration)
|
||||
|
||||
|
||||
|
||||
def playlist_delete_track(conn, episode_number, episode_duration):
|
||||
|
||||
global track_count
|
||||
|
@ -315,7 +318,7 @@ def playlist_delete_track(conn, episode_number, episode_duration):
|
|||
|
||||
modify_playlist(conn, episode_number, episode_duration)
|
||||
|
||||
|
||||
|
||||
def playlist_shuffle_tracks(conn, episode_number, episode_duration):
|
||||
|
||||
os.system("clear")
|
||||
|
@ -337,7 +340,7 @@ def playlist_shuffle_tracks(conn, episode_number, episode_duration):
|
|||
track_number = '{:0>2}'.format(track_count)
|
||||
id = str(uuid.uuid4())
|
||||
q = e.insert(id, episode_number, track_number, str(episode_date),\
|
||||
i[4], i[5], i[6], i[7], i[8], i[9], i[10], i[11], i[11]) #TODO fix last index
|
||||
i[4], i[5], i[6], i[7], i[8], i[9], i[10], i[11], i[11], "","","") #TODO fix last index
|
||||
cursor.execute(str(q))
|
||||
track_count += 1;
|
||||
episode_duration = episode_duration
|
||||
|
@ -423,7 +426,7 @@ def combine_images(columns, space, images, variants:int):
|
|||
|
||||
global show_cover
|
||||
|
||||
|
||||
print(images)
|
||||
set_episode_date(input_date)
|
||||
|
||||
rows = len(images) // columns
|
||||
|
@ -466,7 +469,8 @@ def combine_images(columns, space, images, variants:int):
|
|||
# Add Text to the image ----------------------------------------
|
||||
|
||||
# some logic to shuffle the list if sub sections of list are too long for layout
|
||||
str_length_thresh = 50
|
||||
str_length_thresh = 55
|
||||
artist_abreviated = list_episode_artists()
|
||||
|
||||
#TODO if an artist is listed as Various Arist then remove it from cover display and think of logic
|
||||
#TODO exit while loop if it cant find a solution and restart script or shrink font and adjust rules
|
||||
|
@ -479,8 +483,9 @@ def combine_images(columns, space, images, variants:int):
|
|||
...................shuffling the list for a better look: {0}'''.format(artist_abreviated))
|
||||
|
||||
random.shuffle(artist_abreviated)
|
||||
|
||||
im.text((30,10), '''an eclectic selection of contemporary independent music from slovenia: {0} - E P I S O D E #{1}
|
||||
|
||||
|
||||
im.text((30,10), '''An eclectic selection of independent and alternative music from Slovenia: {0}
|
||||
'''\
|
||||
.format(episode_date,episode_number), fill="white", font=mf_h3)
|
||||
im.text((30,280), ''' THIS WEEK ON \n EPISODE #{0} of \n {1}!'''.upper()\
|
||||
|
@ -537,9 +542,106 @@ def create_show_coverart(variants):
|
|||
# if len(show_cover_jpgs) > 0: # duplicate this for variations of geometry
|
||||
for i in range(variants):
|
||||
x = show_cover_jpgs[:12]
|
||||
print(x)
|
||||
combine_images(columns=4, space=10, images=random.sample(x,len(x)),variants=i)
|
||||
return show_cover
|
||||
|
||||
def list_episode_artists():
|
||||
episode_artists = []
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('SELECT artist FROM EPISODES WHERE EPISODE=?', [episode_number])
|
||||
a = cursor.fetchall()
|
||||
for i in a: # database >> python list
|
||||
artist = string=re.sub("\(.*?\)","",i[0])
|
||||
# shorten verbose artist names such as trojnik Trojnik (Cene Resnik, Tomaž Grom, Vid Drašler)
|
||||
#artist=(','.join(artist))
|
||||
|
||||
#artist = string=re.sub('\[',"",artist)
|
||||
#artist = string=re.sub(']',"",artist)
|
||||
#artist = string=re.sub('\'',"",artist)
|
||||
#artist = string=re.sub("and","&",artist)
|
||||
#artist = string=re.sub("and","&",artist)
|
||||
|
||||
episode_artists.append(artist)
|
||||
#print(episode_artists)
|
||||
return episode_artists
|
||||
|
||||
def social_media_post():
|
||||
a = list_episode_artists()
|
||||
n=(', '.join(a))
|
||||
#a = (a.replace(" ,", ""))
|
||||
heads = (
|
||||
"This week Uho! brings you music from",
|
||||
"On this weeks episode of Uho! we have music from",
|
||||
"This week on Uho! you will hear music from",
|
||||
"Some fine tunes this week on Uho from",
|
||||
"This week Uho! will delight your ears with tracks from")
|
||||
|
||||
tags = "#independentmusic #alternativemusic #experimentalmusic #improvisedmusic #podcast #slovenianmusic #slovenia #musicpodcast #glasba"
|
||||
|
||||
labels = '''@zavodsploh #zavodsploh @kaparecords @moonleerecords @naturescene_music @kamizdat #pharmafabrik @radiostudent
|
||||
FM broadcast on @radiomars 95.9 in Maribor SI podcast hosted by @retroerto a @zavodrizoma production thanks to @ljudmila for the podcast hosting'''
|
||||
|
||||
with open("html/episode/{0}/socials.html".format(episode_number), "w") as episode_page:
|
||||
episode_page.write('''
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>{{show_name}}</title>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h2>TEXTS FOR SOCIAL MEDIA POSTS BY THE UHO_BOT!</h2>
|
||||
|
||||
<h3>FB and Insta!</h3>
|
||||
''' )
|
||||
|
||||
for i in range(len(heads)):
|
||||
|
||||
p = '''{0} {1} and {2} {3} {4}'''\
|
||||
.format(random.choice(heads), str(a[:-1]).upper(),\
|
||||
str(a[len(a)-1]).upper(), tags, labels)
|
||||
p = (p.replace("'", ""))
|
||||
p = (p.replace("", ""))
|
||||
p = (p.replace("[", ""))
|
||||
p = (p.replace("]", ""))
|
||||
p = (p.replace(" ,", ","))
|
||||
|
||||
print(p + "charachter count: _____________" + str(len(str(p))))
|
||||
|
||||
with open("html/episode/{0}/socials.html".format(episode_number), "a") as episode_page:
|
||||
episode_page.write("<p>{0}</p> <br><br>".format(p))
|
||||
|
||||
twitter_end = "http://uho.rizom.si"
|
||||
|
||||
with open("html/episode/{0}/socials.html".format(episode_number), "a") as episode_page:
|
||||
episode_page.write("<h3>Twtter X 280 char limit</h3>".format(p))
|
||||
|
||||
for i in range(len(heads)):
|
||||
|
||||
p = '''uho! episode #{0} now available music from: {1} and {2} {3}'''\
|
||||
.format(episode_number, str(a[:-1]).upper(),\
|
||||
str(a[len(a)-1]).upper(), twitter_end )
|
||||
p = (p.replace("'", ""))
|
||||
p = (p.replace("", ""))
|
||||
p = (p.replace("[", ""))
|
||||
p = (p.replace("]", ""))
|
||||
p = (p.replace(" ,", ","))
|
||||
|
||||
print(p + "character count: _____________" + str(len(str(p))))
|
||||
|
||||
with open("html/episode/{0}/socials.html".format(episode_number), "a") as episode_page:
|
||||
episode_page.write("<p>{0}</p> <br><br>".format(p))
|
||||
|
||||
with open("html/episode/{0}/socials.html".format(episode_number), "a") as episode_page:
|
||||
episode_page.write('''
|
||||
</body>
|
||||
''')
|
||||
|
||||
|
||||
|
||||
|
||||
def create_animated_gif():
|
||||
|
||||
# filepaths
|
||||
|
@ -613,7 +715,7 @@ def create_podcast():
|
|||
|
||||
# Insert a midshow CTA between track 6 outro and track 7 intro --------
|
||||
|
||||
# final_playlist.insert(24, get_midshow_CTA()) # <-----------------------
|
||||
final_playlist.insert(24, get_midshow_CTA()) # <-----------------------
|
||||
|
||||
# ------------ MAIN SHOW STRUCTURE ENDS HERE --------------------------
|
||||
|
||||
|
@ -650,10 +752,10 @@ def create_podcast():
|
|||
|
||||
# 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...")
|
||||
# playlist.export(out_f, format='flac')
|
||||
# print("FLAC audio file exported...")
|
||||
with open("html/episode/{0}/show.flac".format(episode_number), 'wb') as out_f:
|
||||
print("FLAC output file opened...writing to file...")
|
||||
playlist.export(out_f, format='flac')
|
||||
print("FLAC audio file exported...")
|
||||
|
||||
# save the entire poidcast as MP3
|
||||
|
||||
|
@ -681,7 +783,7 @@ def create_html_homepage_from_template():
|
|||
env = Environment(loader=FileSystemLoader('html/templates'))
|
||||
homepage_template = env.get_template('homepage.jinja')
|
||||
|
||||
conn = sqlite3.connect("database/show.db")
|
||||
conn = sqlite3.connect("database/uho_music.db")
|
||||
cursor = conn.cursor()
|
||||
|
||||
#global episode_artists
|
||||
|
@ -691,7 +793,7 @@ def create_html_homepage_from_template():
|
|||
cursor.execute('SELECT MAX(episode) FROM EPISODES')
|
||||
|
||||
num_eps = cursor.fetchone()[0]
|
||||
num_eps = num_eps+1
|
||||
num_eps = num_eps
|
||||
|
||||
for i in range(num_eps):
|
||||
artists = []
|
||||
|
@ -716,8 +818,8 @@ def create_html_homepage_from_template():
|
|||
|
||||
episodes.append(an_episode)
|
||||
# reversed order to most recent episode appears first in list
|
||||
episodes = reversed(episodes[1:episode_number])
|
||||
|
||||
episodes = reversed(episodes[0:episode_number])
|
||||
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('SELECT * FROM EPISODES WHERE episode=? ORDER BY track_number ASC', [episode_number])
|
||||
r = cursor.fetchall()
|
||||
|
@ -789,7 +891,7 @@ def parse_db_episode():
|
|||
# populate the jinja html template for the EPISODE
|
||||
|
||||
output_from_parsed_template = episode_template.render(\
|
||||
episode_artists=episode_artists,\
|
||||
episode_artists=list_episode_artists(),\
|
||||
show_name=show_name,\
|
||||
episode_author=episode_author,\
|
||||
episode_number=episode_number, show_url=show_url, \
|
||||
|
@ -902,9 +1004,9 @@ def create_RSS_XML_from_template():
|
|||
|
||||
episodes.append(an_episode)
|
||||
# reversed order to most recent episode appears first in list
|
||||
print(episodes)
|
||||
#print(episodes)
|
||||
|
||||
episodes = reversed(episodes[0:episode_number])
|
||||
episodes = reversed(episodes[0:episode_number+1])
|
||||
#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)
|
||||
|
@ -930,9 +1032,11 @@ def main():
|
|||
|
||||
elif args.playlist=="keep":
|
||||
print("working with playlist from database... ")
|
||||
|
||||
elif args.playlist=="edit":
|
||||
print("edit the playlishttps://uho.rizom.si/podcast_rss.xmlt...")
|
||||
modify_playlist(conn, episode_number, episode_duration)
|
||||
|
||||
else:
|
||||
print("not creating new show....")
|
||||
|
||||
|
@ -957,6 +1061,12 @@ def main():
|
|||
create_show_coverart(4)
|
||||
#create_animated_gif()
|
||||
|
||||
if args.socials == True:
|
||||
print("creating text for socials ......")
|
||||
social_media_post()
|
||||
#create_animated_gif()
|
||||
|
||||
|
||||
if args.mp3 == True:
|
||||
print("creating MP3 audio output......")
|
||||
#get_intro()
|
||||
|
|
Loading…
Reference in New Issue