diff --git a/database/show.db b/database/show.db index a3dc542..5ce46c2 100644 Binary files a/database/show.db and b/database/show.db differ diff --git a/html/templates/episode.jinja b/html/templates/episode.jinja index 702220c..bc73a05 100644 --- a/html/templates/episode.jinja +++ b/html/templates/episode.jinja @@ -4,8 +4,8 @@ {{show_name}} - - + + @@ -90,8 +90,10 @@
-
+

{{show_name}} | Episode #{{episode_number}}

+

Latest Episode: #{{episode_number}} with music from: {{episode_artists}}

+
Hosted by: {{episode_author}} | First broadcast: {{episode_date}} |
Total running time: {{episode_duration}}
@@ -269,7 +271,7 @@
- podcast + podcast "P", palette=Image.ADAPTIVE, colors=256
{{show_url}}/{{show_rss}} diff --git a/html/templates/homepage.jinja b/html/templates/homepage.jinja index a4bdc6d..cfe70e2 100644 --- a/html/templates/homepage.jinja +++ b/html/templates/homepage.jinja @@ -95,7 +95,7 @@

The Podcast {{show_name}}!

The best alternative music from Slovenia, every week.

- +

Latest Episode: #{{episode_number}} with music from: {{episode_artists}}

Episode #{{episode_number}} Details and Player

Presented by: {{episode_author}} / Zavod Rizoma | {{episode_date}} diff --git a/mk_music_library_db.py b/mk_music_library_db.py index dcdf857..ad12aa1 100755 --- a/mk_music_library_db.py +++ b/mk_music_library_db.py @@ -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") diff --git a/mk_show.py b/mk_show.py index 2eba914..d846fa2 100755 --- a/mk_show.py +++ b/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(''' + + + {{show_name}} + + + + + +

TEXTS FOR SOCIAL MEDIA POSTS BY THE UHO_BOT!

+ +

FB and Insta!

+ ''' ) + + 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("

{0}



".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("

Twtter X 280 char limit

".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("

{0}



".format(p)) + + with open("html/episode/{0}/socials.html".format(episode_number), "a") as episode_page: + episode_page.write(''' + + ''') + + + + 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()