librex.py 934 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env python
  2. import requests
  3. import json
  4. import os
  5. import sys
  6. librex_instance = "https://search.davidovski.xyz/"
  7. # put a space at the end for it to work
  8. command = "palemoon "
  9. # C O L E R S
  10. bold = "\033[01m"
  11. norm = "\033[00m"
  12. bright_cyan = "\033[46m"
  13. colora = "\033[45m"
  14. colorb = "\033[44m"
  15. try:
  16. query = sys.argv[2]
  17. except:
  18. query = input("Searching for: ")
  19. query = str(query)
  20. size = str(19)
  21. librex_search = librex_instance + "api.php?q=" + query + "&p=1&img_search=false"
  22. data = requests.get(librex_search)
  23. json_stuff = json.loads(data.text)
  24. for i, vid in enumerate(json_stuff):
  25. print(i, colora+vid["title"]+norm+"\n"+colorb+vid["url"]+norm)
  26. c = 100000
  27. while not c >= 0 or not c <= 19:
  28. c = input('Number from 1-' + size + " of the URL you want to open: ")
  29. try:
  30. c = int(c)
  31. except:
  32. c = 100000
  33. selected_url = json_stuff[c]["url"]
  34. os.system(command + selected_url)
  35. quit()