From cc587f60b3bf15171cfa473c75474022ac9e7aa9 Mon Sep 17 00:00:00 2001 From: Rob Canning Date: Sun, 11 Feb 2024 02:47:44 +0100 Subject: [PATCH] RSS Feed now working --- database/show.db | Bin 446464 -> 446464 bytes feed_parser.py | 3 +- html/templates/episode.jinja | 6 +- html/templates/homepage.jinja | 34 +++------ html/templates/show_RSS.jinja.xml | 59 +++++++-------- mk_music_library_db.py | 2 +- mk_show.py | 120 +++++++++++++++++++++--------- music/README.md | 15 ++++ 8 files changed, 145 insertions(+), 94 deletions(-) diff --git a/database/show.db b/database/show.db index e5ac2397348a61766fd9c8cc3ea3922e056e5004..a3dc542efe3172910687e6044961d868b030ab64 100644 GIT binary patch delta 4474 zcma)9dvH|M8NYk)-Ltvb-7FB2kSv>Qf=kHYf%|@pVv+%bYJxl#uu?nRCy8JZ0%(EJ zaMuU5t>qEvQA7z2*kP;{C(}ly^+Bh#9i5R@#a6~v+Ob8&R_e5!wuAJ$cVpp?m25KS z?9I8~=J!2*-{b5UN$(g*?@lKVQxtVOtng>gEG=^Q*|mq})~C)#Odss*b)`@kH{&#H_?N=F`}{%rDSbwDY#u#TXZTh+9-Suj*L*>G+!DzSPZeF1Ds} zD%Xgnq}XISjIL~j-?9h31p)OQ*%1+>TnyglGZd?ly%+3rfiE?mK*^arm0{>v3XwPU6a>j z>PR4|I<6|IiiR!6cCakF7B+NUz^Z54mS|ausYuilfuu8JNVX=p3f48%z_PA**noeA zZO5}6O)yoH*QrB+sON~PDcCA@Y#kJ}MH%aX-nwH5x@O9j=-JdrAgS1bX=$p7ZOM|b zY#AapMV`m5$_u)WJYf;D;>URCN=(t|nla_rNAw4g4TEu5QSRC5hDIfvD>` zj_yb%)(y=B>%j#UZx~pTWJ4AO&viYWdMuC>dC#^akH?befLl$)g73HhFYq=m7_wtn z4s{@qv|VvXRx}OFRaFJcstA72B^`^V=kTV6)Y zYpyBi;4_KZA4qDZVK}A@I_ef|ye47Yvt_Jl60e%Br3to9JrYRjnl5!2x}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_CX&c}Q^ zs6Gbh=u^Ix??2h_?Ix4f;>HrqP8cet;V&)?qN?QUz^;C5~A zH5<2dPW?1BT!`aegLb@1Wyj2AhW1-Z+WGen;tUp@Hjb#h^ z!6=6YTU!DNE8zmaaOYHYRruhN1Ze9SLo^H!!gieHsAFct@ zaQ-+`g!lcAL-JX>BcSInIN zx3V*Lg0)n3>H8p?%mdNWAwHk{6VFVrv5V2uq^gcav!{1~6(I3M6?O+t1tX2+b^ict CA3b;g diff --git a/feed_parser.py b/feed_parser.py index bdf32f8..42d0ab9 100755 --- a/feed_parser.py +++ b/feed_parser.py @@ -3,7 +3,8 @@ import feedparser #d = feedparser.parse('http://www.reddit.com/r/python/.rss') -d = feedparser.parse('file:///home/rob/antena/html/podcast_rss.xml') +#d = feedparser.parse('file:///home/rob/uho/html/podcast_rss.xml') +d = feedparser.parse('https://uho.rizom.si/podcast_rss.xml') for post in d.entries: # print(post.title + ": " + post.link + "") diff --git a/html/templates/episode.jinja b/html/templates/episode.jinja index fa253ef..702220c 100644 --- a/html/templates/episode.jinja +++ b/html/templates/episode.jinja @@ -4,7 +4,7 @@ {{show_name}} - + @@ -269,9 +269,9 @@
- podcast + podcast -
+ "P", palette=Image.ADAPTIVE, colors=256 {{show_url}}/{{show_rss}}
You can also subscribe to our RSS feed via Soundcloud or Youtube diff --git a/html/templates/homepage.jinja b/html/templates/homepage.jinja index fb30071..a4bdc6d 100644 --- a/html/templates/homepage.jinja +++ b/html/templates/homepage.jinja @@ -5,7 +5,7 @@ {{show_name}} - + @@ -92,14 +92,13 @@
-

{{show_name}}

-

{{about_show}}

-

Latest Episode: # {{episode_number}}

-

This week music from: {{episode_artists}}

+

The Podcast {{show_name}}!

+

The best alternative music from Slovenia, every week.

-

Episode Details and Player

+ + +

Episode #{{episode_number}} Details and Player

Presented by: {{episode_author}} / Zavod Rizoma | {{episode_date}} -
-

{{show_url}}

-
@@ -142,14 +139,6 @@ - - - - - - - -
@@ -270,7 +259,7 @@
- +

{{about_show}}

@@ -338,15 +327,14 @@ - We are on most of the social media platforms, please follow us and tell your friends about the podcast! + We are on most of the social media platforms, please follow us and tell your friends about the podcast!
- - - + +

@@ -372,7 +360,7 @@
- podcast + podcast
{{show_url}}/{{show_rss}} diff --git a/html/templates/show_RSS.jinja.xml b/html/templates/show_RSS.jinja.xml index 4fffbba..0d2b615 100644 --- a/html/templates/show_RSS.jinja.xml +++ b/html/templates/show_RSS.jinja.xml @@ -1,49 +1,44 @@ - - -Hiking Treks https://www.apple.com/itunes/podcasts/ +The Podcast UHO! https://uho.rizom.si/podcast_rss.xml en-us -© 2019 John Appleseed -The Sunset Explorers - {{short_description}} -serial - {{show_name}} -{{show_email}} +© 2024 Zavod Rizoma +Zavod Rizoma +{{about_show}} +{{about_show}} +music + + {{show_name}} + {{show_email}} - - - + + false -{% for rss_item in range(episode_number) %} +{% for rss_item in episodes %} - podcast - {{show_name}} Episode # {{episode_number}} - - - Rizoma Podcasts Homepage.]]> - + #{{rss_item.episode_number}} : {{rss_item.episode_artists}} {{rss_item.episode_date[0][0]}} https://uho.rizom.si/episode/{{rss_item.episode_number}} + full + The Podcast UHO! Episode # {{rss_item.episode_number}} + {{rss_item.episode_artists}} For full playlist details see: https://uho.rizom.si/episode/{{rss_item.eepisode_number}} + + + {{rss_item.episode_artists}} For full playlist details see: https://uho.rizom.si/episode/{{rss_item.episode_number}} - aae20190418 - {{episode_pub_date}} - - {{episode_duration}} + + {{rss_item.episode_number}} + + {{rss_item.episode_date[0][0]}} + {{rss_item.episode_duration[0]}} false {% endfor %} - - - diff --git a/mk_music_library_db.py b/mk_music_library_db.py index 767563d..dcdf857 100755 --- a/mk_music_library_db.py +++ b/mk_music_library_db.py @@ -13,7 +13,7 @@ import uuid from pypika import Query, Table, Field, Column music_library_path = "/home/rob/uho/music/" -conn = sqlite3.connect("database/show.db") +conn = sqlite3.connect("database/uho_music.db") #TODO fix getting bandcamp urls into db labelnames = [("sploh", "https://sploh.bandcamp.com"), ("terraformer"), ("pharamafabric") ] diff --git a/mk_show.py b/mk_show.py index f99f38f..2eba914 100755 --- a/mk_show.py +++ b/mk_show.py @@ -31,14 +31,13 @@ args = parser.parse_args() path = pathlib.Path.cwd() -show_name = "UhO" +show_name = "UHO" show_url = "https://uho.rizom.si" show_rss = "podcast_rss.xml" show_email = "uho.podcast@gmail.com" episode_author="Rob Canning" -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, glitch, jazz skronk, 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''' - +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, glitch, jazz skronk, field recordings, ambient, drone....etc etc... whatever the genre, you can be sure you are listening to the latest and most innovative 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 @@ -50,6 +49,8 @@ archive = [] #artists_played = [] artist_abreviated = [] +episode_artists = [] + # sqlite database connection conn = sqlite3.connect("database/show.db") @@ -435,7 +436,7 @@ def combine_images(columns, space, images, variants:int): background_width = width_max*columns + (space*columns)-space background_height = height_max*rows + (space*rows)-space #background = Image.new('RGBA', (background_width, background_height), (0, 0, 0, 255)) - background = Image.new('RGBA', (width_max*columns , height_max*columns), (0, 0, 0, 255)) + background = Image.new('RGB', (width_max*columns , height_max*columns), (0, 0, 0, 255)) x = 0 y = 0 @@ -496,8 +497,9 @@ def combine_images(columns, space, images, variants:int): 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)) + show_cover = 'img/cover{2}.jpg'.format(episode_number,episode_date, variants) + background.convert("P", palette=Image.ADAPTIVE, colors=256) + background.save("html/" + "episode/{0}/{1}".format(episode_number, show_cover), optimize=True) #convert -delay 100 -loop 0 html/episode/2/img/show_cover_2024-01-12* animatedGIF.gif return show_cover @@ -541,7 +543,7 @@ def create_show_coverart(variants): def create_animated_gif(): # filepaths - fp_in = "/home/rob/uho/html/episode/2/img/*.png".format(episode_number) + fp_in = "/home/rob/uho/html/episode/2/img/*.jpg".format(episode_number) fp_out = "/home/rob/uho/html/episode/2/img/show_cover.gif" # use exit stack to automatically close opened images @@ -563,7 +565,7 @@ def create_animated_gif(): # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def create_podcast(): - +#TODO normalise-audio the wav fills before conversion to flac then replay-gain print('''------------------------ creating show audio ------------------------''') @@ -611,7 +613,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 -------------------------- @@ -646,7 +648,6 @@ def create_podcast(): 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: @@ -661,7 +662,7 @@ def create_podcast(): playlist.export(out_f, format='mp3',\ tags={'title': str('Uho! Episode #{0} '.format(episode_number)),\ 'artist': 'https://uho.rizom.si',\ - 'album': 'THE UHO PODCAST',\ + 'album': 'The Podcast UHO!',\ 'comments': 'https://uho.rizom.si'}) print("MP3 audio file exported...") @@ -683,7 +684,7 @@ def create_html_homepage_from_template(): conn = sqlite3.connect("database/show.db") cursor = conn.cursor() - episode_artists = [] + #global episode_artists #TODO fix this - now it reports zero # get number of episodes from DB @@ -700,7 +701,7 @@ def create_html_homepage_from_template(): for artist in rows: art = string=re.sub("\(.*?\)","", artist[0]) # shorten verbose artist names such as trojnik Trojnik (Cene Resnik, Tomaž Grom, Vid Drašler) - artist = string=re.sub("and","&",art) + artist = string=re.sub("and","+",art) artists.append(artist) episode_artists.append(artists) @@ -743,7 +744,7 @@ def create_html_homepage_from_template(): episode_artists=str(episode_artists[episode_number])\ .strip("[").strip("]").strip('\'').strip('\''), \ about_show=show_short_description, \ - episode_image="img/cover0.png".format(episode_number)) + episode_image="img/cover0.jpg".format(episode_number)) with open("html/index.html".format(episode_number), "w") as episode_page: episode_page.write(output_from_parsed_template) @@ -788,13 +789,15 @@ def parse_db_episode(): # populate the jinja html template for the EPISODE output_from_parsed_template = episode_template.render(\ - 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)) - + episode_artists=episode_artists,\ + 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.jpg".format(episode_number)) return output_from_parsed_template def create_html_episode_from_template(episode_number, episode_duration): @@ -851,23 +854,72 @@ def create_html_episode_from_template(episode_number, episode_duration): episode_page.write(output_from_parsed_template) def create_RSS_XML_from_template(): + playlist_table = [] 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=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) - + + cursor = conn.cursor() + + cursor.execute('SELECT MAX(episode) FROM EPISODES') + + num_eps = cursor.fetchone()[0] + num_eps = num_eps+1 + + for i in range(num_eps): + artists = [] + cursor.execute("SELECT artist FROM EPISODES WHERE episode=? ORDER BY track_number ASC", [i]) + rows = cursor.fetchall() + + for artist in rows: + art = string=re.sub("\(.*?\)","", artist[0]) + # shorten verbose artist names such as trojnik Trojnik (Cene Resnik, Tomaž Grom, Vid Drašler) + artist = string=re.sub("and","+",art) + artists.append(artist) + episode_artists.append(artists) + + dates = [] + cursor.execute("SELECT date FROM EPISODES WHERE episode=? ORDER BY track_number ASC", [i]) + d = cursor.fetchone() + dates.append(d) + + trackdurs = [] + cursor.execute("SELECT trackdur FROM EPISODES WHERE episode=? ORDER BY track_number ASC", [i]) + td = cursor.fetchone() + trackdurs.append(str(60*60)) + # TODO this is not what i need here - i need a final episode duraton so for now putting in a dummy value + + episodes = [] + for i in range(num_eps): # get this from new table EPISODE_STATS number of tracks in DB + #print(episode_artists[i]) + an_episode = dict(date="2012-02-", \ + episode_artists=str(episode_artists[i])\ + .strip("[").strip("]").strip("\'"), episode_number=i, \ + episode_date=dates, episode_mp3_url=show_url+"/episode/"+str(i)+"/show.mp3",\ + episode_duration=trackdurs) + + episodes.append(an_episode) + # reversed order to most recent episode appears first in list + print(episodes) + + episodes = reversed(episodes[0:episode_number]) + #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 = rss_template.render(\ + 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.jpg".format(episode_number)) + with open("html/podcast_rss.xml".format(episode_number), "w") as rss_page: + rss_page.write(output_from_parsed_template) + def main(): # playlist options @@ -879,7 +931,7 @@ def main(): elif args.playlist=="keep": print("working with playlist from database... ") elif args.playlist=="edit": - print("edit the playlist...") + print("edit the playlishttps://uho.rizom.si/podcast_rss.xmlt...") modify_playlist(conn, episode_number, episode_duration) else: print("not creating new show....") diff --git a/music/README.md b/music/README.md index e69de29..69402ec 100644 --- a/music/README.md +++ b/music/README.md @@ -0,0 +1,15 @@ +# Featured Labels + +BETON RECORDS +KAMIZDAT +MENT FESTIVAL +PHARMAFABRIK +TERRAFORMER_RF +DEBILA +KAPA RECORDS +NATURE SCENE RECORDS +MOONLEE RECORDS +SPLOH +ZARŠ + ++ MANY SELF_RELEASES