run.py 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. print(" "+clr["bdma"]+wdth(" ",89)+clr["norm"])
  36. print(" "+clr["bdma"]+" "+clr["bdbu"]+wdth(" ",87)+clr["bdma"]+" "+clr["norm"])
  37. print(" "+clr["bdma"]+" "+clr["bdbu"]+wdth(" ",87)+clr["bdma"]+" "+clr["norm"])
  38. print(" "+clr["bdma"]+" "+clr["bdbu"]+wdth(" ",87)+clr["bdma"]+" "+clr["norm"])
  39. print(" "+clr["bdma"]+" "+clr["bdbu"]+clr["bold"]+wdth(" ",16)+" _____ ____ ____"+wdth(" ",27)+clr["bdma"]+" "+clr["norm"])
  40. print(" "+clr["bdma"]+" "+clr["bdbu"]+clr["bold"]+wdth(" ",16)+" | | | \ | \ | |"+wdth(" ",17)+clr["bdma"]+" "+clr["norm"])
  41. print(" "+clr["bdma"]+" "+clr["bdbu"]+clr["bold"]+wdth(" ",16)+" | ___ _______ | | | | | \ /"+wdth(" ",17)+clr["bdma"]+" "+clr["norm"])
  42. print(" "+clr["bdma"]+" "+clr["bdbu"]+clr["bold"]+wdth(" ",16)+" |___ /\ | | | |____/ |____/ \ / "+wdth(" ",17)+clr["bdma"]+" "+clr["norm"])
  43. print(" "+clr["bdma"]+" "+clr["bdbu"]+clr["bold"]+wdth(" ",16)+" | / \ |___ | | | \ | \ \ / "+wdth(" ",17)+clr["bdma"]+" "+clr["norm"])
  44. print(" "+clr["bdma"]+" "+clr["bdbu"]+clr["bold"]+wdth(" ",16)+" | /____\ | | | | | | | | "+wdth(" ",17)+clr["bdma"]+" "+clr["norm"])
  45. print(" "+clr["bdma"]+" "+clr["bdbu"]+clr["bold"]+wdth(" ",16)+" | / \ ___| | |_____ |____/ | | | "+wdth(" ",17)+clr["bdma"]+" "+clr["norm"])
  46. print(" "+clr["bdma"]+" "+clr["bdbu"]+wdth(" ",87)+clr["bdma"]+" "+clr["norm"])
  47. print(" "+clr["bdma"]+" "+clr["bdbu"]+clr["bold"]+wdth(" ",16)+" The Terminal Client "+wdth(" ",17)+clr["bdma"]+" "+clr["norm"])
  48. print(" "+clr["bdma"]+" "+clr["bdbu"]+wdth(" ",87)+clr["bdma"]+" "+clr["norm"])
  49. print(" "+clr["bdma"]+" "+clr["bdbu"]+wdth(" ",87)+clr["bdma"]+" "+clr["norm"])
  50. print(" "+clr["bdma"]+" "+clr["bdbu"]+wdth(" ",87)+clr["bdma"]+" "+clr["norm"])
  51. print(" "+clr["bold"]+clr["bdma"],
  52. " ---type help to see list of features---",
  53. wdth(" ",24)+clr["norm"])
  54. # Importing all kinds of other things needed for the operations
  55. from flbry import connect
  56. from flbry import search
  57. from flbry import channel
  58. from flbry import wallet
  59. from flbry import uploads
  60. from flbry import list_files
  61. # Now we gonna start the main loop. It will give the user to input
  62. # any function. And when the function is executed, it will give it
  63. # again. Forever. Until the user exits.
  64. while True:
  65. command = input(" : ") # the : will be the presented function
  66. if command == "exit":
  67. connect.stop()
  68. break # breaks the while True: loop
  69. elif command == "quit":
  70. print(" Quit does not disconnect the SDK!")
  71. print(" To disconnet use exit or disconnect.")
  72. break
  73. elif command == "help":
  74. print("""
  75. This is the help menu of the FastLBRY. It will list the currently
  76. implemented features. If you want to help us develop more features
  77. or help with understanding the LBRY SDK. You can contact us either
  78. in the repository or using the Matrix chat.
  79. -------------------| HELP AND CONTRIBUTION |----------------------
  80. help - Returns this help message.
  81. exit - Exits the software.
  82. quit - Exit the program without disconnecting. Used for
  83. testing new code changes.
  84. matrix - Gives the Matrix url to join the official room.
  85. repository - Gives the repository url for contributors.
  86. report - Gives the url of the issue tracker.
  87. license - Returns the legal code of the license.
  88. -------------------| SIMPLE LBRY COMMANDS |----------------------
  89. connect - Will connect to the LBRY network
  90. disconnect - Will disconnect from the LBRY network
  91. search - Give you an ability to search on LBRY
  92. channel - Gives a list of publications from a
  93. specific LBRY channel. Use lbry link to
  94. the channel and not the title.
  95. ------------------| ACCOUNT MANAGEMENT |-----------------------
  96. login - Logic into LBRY
  97. history - See your download history.
  98. uploads - See your upload history.
  99. wallet - See wallet history.
  100. """)
  101. # HELP AND CONTRIBUTION FUNCTIONS
  102. elif command == "matrix":
  103. print(" #FastLBRY:matrix.org")
  104. elif command == "repository":
  105. print(" https://notabug.org/jyamihud/FastLBRY-terminal")
  106. elif command == "report":
  107. print(" https://notabug.org/jyamihud/FastLBRY-terminal/issues")
  108. elif command == "license":
  109. l = open("LICENSE", "r")
  110. print(l.read())
  111. # LBRY COMMANDS
  112. elif command == "connect":
  113. connect.start()
  114. elif command == "disconnect":
  115. connect.stop()
  116. elif command == "history":
  117. list_files.downloaded()
  118. elif command.startswith("search"):
  119. if " " in command:
  120. search.simple(command[command.find(" ")+1:])
  121. else:
  122. search.simple()
  123. elif command.startswith("channel"):
  124. if " " in command:
  125. channel.simple(command[command.find(" ")+1:])
  126. else:
  127. channel.simple()
  128. ###### WALLET ######
  129. elif command == "login":
  130. print("""
  131. Currently FastLBRY login is not yet implement. But it is
  132. possible to login. While hacking on the LBRY SDK ( lbrynet )
  133. I realized that it shares account information with any
  134. lbrynet running on the same system. So if you launch the
  135. LBRY Desktop app ones to log in, it will spread the login
  136. to all the other SDKs including FastLBRY.
  137. As soon as I will figure out how to make a login. I will
  138. implement it here, and this message will disappear.
  139. For now. Get LBRY Desktop ( lbry.com ) login there. And
  140. come back to here. You will be logged in.
  141. """)
  142. elif command == "wallet":
  143. wallet.history()
  144. elif command == "uploads":
  145. uploads.simple()