table creation to seperate file
parent
2b7f711641
commit
2394d9387d
BIN
database/show.db
BIN
database/show.db
Binary file not shown.
|
@ -117,7 +117,7 @@
|
|||
<div class="col-md-7">
|
||||
<h4>This weeks playlist:</h4>
|
||||
{% for track in episode_playlist[0:] %}
|
||||
<h4>{{track}}</h4>
|
||||
<p><b> {{track}} </b> </p>
|
||||
{% endfor %}
|
||||
<!-- <table> -->
|
||||
<!-- {% for track in episode_playlist[0:] %} -->
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
66
mk_show.py
66
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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue