run.py 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. logotext_left = [
  36. "_____ ",
  37. "| ",
  38. "| ___ _______ ",
  39. "|___ /\ | | ",
  40. "| / \ |___ | ",
  41. "| /____\ | | ",
  42. "| / \ ___| | "]
  43. logotext_right = [
  44. " ____ ____ ",
  45. "| | \ | \ | |",
  46. "| | | | | \ /",
  47. "| |____/ |____/ \ / ",
  48. "| | \ | \ \ / ",
  49. "| | | | | | ",
  50. "|_____ |____/ | | | "]
  51. logotext = [
  52. logotext_left[0]+logotext_right[0],
  53. logotext_left[1]+logotext_right[1],
  54. logotext_left[2]+logotext_right[2],
  55. logotext_left[3]+logotext_right[3],
  56. logotext_left[4]+logotext_right[4],
  57. logotext_left[5]+logotext_right[5],
  58. logotext_left[6]+logotext_right[6],
  59. "The Terminal Client"]
  60. from flbry import ui
  61. # Print logo:
  62. if ui.terminal_width >= 57:
  63. print(ui.midtext(box = "horizontal_side")) # Dynamic print size with ui.midtext function
  64. print(ui.midtext(box = "inside"))
  65. print(ui.midtext(box = "inside"))
  66. print(ui.midtext(box = "inside"))
  67. print(ui.midtext(logotext[0]))
  68. print(ui.midtext(logotext[1]))
  69. print(ui.midtext(logotext[2]))
  70. print(ui.midtext(logotext[3]))
  71. print(ui.midtext(logotext[4]))
  72. print(ui.midtext(logotext[5]))
  73. print(ui.midtext(logotext[6]))
  74. print(ui.midtext(box = "inside"))
  75. print(ui.midtext(logotext[7]))
  76. print(ui.midtext(box = "inside"))
  77. print(ui.midtext(box = "inside"))
  78. print(ui.midtext(box = "inside"))
  79. print(ui.midtext("---Type 'help' to see the list of features---", box = "horizontal_side"))
  80. else:
  81. print(ui.midtext("=== FastLBRY === ", box = None))
  82. print(ui.midtext(logotext[7], box = None))
  83. print(ui.midtext("Type 'help' to see the list of features.", box = None))
  84. # Importing all kinds of other things needed for the operations
  85. from flbry import connect
  86. from flbry import search
  87. from flbry import channel
  88. from flbry import wallet
  89. from flbry import uploads
  90. from flbry import list_files
  91. from flbry import markdown
  92. # Now we gonna start the main loop. It will give the user to input
  93. # any function. And when the function is executed, it will give it
  94. # again. Forever. Until the user exits.
  95. while True:
  96. command = input(typing_dots()) # the : will be the presented function
  97. if command == "exit":
  98. connect.stop()
  99. break # breaks the while True: loop
  100. elif command == "quit":
  101. print(" Quit does not disconnect the SDK!")
  102. print(" To disconnet use exit or disconnect.")
  103. break
  104. elif command == "help":
  105. markdown.draw("help/main.md", "Help")
  106. # HELP AND CONTRIBUTION FUNCTIONS
  107. elif command == "matrix":
  108. print(" #FastLBRY:matrix.org")
  109. elif command == "repository":
  110. print(" https://notabug.org/jyamihud/FastLBRY-terminal")
  111. elif command == "report":
  112. print(" https://notabug.org/jyamihud/FastLBRY-terminal/issues")
  113. elif command == "license":
  114. markdown.draw("LICENSE.md", "License (GPLv3 or later)")
  115. # LBRY COMMANDS
  116. elif command == "connect":
  117. connect.start()
  118. elif command == "disconnect":
  119. connect.stop()
  120. elif command == "history":
  121. list_files.downloaded()
  122. elif command.startswith("search"):
  123. if " " in command:
  124. search.simple(command[command.find(" ")+1:])
  125. else:
  126. search.simple()
  127. elif command.startswith("channel"):
  128. if " " in command:
  129. channel.simple(command[command.find(" ")+1:])
  130. else:
  131. channel.simple()
  132. ###### WALLET ######
  133. elif command == "login":
  134. markdown.draw("help/login.md", "Login Help")
  135. elif command == "wallet":
  136. wallet.history()
  137. elif command == "uploads":
  138. uploads.simple()