A tool which can be used to search and play YouTube music!
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 

26 rader
808 B

  1. #!/usr/bin/python3
  2. from youtube_search import YoutubeSearch
  3. import sys, getopt
  4. def main(argv):
  5. inputfile = ''
  6. outputfile = ''
  7. try:
  8. opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="])
  9. except getopt.GetoptError:
  10. print ('spotitube.py -i <Search Keyword>')
  11. sys.exit(2)
  12. for opt, arg in opts:
  13. if opt == '-h':
  14. print ('test.py -i <inputfile> -o <outputfile>')
  15. sys.exit()
  16. elif opt in ("-i", "--ifile"):
  17. inputfile = arg
  18. elif opt in ("-o", "--ifile"):
  19. numberfile = arg
  20. results = YoutubeSearch(inputfile, max_results=int(numberfile)).to_dict()
  21. ans = 'https://youtu.be/' + results[int(numberfile)-1]['url_suffix'][9:]
  22. print(ans)
  23. if __name__ == "__main__":
  24. main(sys.argv[1:])