[LIVE] Trying LBRY UP 3.0 Python Script (LBRY first-Script)
shortcut
Learning code with LBRY and Python
import os
from platform import system
import json
requests = "pip install requests"
os.system(requests)
import requests
from PIL import Image, ImageTk
# ------------------------------------ Google Stuff ------------------------------------
import datetime
from Google import Create_Service
from googleapiclient.http import MediaFileUpload
CLIENT_SECRET_FILE = 'Client_Secret.json'
API_NAME = 'youtube'
API_VERSION = 'v3'
SCOPES = ['https://www.googleapis.com/auth/youtube.upload']
service = Create_Service(CLIENT_SECRET_FILE, API_NAME, API_VERSION, SCOPES)
# ----------------------------------- Tkinter Stuff -----------------------------------
try:
from tkinter import *
from tkinter import ttk
from tkinter import filedialog
from tkinter.filedialog import askopenfile
except ImportError:
import Tkinter as tk
import ttk
from tkcalendar import Calendar, DateEntry
# ----------------------------------- Functions ---------------------------------------
def browse_thumb():
global thumbnail_path
def browsefunc():
global filepath
filepath = filedialog.askopenfilename()
selected_file_placeholder= Entry(tab1, width=60)
selected_file_placeholder.insert(0,filepath)
selected_file_placeholder.grid(column=1,row=1)
print(thumbnail_path)
print(filepath)
def get_date():
date_choice=str(cal.get_date())
date_values=date_choice.split("/")
year = int("20"+str(date_values[2]))
month = int(date_values[0])
day = int(date_values[1])
hour = 0
minute = 0
second= 0
global upload_date_time
upload_date_time = datetime.datetime(year, month, day, hour, minute, second).isoformat() + '.000Z'
print(upload_date_time)
def upload():
global name
name = str(name_entry.get())
Label(tab1, text = "lbry://" + channel_options.get() + "/"+ name).grid(column=0, row=6)
global title
title = str(title_entry.get())
print(title)
global bid
bid = str(bid_entry.get())
global tags
global tags_entry
tags_str = str(tags_entry.get())
tags= tags_str.split(',')
global channel_id
channel_id = channel_dict[channel_options.get()]
print(channel_id)
global categoryI
categoryI = int(Categories_IDs[Categories.get()])
global description
description =str(description_entry.get())
#---------------------------------- | Youtube Metadata | ---------------------------------
request_body = {
'snippet': {
'categoryI': categoryI,
'title': title,
'description': description,
'tags': tags
},
'status': {
'privacyStatus': 'public',
'publishAt': upload_date_time,
'selfDeclaredMadeForKids': False,
},
'notifySubscribers': True
}
print(request_body)
#---------------------------------- | LBRY Metadata | ---------------------------------
def show_calendar():
global cal
cal= Calendar(tab1, selectmode="day",year= 2021, month=9, day=1)
cal.grid(column=1, row=9)
button= Button(tab1, text= "Select the Date", command= get_date)
button.grid(column=2, row=9)
# ---------------------------------- window settings ---------------------------------
platformD = system()
window = Tk()
window.title("LBRY UP 3.0")
window.geometry("800x600")
if platformD == 'Windows':
window.iconbitmap(default='images/2.ico')
image = PhotoImage(file='images/1.png')
else:
window.iconbitmap(os.path.dirname(os.path.abspath(__file__))+'/images/2.ico')
image = PhotoImage(os.path.dirname(os.path.abspath(__file__))+'/images/1.png')
window.title("LBRY Reverse Sync")
# ----------------------------------- Tabs settings ------------------------------------
tab_control = ttk.Notebook(window)
# -------------------------------- Tab 1 (LBRY -> YT) -----------------------------------
tab1 = ttk.Frame(tab_control)
tab_control.add(tab1, text='LBRY -> YT')
lbl1 = Label(tab1, text= 'This tab allows you to upload your videos first on LBRY/ODYSEE\nand then syncs it to your YouTube channel, you will need to download\n your Client_Secret Json file from https://cloud.google.console',font='Helvetica 8 bold',padx=0, pady=0)
lbl1.grid(column=1, row=0)
label = Label(tab1, image = image)
label.grid(column=0, row=0)
# ---------------------------------- ChannelId Dropdown -----------------------------------
channel_list = requests.post("http://localhost:5279", json={"method": "channel_list", "params": {"name": [], "claim_id": [], "is_spent": False, "resolve": False, "no_totals": False}}).json()
channel_dict = {}
for i in range (10):
channel_dict[channel_list["result"]["items"][i]["name"]] = channel_list["result"]["items"][i]["claim_id"]
channel_list = list((channel_dict).keys())
channels_label = Label(tab1, text="LBRY Channel: ")
channels_label.grid(column=0,row=2)
channel_options = ttk.Combobox(tab1, values=channel_list)
channel_options.grid(colum```
2021-08-22
0.0 LBC
None
4911059049 Bytes