From 2394d9387d798a3a7a6ab5dfc8f9f7ada0fdf90f Mon Sep 17 00:00:00 2001 From: Rob Canning Date: Sun, 21 Jan 2024 01:29:33 +0100 Subject: [PATCH] table creation to seperate file --- database/show.db | Bin 446464 -> 446464 bytes html/templates/episode.jinja | 2 +- mk_music_library_db.py | 36 +++++++++++++++ mk_show.py | 66 +++++++--------------------- playlists/track_playout_history.txt | 20 ++++----- 5 files changed, 61 insertions(+), 63 deletions(-) diff --git a/database/show.db b/database/show.db index 6b52de323831f18656065f1192e1660bf2ec176c..ce70dc0773b0fc8a8e83203366846bb221fd0f0d 100644 GIT binary patch delta 1921 zcmZwHdrVwa8UXM)_nvd+!90a248!d_D6~LfZh4ea+rmJnFSbDKV-Q-(6vu@^OM!OV zYAc*OkNsn#rJ2O9(O7GAjc&5q29;%95;oBoi1SZ`oS3n@A8}3&XA>rq z>3H@aI+Sfkf1YhYAI@$<0IgR#aPM|%RB>G_HFdENv zpa(Ni^nr|yc4f-Z&P*}7H)BQH)92AWlj&jn*p==>ccu@ZvGfkKE!~K=rmN7FbO3Em z%ko>(7IaJM9J)CrW1CVkc2lYgZA`VI4XHY`E>()wrexHH6hkA%1X^tzL)RM*pq0j? z3|ME#fO13LIga$t&tuZYjbGZM@&) zs(1D{Ubo-Mdppl(TVts(CwMM&y?G`W57>#=;_Il?(G5%9KLIAhmjJeYK89T~OCIFCXx$d!*D#Zgq?fO(e~?!Q)_$ zcv9yqP7D)`VmM~@dQ-jdk2$O`^(Je8uHUd$a9?HB(E1W9fe&6{7WnS>JSMN6lNV~k zV%#jN9`X2OdyOkqjZ(61Ra1Ri;^aVbq~#Zf_r3Yg>dKDMlS%U;+!!EncsNS7#Y6>{ ziM(qy#ixkg6%xsiUCHs}>7jv%;EvJp;do+vaCCekN!A}o4h)_gHGcy)zEk$V%Xbvb zW!Ra_*Kn{(HntV)f8gctO%2%sAO4POaJPU|!eoTR!=jJMg=^~qa-p_DVfgk5zJV`y z{55?1E^CCFJ-iYAa)=j)M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?@JF|`fweMa4dwIiMG7%?FS84F|4yt^rDJpx#ez+CxWu=)n927Au=^(| Nq)1yR51ap+;J-M31Kj`s diff --git a/html/templates/episode.jinja b/html/templates/episode.jinja index 93471b1..da301db 100644 --- a/html/templates/episode.jinja +++ b/html/templates/episode.jinja @@ -117,7 +117,7 @@

This weeks playlist:

{% for track in episode_playlist[0:] %} -

{{track}}

+

{{track}}

{% endfor %} diff --git a/mk_music_library_db.py b/mk_music_library_db.py index 7a9300d..a24f14a 100755 --- a/mk_music_library_db.py +++ b/mk_music_library_db.py @@ -1,5 +1,7 @@ #!/usr/bin/python3 +# CREATE MUSIC DATABASE ------------------------------------------ + import sys, os, datetime, fnmatch, glob, random, time, pathlib, re from datetime import timedelta from os.path import join @@ -43,6 +45,39 @@ def database_create(conn): conn.execute(str(mus_lib)) print('''MUSIC LIBRARY Table created successfully'''); + +#conn = '' + +def database_create_episodes_table(conn): + # the show database + +# conn = sqlite3.connect("database/show.db") + + #TODO put the below back as a raw quiry to make if not exists possible + q = Query \ + .create_table("EPISODES") \ + .columns( + Column("id", "INT", nullable=True), + Column("episode", "INT", nullable=True), + Column("date", 'DATETIME', nullable=True), + Column("album", "VARCHAR(200)", nullable=True), + Column("track", "VARCHAR(120)", nullable=True), + Column("artist", "VARCHAR(120)", nullable=True), + Column("trackdur", "FLOAT", nullable=True), + Column("genre", "VARCHAR(120)", nullable=True), + Column("year", 'DATETIME', nullable=True), + Column("path", "VARCHAR(120)", nullable=False))\ + .unique("path") \ + .primary_key("path") + + #TODO get the unique path back into action find bug + conn.execute(str(q)) + + + + + print("EPISODES Table created successfully"); + def mk_db_entry(conn): print("ADDING TRACKS TO DATABASE > > > one moment please! "); label_url = "https://fixme.bandcamp.com/" @@ -76,6 +111,7 @@ def count_tracks(conn): def main(): database_create(conn) + database_create_episodes_table(conn) mk_db_entry(conn) count_tracks(conn) diff --git a/mk_show.py b/mk_show.py index e85c889..d111c31 100755 --- a/mk_show.py +++ b/mk_show.py @@ -1,5 +1,7 @@ #!/usr/bin/python3 +# CREATE PODCAST ----------------------------------------- + import sys, os, datetime, fnmatch, glob, random, time, pathlib, re from datetime import timedelta from os.path import join @@ -30,6 +32,8 @@ artist_abreviated = [] web_path = "/home/rob/antena/html/episode/{0}/img".format(episode_number) +conn = sqlite3.connect("database/show.db") + if os.path.exists(web_path): print("path_exists_doing_nothing") else: os.makedirs(web_path) @@ -44,49 +48,6 @@ def set_episode_date(input_date): #return episode_date print(episode_date) -conn = '' -def database_create_episodes_table(): - # the show database - global conn - conn = sqlite3.connect("database/show.db") - - q = Query \ - .create_table("EPISODES") \ - .columns( - Column("id", "INT", nullable=True), - Column("episode", "INT", nullable=True), - Column("date", 'DATETIME', nullable=True), - Column("album", "VARCHAR(200)", nullable=True), - Column("track", "VARCHAR(120)", nullable=True), - Column("artist", "VARCHAR(120)", nullable=True), - Column("trackdur", "FLOAT", nullable=True), - Column("genre", "VARCHAR(120)", nullable=True), - Column("year", 'DATETIME', nullable=True), - Column("path", "VARCHAR(120)", nullable=False))\ - .primary_key("path") - #.unique("path") \ - #TODO get the unique path back into action find bug - conn.execute(str(q)) - - - - - print("EPISODES Table created successfully"); - - - - - - - - - - - - - - - def create_intro(episode_playlist): intropath = path + "audio/texts/clips/this_is" intro = random.choice(os.listdir(intropath)) @@ -108,7 +69,7 @@ def check_archive(track): print("____ TRACK ALREADY PLAYED _____") return False -def create_episode_playlist(episode_playlist: list, complete_playlist:list): +def create_episode_playlist(conn, episode_playlist: list, complete_playlist:list): global episode_duration global archive @@ -125,7 +86,7 @@ def create_episode_playlist(episode_playlist: list, complete_playlist:list): cursor = conn.cursor() cursor.execute("SELECT * FROM MUSIC_LIBRARY ORDER BY RANDOM() LIMIT 1 ;") r = cursor.fetchone() # FETCH ONE RANDOM TRACK FROM THE DATABASE - print(str(r)+"ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss") + # for t in r: song = str(r[9]) track_label = str(r[1]) @@ -135,8 +96,8 @@ def create_episode_playlist(episode_playlist: list, complete_playlist:list): track_duration = float(r[6]) track_genre = str(r[5]) track_year = str(r[7]) - track_path = '/'.join(song.split('/')[0:-1]) - + track_path = song #'/'.join(song.split('/')[0:-1]) + #print(str(song)+"ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss") # SOME LOGIC TO SEE IF WE ALLOW THAT TRACK OR NOT @@ -404,7 +365,10 @@ def create_html_homepage_from_template(episode_playlist): show_info = [] episode_artists = [] - for i in range(10): + + num_eps = 4 + + for i in range(num_eps): artists = [] cursor.execute("SELECT artist FROM EPISODES WHERE episode=?", [i]) rows = cursor.fetchall() @@ -417,7 +381,7 @@ def create_html_homepage_from_template(episode_playlist): episode_artists.append(artists) episodes = [] - for i in range(10): # get this from new table EPISODE_STATS number of tracks in DB + 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=episode_artists[i], episode_number=i, \ @@ -524,9 +488,9 @@ def create_RSS_XML_from_template(): def main(): - database_create_episodes_table() +# database_create_episodes_table() set_episode_date(input_date) - create_episode_playlist(episode_playlist, complete_playlist) + create_episode_playlist(conn, episode_playlist, complete_playlist) create_show_coverart(episode_playlist, 1) #episode_duration = 100 #create_animated_gif() create_intro(episode_playlist) diff --git a/playlists/track_playout_history.txt b/playlists/track_playout_history.txt index d4290f3..e90dd7b 100644 --- a/playlists/track_playout_history.txt +++ b/playlists/track_playout_history.txt @@ -1,13 +1,11 @@ -Stampede -Vrtnice -zvoki iz dnevne sobe -jez -The Left Eye -NeoPogo - FeS2 -BE CREEP - Burnt Dreams -Zlatko Kaučič, Tomaž Grom - Torn Memories Of Folklore - Raztrgana folklora spomina - 08 Almost The Same +Some Spatter Left The Mother (Act VII) -一点一滴 -Jean-Luc Guionnet & Samo Kutin - Kopaš - 02 02 -Vertex +Tilt - Tilt - 03 Alicante 3 +Hunahpu & Xbalanque +Maskardh - Thrills Of Deconstruction +Heretics Fork +94 +Zlatko Kaučič, Tomaž Grom - The Ear Is The Shadow Of The Eye - 12 Battling For A Title - Za naslov se boriva +Crossing The Rubicon +šopscum solata