Add files from 6a34355fda commit of FastLBRY-GTK notabug.org repo by jyamihud without the flbry/lbrynet binary
68 lines
3.2 KiB
Python
68 lines
3.2 KiB
Python
#####################################################################
|
|
# #
|
|
# 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. #
|
|
# #
|
|
#####################################################################
|
|
|
|
def bar(text):
|
|
|
|
# This function is intended to parse the bar in the
|
|
# top of the FastLBRY GTK application.
|
|
|
|
##### Converting an HTTPS domain ( of any website ) into lbry url ###
|
|
|
|
# Any variation of this:
|
|
# https://odysee.com/@blenderdumbass:f/hacking-fastlbry-live-with-you:6
|
|
# customlbry.com/@blenderdumbass:f/hacking-fastlbry-live-with-you:6
|
|
|
|
# Should become this:
|
|
# lbry://@blenderdumbass:f/hacking-fastlbry-live-with-you:6
|
|
|
|
if "?" in text:
|
|
# This means some kinds of variables given to the server through HTTP
|
|
# we should ignore them
|
|
text = text[:text.rfind("?")]
|
|
|
|
if "api/" in text and "free/" in text:
|
|
# The link might resemble something like:
|
|
# https://cdn.lbryplayer.xyz/api/v4/streams/free/cc-by-sa-credit-01/38688684ce7164cbb21fcef7c49414854375b6fd/84f493
|
|
|
|
name = text[text.find("free/")+5 :]
|
|
name = name[:name.rfind("/")]
|
|
name = name.replace("/", ":")
|
|
return name
|
|
|
|
|
|
if "/" in text and not text.startswith("@") and not text.startswith("lbry://"):
|
|
if "@" in text:
|
|
text = text[text.find("@"):]
|
|
else:
|
|
text = text[text.rfind("/")+1:]
|
|
|
|
#text = "lbry://"+text
|
|
|
|
return text
|
|
|