massupload.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env python
  2. import os
  3. import subprocess
  4. import re
  5. import platform
  6. import time
  7. import sys
  8. import json
  9. lbrynet = "lbrynet"
  10. files = os.listdir()
  11. if platform.system() == "Windows":
  12. slash = "\\"
  13. else:
  14. slash = "/"
  15. file_path = os.getcwd() + slash
  16. if subprocess.getoutput(f"{lbrynet} version") == "Could not connect to daemon. Are you sure it's running?":
  17. print('It looks like lbrynet has not started yet. In another terminal window/tab do "lbrynet start" and rerun this script.')
  18. quit()
  19. channels = subprocess.getoutput(f"{lbrynet} channel list")
  20. json_stuff = json.loads(channels)
  21. for i, channel in enumerate(json_stuff["items"]):
  22. print(i, "|", channel["name"])
  23. c = 100000
  24. while not c >= 0 or not c <= i:
  25. c = input('Select a channel from 0-'+str(i)+': ')
  26. try:
  27. c = int(c)
  28. except:
  29. c = 100000
  30. channel = json_stuff["items"][c]["name"]
  31. print(f"Mass uploading to {channel}.")
  32. try:
  33. print("---\nCould be costly to do a mass upload, press enter and bid will be 0.1")
  34. bid = str(input("Per upload, how much bid do you want? "))
  35. except:
  36. bid = str(0.1)
  37. #try:
  38. # print('---\nDo you want a special description? Press enter and the description will be "mass upload"')
  39. # description = input('Description for every upload: ')
  40. #except:
  41. # description = "mass upload"
  42. for image in files:
  43. if sys.argv[0] in image:
  44. print("Not going to upload {sys.argv[0]}")
  45. pass
  46. else:
  47. os.system(f'{lbrynet} publish --name={image} --bid=0.1 --file_path="{file_path + image}" --title="{image}" --channel_name={channel}')
  48. time.sleep(30)
  49. for image in files:
  50. print(f"https://spee.ch/{channel}/{image}")