123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- #####################################################################
- # #
- # THIS IS A SOURCE CODE FILE FROM A PROGRAM TO INTERACT WITH THE #
- # LBRY PROTOCOL ( lbry.com ). IT WILL USE THE LBRY SDK ( lbrynet ) #
- # FROM THEIR REPOSITORY ( https://github.com/lbryio/lbry-sdk ) #
- # WHICH I GONNA PRESENT TO YOU AS A BINARY. SINCE I DID NOT DEVELOP #
- # IT AND I'M LAZY TO INTEGRATE IN A MORE SMART WAY. THE SOURCE CODE #
- # OF THE SDK IS AVAILABLE IN THE REPOSITORY MENTIONED ABOVE. #
- # #
- # ALL THE CODE IN THIS REPOSITORY INCLUDING THIS FILE IS #
- # (C) J.Y.Amihud and Other Contributors 2021. EXCEPT THE LBRY SDK. #
- # YOU CAN USE THIS FILE AND ANY OTHER FILE IN THIS REPOSITORY UNDER #
- # THE TERMS OF GNU GENERAL PUBLIC LICENSE VERSION 3 OR ANY LATER #
- # VERSION. TO FIND THE FULL TEXT OF THE LICENSE GO TO THE GNU.ORG #
- # WEBSITE AT ( https://www.gnu.org/licenses/gpl-3.0.html ). #
- # #
- # THE LBRY SDK IS UNFORTUNATELY UNDER THE MIT LICENSE. IF YOU ARE #
- # NOT INTENDING TO USE MY CODE AND JUST THE SDK. YOU CAN FIND IT ON #
- # THEIR OFFICIAL REPOSITORY ABOVE. THEIR LICENSE CHOICE DOES NOT #
- # SPREAD ONTO THIS PROJECT. DON'T GET A FALSE ASSUMPTION THAT SINCE #
- # THEY USE A PUSH-OVER LICENSE, I GONNA DO THE SAME. I'M NOT. #
- # #
- # THE LICENSE CHOSEN FOR THIS PROJECT WILL PROTECT THE 4 ESSENTIAL #
- # FREEDOMS OF THE USER FURTHER, BY NOT ALLOWING ANY WHO TO CHANGE #
- # THE LICENSE AT WILL. SO NO PROPRIETARY SOFTWARE DEVELOPER COULD #
- # TAKE THIS CODE AND MAKE THEIR USER-SUBJUGATING SOFTWARE FROM IT. #
- # #
- #####################################################################
- import os
- import readline
- from flbry import variables
- from flbry.variables import *
- # Make sure the config file exists and is up to date
- from flbry import settings
- settings.check_config()
- settings.check_missing_keys()
- # Do some things with the settings
- hist_file = settings.get_settings_folder()+"terminal-history"
- settings.initial_settings_stuff(hist_file)
- # A welcome logo.
- logo()
- # Here I want to make a simple check for an operating system
- # The software is built to work on GNU / Linux so I need to
- # check whether the user runs it on a proper system. If not
- # give them a warning message.
- import platform
- if platform.system() != "Linux": # IK It should be GNU / Linux
- center("OS "+platform.system().upper()+" NOT SUPPORTED!", "bdrd", True)
- center("Type 'osinfo' to learn more.", "bdrd")
- # Importing all kinds of other things needed for the operations
- from flbry import connect
- from flbry import search
- from flbry import channel
- from flbry import wallet
- from flbry import uploads
- from flbry import list_files
- from flbry import following
- from flbry import markdown
- from flbry import trending
- from flbry import url
- from flbry import publish
- from flbry import comments
- from flbry import donate
- from flbry import simple
- # Now we gonna start the main loop. It will give the user to input
- # any function. And when the function is executed, it will give it
- # again. Forever. Until the user exits.
- # List of commands for autocomplete feature.
- main_commands = [
- "exit",
- "quit",
- "help",
- "osinfo",
- "matrix",
- "clear",
- "repository",
- "report",
- "license",
- "connect",
- "disconnect",
- "publish",
- "history",
- "search",
- "channels",
- "channel",
- "channel_new",
- "trending",
- "articles",
- "login",
- "wallet",
- "balance",
- "inbox",
- "uploads",
- "following",
- "subscriptions",
- "install",
- "install_force",
- "settings",
- "addresses",
- "send",
- "donations_test",
- "donations_diff",
- "donations_update",
- "donations_add",
- "donate",
- "reupload"
- ]
- complete(main_commands)
- while True:
- command = input(typing_dots()) # the : will be the presented function
- if command == "exit":
- if settings.get("save_history"):
- readline.write_history_file(hist_file)
- connect.stop()
- break # breaks the while True: loop
-
- elif command == "quit":
- if settings.get("save_history"):
- readline.write_history_file(hist_file)
- print(" Quit does not disconnect the SDK!")
- print(" To disconnet use exit or disconnect.")
- break
-
- elif command == "help":
- markdown.draw("help/main.md", "Help")
- elif command == "osinfo":
- markdown.draw("help/os.md", "Operating System Information")
- # HELP AND CONTRIBUTION FUNCTIONS
-
- elif command == "matrix":
- print(" #FastLBRY:matrix.org")
- elif command == "clear":
- os.system("clear")
- elif command == "repository":
- print(" https://notabug.org/jyamihud/FastLBRY-terminal")
- elif command == "report":
- print(" https://notabug.org/jyamihud/FastLBRY-terminal/issues")
- elif command == "license":
- markdown.draw("LICENSE.md", "License (GPLv3 or later)")
- # LBRY COMMANDS
- elif command == "connect":
- connect.start()
-
- elif command == "disconnect":
- connect.stop()
- elif command.startswith("publish"):
- if " " in command:
- publish.configure(command[command.find(" ")+1:])
- else:
- publish.configure()
-
- elif command == "history":
- list_files.downloaded()
- elif command.startswith("search"):
- if " " in command:
- search.simple(command[command.find(" ")+1:])
- else:
- search.simple()
- elif command == "channels":
- channel.simple(channel.select())
-
- elif command == "channel_new":
- channel.create()
-
- elif command.startswith("channel"):
- if " " in command:
- channel.simple(command[command.find(" ")+1:])
- else:
- channel.simple()
- elif command.startswith("trending"):
- trending.simple()
- elif command.startswith("articles"):
- trending.simple(articles=True)
- elif command in ("following", "subscriptions"):
- following.following()
- elif command.startswith("reupload"):
- re-upload.simple()
-
- ###### WALLET ######
- elif command == "login":
- markdown.draw("help/login.md", "Login Help")
-
- elif command == "wallet":
- wallet.history()
- elif command == "balance":
- wallet.balance()
- elif command.startswith("inbox"):
- if " " in command:
- comments.inbox(command[command.find(" ")+1:])
- else:
- comments.inbox()
- elif command == "uploads":
- uploads.simple()
- elif command == "install":
- settings.install_desktop(False)
- elif command == "install_force":
- settings.install_desktop(True)
- elif command == "settings":
- settings.ui()
- elif command == "addresses":
- wallet.addresses()
- elif command == "send":
- wallet.address_send()
- elif command == "donations_update":
- donate.check_devs_file(save_changes=True)
- elif command == "donations_test":
- donate.check_devs_file(user_check=True)
-
- elif command == "donations_diff":
- donate.check_devs_file(user_check=True, diff=True)
- elif command == "donations_add":
- donate.add()
- elif command == "donate":
- donate.donate()
-
- # If a user types anything ELSE, except just simply pressing
- # Enter. So if any text is in the command, but non of the
- # above were activated.
- # Here I want to just run the URL module and try to resolve
- # the url. The Url module will need to be able to handle a
- # lot of it.
-
- elif command:
- url.get(command)
- # Restore the commands completion
- complete(main_commands)
|