run.py 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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. import os
  30. from flbry import variables
  31. from flbry.variables import *
  32. from flbry import settings
  33. settings.check_config()
  34. settings.set_theme(settings.get("theme"))
  35. # A welcome logo.
  36. logo()
  37. # Here I want to make a simple check for an operating system
  38. # The software is built to work on GNU / Linux so I need to
  39. # check whether the user runs it on a proper system. If not
  40. # give them a warning message.
  41. import platform
  42. if platform.system() != "Linux": # IK It should be GNU / Linux
  43. center("OS "+platform.system().upper()+" NOT SUPPORTED!", "bdrd", True)
  44. center("Type 'osinfo' to learn more.", "bdrd")
  45. # Importing all kinds of other things needed for the operations
  46. from flbry import connect
  47. from flbry import search
  48. from flbry import channel
  49. from flbry import wallet
  50. from flbry import uploads
  51. from flbry import list_files
  52. from flbry import following
  53. from flbry import markdown
  54. from flbry import trending
  55. from flbry import url
  56. from flbry import publish
  57. from flbry import comments
  58. # Now we gonna start the main loop. It will give the user to input
  59. # any function. And when the function is executed, it will give it
  60. # again. Forever. Until the user exits.
  61. # List of commands for autocomplete feature.
  62. main_commands = [
  63. "exit",
  64. "quit",
  65. "help",
  66. "osinfo",
  67. "matrix",
  68. "clear",
  69. "repository",
  70. "report",
  71. "license",
  72. "connect",
  73. "disconnect",
  74. "publish",
  75. "history",
  76. "search",
  77. "channels",
  78. "channel",
  79. "trending",
  80. "articles",
  81. "login",
  82. "wallet",
  83. "balance",
  84. "inbox",
  85. "uploads",
  86. "following",
  87. "subscriptions",
  88. "install",
  89. "install_force"
  90. ]
  91. complete(main_commands)
  92. while True:
  93. command = input(typing_dots()) # the : will be the presented function
  94. if command == "exit":
  95. connect.stop()
  96. break # breaks the while True: loop
  97. elif command == "quit":
  98. print(" Quit does not disconnect the SDK!")
  99. print(" To disconnet use exit or disconnect.")
  100. break
  101. elif command == "help":
  102. markdown.draw("help/main.md", "Help")
  103. elif command == "osinfo":
  104. markdown.draw("help/os.md", "Operating System Information")
  105. # HELP AND CONTRIBUTION FUNCTIONS
  106. elif command == "matrix":
  107. print(" #FastLBRY:matrix.org")
  108. elif command == "clear":
  109. os.system("clear")
  110. elif command == "repository":
  111. print(" https://notabug.org/jyamihud/FastLBRY-terminal")
  112. elif command == "report":
  113. print(" https://notabug.org/jyamihud/FastLBRY-terminal/issues")
  114. elif command == "license":
  115. markdown.draw("LICENSE.md", "License (GPLv3 or later)")
  116. # LBRY COMMANDS
  117. elif command == "connect":
  118. connect.start()
  119. elif command == "disconnect":
  120. connect.stop()
  121. elif command.startswith("publish"):
  122. if " " in command:
  123. publish.configure(command[command.find(" ")+1:])
  124. else:
  125. publish.configure()
  126. elif command == "history":
  127. list_files.downloaded()
  128. elif command.startswith("search"):
  129. if " " in command:
  130. search.simple(command[command.find(" ")+1:])
  131. else:
  132. search.simple()
  133. elif command == "channels":
  134. channel.simple(channel.select())
  135. elif command.startswith("channel"):
  136. if " " in command:
  137. channel.simple(command[command.find(" ")+1:])
  138. else:
  139. channel.simple()
  140. elif command.startswith("trending"):
  141. trending.simple()
  142. elif command.startswith("articles"):
  143. trending.simple(articles=True)
  144. elif command in ("following", "subscriptions"):
  145. following.following()
  146. ###### WALLET ######
  147. elif command == "login":
  148. markdown.draw("help/login.md", "Login Help")
  149. elif command == "wallet":
  150. wallet.history()
  151. elif command == "balance":
  152. wallet.balance()
  153. elif command.startswith("inbox"):
  154. if " " in command:
  155. comments.inbox(command[command.find(" ")+1:])
  156. else:
  157. comments.inbox()
  158. elif command == "uploads":
  159. uploads.simple()
  160. elif command == "install":
  161. settings.install_desktop(False)
  162. elif command == "install_force":
  163. settings.install_desktop(True)
  164. elif command == "settings":
  165. settings.ui()
  166. # If a user types anything ELSE, except just simply pressing
  167. # Enter. So if any text is in the command, but non of the
  168. # above were activated.
  169. # Here I want to just run the URL module and try to resolve
  170. # the url. The Url module will need to be able to handle a
  171. # lot of it.
  172. elif command:
  173. url.get(command)
  174. # Restore the commands completion
  175. complete(main_commands)