run.py 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #####################################################################
  2. # #
  3. # THIS IS A SOURCE CODE FILE FROM A PROGRAM TO INTERACT WITH THE #
  4. # LBRY PROTOCOL ( lbry.com ). IT WILL USE THE LBRY SDK ( lbrynet ) #
  5. # FROM THEIR REPOSITORY ( https://github.com/lbryio/lbry-sdk ) #
  6. # WHICH I GONNA PRESENT TO YOU AS A BINARY. SINCE I DID NOT DEVELOP #
  7. # IT AND I'M LAZY TO INTEGRATE IN A MORE SMART WAY. THE SOURCE CODE #
  8. # OF THE SDK IS AVAILABLE IN THE REPOSITORY MENTIONED ABOVE. #
  9. # #
  10. # ALL THE CODE IN THIS REPOSITORY INCLUDING THIS FILE IS #
  11. # (C) J.Y.Amihud and Other Contributors 2021. EXCEPT THE LBRY SDK. #
  12. # YOU CAN USE THIS FILE AND ANY OTHER FILE IN THIS REPOSITORY UNDER #
  13. # THE TERMS OF GNU GENERAL PUBLIC LICENSE VERSION 3 OR ANY LATER #
  14. # VERSION. TO FIND THE FULL TEXT OF THE LICENSE GO TO THE GNU.ORG #
  15. # WEBSITE AT ( https://www.gnu.org/licenses/gpl-3.0.html ). #
  16. # #
  17. # THE LBRY SDK IS UNFORTUNATELY UNDER THE MIT LICENSE. IF YOU ARE #
  18. # NOT INTENDING TO USE MY CODE AND JUST THE SDK. YOU CAN FIND IT ON #
  19. # THEIR OFFICIAL REPOSITORY ABOVE. THEIR LICENSE CHOICE DOES NOT #
  20. # SPREAD ONTO THIS PROJECT. DON'T GET A FALSE ASSUMPTION THAT SINCE #
  21. # THEY USE A PUSH-OVER LICENSE, I GONNA DO THE SAME. I'M NOT. #
  22. # #
  23. # THE LICENSE CHOSEN FOR THIS PROJECT WILL PROTECT THE 4 ESSENTIAL #
  24. # FREEDOMS OF THE USER FURTHER, BY NOT ALLOWING ANY WHO TO CHANGE #
  25. # THE LICENSE AT WILL. SO NO PROPRIETARY SOFTWARE DEVELOPER COULD #
  26. # TAKE THIS CODE AND MAKE THEIR USER-SUBJUGATING SOFTWARE FROM IT. #
  27. # #
  28. #####################################################################
  29. # Preparing the executable of lbrynet to be running. If we don't that
  30. # there will be a nasty error of permission being denied.
  31. import os
  32. os.system("chmod u+x flbry/lbrynet")
  33. from flbry.variables import *
  34. # A welcome logo.
  35. logo()
  36. # Here I want to make a simple check for an operating system
  37. # The software is built to work on GNU / Linux so I need to
  38. # check whether the user runs it on a proper system. If not
  39. # give them a warning message.
  40. import platform
  41. if platform.system() != "Linux": # IK It should be GNU / Linux
  42. center("OS "+platform.system().upper()+" NOT SUPPORTED!", "bdrd", True)
  43. center("Type 'osinfo' to learn more.", "bdrd")
  44. # Importing all kinds of other things needed for the operations
  45. from flbry import connect
  46. from flbry import search
  47. from flbry import channel
  48. from flbry import wallet
  49. from flbry import uploads
  50. from flbry import list_files
  51. from flbry import markdown
  52. from flbry import trending
  53. from flbry import url
  54. from flbry import publish
  55. # Now we gonna start the main loop. It will give the user to input
  56. # any function. And when the function is executed, it will give it
  57. # again. Forever. Until the user exits.
  58. while True:
  59. command = input(typing_dots()) # the : will be the presented function
  60. if command == "exit":
  61. connect.stop()
  62. break # breaks the while True: loop
  63. elif command == "quit":
  64. print(" Quit does not disconnect the SDK!")
  65. print(" To disconnet use exit or disconnect.")
  66. break
  67. elif command == "help":
  68. markdown.draw("help/main.md", "Help")
  69. elif command == "osinfo":
  70. markdown.draw("help/os.md", "Operating System Information")
  71. # HELP AND CONTRIBUTION FUNCTIONS
  72. elif command == "matrix":
  73. print(" #FastLBRY:matrix.org")
  74. elif command == "clear":
  75. os.system("clear")
  76. elif command == "repository":
  77. print(" https://notabug.org/jyamihud/FastLBRY-terminal")
  78. elif command == "report":
  79. print(" https://notabug.org/jyamihud/FastLBRY-terminal/issues")
  80. elif command == "license":
  81. markdown.draw("LICENSE.md", "License (GPLv3 or later)")
  82. # LBRY COMMANDS
  83. elif command == "connect":
  84. connect.start()
  85. elif command == "disconnect":
  86. connect.stop()
  87. elif command.startswith("publish"):
  88. if " " in command:
  89. publish.configure(command[command.find(" ")+1:])
  90. else:
  91. publish.configure()
  92. elif command == "history":
  93. list_files.downloaded()
  94. elif command.startswith("search"):
  95. if " " in command:
  96. search.simple(command[command.find(" ")+1:])
  97. else:
  98. search.simple()
  99. elif command == "channels":
  100. channel.simple(channel.select())
  101. elif command.startswith("channel"):
  102. if " " in command:
  103. channel.simple(command[command.find(" ")+1:])
  104. else:
  105. channel.simple()
  106. elif command.startswith("trending"):
  107. trending.simple()
  108. elif command.startswith("articles"):
  109. trending.simple(articles=True)
  110. ###### WALLET ######
  111. elif command == "login":
  112. markdown.draw("help/login.md", "Login Help")
  113. elif command == "wallet":
  114. wallet.history()
  115. elif command == "balance":
  116. wallet.balance()
  117. elif command == "uploads":
  118. uploads.simple()
  119. ###### RSS ######
  120. elif command.startswith("RSS"):
  121. channel = input("channel:")
  122. print("https://odysee.com/$/rss/" + channel)
  123. # If a user types anything ELSE, except just simply pressing
  124. # Enter. So if any text is in the command, but non of the
  125. # above were activated.
  126. # Here I want to just run the URL module and try to resolve
  127. # the url. The Url module will need to be able to handle a
  128. # lot of it.
  129. elif command:
  130. url.get(command)