Skip to content

Commit

Permalink
Fixed a hell lot of stuff, thanks to @Hussain29
Browse files Browse the repository at this point in the history
  • Loading branch information
gopal-kaul committed Feb 13, 2021
1 parent 55e54d2 commit e801c17
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions CSDJ.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ def download(name):

def movetodir(name):
if platform.system() == 'Windows':
ffmpeg_cmd = f"{os.path.join(os.getcwd(), 'utils', 'ffmpegw.exe')}" + " -i " + f"{os.path.join(os.getcwd(),'cache',f'{name}.webm')}" + \
basedir = os.getcwd().replace(' ', r'\ ')
ffmpeg_cmd = f"{os.path.join(basedir,'utils', 'ffmpegw.exe')}" + " -i " + f"{os.path.join(basedir,'cache',f'{name}.webm')}" + \
" -acodec pcm_s16le -ar 22050 -ac 1 -fflags +bitexact -flags:v +bitexact -flags:a +bitexact " + \
f"{os.path.join(os.getcwd(),'cache','voice_input.wav')}" + " -y"
f"{os.path.join(basedir,'cache','voice_input.wav')}" + " -y"
subprocess.call(ffmpeg_cmd, shell=True)
# Call to ffmpeg to run the conversion
elif platform.system() == "Linux":
Expand All @@ -44,11 +45,11 @@ def movetodir(name):
try:
cfg = open('csdir.cfg')
dest = str(cfg.read())
if platform.system()=='Windows':
path = os.path.join(os.getcwd(), 'cache\\','voice_input.wav')
if platform.system() == 'Windows':
path = os.path.join(os.getcwd(), 'cache\\', 'voice_input.wav')
shutil.copy(path, f"{dest}\\")
elif platform.system() == "Linux":
path = os.path.join(os.getcwd(), 'cache/','voice_input.wav')
path = os.path.join(os.getcwd(), 'cache/', 'voice_input.wav')
shutil.copy(path, f"{dest}")
sg.PopupQuick("Copied!")
if os.path.exists(os.path.join(dest, 'csgo', 'cfg', 'csdj.cfg')) == False:
Expand Down Expand Up @@ -86,26 +87,31 @@ def movetodir(name):
cfg.close()


sg.theme('Dark Blue 14')
layout = []
layout.append([sg.Text("Select one : ")])
for i in os.listdir(os.path.join(os.getcwd(), 'cache')):
name = i.replace(".webm",'')
if i not in ['.gitkeep', 'voice_input.wav']:
layout.append([sg.Text(name), sg.Button("Select", key=name)])
def layoutbuild():
layout = []
for i in os.listdir(os.path.join(os.getcwd(), 'cache')):
name = i.replace(".webm", '')
if i not in ['.gitkeep', 'voice_input.wav']:
layout.append(name)
return layout


layout = [[sg.Text("Select from available songs or add from YouTube : ")], [sg.Listbox(
values=layoutbuild(), size=(40, 2*len(layoutbuild())), enable_events=True, key="-FILES-")]]
sg.theme('Dark Blue 14')
layout.append([sg.HSeparator()])
layout.append([sg.Button("Add from YouTube",key='yt')])
layout.append([sg.Button("Add from YouTube", key='yt')])
window = sg.Window('CSDJ', layout)
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == 'Cancel':
break
elif event == 'yt':
song = sg.popup_get_text("Enter the song name : " )
song = sg.popup_get_text("Enter the song name : ")
download(song)
movetodir(song)
sg.popup_ok(f"{song} successfully downloaded and copied!")
else:
movetodir(event)
window['-FILES-'].update(layoutbuild())
elif event == '-FILES-':
movetodir(values['-FILES-'][0])
window.close()

0 comments on commit e801c17

Please sign in to comment.