main.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import sites as sites
  2. from helper.settings import Settings
  3. from helper import console as console
  4. import os.path
  5. import command
  6. def main():
  7. Settings.read()
  8. Settings.initialize()
  9. os.makedirs(Settings.tmpDir.get(), exist_ok=True)
  10. console.unlock()
  11. console.output('Music downloader by Deben Oldert')
  12. console.output()
  13. console.output('Download directory: {0}'.format(Settings.SaveDir.get()))
  14. console.output()
  15. help()
  16. console.output()
  17. console.output('Available sites: {0}'.format(', '.join(list(map(lambda x: x.url, sites.available)))))
  18. console.output('Selected site is: {0}'.format(sites.available[selected_site].url))
  19. console.output()
  20. while True:
  21. if not idle():
  22. break
  23. console.output('Quitting...')
  24. exit(0)
  25. def idle():
  26. _command = console.ask_input('Type command')
  27. for comm in command.commands:
  28. if comm[0] == _command.lower():
  29. return comm[1]()
  30. console.output('Command \'{0}\' not found. Type help to see a list of possible commands'.format(_command))
  31. return True
  32. def quit():
  33. return False
  34. selected_site = 0
  35. search_cache = None
  36. if __name__ == '__main__':
  37. main()