translate ver 0.1
discord.py req update to actual
This commit is contained in:
@@ -64,7 +64,7 @@ try:
|
||||
PLEX_TOKEN = config.get(BOT_SECTION, 'plex_token')
|
||||
PLEX_BASE_URL = config.get(BOT_SECTION, 'plex_base_url')
|
||||
except:
|
||||
print("No Plex auth token details found")
|
||||
print("Сведения о токене аутентификации Plex не найдены.")
|
||||
plex_token_configured = False
|
||||
|
||||
# Get Plex config
|
||||
@@ -73,16 +73,16 @@ try:
|
||||
PLEXUSER = config.get(BOT_SECTION, 'plex_user')
|
||||
PLEXPASS = config.get(BOT_SECTION, 'plex_pass')
|
||||
except:
|
||||
print("No Plex login info found")
|
||||
print("Информация для входа в Plex не найдена")
|
||||
if not plex_token_configured:
|
||||
print("Could not load plex config")
|
||||
print("Не удалось загрузить конфигурацию plex")
|
||||
plex_configured = False
|
||||
|
||||
# Get Plex roles config
|
||||
try:
|
||||
plex_roles = config.get(BOT_SECTION, 'plex_roles')
|
||||
except:
|
||||
print("Could not get Plex roles config")
|
||||
print("Не удалось получить конфигурацию ролей Plex.")
|
||||
plex_roles = None
|
||||
if plex_roles:
|
||||
plex_roles = list(plex_roles.split(','))
|
||||
@@ -93,7 +93,7 @@ else:
|
||||
try:
|
||||
Plex_LIBS = config.get(BOT_SECTION, 'plex_libs')
|
||||
except:
|
||||
print("Could not get Plex libs config. Defaulting to all libraries.")
|
||||
print("Не удалось получить конфигурацию Plex libs. По умолчанию для всех библиотек.")
|
||||
Plex_LIBS = None
|
||||
if Plex_LIBS is None:
|
||||
Plex_LIBS = ["all"]
|
||||
@@ -105,7 +105,7 @@ try:
|
||||
JELLYFIN_SERVER_URL = config.get(BOT_SECTION, 'jellyfin_server_url')
|
||||
JELLYFIN_API_KEY = config.get(BOT_SECTION, "jellyfin_api_key")
|
||||
except:
|
||||
print("Could not load Jellyfin config")
|
||||
print("Не удалось загрузить конфигурацию Jellyfin.")
|
||||
jellyfin_configured = False
|
||||
|
||||
try:
|
||||
@@ -114,13 +114,13 @@ try:
|
||||
JELLYFIN_EXTERNAL_URL = JELLYFIN_SERVER_URL
|
||||
except:
|
||||
JELLYFIN_EXTERNAL_URL = JELLYFIN_SERVER_URL
|
||||
print("Could not get Jellyfin external url. Defaulting to server url.")
|
||||
print("Не удалось получить внешний URL-адрес Jellyfin. По умолчанию используется URL-адрес сервера.")
|
||||
|
||||
# Get Jellyfin roles config
|
||||
try:
|
||||
jellyfin_roles = config.get(BOT_SECTION, 'jellyfin_roles')
|
||||
except:
|
||||
print("Could not get Jellyfin roles config")
|
||||
print("Не удалось получить конфигурацию ролей Jellyfin.")
|
||||
jellyfin_roles = None
|
||||
if jellyfin_roles:
|
||||
jellyfin_roles = list(jellyfin_roles.split(','))
|
||||
@@ -131,7 +131,7 @@ else:
|
||||
try:
|
||||
jellyfin_libs = config.get(BOT_SECTION, 'jellyfin_libs')
|
||||
except:
|
||||
print("Could not get Jellyfin libs config. Defaulting to all libraries.")
|
||||
print("Не удалось получить конфигурацию Jellyfin libs. По умолчанию для всех библиотек.")
|
||||
jellyfin_libs = None
|
||||
if jellyfin_libs is None:
|
||||
jellyfin_libs = ["all"]
|
||||
@@ -143,14 +143,14 @@ try:
|
||||
USE_JELLYFIN = config.get(BOT_SECTION, 'jellyfin_enabled')
|
||||
USE_JELLYFIN = USE_JELLYFIN.lower() == "true"
|
||||
except:
|
||||
print("Could not get Jellyfin enable config. Defaulting to False")
|
||||
print("Не удалось получить конфигурацию включения Jellyfin. По умолчанию установлено значение False")
|
||||
USE_JELLYFIN = False
|
||||
|
||||
try:
|
||||
USE_PLEX = config.get(BOT_SECTION, "plex_enabled")
|
||||
USE_PLEX = USE_PLEX.lower() == "true"
|
||||
except:
|
||||
print("Could not get Plex enable config. Defaulting to False")
|
||||
print("Не удалось получить конфигурацию включения Plex. По умолчанию установлено значение False")
|
||||
USE_PLEX = False
|
||||
|
||||
def get_config():
|
||||
@@ -162,7 +162,7 @@ def get_config():
|
||||
return config
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print('error in reading config')
|
||||
print('ошибка чтения конфига')
|
||||
return None
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ def change_config(key, value):
|
||||
config.read(CONFIG_PATH)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print("Cannot Read config.")
|
||||
print("Невозможно прочитать конфигурацию.")
|
||||
|
||||
try:
|
||||
config.set(BOT_SECTION, key, str(value))
|
||||
@@ -188,4 +188,4 @@ def change_config(key, value):
|
||||
config.write(configfile)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print("Cannot write to config.")
|
||||
print("Не могу записать в конфиг.")
|
||||
|
||||
@@ -50,17 +50,17 @@ def save_user_email(username, email):
|
||||
VALUES('{username}', '{email}')
|
||||
""")
|
||||
conn.commit()
|
||||
print("User added to db.")
|
||||
print("Пользователь добавлен в базу.")
|
||||
else:
|
||||
return "Username and email cannot be empty"
|
||||
return "Имя пользователя и адрес электронной почты не могут быть пустыми."
|
||||
|
||||
def save_user(username):
|
||||
if username:
|
||||
conn.execute("INSERT INTO clients (discord_username) VALUES ('"+ username +"')")
|
||||
conn.commit()
|
||||
print("User added to db.")
|
||||
print("Пользователь добавлен в БД.")
|
||||
else:
|
||||
return "Username cannot be empty"
|
||||
return "Имя пользователя не может быть пустым"
|
||||
|
||||
def save_user_jellyfin(username, jellyfin_username):
|
||||
if username and jellyfin_username:
|
||||
@@ -69,9 +69,9 @@ def save_user_jellyfin(username, jellyfin_username):
|
||||
VALUES('{username}', '{jellyfin_username}')
|
||||
""")
|
||||
conn.commit()
|
||||
print("User added to db.")
|
||||
print("Пользователь добавлен в БД.")
|
||||
else:
|
||||
return "Discord and Jellyfin usernames cannot be empty"
|
||||
return "Имена пользователей Discord и Jellyfin не могут быть пустыми."
|
||||
|
||||
def save_user_all(username, email, jellyfin_username):
|
||||
if username and email and jellyfin_username:
|
||||
@@ -80,7 +80,7 @@ def save_user_all(username, email, jellyfin_username):
|
||||
VALUES('{username}', '{email}', '{jellyfin_username}')
|
||||
""")
|
||||
conn.commit()
|
||||
print("User added to db.")
|
||||
print("Пользователь добавлен в БД.")
|
||||
elif username and email:
|
||||
save_user_email(username, email)
|
||||
elif username and jellyfin_username:
|
||||
@@ -88,7 +88,7 @@ def save_user_all(username, email, jellyfin_username):
|
||||
elif username:
|
||||
save_user(username)
|
||||
else:
|
||||
return "Discord username must all be provided"
|
||||
return "Необходимо указать имя пользователя Discord."
|
||||
|
||||
def get_useremail(username):
|
||||
if username:
|
||||
@@ -99,11 +99,11 @@ def get_useremail(username):
|
||||
if email:
|
||||
return email
|
||||
else:
|
||||
return "No email found"
|
||||
return "Электронная почта не найдена"
|
||||
except:
|
||||
return "error in fetching from db"
|
||||
return "ошибка при извлечении из БД"
|
||||
else:
|
||||
return "username cannot be empty"
|
||||
return "имя пользователя не может быть пустым"
|
||||
|
||||
def get_jellyfin_username(username):
|
||||
"""
|
||||
@@ -121,11 +121,11 @@ def get_jellyfin_username(username):
|
||||
if jellyfin_username:
|
||||
return jellyfin_username
|
||||
else:
|
||||
return "No users found"
|
||||
return "Пользователи не найдены"
|
||||
except:
|
||||
return "error in fetching from db"
|
||||
return "ошибка при извлечении из БД"
|
||||
else:
|
||||
return "username cannot be empty"
|
||||
return "имя пользователя не может быть пустым"
|
||||
|
||||
def remove_email(username):
|
||||
"""
|
||||
@@ -134,10 +134,10 @@ def remove_email(username):
|
||||
if username:
|
||||
conn.execute(f"UPDATE clients SET email = null WHERE discord_username = '{username}'")
|
||||
conn.commit()
|
||||
print(f"Email removed from user {username} in database")
|
||||
print(f"Адрес электронной почты удален от пользователя {username} в базе данных.")
|
||||
return True
|
||||
else:
|
||||
print(f"Username cannot be empty.")
|
||||
print(f"Имя пользователя не может быть пустым.")
|
||||
return False
|
||||
|
||||
def remove_jellyfin(username):
|
||||
@@ -147,10 +147,10 @@ def remove_jellyfin(username):
|
||||
if username:
|
||||
conn.execute(f"UPDATE clients SET jellyfin_username = null WHERE discord_username = '{username}'")
|
||||
conn.commit()
|
||||
print(f"Jellyfin username removed from user {username} in database")
|
||||
print(f"Имя пользователя Jellyfin удалено из пользователя {username} в базе данных.")
|
||||
return True
|
||||
else:
|
||||
print(f"Username cannot be empty.")
|
||||
print(f"Имя пользователя не может быть пустым.")
|
||||
return False
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ def delete_user(username):
|
||||
except:
|
||||
return False
|
||||
else:
|
||||
return "username cannot be empty"
|
||||
return "Имя пользователя не может быть пустым"
|
||||
|
||||
def read_all():
|
||||
cur = conn.cursor()
|
||||
|
||||
@@ -16,7 +16,7 @@ def add_user(jellyfin_url, jellyfin_api_key, username, password, jellyfin_libs):
|
||||
userId = response.json()["Id"]
|
||||
|
||||
if response.status_code != 200:
|
||||
print(f"Error creating new Jellyfin user: {response.text}")
|
||||
print(f"Ошибка создания нового пользователя Jellyfin: {response.text}")
|
||||
return False
|
||||
|
||||
# Grant access to User
|
||||
@@ -35,7 +35,7 @@ def add_user(jellyfin_url, jellyfin_api_key, username, password, jellyfin_libs):
|
||||
enabled_folders.append(server_lib['ItemId'])
|
||||
found = True
|
||||
if not found:
|
||||
print(f"Couldn't find Jellyfin Library: {lib}")
|
||||
print(f"Не удалось найти библиотеку Jellyfin: {lib}")
|
||||
|
||||
payload = {
|
||||
"IsAdministrator": False,
|
||||
@@ -84,7 +84,7 @@ def add_user(jellyfin_url, jellyfin_api_key, username, password, jellyfin_libs):
|
||||
if response.status_code == 200 or response.status_code == 204:
|
||||
return True
|
||||
else:
|
||||
print(f"Error setting user permissions: {response.text}")
|
||||
print(f"Ошибка установки прав пользователя: {response.text}")
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
@@ -119,7 +119,7 @@ def remove_user(jellyfin_url, jellyfin_api_key, jellyfin_username):
|
||||
|
||||
if userId is None:
|
||||
# User not found
|
||||
print(f"Error removing user {jellyfin_username} from Jellyfin: Could not find user.")
|
||||
print(f"Ошибка удаления пользователя {jellyfin_username} из Jellyfin: не удалось найти пользователя.")
|
||||
return False
|
||||
|
||||
# Delete User
|
||||
@@ -131,7 +131,7 @@ def remove_user(jellyfin_url, jellyfin_api_key, jellyfin_username):
|
||||
if response.status_code == 204 or response.status_code == 200:
|
||||
return True
|
||||
else:
|
||||
print(f"Error deleting Jellyfin user: {response.text}")
|
||||
print(f"Ошибка удаления пользователя Jellyfin: {response.text}")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return False
|
||||
@@ -147,7 +147,7 @@ def get_users(jellyfin_url, jellyfin_api_key):
|
||||
def generate_password(length, lower=True, upper=True, numbers=True, symbols=True):
|
||||
character_list = []
|
||||
if not (lower or upper or numbers or symbols):
|
||||
raise ValueError("At least one character type must be provided")
|
||||
raise ValueError("Должен быть указан хотя бы один тип символов.")
|
||||
|
||||
if lower:
|
||||
character_list += string.ascii_lowercase
|
||||
|
||||
@@ -8,7 +8,7 @@ def plexadd(plex, plexname, Plex_LIBS):
|
||||
plex.myPlexAccount().inviteFriend(user=plexname, server=plex, sections=Plex_LIBS, allowSync=False,
|
||||
allowCameraUpload=False, allowChannels=False, filterMovies=None,
|
||||
filterTelevision=None, filterMusic=None)
|
||||
print(plexname +' has been added to plex')
|
||||
print(plexname +' добавлен в plex')
|
||||
return True
|
||||
except Exception as e:
|
||||
print(e)
|
||||
@@ -18,7 +18,7 @@ def plexadd(plex, plexname, Plex_LIBS):
|
||||
def plexremove(plex, plexname):
|
||||
try:
|
||||
plex.myPlexAccount().removeFriend(user=plexname)
|
||||
print(plexname +' has been removed from plex')
|
||||
print(plexname +' удалён из plex')
|
||||
return True
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
Reference in New Issue
Block a user