123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- #####################################################################
- # #
- # 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. #
- # #
- #####################################################################
- # This file is a set of variables used by different files. It's needed
- # so I will not need to hard code the values each time. Stuff like
- # basic translations of the LBRY data into human language. And a more
- # complex functions like translating size in bytes into something more
- # readable.
- # Colors are used to make the
- clr = {
- "norm":"\033[00m", # Reset to normal
- "bold":"\033[01m", # Bold Text
- "ital":"\033[03m", # Italic Text
- "undr":"\033[04m", # Underlined
- "blnk":"\033[05m", # Blinking
-
- # Text
- "tdbl":"\033[30m", # Dark Black
- "tdrd":"\033[31m", # Dark Red
- "tdgr":"\033[32m", # Dark Green
- "tdyl":"\033[33m", # Dark Yellow
- "tdbu":"\033[34m", # Dark Blue
- "tdma":"\033[35m", # Dark Magenta
- "tdcy":"\033[36m", # Dark Cyan
- "tdwh":"\033[37m", # Dark White
-
- "tbbl":"\033[90m", # Bright Black
- "tbrd":"\033[91m", # Bright Red
- "tbgr":"\033[92m", # Bright Green
- "tbyl":"\033[93m", # Bright Yellow
- "tbbu":"\033[94m", # Bright Blue
- "tbma":"\033[95m", # Bright Magenta
- "tbcy":"\033[96m", # Bright Cyan
- "tbwh":"\033[97m", # Bright White
- # Background
- "bdbl":"\033[40m", # Dark Black
- "bdrd":"\033[41m", # Dark Red
- "bdgr":"\033[42m", # Dark Green
- "bdyl":"\033[43m", # Dark Yellow
- "bdbu":"\033[44m", # Dark Blue
- "bdma":"\033[45m", # Dark Magenta
- "bdcy":"\033[46m", # Dark Cyan
- "bdwh":"\033[47m", # Dark White
-
- "bbbl":"\033[100m", # Bright Black
- "bbrd":"\033[101m", # Bright Red
- "bbgr":"\033[102m", # Bright Green
- "bbyl":"\033[103m", # Bright Yellow
- "bbbu":"\033[104m", # Bright Blue
- "bbma":"\033[105m", # Bright Magenta
- "bbcy":"\033[106m", # Bright Cyan
- "bbwh":"\033[108m" # Bright White
- }
- # A function that insures a specific width of the printed part
- def wdth(x, n):
- # Just in case...
- x = str(x)
- if len(x) < n:
- x = (" "*(n-len(x)))+x
- elif len(x) > n:
- if n > 10:
- x = x[:n-3]+"..."
- else:
- x = x[:n]
-
- return x
- # A dictionary for translations of things from the SDK into
- # readable thing
- what = {
- "stream":"FILE",
- "repost":"SHARED",
- "channel": "CHANNEL",
- "collection": "PLAYLIST"
- }
- # This function will take a list and present in a pretty
- # way.
- def tgz(x):
- # Just in case
- if type(x) != list:
- x = x.split()
- y = ""
- for i in x:
- y = y + i + ", "
- return y[:-2]
- # This function will convert bites into readable data making sense
- def csize(x):
- x = float(x)
-
- l = ["B","KB", "MB", "GB", "TB"]
- for i in range(5):
- if x > 1024:
- x = x / 1024
- else:
- return str(round(x, 2))+" "+l[i]
- return str(round(x, 2))+" "+l[i]
- # This next function will select the amount of ::: for a given
- # input.
- def typing_dots():
- import inspect
- depth = len(inspect.stack()) # This is the depth of the stack
- # since this function call adds 1 to the stack we need
- # to decrease the number by one
- depth -= 1
- # Now I want to select a sequence of colors.
- x = ["bdma","bdbu", "bdrd", "bdgr", "bdcy", "bdyl"]
- ret = " "+clr["bold"]
- for i in reversed(range(depth)):
- ret = ret + clr["tbwh"] + clr[x[i % len(x)]] + ":"
- ret = ret + clr["norm"]+" "
-
- return ret
-
|