replace a specific file from playlist
parent
08cace37e3
commit
7eaa8f5959
BIN
database/show.db
BIN
database/show.db
Binary file not shown.
140
mk_show.py
140
mk_show.py
|
@ -247,69 +247,101 @@ def modify_playlist(conn, episode_number, episode_duration):
|
|||
preview = cursor.fetchall()
|
||||
for i in preview:
|
||||
print('{0} : {1} {2} {3} {4} '.format(i[2], i[4], i[5], i[6], i[7],))
|
||||
dj_is_unsure=True
|
||||
|
||||
#dj_is_unsure=True
|
||||
|
||||
cursor = conn.cursor()
|
||||
|
||||
if dj_is_unsure:
|
||||
#if dj_is_unsure:
|
||||
|
||||
user_input = input('''nice playlist?
|
||||
p = audio preview of a track + replace or not
|
||||
y = generate a new playlist,
|
||||
s = shuffle the existing playlist
|
||||
r = replace an index with random OR specific
|
||||
OR PRESS ENTER TO PROCEED....''')
|
||||
user_input = input('''nice playlist?
|
||||
p = audio preview of a track + replace or not
|
||||
y = generate a new playlist,
|
||||
s = shuffle the existing playlist
|
||||
r = replace an index with random OR specific
|
||||
OR PRESS ENTER TO PROCEED....''')
|
||||
|
||||
if user_input == 'y':
|
||||
print("action")
|
||||
create_episode_playlist(conn, episode_number)
|
||||
if user_input == 'y':
|
||||
print("action")
|
||||
create_episode_playlist(conn, episode_number)
|
||||
|
||||
elif user_input == 's':
|
||||
# shuffle the episode
|
||||
q = 'SELECT * FROM EPISODES WHERE EPISODE = {0} ORDER BY random();'.format(episode_number)
|
||||
cursor.execute(q)
|
||||
r = cursor.fetchall()
|
||||
# delete the old episode
|
||||
cursor.execute('DELETE FROM EPISODES WHERE episode = {0}'.format(episode_number))
|
||||
track_count = 0;
|
||||
# write in the shuffled version
|
||||
for i in r:
|
||||
print('{0} : {1} {2} {3} {4} '.format(i[2], i[4], i[5], i[6], i[7],))
|
||||
# write the shuffled back to a tmp buffer episode {1000}
|
||||
e = Table('EPISODES')
|
||||
track_number = 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[12])
|
||||
cursor.execute(str(q))
|
||||
# TODO put this shuffle in a function and sort out the logic flow so i can keep shuffling - remove
|
||||
track_count += 1;
|
||||
#episode_duration = episode_duration + track_duration
|
||||
conn.commit()
|
||||
elif user_input == 's':
|
||||
# shuffle the episode
|
||||
q = 'SELECT * FROM EPISODES WHERE EPISODE = {0} ORDER BY random();'.format(episode_number)
|
||||
cursor.execute(q)
|
||||
r = cursor.fetchall()
|
||||
# delete the old episode
|
||||
cursor.execute('DELETE FROM EPISODES WHERE episode = {0}'.format(episode_number))
|
||||
track_count = 0;
|
||||
# write in the shuffled version
|
||||
for i in r:
|
||||
print('{0} : {1} {2} {3} {4} '.format(i[2], i[4], i[5], i[6], i[7],))
|
||||
|
||||
e = Table('EPISODES')
|
||||
track_number = 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[12])
|
||||
cursor.execute(str(q))
|
||||
# TODO put this shuffle in a function and sort out the logic flow so i can keep shuffling - remove
|
||||
track_count += 1;
|
||||
episode_duration = episode_duration #+ track_duration
|
||||
conn.commit()
|
||||
|
||||
|
||||
elif user_input == 'r':
|
||||
|
||||
to_replace = int(input("which track number would you like to replace?"))
|
||||
|
||||
# get a random track to replace the removed
|
||||
|
||||
q = 'SELECT * FROM EPISODES WHERE EPISODE = {0} ORDER BY random() LIMIT 1;'.format(episode_number)
|
||||
# TODO let me have a choice of specific file/folder or random file
|
||||
# a number of q choices through an input()
|
||||
|
||||
cursor.execute(q)
|
||||
r = cursor.fetchall()
|
||||
print(r)
|
||||
# delete the old episode
|
||||
cursor.execute('DELETE FROM EPISODES WHERE episode = {0} AND track_number={1}'.format(episode_number, to_replace ))
|
||||
track_count = 0;
|
||||
# write in the shuffled version
|
||||
for i in r:
|
||||
print('{0} : {1} {2} {3} {4} '.format(i[2], i[4], i[5], i[6], i[7],))
|
||||
e = Table('EPISODES')
|
||||
track_number = track_count
|
||||
id = str(uuid.uuid4())
|
||||
q = e.insert(id, episode_number, to_replace, str(episode_date),\
|
||||
i[4], i[5], i[6], i[7], i[8], i[9], i[10], i[11], i[12])
|
||||
cursor.execute(str(q))
|
||||
track_count += 1;
|
||||
episode_duration = episode_duration #+ track_duration
|
||||
conn.commit()
|
||||
|
||||
|
||||
elif user_input == 'p':
|
||||
# preview a track --------------------------------------
|
||||
preview_track = input("which track would you like to preview [0-12]:")
|
||||
cursor.execute('SELECT path FROM EPISODES WHERE EPISODE=? AND track_number=?', [episode_number, preview_track ])
|
||||
preview_track_path = cursor.fetchone()[0]
|
||||
print(preview_track_path)
|
||||
#os.system("mplayer '{0}' &".format(preview_track_path))
|
||||
subprocess.Popen(["nohup mplayer '{0}' &".format(preview_track_path)], shell=True)
|
||||
#Popen.run("mplayer '{0}' &".format(preview_track_path))
|
||||
track_previewed = input("track OK? :")
|
||||
if track_previewed == 'y':
|
||||
print("ok groovy choice then...")
|
||||
else:
|
||||
input("do the db replace logic")
|
||||
playlist_replace_track(conn, episode_number, preview_track)
|
||||
elif user_input == 's':
|
||||
print("the logic to shuffle the existing playlist order")
|
||||
|
||||
elif user_input == 'p':
|
||||
# preview a track --------------------------------------
|
||||
preview_track = input("which track would you like to preview [0-12]:")
|
||||
cursor.execute('SELECT path FROM EPISODES WHERE EPISODE=? AND track_number=?', [episode_number, preview_track ])
|
||||
preview_track_path = cursor.fetchone()[0]
|
||||
print(preview_track_path)
|
||||
#os.system("mplayer '{0}' &".format(preview_track_path))
|
||||
subprocess.Popen(["nohup mplayer '{0}' &".format(preview_track_path)], shell=True)
|
||||
#Popen.run("mplayer '{0}' &".format(preview_track_path))
|
||||
track_previewed = input("track OK? :")
|
||||
if track_previewed == 'y':
|
||||
print("ok groovy choice then...")
|
||||
else:
|
||||
print(">>>>>>>>>>>>>>>>>> Goodbye Happy DJ !!!!!!!!!!!!!!")
|
||||
episode_duration = timedelta(seconds=round(episode_duration))
|
||||
print("Total Duration = {0}".format(episode_duration))
|
||||
input("do the db replace logic")
|
||||
playlist_replace_track(conn, episode_number, preview_track)
|
||||
elif user_input == 's':
|
||||
print("the logic to shuffle the existing playlist order")
|
||||
|
||||
else:
|
||||
print(">>>>>>>>>>>>>>>>>> Goodbye Happy DJ !!!!!!!!!!!!!!")
|
||||
episode_duration = timedelta(seconds=round(episode_duration))
|
||||
print("Total Duration = {0}".format(episode_duration))
|
||||
|
||||
return user_input
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue