2021-01-15 23:01:23 +02:00
# -*- coding: utf-8 -*-
import subprocess
2021-01-21 14:00:58 +02:00
import contextlib
import importlib
2021-01-15 23:01:23 +02:00
import time
import datetime
import os
import pathlib
import json
import getopt
import sys
from random import randint
from pathlib import Path
from datetime import datetime , date , timedelta
2021-01-21 14:00:58 +02:00
from functions import *
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
if getConfig ( " use_colors " ) :
from colors import *
2021-04-24 03:08:43 +03:00
appendLog ( ' Colors imported ' )
2021-01-21 14:00:58 +02:00
else :
RESET = ' '
BLACK = RED = GREEN = YELLOW = BLUE = MAGENTA = CYAN = WHITE = ' '
BBLACK = BRED = BGREEN = BYELLOW = BBLUE = BMAGENTA = BCYAN = BWHITE = ' '
ULINE = REVERSE = ' '
2021-04-24 03:08:43 +03:00
appendLog ( ' Loading without colors ' )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
if os . name == ' nt ' :
clear = lambda : os . system ( ' cls ' )
else :
clear = lambda : os . system ( ' clear ' )
2021-04-07 23:57:02 +03:00
if os . name == ' nt ' :
import winsound
else :
import playsound
2021-01-21 14:00:58 +02:00
clear ( )
os . system ( " title Загрузка daemon... " )
2021-04-24 03:08:43 +03:00
appendLog ( ' Loading daemon ' )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
import libinstaller
import easygui
import tkinter
import keyboard
import ast
import inputimeout
import telegram_send
2021-04-24 03:08:43 +03:00
import getpass
2021-01-15 23:01:23 +02:00
menu_choose = None
try :
from inputimeout import inputimeout , TimeoutOccurred
2021-04-24 03:08:43 +03:00
appendLog ( ' inputimeout imported ' )
except Exception as exp :
appendLog ( f ' Failed to import inputimeout: { exp } ' )
2021-01-21 14:00:58 +02:00
print ( f ' [ { YELLOW } WARN { RESET } ] Н е удалось импортировать классы " inputimeout " и " TimeoutOccurred " из модуля " inputimeout " ' )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
def nowtime ( seconds = True , noice = True , color = True ) :
2021-01-15 23:01:23 +02:00
now = datetime . now ( )
if seconds == True :
justnow = now . strftime ( " % H: % M: % S " )
else :
justnow = now . strftime ( " % H: % M " )
if noice == True :
2021-01-21 14:00:58 +02:00
if not color :
beautiful = f ' [ { justnow } ] '
else :
beautiful = f ' [ { CYAN } { justnow } { RESET } ] '
2021-01-15 23:01:23 +02:00
else :
2021-01-21 14:00:58 +02:00
if not color :
beautiful = f ' { justnow } '
else :
beautiful = f ' { CYAN } { justnow } { RESET } '
2021-01-15 23:01:23 +02:00
return beautiful
def act ( x ) :
return x + 10
def waitStart ( runTime , action ) :
from datetime import datetime , time
from time import sleep
startTime = time ( * ( map ( int , runTime . split ( ' : ' ) ) ) )
while startTime > datetime . today ( ) . time ( ) :
sleep ( 2 )
2021-04-24 03:08:43 +03:00
2021-01-15 23:01:23 +02:00
return action
def getPair ( line ) :
key , sep , value = line . strip ( ) . partition ( " " )
return int ( key ) , value
def getLessons ( ) :
if not os . path . exists ( files_folder + ' lessons.json ' ) :
2021-04-24 03:08:43 +03:00
appendLog ( ' File lessons.json does not exist ' )
2021-01-15 23:01:23 +02:00
with open ( files_folder + ' lessons.json ' , ' w ' , encoding = " utf-8 " ) as f :
f . write ( " [] " )
2021-04-06 01:32:55 +03:00
f . close ( )
2021-01-15 23:01:23 +02:00
lessons_list = [ ]
2021-04-24 03:08:43 +03:00
appendLog ( f ' Created lessons.json ' )
2021-01-15 23:01:23 +02:00
else :
with open ( files_folder + ' lessons.json ' , encoding = " utf-8 " ) as json_file :
lessons_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-15 23:01:23 +02:00
2021-04-24 03:08:43 +03:00
appendLog ( ' File lessons.json loaded ' )
2021-01-15 23:01:23 +02:00
return lessons_list
def getState ( ) :
2021-04-24 03:08:43 +03:00
if os . name == ' nt ' :
2021-04-07 23:57:02 +03:00
2021-04-24 03:08:43 +03:00
try :
output = os . popen ( f ' tasklist /fi " IMAGENAME eq CptHost.exe " /fi " USERNAME ne NT AUTHORITY \ { getpass . getuser ( ) } " ' ) . read ( )
if " CptHost.exe " in output :
return True
else :
return False
except Exception as exp :
appendLog ( f ' Failed to get state using tasklist: { exp } ' )
output = os . popen ( ' wmic process get description, processid ' ) . read ( )
if " CptHost.exe " in output :
return True
else :
return False
2021-01-15 23:01:23 +02:00
def listLessons ( from_where = ' remove ' ) :
2021-04-24 03:08:43 +03:00
2021-01-15 23:01:23 +02:00
try :
2021-04-24 03:08:43 +03:00
appendLog ( ' Showing list of everything planned ' )
2021-01-15 23:01:23 +02:00
if from_where == ' editor ' :
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Полный список запланированных конференций: \n ' )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
print ( f ' { BBLACK } ================================================ { RESET } ' )
2021-01-15 23:01:23 +02:00
for les in enumerate ( getLessons ( ) ) :
if les [ 1 ] [ " repeat " ] :
repeat = ' Вкл. '
else :
repeat = ' Выкл. '
if les [ 1 ] [ " record " ] :
record = ' Вкл. '
else :
record = ' Выкл. '
try :
repeat_day = getDay ( les [ 1 ] [ " repeat_day " ] )
except :
repeat_day = ' Н е повторяется'
length = len ( str ( les [ 0 ] ) )
2021-01-21 14:00:58 +02:00
spacer_all = 6 * ' '
spacer_ind = ( 5 - length ) * ' '
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
print ( f ' { spacer_all } Имя: { YELLOW } { les [ 1 ] [ " name " ] } { RESET } ' )
print ( f ' { spacer_all } Дата: { YELLOW } { les [ 1 ] [ " date " ] } { RESET } ' )
print ( f ' { spacer_all } Время: { YELLOW } { les [ 1 ] [ " time " ] } { RESET } ' )
print ( f ' { GREEN } { les [ 0 ] } { RESET } { spacer_ind } Ссылка: { YELLOW } { les [ 1 ] [ " link " ] } { RESET } ' )
print ( f ' { spacer_all } Повтор: { YELLOW } { repeat } { RESET } ' )
print ( f ' { spacer_all } День: { YELLOW } { repeat_day } { RESET } ' )
print ( f ' { spacer_all } Запись: { YELLOW } { record } { RESET } ' )
print ( f ' { BBLACK } ================================================ { RESET } ' )
2021-01-15 23:01:23 +02:00
if from_where == ' editor ' :
none = input ( ' \n \n > ' )
2021-04-24 03:08:43 +03:00
2021-01-15 23:01:23 +02:00
except KeyboardInterrupt :
clear ( )
return
def sortLessons ( dictionary ) :
dictionary . sort ( key = lambda x : datetime . strptime ( x [ ' time ' ] , ' % H: % M ' ) )
dictionary . sort ( key = lambda x : datetime . strptime ( x [ ' date ' ] , ' %d . % m. % Y ' ) )
2021-04-24 03:08:43 +03:00
appendLog ( ' Lessons dictionary sorted ' )
2021-01-15 23:01:23 +02:00
def getDayNum ( day ) :
output = datetime . strptime ( day , " %d . % m. % Y " ) . isoweekday ( )
return output
def getDay ( number ) :
if number == 1 :
return ' Понедельник '
if number == 2 :
return ' Вторник '
if number == 3 :
return ' Среда '
if number == 4 :
return ' Четверг '
if number == 5 :
return ' Пятница '
if number == 6 :
return ' Суббота '
if number == 7 :
return ' Воскресенье '
def addLesson ( ) :
2021-04-24 03:08:43 +03:00
appendLog ( ' Adding new lesson ' )
2021-01-15 23:01:23 +02:00
try :
local_lessons = { }
lessons_got = getLessons ( )
2021-04-24 03:08:43 +03:00
lessname = input ( f ' { RESET } Введите (своё) имя конференции: \n { BBLACK } Нужно лишь для отображения в Discord и самом AutoZoom { RESET } \n \n > { CYAN } ' )
2021-01-15 23:01:23 +02:00
local_lessons . update ( { " name " : lessname } )
while True :
clear ( )
today = date . today ( )
today_1 = date . today ( ) + timedelta ( days = 1 )
today_2 = date . today ( ) + timedelta ( days = 2 )
today_3 = date . today ( ) + timedelta ( days = 3 )
today_4 = date . today ( ) + timedelta ( days = 4 )
today_5 = date . today ( ) + timedelta ( days = 5 )
today_6 = date . today ( ) + timedelta ( days = 6 )
2021-04-24 03:08:43 +03:00
print ( f ' { RESET } Введите дату конференции или номер дня ( { BRED } ДД.М М .ГГГГ { RESET } ): \n ' )
2021-01-21 14:00:58 +02:00
print ( f ' { BRED } 1. { RESET } { today . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 2. { RESET } { today_1 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_1 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 3. { RESET } { today_2 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_2 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 4. { RESET } { today_3 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_3 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 5. { RESET } { today_4 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_4 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 6. { RESET } { today_5 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_5 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 7. { RESET } { today_6 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_6 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
2021-01-15 23:01:23 +02:00
try :
2021-01-21 14:00:58 +02:00
lessdate = input ( f ' \n > { BRED } ' )
2021-01-15 23:01:23 +02:00
if lessdate == ' ' :
finallessdate = lessons_got [ edi ] [ " date " ]
elif lessdate == ' 1 ' :
finallessdate = today . strftime ( " %d . % m. % Y " )
elif lessdate == ' 2 ' :
finallessdate = today_1 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 3 ' :
finallessdate = today_2 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 4 ' :
finallessdate = today_3 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 5 ' :
finallessdate = today_4 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 6 ' :
finallessdate = today_5 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 7 ' :
finallessdate = today_6 . strftime ( " %d . % m. % Y " )
else :
try :
test = ( datetime . strptime ( lessdate , " %d . % m. % Y " ) )
finallessdate = lessdate
except :
continue
local_lessons . update ( { " date " : finallessdate } )
break
except :
continue
while True :
clear ( )
try :
2021-01-21 14:00:58 +02:00
lesstime = input ( f ' { RESET } Введите время конференции ( { BRED } ЧЧ:М М { RESET } ): \n \n > { BRED } ' )
2021-01-15 23:01:23 +02:00
finallesstime = ( datetime . strptime ( lesstime , " % H: % M " ) )
local_lessons . update ( { " time " : lesstime } )
break
except :
continue
clear ( )
2021-04-24 03:08:43 +03:00
lesslink = input ( f ' { RESET } Введите ссылку на конференцию: \n { BBLACK } Формат: { BRED } https://us01web.zoom.us/j/ИДЕНТИФИКАТОР?pwd=ПАРОЛЬ { RESET } \n { BBLACK } Либо введите { YELLOW } 1 { BBLACK } для добавления по номеру и паролю { RESET } \n \n > { BRED } ' ) . replace ( " " , " " )
2021-04-07 23:57:02 +03:00
if lesslink . replace ( ' ' , ' ' ) == ' 1 ' :
clear ( )
lessid = input ( f ' { RESET } Введите идентификатор конференции: \n { BBLACK } Формат: { BRED } 012 3456 7890 { BBLACK } либо { BRED } 01234567890 { RESET } \n \n > { BRED } ' )
clear ( )
lesspasswd = input ( f ' { RESET } Введите код доступа (пароль) конференции: \n \n > { BRED } ' )
lesslink = f ' https://us01web.zoom.us/j/ { lessid . replace ( " " , " " ) } ?pwd= { lesspasswd . replace ( " " , " " ) } '
2021-01-15 23:01:23 +02:00
local_lessons . update ( { " link " : lesslink } )
while True :
clear ( )
2021-01-21 14:00:58 +02:00
repeat = input ( f ' { RESET } Повторять эту конференцию ( { getDay ( getDayNum ( finallessdate ) ) } )? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ) \n \n > ' )
2021-01-15 23:01:23 +02:00
if repeat . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
finalrepeat = True
finalrepeatday = getDayNum ( finallessdate )
local_lessons . update ( { " repeat " : finalrepeat } )
local_lessons . update ( { " repeat_day " : finalrepeatday } )
break
elif repeat . lower ( ) in [ ' n ' , ' no ' , ' н ' , ' нет ' ] :
finalrepeat = False
finalrepeatday = None
local_lessons . update ( { " repeat " : finalrepeat } )
local_lessons . update ( { " repeat_day " : finalrepeatday } )
break
else :
continue
while True :
clear ( )
2021-01-21 14:00:58 +02:00
lessrecord = input ( f ' Записать эту конференцию? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ) \n \n > ' )
2021-01-15 23:01:23 +02:00
if lessrecord . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
finallessrecord = True
local_lessons . update ( { " record " : finallessrecord } )
break
elif lessrecord . lower ( ) in [ ' n ' , ' no ' , ' н ' , ' нет ' ] :
finallessrecord = False
local_lessons . update ( { " record " : finallessrecord } )
break
else :
continue
lessons_got . append ( dict ( local_lessons ) )
sortLessons ( lessons_got )
saveJson ( files_folder + ' lessons.json ' , lessons_got )
clear ( )
2021-04-24 03:08:43 +03:00
print ( f ' Добавлена конференция { CYAN } { local_lessons [ " name " ] } { RESET } за { BRED } { local_lessons [ " date " ] } { RESET } на время { BRED } { local_lessons [ " time " ] } { RESET } . ' )
appendLog ( f ' Added lesson { local_lessons [ " name " ] } (Date: { local_lessons [ " date " ] } , Time: { local_lessons [ " time " ] } , Link: { local_lessons [ " link " ] } ) ' )
2021-01-15 23:01:23 +02:00
none = input ( ' \n > ' )
2021-04-24 03:08:43 +03:00
2021-01-15 23:01:23 +02:00
except KeyboardInterrupt :
2021-04-24 03:08:43 +03:00
appendLog ( ' Lesson adding aborted ' )
2021-01-15 23:01:23 +02:00
clear ( )
return
def editLesson ( ) :
2021-04-24 03:08:43 +03:00
appendLog ( f ' Editing existing lesson ' )
2021-01-15 23:01:23 +02:00
try :
local_lessons = { }
lessons_got = getLessons ( )
while True :
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Выберите номер (индекс) для изменения: \n ' )
2021-01-15 23:01:23 +02:00
listLessons ( )
lessons_got = getLessons ( )
2021-01-21 14:00:58 +02:00
print ( f ' \n Для отмены операции введите { BRED } c { RESET } или { BRED } cancel { RESET } ' )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
edi = input ( f ' \n > { BGREEN } ' )
2021-01-15 23:01:23 +02:00
if not isinstance ( edi , int ) :
if edi . lower ( ) == ' c ' or edi . lower ( ) == ' cancel ' :
clear ( )
return
try :
edi = int ( edi )
except :
clear ( )
continue
try :
probe = lessons_got [ edi ] [ " name " ]
break
except :
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Выберите { ULINE } правильный { RESET } индекс (номер) для изменения. ' )
2021-01-15 23:01:23 +02:00
time . sleep ( 3 )
clear ( )
continue
break
clear ( )
2021-04-24 03:08:43 +03:00
lessname = input ( f ' { RESET } Введите (своё) имя конференции: \n { BBLACK } Нужно лишь для отображения в Discord и самом AutoZoom { RESET } \n \n Оригинальное имя: { CYAN } { lessons_got [ edi ] [ " name " ] } { RESET } \n \n > { CYAN } ' )
2021-01-15 23:01:23 +02:00
if lessname == ' ' :
lessname = lessons_got [ edi ] [ " name " ]
local_lessons . update ( { " name " : lessname } )
while True :
clear ( )
today = date . today ( )
today_1 = date . today ( ) + timedelta ( days = 1 )
today_2 = date . today ( ) + timedelta ( days = 2 )
today_3 = date . today ( ) + timedelta ( days = 3 )
today_4 = date . today ( ) + timedelta ( days = 4 )
today_5 = date . today ( ) + timedelta ( days = 5 )
today_6 = date . today ( ) + timedelta ( days = 6 )
2021-04-24 03:08:43 +03:00
print ( f ' { RESET } Введите дату конференции или номер дня ( { BRED } ДД.М М .ГГГГ { RESET } ): \n ' )
2021-01-21 14:00:58 +02:00
print ( f ' { BRED } 1. { RESET } { today . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 2. { RESET } { today_1 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_1 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 3. { RESET } { today_2 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_2 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 4. { RESET } { today_3 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_3 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 5. { RESET } { today_4 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_4 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 6. { RESET } { today_5 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_5 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 7. { RESET } { today_6 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_6 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' \n Оригинальная дата: { BRED } { lessons_got [ edi ] [ " date " ] } { RESET } ' )
2021-01-15 23:01:23 +02:00
try :
2021-01-21 14:00:58 +02:00
lessdate = input ( f ' \n > { BRED } ' )
2021-01-15 23:01:23 +02:00
if lessdate == ' ' :
finallessdate = lessons_got [ edi ] [ " date " ]
elif lessdate == ' 1 ' :
finallessdate = today . strftime ( " %d . % m. % Y " )
elif lessdate == ' 2 ' :
finallessdate = today_1 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 3 ' :
finallessdate = today_2 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 4 ' :
finallessdate = today_3 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 5 ' :
finallessdate = today_4 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 6 ' :
finallessdate = today_5 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 7 ' :
finallessdate = today_6 . strftime ( " %d . % m. % Y " )
else :
try :
test = ( datetime . strptime ( lessdate , " %d . % m. % Y " ) )
finallessdate = lessdate
except :
continue
local_lessons . update ( { " date " : finallessdate } )
break
except :
continue
while True :
clear ( )
try :
2021-01-21 14:00:58 +02:00
lesstime = input ( f ' { RESET } Введите время конференции ( { BRED } ЧЧ:М М { RESET } ): \n \n Оригинальное время: { BRED } { lessons_got [ edi ] [ " time " ] } { RESET } \n \n > { BRED } ' )
2021-01-15 23:01:23 +02:00
if lesstime == ' ' :
finallesstime = lessons_got [ edi ] [ " time " ]
lesstime = lessons_got [ edi ] [ " time " ]
else :
try :
finallesstime = ( datetime . strptime ( lesstime , " % H: % M " ) )
2021-01-21 14:00:58 +02:00
finallesstime = lesstime
2021-01-15 23:01:23 +02:00
except :
continue
local_lessons . update ( { " time " : lesstime } )
break
except :
continue
clear ( )
2021-04-24 03:08:43 +03:00
lesslink = input ( f ' { RESET } Введите ссылку на конференцию: \n { BBLACK } Формат: { BRED } https://us01web.zoom.us/j/ИДЕНТИФИКАТОР?pwd=ПАРОЛЬ { RESET } \n { BBLACK } Либо введите { YELLOW } 1 { BBLACK } для добавления по номеру и паролю { RESET } \n \n > { BRED } ' ) . replace ( " " , " " )
2021-04-07 23:57:02 +03:00
if lesslink . replace ( ' ' , ' ' ) == ' 1 ' :
clear ( )
lessid = input ( f ' { RESET } Введите идентификатор конференции: \n { BBLACK } Формат: { BRED } 012 3456 7890 { BBLACK } либо { BRED } 01234567890 { RESET } \n \n > { BRED } ' )
clear ( )
lesspasswd = input ( f ' { RESET } Введите код доступа (пароль) конференции: \n \n > { BRED } ' )
lesslink = f ' https://us01web.zoom.us/j/ { lessid . replace ( " " , " " ) } ?pwd= { lesspasswd . replace ( " " , " " ) } '
2021-01-15 23:01:23 +02:00
if lesslink == ' ' :
lesslink = lessons_got [ edi ] [ " link " ]
2021-04-07 23:57:02 +03:00
2021-01-15 23:01:23 +02:00
local_lessons . update ( { " link " : lesslink } )
while True :
clear ( )
2021-01-21 14:00:58 +02:00
try :
lessrepeatday = getDay ( lessons_got [ edi ] [ " repeat_day " ] )
except :
lessrepeatday = ' Н е повторяется'
print ( f ' { RESET } Повторять эту конференцию ( { YELLOW } { getDay ( getDayNum ( finallessdate ) ) } { RESET } )? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ) ' )
print ( f ' \n Оригинальное значение: { BRED } { lessrepeatday } { RESET } ' )
repeat = input ( ' \n > ' )
2021-01-15 23:01:23 +02:00
if repeat . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
finalrepeat = True
finalrepeatday = getDayNum ( finallessdate )
local_lessons . update ( { " repeat " : finalrepeat } )
local_lessons . update ( { " repeat_day " : finalrepeatday } )
break
elif repeat . lower ( ) in [ ' n ' , ' no ' , ' н ' , ' нет ' ] :
finalrepeat = False
local_lessons . update ( { " repeat " : finalrepeat } )
break
elif repeat == ' ' :
finalrepeat = lessons_got [ edi ] [ " repeat " ]
local_lessons . update ( { " repeat " : finalrepeat } )
try :
finalrepeatday = lessons_got [ edi ] [ " repeat_day " ]
local_lessons . update ( { " repeat_day " : finalrepeatday } )
except :
pass
break
else :
continue
while True :
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' Записать эту конференцию? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ) ' )
print ( f ' \n Оригинальное значение: { BRED } { lessons_got [ edi ] [ " record " ] } { RESET } ' )
lessrecord = input ( ' \n > ' )
2021-01-15 23:01:23 +02:00
if lessrecord . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
finallessrecord = True
local_lessons . update ( { " record " : finallessrecord } )
break
elif lessrecord . lower ( ) in [ ' n ' , ' no ' , ' н ' , ' нет ' ] :
finallessrecord = False
local_lessons . update ( { " record " : finallessrecord } )
break
elif lessrecord == ' ' :
finallessrecord = lessons_got [ edi ] [ " record " ]
local_lessons . update ( { " record " : finallessrecord } )
break
else :
continue
del lessons_got [ edi ]
lessons_got . append ( dict ( local_lessons ) )
sortLessons ( lessons_got )
saveJson ( files_folder + ' lessons.json ' , lessons_got )
clear ( )
2021-04-24 03:08:43 +03:00
print ( f ' Изменена конференция { CYAN } { lessname } { RESET } за { BRED } { finallessdate } { RESET } на время { BRED } { finallesstime } { RESET } . ' )
appendLog ( f ' Edited lesson { lessname } (Date: { finallessdate } , Time: { finallesstime } , Link: { local_lessons [ " link " ] } ) ' )
2021-01-15 23:01:23 +02:00
none = input ( ' \n > ' )
2021-04-24 03:08:43 +03:00
2021-01-15 23:01:23 +02:00
except KeyboardInterrupt :
2021-04-24 03:08:43 +03:00
appendLog ( ' Editing existing lesson aborted ' )
2021-01-15 23:01:23 +02:00
clear ( )
return
def removeLesson ( ) :
2021-04-24 03:08:43 +03:00
appendLog ( f ' Removing existing lesson ' )
2021-01-15 23:01:23 +02:00
try :
while True :
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Выберите номер (индекс) для удаления: \n ' )
2021-01-15 23:01:23 +02:00
listLessons ( )
lessons_local = getLessons ( )
2021-01-21 14:00:58 +02:00
print ( f ' \n { BBLACK } Для отмены операции введите { BRED } c { BBLACK } или { BRED } cancel { RESET } ' )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
rem = input ( f ' \n > { BRED } ' )
2021-01-15 23:01:23 +02:00
if rem . lower ( ) == ' c ' or rem . lower ( ) == ' cancel ' :
clear ( )
break
else :
try :
rem = int ( rem )
except :
clear ( )
continue
try :
del_name = lessons_local [ rem ] [ " name " ]
del_date = lessons_local [ rem ] [ " date " ]
del_time = lessons_local [ rem ] [ " time " ]
del lessons_local [ rem ]
except :
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Выберите { ULINE } правильный { RESET } индекс (номер) для удаления. ' )
2021-01-15 23:01:23 +02:00
time . sleep ( 3 )
clear ( )
continue
sortLessons ( lessons_local )
saveJson ( files_folder + ' lessons.json ' , lessons_local )
clear ( )
2021-04-24 03:08:43 +03:00
print ( f ' { RESET } Удалена конференция { CYAN } { del_name } { RESET } за { BRED } { del_date } { RESET } на время { BRED } { del_time } { RESET } . ' )
appendLog ( f ' Removed lesson { del_name } (Date: { del_date } , Time: { del_time } ) ' )
2021-01-15 23:01:23 +02:00
none = input ( ' \n > ' )
break
except KeyboardInterrupt :
2021-04-24 03:08:43 +03:00
appendLog ( ' Lesson removal aborted ' )
2021-01-15 23:01:23 +02:00
clear ( )
return
def removeAllLessons ( ) :
2021-04-24 03:08:43 +03:00
appendLog ( ' Removing all lessons ' )
2021-01-15 23:01:23 +02:00
try :
while True :
clear ( )
2021-01-21 14:00:58 +02:00
removeall = input ( f ' { RESET } Вы уверены что хотите удалить все конференции? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ) \n { BRED } Внимание! { RESET } Это действие нельзя обратить! \n Ваши настройки затронуты Н Е будут. \n \n > ' )
2021-01-15 23:01:23 +02:00
if removeall . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
with open ( files_folder + ' lessons.json ' , ' w ' , encoding = " utf-8 " ) as f :
f . write ( " [] " )
2021-04-06 01:32:55 +03:00
f . close ( )
2021-04-24 03:08:43 +03:00
appendLog ( ' All lessons removed ' )
2021-01-15 23:01:23 +02:00
clear ( )
2021-04-24 03:08:43 +03:00
none = input ( ' В с е конференции были удалены.\n \n > ' )
2021-01-15 23:01:23 +02:00
clear ( )
break
elif removeall . lower ( ) in [ ' n ' , ' no ' , ' н ' , ' нет ' ] :
2021-04-24 03:08:43 +03:00
appendLog ( ' All lessons removal aborted ' )
2021-01-15 23:01:23 +02:00
clear ( )
break
else :
continue
2021-04-24 03:08:43 +03:00
2021-01-15 23:01:23 +02:00
except KeyboardInterrupt :
2021-04-24 03:08:43 +03:00
appendLog ( ' All lessons removal aborted ' )
2021-01-15 23:01:23 +02:00
clear ( )
return
2021-01-21 14:00:58 +02:00
import rpc
2021-01-15 23:01:23 +02:00
def editor ( ) :
try :
2021-01-21 14:00:58 +02:00
os . system ( " title AutoZoom (Редактор) " )
2021-04-24 03:08:43 +03:00
appendLog ( ' Editor menu opened ' )
2021-01-15 23:01:23 +02:00
from main import mainMenu
2021-04-24 03:08:43 +03:00
2021-01-15 23:01:23 +02:00
while True :
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' { BBLACK } » { RESET } Меню редактора \n ' )
2021-04-24 03:08:43 +03:00
print ( f ' { BRED } 1. { RESET } Добавить конференцию ' )
print ( f ' { BRED } 2. { RESET } Изменить конференцию ' )
print ( f ' { BRED } 3. { RESET } Удалить конференцию ' )
print ( f ' { BRED } 4. { RESET } Посмотреть конференции ' )
print ( f ' { BRED } 5. { RESET } Удалить все конференции ' )
2021-01-21 14:00:58 +02:00
print ( f ' { BRED } 6. { RESET } В главное меню ' )
editor_choose = input ( f ' \n > { BRED } ' )
2021-01-15 23:01:23 +02:00
if editor_choose == ' 1 ' :
2021-04-24 03:08:43 +03:00
appendLog ( ' Went to lesson adding ' )
2021-01-15 23:01:23 +02:00
clear ( )
addLesson ( )
elif editor_choose == ' 2 ' :
2021-04-24 03:08:43 +03:00
appendLog ( ' Went to lesson editing ' )
2021-01-15 23:01:23 +02:00
clear ( )
editLesson ( )
elif editor_choose == ' 3 ' :
2021-04-24 03:08:43 +03:00
appendLog ( ' Went to lesson removal ' )
2021-01-15 23:01:23 +02:00
clear ( )
removeLesson ( )
elif editor_choose == ' 4 ' :
2021-04-24 03:08:43 +03:00
appendLog ( ' Went to lesson lising ' )
2021-01-15 23:01:23 +02:00
clear ( )
listLessons ( from_where = ' editor ' )
elif editor_choose == ' 5 ' :
2021-04-24 03:08:43 +03:00
appendLog ( ' Went to all lessons removal ' )
2021-01-15 23:01:23 +02:00
clear ( )
removeAllLessons ( )
elif editor_choose == ' 6 ' :
2021-04-24 03:08:43 +03:00
appendLog ( ' Exiting back to main menu ' )
2021-01-21 14:00:58 +02:00
rpc . inMenu ( )
2021-01-15 23:01:23 +02:00
clear ( )
2021-01-21 14:00:58 +02:00
os . system ( " title AutoZoom (Главная) " )
2021-01-15 23:01:23 +02:00
mainMenu ( )
else :
continue
2021-04-24 03:08:43 +03:00
2021-01-15 23:01:23 +02:00
except KeyboardInterrupt :
2021-04-24 03:08:43 +03:00
appendLog ( ' Exiting back to main menu ' )
2021-01-21 14:00:58 +02:00
rpc . inMenu ( )
2021-01-15 23:01:23 +02:00
clear ( )
return
def tgsend ( enabled , message ) :
if enabled :
2021-01-21 14:00:58 +02:00
if os . path . exists ( files_folder + ' telegram.conf ' ) :
tg_file = open ( files_folder + ' telegram.conf ' , ' r ' , encoding = " utf-8 " )
tg_text = tg_file . read ( )
2021-04-24 03:08:43 +03:00
2021-01-21 14:00:58 +02:00
if tg_text != ' Not Configured ' :
2021-04-07 23:57:02 +03:00
try :
telegram_send . send ( messages = [ f " { message } " ] , parse_mode = " markdown " , conf = files_folder + " telegram.conf " )
2021-04-24 03:08:43 +03:00
except Exception as excep :
appendLog ( f ' Failed to send TG message " { message } " : { exp } ' )
print ( f ' { nowtime ( ) } Н е удалось отправить Telegram сообщение " { message } " (Ошибка: { exp } ) ' )
2021-01-21 14:00:58 +02:00
def playSound ( soundname ) :
2021-04-24 03:08:43 +03:00
2021-01-21 14:00:58 +02:00
if getConfig ( " sounds " ) :
2021-04-07 23:57:02 +03:00
if os . name == ' nt ' :
winsound . PlaySound ( sounds_folder + soundname + " .wav " , winsound . SND_FILENAME )
else :
playsound . playsound ( sounds_folder + soundname + " .wav " )
2021-01-15 23:01:23 +02:00
def settings ( ) :
2021-04-24 03:08:43 +03:00
appendLog ( ' Settings page 1 opened ' )
2021-01-15 23:01:23 +02:00
try :
while True :
2021-01-21 14:00:58 +02:00
os . system ( " title AutoZoom (Настройки) " )
2021-01-15 23:01:23 +02:00
clear ( )
if getConfig ( " debug " ) :
2021-01-21 14:00:58 +02:00
debug_val = f ' { BGREEN } Вкл. { RESET } '
2021-01-15 23:01:23 +02:00
elif not getConfig ( " debug " ) :
2021-01-21 14:00:58 +02:00
debug_val = f ' { BRED } Выкл. { RESET } '
else :
debug_val = f ' { BRED } ERROR { RESET } '
if getConfig ( " run_fullscreen " ) :
fullscreen_val = f ' { BGREEN } Вкл. { RESET } '
elif not getConfig ( " run_fullscreen " ) :
fullscreen_val = f ' { BRED } Выкл. { RESET } '
else :
fullscreen_val = f ' { BRED } ERROR { RESET } '
if getConfig ( " sounds " ) :
sounds_val = f ' { BGREEN } Вкл. { RESET } '
elif not getConfig ( " sounds " ) :
sounds_val = f ' { BRED } Выкл. { RESET } '
2021-01-15 23:01:23 +02:00
else :
2021-01-21 14:00:58 +02:00
sounds_val = f ' { BRED } ERROR { RESET } '
2021-01-22 14:53:33 +02:00
if getConfig ( " obs_exe " ) and getConfig ( " obs_core " ) not in [ None , ' Disabled ' ] :
obs_val = f ' { BGREEN } Вкл. { RESET } '
else :
obs_val = f ' { BRED } Выкл. { RESET } '
2021-01-21 14:00:58 +02:00
if getConfig ( " use_colors " ) :
color_val = f ' { BGREEN } Вкл. { RESET } '
elif not getConfig ( " use_colors " ) :
color_val = f ' { BRED } Выкл. { RESET } '
else :
color_val = f ' { BRED } ERROR { RESET } '
2021-01-15 23:01:23 +02:00
if getConfig ( " shutdown_enabled " ) :
2021-01-21 14:00:58 +02:00
shutdown_en_val = f ' { BGREEN } Вкл. { RESET } '
2021-01-15 23:01:23 +02:00
elif not getConfig ( " shutdown_enabled " ) :
2021-01-21 14:00:58 +02:00
shutdown_en_val = f ' { BRED } Выкл. { RESET } '
2021-01-15 23:01:23 +02:00
else :
2021-01-21 14:00:58 +02:00
shutdown_en_val = f ' { BRED } ERROR { RESET } '
2021-01-15 23:01:23 +02:00
if os . path . exists ( files_folder + ' telegram.conf ' ) :
2021-01-21 14:00:58 +02:00
tg_file = open ( files_folder + ' telegram.conf ' , ' r ' , encoding = " utf-8 " )
tg_text = tg_file . read ( )
if tg_text != ' Not Configured ' :
tg_var = f ' { BGREEN } Настроен { RESET } '
else :
tg_var = f ' { BRED } Н е настроен{ RESET } '
2021-01-15 23:01:23 +02:00
else :
2021-01-21 14:00:58 +02:00
tg_var = f ' { BRED } Н е настроен{ RESET } '
2021-01-15 23:01:23 +02:00
if getConfig ( " telegram_enabled " ) :
2021-01-21 14:00:58 +02:00
telegram_en_val = f ' { BGREEN } Вкл. { RESET } '
2021-01-15 23:01:23 +02:00
elif not getConfig ( " debug " ) :
2021-01-21 14:00:58 +02:00
telegram_en_val = f ' { BRED } Выкл. { RESET } '
2021-01-15 23:01:23 +02:00
else :
2021-01-21 14:00:58 +02:00
telegram_en_val = f ' { BRED } ERROR { RESET } '
2021-01-15 23:01:23 +02:00
shutdown_time_val = getConfig ( " shutdown_timeout " )
start_val = getConfig ( " start " )
stop_val = getConfig ( " stop " )
2021-01-21 14:00:58 +02:00
2021-04-24 03:08:43 +03:00
print ( f ' { RESET } { BBLACK } » { RESET } Настройки (1 стр.) \n ' )
2021-01-21 14:00:58 +02:00
print ( f ' { BRED } 1. { RESET } Режим отладки ( { debug_val } ) ' )
print ( f ' { BBLACK } Н е рекомендуем включать е г о без необходимости\n ' )
print ( f ' { BRED } 2. { RESET } Цветной вывод ( { color_val } ) ' )
print ( f ' { BBLACK } Отображение цветных текстов в меню и выводе (нужен перезапуск) \n ' )
print ( f ' { BRED } 3. { RESET } Полный экран ( { fullscreen_val } ) ' )
print ( f ' { BBLACK } Эмулировать вызов полного экрана при запуске (окно должно быть в фокусе) \n ' )
print ( f ' { BRED } 4. { RESET } Звуковые сигналы ( { sounds_val } ) ' )
2021-04-24 03:08:43 +03:00
print ( f ' { BBLACK } Воспроизводить звуки при начале/конце конференций и записи видео \n ' )
2021-01-22 14:53:33 +02:00
print ( f ' { BRED } 5. { RESET } Запись через OBS ( { obs_val } ) ' )
2021-04-24 03:08:43 +03:00
print ( f ' { BBLACK } Возможность записи конференций через OBS \n ' )
2021-01-21 14:00:58 +02:00
2021-01-22 14:53:33 +02:00
print ( f ' { BRED } 6. { RESET } Автовыключение ( { shutdown_en_val } ) ' )
2021-04-24 03:08:43 +03:00
print ( f ' { BBLACK } Когда конференции закончатся компьютер выключится \n ' )
2021-01-21 14:00:58 +02:00
2021-04-24 03:08:43 +03:00
print ( f ' { BRED } 7. { RESET } Следующая страница ' )
print ( f ' { BBLACK } Перейти на вторую страницу настроек \n ' )
2021-01-21 14:00:58 +02:00
2021-04-24 03:08:43 +03:00
print ( f ' { BRED } 8. { RESET } В главное меню ' )
print ( f ' { BBLACK } Вернуться в основное меню { RESET } \n ' )
2021-01-21 14:00:58 +02:00
2021-04-24 03:08:43 +03:00
print ( f ' { BBLACK } Для переключения параметров Вкл/Выкл просто введите номер { RESET } ' ) #\n Если окно приложения слишком мелкое - увеличьте е г о или листайте это меню{RESET}')
2021-01-21 14:00:58 +02:00
settings_choose = input ( f ' \n > { BRED } ' )
2021-01-15 23:01:23 +02:00
if settings_choose == ' 1 ' :
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-15 23:01:23 +02:00
config_list [ " debug " ] = not getConfig ( " debug " )
saveJson ( files_folder + ' config.json ' , config_list )
2021-04-24 03:08:43 +03:00
appendLog ( f ' Changed option " debug " to { getConfig ( " debug " ) } ' )
2021-01-15 23:01:23 +02:00
clear ( )
continue
2021-01-21 14:00:58 +02:00
2021-01-15 23:01:23 +02:00
elif settings_choose == ' 2 ' :
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
config_list [ " use_colors " ] = not getConfig ( " use_colors " )
2021-01-15 23:01:23 +02:00
saveJson ( files_folder + ' config.json ' , config_list )
2021-04-24 03:08:43 +03:00
appendLog ( f ' Changed option " use_colors " to { getConfig ( " use_colors " ) } ' )
2021-01-15 23:01:23 +02:00
clear ( )
continue
2021-01-21 14:00:58 +02:00
2021-01-15 23:01:23 +02:00
elif settings_choose == ' 3 ' :
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
config_list [ " run_fullscreen " ] = not getConfig ( " run_fullscreen " )
saveJson ( files_folder + ' config.json ' , config_list )
2021-04-24 03:08:43 +03:00
appendLog ( f ' Changed option " run_fullscreen " to { getConfig ( " run_fullscreen " ) } ' )
2021-01-21 14:00:58 +02:00
clear ( )
continue
elif settings_choose == ' 4 ' :
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-21 14:00:58 +02:00
config_list [ " sounds " ] = not getConfig ( " sounds " )
saveJson ( files_folder + ' config.json ' , config_list )
2021-04-24 03:08:43 +03:00
appendLog ( f ' Changed option " sounds " to { getConfig ( " sounds " ) } ' )
2021-01-21 14:00:58 +02:00
clear ( )
continue
2021-01-22 14:53:33 +02:00
elif settings_choose == ' 5 ' :
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-22 14:53:33 +02:00
if getConfig ( " obs_core " ) and getConfig ( " obs_exe " ) not in [ None , ' Disabled ' ] :
config_list [ " obs_core " ] = ' Disabled '
config_list [ " obs_exe " ] = ' Disabled '
else :
clear ( )
obs_choice = input ( f ' { RESET } Хотите использовать запись через OBS? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ): ' )
if obs_choice . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
while True :
try :
filename = easygui . fileopenbox ( ' Выберите путь до obs32.exe или obs64.exe ' )
if filename . find ( " obs64.exe " ) != - 1 :
config_list [ " obs_exe " ] = filename
config_list [ " obs_core " ] = filename [ : - 9 ]
print ( f ' Сохранены пути для OBS: \n Приложение: { BRED } { filename } { RESET } \n Корневая папка: { BRED } { filename [ : - 9 ] } { RESET } ' )
time . sleep ( 3 )
break
elif filename . find ( " obs32.exe " ) != - 1 :
config_list [ " obs_exe " ] = filename
config_list [ " obs_core " ] = filename [ : - 9 ]
print ( f ' Сохранены пути для OBS: \n Приложение: { BRED } { filename } { RESET } \n Корневая папка: { BRED } { filename [ : - 9 ] } { RESET } ' )
time . sleep ( 3 )
break
elif filename . find ( " obs.exe " ) != - 1 :
f . write ( filename )
config_list [ " obs_exe " ] = filename
config_list [ " obs_core " ] = filename [ : - 7 ]
print ( f ' Сохранены пути для OBS: \n Приложение: { BRED } { filename } { RESET } \n Корневая папка: { BRED } { filename [ : - 7 ] } { RESET } ' )
time . sleep ( 3 )
break
else :
easygui . msgbox ( " Неверный путь " )
break
2021-04-24 03:08:43 +03:00
except Exception as exp :
appendLog ( f ' Could not select OBS path: { exp } ' )
2021-01-22 14:53:33 +02:00
none = input ( ' Вы не выбрали верный путь для OBS. \n \n > ' )
clear ( )
break
saveJson ( files_folder + ' config.json ' , config_list )
2021-04-24 03:08:43 +03:00
appendLog ( f ' Changed option " obs_exe " to { getConfig ( " obs_exe " ) } ' )
appendLog ( f ' Changed option " obs_core " to { getConfig ( " obs_core " ) } ' )
2021-01-22 14:53:33 +02:00
clear ( )
continue
2021-01-21 14:00:58 +02:00
2021-01-22 14:53:33 +02:00
elif settings_choose == ' 6 ' :
2021-01-21 14:00:58 +02:00
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-21 14:00:58 +02:00
config_list [ " shutdown_enabled " ] = not getConfig ( " shutdown_enabled " )
saveJson ( files_folder + ' config.json ' , config_list )
2021-04-24 03:08:43 +03:00
appendLog ( f ' Changed option " shutdown_enabled " to { getConfig ( " shutdown_enabled " ) } ' )
2021-01-21 14:00:58 +02:00
clear ( )
continue
2021-01-22 14:53:33 +02:00
elif settings_choose == ' 7 ' :
2021-04-24 03:08:43 +03:00
clear ( )
settings2 ( )
elif settings_choose == ' 8 ' :
rpc . inMenu ( )
clear ( )
os . system ( " title AutoZoom (Главная) " )
return
except KeyboardInterrupt :
rpc . inMenu ( )
clear ( )
return
def settings2 ( ) :
appendLog ( ' Settings page 2 opened ' )
try :
while True :
os . system ( " title AutoZoom (Настройки) " )
clear ( )
if getConfig ( " use_colors " ) :
color_val = f ' { BGREEN } Вкл. { RESET } '
elif not getConfig ( " use_colors " ) :
color_val = f ' { BRED } Выкл. { RESET } '
else :
color_val = f ' { BRED } ERROR { RESET } '
if os . path . exists ( files_folder + ' telegram.conf ' ) :
tg_file = open ( files_folder + ' telegram.conf ' , ' r ' , encoding = " utf-8 " )
tg_text = tg_file . read ( )
if tg_text != ' Not Configured ' :
tg_var = f ' { BGREEN } Настроен { RESET } '
else :
tg_var = f ' { BRED } Н е настроен{ RESET } '
else :
tg_var = f ' { BRED } Н е настроен{ RESET } '
if getConfig ( " telegram_enabled " ) :
telegram_en_val = f ' { BGREEN } Вкл. { RESET } '
elif not getConfig ( " debug " ) :
telegram_en_val = f ' { BRED } Выкл. { RESET } '
else :
telegram_en_val = f ' { BRED } ERROR { RESET } '
if getConfig ( " update_check " ) :
update_val = f ' { BGREEN } Вкл. { RESET } '
elif not getConfig ( " update_check " ) :
update_val = f ' { BRED } Выкл. { RESET } '
else :
update_val = f ' { BRED } ERROR { RESET } '
shutdown_time_val = getConfig ( " shutdown_timeout " )
start_val = getConfig ( " start " )
stop_val = getConfig ( " stop " )
print ( f ' { RESET } { BBLACK } » { RESET } Настройки (2 стр.) \n ' )
print ( f ' { BRED } 1. { RESET } Таймаут выключения ( { YELLOW } { shutdown_time_val } мин. { RESET } ) ' )
print ( f ' { BBLACK } Время в минутах после которого ПК будет выключен \n ' )
print ( f ' { BRED } 2. { RESET } Начать запись ( { YELLOW } { start_val } { RESET } ) ' )
print ( f ' { BBLACK } Комбинация клавиш для начала записи через OBS (см. документацию) \n ' )
print ( f ' { BRED } 3. { RESET } Остановить запись ( { YELLOW } { stop_val } { RESET } ) ' )
print ( f ' { BBLACK } Комбинация клавиш для остановки записи через OBS (см. документацию) \n ' )
print ( f ' { BRED } 4. { RESET } Отправлять уведомления ( { telegram_en_val } ) ' )
print ( f ' { BBLACK } Ваш бот отправит сообщениия о начале/конце конференции и выключении ПК \n ' )
print ( f ' { BRED } 5. { RESET } Настроить Telegram бота ( { tg_var } ) ' )
print ( f ' { BBLACK } Настроить на вашем ПК бота для ЛС (см. документацию) \n ' )
print ( f ' { BRED } 6. { RESET } Проверка обновлений ( { update_val } ) ' )
print ( f ' { BBLACK } Н е рекомендуем выключать без необходимости\n ' )
print ( f ' { BRED } 7. { RESET } Следующая страница ' )
print ( f ' { BBLACK } Перейти на третью страницу настроек \n ' )
print ( f ' { BRED } 8. { RESET } Назад ' )
print ( f ' { BBLACK } Вернуться на предыдущую страницу { RESET } \n ' )
print ( f ' { BBLACK } Для переключения параметров Вкл/Выкл просто введите номер { RESET } ' ) #\n Если окно приложения слишком мелкое - увеличьте е г о или листайте это меню{RESET}')
settings_choose = input ( f ' \n > { BRED } ' )
if settings_choose == ' 1 ' :
2021-01-21 14:00:58 +02:00
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-21 14:00:58 +02:00
2021-01-15 23:01:23 +02:00
try :
clear ( )
2021-01-21 14:00:58 +02:00
config_list [ " shutdown_timeout " ] = int ( input ( f ' { RESET } Введите через сколько минут после конференции выключать ПК: \n \n > { BRED } ' ) )
2021-01-15 23:01:23 +02:00
saveJson ( files_folder + ' config.json ' , config_list )
2021-04-24 03:08:43 +03:00
appendLog ( f ' Changed option " shutdown_timeout " to { getConfig ( " shutdown_timeout " ) } ' )
2021-01-15 23:01:23 +02:00
continue
except :
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Нужно использовать целое число. ' )
2021-01-15 23:01:23 +02:00
time . sleep ( 2 )
continue
continue
2021-01-21 14:00:58 +02:00
2021-04-24 03:08:43 +03:00
elif settings_choose == ' 2 ' :
2021-01-15 23:01:23 +02:00
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-15 23:01:23 +02:00
try :
clear ( )
2021-01-21 14:00:58 +02:00
config_list [ " start " ] = input ( f ' { RESET } Введите комбинацию клавиш для начала записи OBS: \n Эта комбинация должна быть идентична оной в самом OBS! \n \n > { YELLOW } ' )
2021-01-15 23:01:23 +02:00
saveJson ( files_folder + ' config.json ' , config_list )
2021-04-24 03:08:43 +03:00
appendLog ( f ' Changed option " start " to { getConfig ( " start " ) } ' )
2021-01-15 23:01:23 +02:00
continue
except :
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Нужно использовать комбинацию клавиш в виде текста. ' )
2021-01-15 23:01:23 +02:00
time . sleep ( 2 )
continue
continue
2021-01-21 14:00:58 +02:00
2021-04-24 03:08:43 +03:00
elif settings_choose == ' 3 ' :
2021-01-15 23:01:23 +02:00
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-15 23:01:23 +02:00
try :
clear ( )
2021-01-21 14:00:58 +02:00
config_list [ " stop " ] = input ( f ' { RESET } Введите комбинацию клавиш для остановки записи OBS: \n Эта комбинация должна быть идентична оной в самом OBS! \n \n > { YELLOW } ' )
2021-01-15 23:01:23 +02:00
saveJson ( files_folder + ' config.json ' , config_list )
2021-04-24 03:08:43 +03:00
appendLog ( f ' Changed option " stop " to { getConfig ( " stop " ) } ' )
2021-01-15 23:01:23 +02:00
continue
except :
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Нужно использовать комбинацию клавиш в виде текста. ' )
2021-01-15 23:01:23 +02:00
time . sleep ( 2 )
continue
continue
2021-01-21 14:00:58 +02:00
2021-04-24 03:08:43 +03:00
elif settings_choose == ' 4 ' :
2021-01-15 23:01:23 +02:00
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-15 23:01:23 +02:00
config_list [ " telegram_enabled " ] = not getConfig ( " telegram_enabled " )
saveJson ( files_folder + ' config.json ' , config_list )
2021-04-24 03:08:43 +03:00
appendLog ( f ' Changed option " telegram_enabled " to { getConfig ( " telegram_enabled " ) } ' )
2021-01-15 23:01:23 +02:00
clear ( )
continue
2021-01-21 14:00:58 +02:00
2021-04-24 03:08:43 +03:00
elif settings_choose == ' 5 ' :
2021-01-15 23:01:23 +02:00
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Пожалуйста, прочтите инструкцию по установке Telegram бота в { BRED } README.txt { RESET } ' )
print ( f ' или в документации/инструкции что в разделе { CYAN } Помощь { RESET } главного меню ' )
print ( f ' чтобы хорошо понимать что сейчас от вас нужно. ' )
none = input ( ' \n > ' )
2021-01-15 23:01:23 +02:00
while True :
clear ( )
try :
telegram_send . configure ( files_folder + ' telegram.conf ' , channel = False , group = False , fm_integration = False )
break
except :
clear ( )
continue
telegram_send . send ( messages = [ f " 🎊 Конфигурация правильна, всё работает! " ] , parse_mode = " markdown " , conf = f " { files_folder } telegram.conf " )
2021-04-24 03:08:43 +03:00
appendLog ( ' Telegram Send successfully configured ' )
clear ( )
continue
elif settings_choose == ' 6 ' :
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
json_file . close ( )
config_list [ " update_check " ] = not getConfig ( " update_check " )
saveJson ( files_folder + ' config.json ' , config_list )
appendLog ( f ' Changed option " update_check " to { getConfig ( " update_check " ) } ' )
clear ( )
continue
elif settings_choose == ' 7 ' :
appendLog ( ' Going to settings page 3 ' )
clear ( )
settings3 ( )
elif settings_choose == ' 8 ' :
appendLog ( ' Returning to settings page 1 ' )
clear ( )
return
except KeyboardInterrupt :
rpc . inMenu ( )
clear ( )
return
def settings3 ( ) :
appendLog ( ' Settings page 3 opened ' )
try :
while True :
os . system ( " title AutoZoom (Настройки) " )
clear ( )
if getConfig ( " write_logs " ) :
logs_val = f ' { BGREEN } Вкл. { RESET } '
elif not getConfig ( " write_logs " ) :
logs_val = f ' { BRED } Выкл. { RESET } '
else :
logs_val = f ' { BRED } ERROR { RESET } '
shutdown_time_val = getConfig ( " shutdown_timeout " )
start_val = getConfig ( " start " )
stop_val = getConfig ( " stop " )
print ( f ' { RESET } { BBLACK } » { RESET } Настройки (3 стр.) \n ' )
print ( f ' { BRED } 1. { RESET } Запись действий в лог ( { logs_val } ) ' )
print ( f ' { BBLACK } Запись каждого действия в файл для отладки (не выключайте без причин) \n ' )
print ( f ' { BRED } 2. { RESET } Размер лога действий ( { YELLOW } { str ( getConfig ( " log_size " ) ) } К б { RESET } ) ' )
print ( f ' { BBLACK } Размер файла лога превышая который он будет упакован в архив \n ' )
print ( f ' { BRED } 3. { RESET } Сбросить все настройки ' )
print ( f ' { BBLACK } Восстановить настройки по умолчанию \n ' )
print ( f ' { BRED } 4. { RESET } Назад ' )
print ( f ' { BBLACK } Вернуться на предыдущую страницу { RESET } \n ' )
print ( f ' { BBLACK } Для переключения параметров Вкл/Выкл просто введите номер { RESET } ' ) #\n Если окно приложения слишком мелкое - увеличьте е г о или листайте это меню{RESET}')
settings_choose = input ( f ' \n > { BRED } ' )
if settings_choose == ' 1 ' :
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
json_file . close ( )
config_list [ " write_logs " ] = not getConfig ( " write_logs " )
saveJson ( files_folder + ' config.json ' , config_list )
appendLog ( f ' Changed option " write_logs " to { getConfig ( " write_logs " ) } ' )
if settings_choose == ' 2 ' :
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
json_file . close ( )
try :
clear ( )
config_list [ " log_size " ] = int ( input ( f ' { RESET } Введите после скольки килобайт архивировать лог: \n \n > { BRED } ' ) )
saveJson ( files_folder + ' config.json ' , config_list )
continue
except :
2021-01-15 23:01:23 +02:00
clear ( )
2021-04-24 03:08:43 +03:00
print ( f ' { RESET } Нужно использовать целое число. ' )
time . sleep ( 2 )
continue
appendLog ( f ' Changed option " log_size " to { getConfig [ " log_size " ] } ' )
2021-01-15 23:01:23 +02:00
continue
2021-01-21 14:00:58 +02:00
2021-04-24 03:08:43 +03:00
elif settings_choose == ' 3 ' :
appendLog ( ' Resetting configuration ' )
2021-01-15 23:01:23 +02:00
while True :
clear ( )
2021-01-21 14:00:58 +02:00
reset_decision = input ( f ' { RESET } Вы уверены что хотите сбросить настройки? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ) \n \n { BRED } Внимание! { RESET } Это действие нельзя обратить! \n Ваш список конференций затронут Н Е будет. \n \n > ' )
2021-04-24 03:08:43 +03:00
2021-01-15 23:01:23 +02:00
if reset_decision . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
2021-04-24 03:08:43 +03:00
from functions import default_config
saveJson ( files_folder + ' config.json ' , default_config )
appendLog ( ' Configuration dropped to default ' )
2021-01-15 23:01:23 +02:00
clear ( )
2021-01-21 14:00:58 +02:00
none = input ( f ' { RESET } В с е настройки были сброшены до стандартных.\n \n > ' )
2021-01-15 23:01:23 +02:00
clear ( )
break
2021-04-24 03:08:43 +03:00
2021-01-15 23:01:23 +02:00
elif reset_decision . lower ( ) in [ ' n ' , ' no ' , ' н ' , ' нет ' ] :
2021-04-24 03:08:43 +03:00
appendLog ( ' Configuration reset aborted ' )
2021-01-15 23:01:23 +02:00
clear ( )
break
2021-04-24 03:08:43 +03:00
2021-01-15 23:01:23 +02:00
else :
clear ( )
continue
2021-04-24 03:08:43 +03:00
2021-01-15 23:01:23 +02:00
continue
2021-04-24 03:08:43 +03:00
2021-01-15 23:01:23 +02:00
clear ( )
continue
2021-01-21 14:00:58 +02:00
2021-04-24 03:08:43 +03:00
elif settings_choose == ' 4 ' :
appendLog ( ' Returning to settings page 2 ' )
2021-01-15 23:01:23 +02:00
clear ( )
return
2021-04-24 03:08:43 +03:00
2021-01-15 23:01:23 +02:00
except KeyboardInterrupt :
2021-01-21 14:00:58 +02:00
rpc . inMenu ( )
2021-01-15 23:01:23 +02:00
clear ( )
return
def main ( source = ' deamon ' ) :
2021-04-06 01:32:55 +03:00
##########################################
# Возможность профилей сделана для себя
# и не планируется как фича, однако
# вы можете присобачить сюда что хотите.
try :
from profile import profilename
except :
profilename = ' '
pass
##########################################
2021-01-15 23:01:23 +02:00
try :
2021-01-21 14:00:58 +02:00
import time
2021-01-15 23:01:23 +02:00
from main import mainMenu
clear ( )
2021-01-21 14:00:58 +02:00
os . system ( " title AutoZoom (Демон) " )
2021-04-24 03:08:43 +03:00
appendLog ( ' Main daemon opened ' )
2021-01-15 23:01:23 +02:00
import webbrowser
2021-01-22 14:53:33 +02:00
if ( getConfig ( " obs_core " ) or getConfig ( " obs_exe " ) ) == None :
2021-01-21 14:00:58 +02:00
clear ( )
2021-01-22 14:53:33 +02:00
while True :
obs_choice = input ( f ' { RESET } Хотите использовать запись через OBS? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ): ' )
if obs_choice . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-22 14:53:33 +02:00
while True :
try :
filename = easygui . fileopenbox ( ' Выберите путь до obs32.exe или obs64.exe ' )
if filename . find ( " obs64.exe " ) != - 1 :
config_list [ " obs_exe " ] = filename
config_list [ " obs_core " ] = filename [ : - 9 ]
saveJson ( files_folder + ' config.json ' , config_list )
print ( f ' Сохранены пути для OBS: \n Приложение: { BRED } { filename } { RESET } \n Корневая папка: { BRED } { filename [ : - 9 ] } { RESET } ' )
time . sleep ( 3 )
break
elif filename . find ( " obs32.exe " ) != - 1 :
config_list [ " obs_exe " ] = filename
config_list [ " obs_core " ] = filename [ : - 9 ]
saveJson ( files_folder + ' config.json ' , config_list )
print ( f ' Сохранены пути для OBS: \n Приложение: { BRED } { filename } { RESET } \n Корневая папка: { BRED } { filename [ : - 9 ] } { RESET } ' )
time . sleep ( 3 )
break
elif filename . find ( " obs.exe " ) != - 1 :
config_list [ " obs_exe " ] = filename
config_list [ " obs_core " ] = filename [ : - 7 ]
saveJson ( files_folder + ' config.json ' , config_list )
print ( f ' Сохранены пути для OBS: \n Приложение: { BRED } { filename } { RESET } \n Корневая папка: { BRED } { filename [ : - 7 ] } { RESET } ' )
time . sleep ( 3 )
break
else :
easygui . msgbox ( " Неверный путь " )
continue
2021-01-15 23:01:23 +02:00
break
2021-04-24 03:08:43 +03:00
except Exception as exp :
2021-01-22 14:53:33 +02:00
none = input ( ' Вы не выбрали верный путь для OBS. \n \n > ' )
config_list [ " obs_exe " ] = ' Disabled '
config_list [ " obs_core " ] = ' Disabled '
saveJson ( files_folder + ' config.json ' , config_list )
2021-04-24 03:08:43 +03:00
appendLog ( f ' Could not select path to OBS: { exp } ' )
2021-01-22 14:53:33 +02:00
clear ( )
2021-01-15 23:01:23 +02:00
break
2021-01-22 14:53:33 +02:00
break
elif obs_choice . lower ( ) in [ ' n ' , ' no ' , ' н ' , ' нет ' ] :
2021-04-06 01:32:55 +03:00
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
config_list [ " obs_exe " ] = ' Disabled '
config_list [ " obs_core " ] = ' Disabled '
saveJson ( files_folder + ' config.json ' , config_list )
json_file . close ( )
2021-01-22 14:53:33 +02:00
clear ( )
break
else :
clear ( )
continue
2021-01-15 23:01:23 +02:00
if not os . path . exists ( files_folder + ' telegram.conf ' ) :
2021-01-21 14:00:58 +02:00
clear ( )
2021-01-22 14:53:33 +02:00
tg_choice = input ( f ' { RESET } Хотите использовать Telegram бота? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ): ' )
if tg_choice . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
2021-01-15 23:01:23 +02:00
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' Пожалуйста, прочтите инструкцию по установке Telegram бота в { BRED } README.txt { RESET } ' )
print ( f ' или в документации/инструкции что в разделе { CYAN } Помощь { RESET } главного меню ' )
print ( f ' чтобы хорошо понимать что сейчас от вас нужно. ' )
none = input ( ' \n > ' )
2021-01-15 23:01:23 +02:00
clear ( )
2021-01-21 14:00:58 +02:00
while True :
clear ( )
2021-04-24 03:08:43 +03:00
2021-01-21 14:00:58 +02:00
try :
telegram_send . configure ( files_folder + ' telegram.conf ' , channel = False , group = False , fm_integration = False )
break
2021-04-24 03:08:43 +03:00
except Exception as exp :
appendLog ( f ' Failed to configure Telegram Send: { exp } ' )
2021-01-21 14:00:58 +02:00
clear ( )
continue
2021-04-24 03:08:43 +03:00
2021-01-21 14:00:58 +02:00
telegram_send . send ( messages = [ f " 🎊 Конфигурация правильна, всё работает! " ] , parse_mode = " markdown " , conf = f " { files_folder } telegram.conf " )
2021-04-24 03:08:43 +03:00
appendLog ( ' Telegram Send successfully configured ' )
2021-01-21 14:00:58 +02:00
clear ( )
2021-04-24 03:08:43 +03:00
2021-01-22 14:53:33 +02:00
elif tg_choice . lower ( ) in [ ' n ' , ' no ' , ' н ' , ' нет ' ] :
2021-01-21 14:00:58 +02:00
with open ( files_folder + ' telegram.conf ' , ' w ' , encoding = " utf-8 " ) as f :
f . write ( ' Not Configured ' )
2021-04-06 01:32:55 +03:00
f . close ( )
2021-04-24 03:08:43 +03:00
2021-01-15 23:01:23 +02:00
lessons_count = 0
try :
if getConfig ( " debug " ) :
2021-01-21 14:00:58 +02:00
print ( f ' { nowtime ( ) } Конфигурация импортирована \n ' )
2021-01-15 23:01:23 +02:00
except :
2021-01-21 14:00:58 +02:00
print ( f ' { nowtime ( ) } Конфигурация { BRED } отсутсвует { RESET } , выключаем отладку \n ' )
2021-01-15 23:01:23 +02:00
for les in getLessons ( ) :
2021-01-21 14:00:58 +02:00
try :
lessons_list = getLessons ( )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
lesson_name = les [ " name " ]
lesson_date = les [ " date " ]
lesson_time = les [ " time " ]
lesson_url = les [ " link " ]
2021-04-24 03:08:43 +03:00
lesson_url_original = les [ " link " ]
2021-01-21 14:00:58 +02:00
lesson_obs = les [ " record " ]
lesson_repeat = les [ " repeat " ]
2021-04-24 03:08:43 +03:00
2021-01-21 14:00:58 +02:00
try :
lesson_repeat_day = les [ " repeat_day " ]
except :
lesson_repeat_day = ' Н е повторяется'
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
today = date . today ( ) . strftime ( " %d . % m. % Y " )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
if ( today == lesson_date ) or ( getDayNum ( today ) == lesson_repeat_day ) :
print ( f ' { BBLACK } ================================================ { RESET } \n ' )
2021-01-15 23:01:23 +02:00
2021-04-24 03:08:43 +03:00
print ( f ' { nowtime ( ) } Найдена конференция { CYAN } { lesson_name } { RESET } в { BRED } { lesson_time } { RESET } . Ждём начала... ' )
2021-01-21 14:00:58 +02:00
waiting_time_unix = int ( time . time ( ) )
rpc . waitLesson ( lesson_name , waiting_time_unix )
waitStart ( lesson_time , lambda : act ( 100 ) )
2021-04-07 23:57:02 +03:00
try :
if os . name == ' nt ' :
i = 0
2021-04-24 03:08:43 +03:00
if i == 0 :
lesson_url = lesson_url . replace ( f " https://zoom.us/j/ " , " zoommtg://zoom.us/join?action=join&confno= " )
2021-04-07 23:57:02 +03:00
while i < 10 :
lesson_url = lesson_url . replace ( f " https://us0 { i } web.zoom.us/j/ " , " zoommtg://zoom.us/join?action=join&confno= " )
i + = 1
lesson_url = lesson_url . replace ( " & " , " ^& " )
lesson_url = lesson_url . replace ( " ?pwd " , " ^&pwd " )
if getConfig ( " debug " ) :
2021-04-24 03:08:43 +03:00
print ( f ' { nowtime ( ) } Ориг. ссылка: { BRED } { lesson_url_original } { RESET } ' )
print ( f ' { nowtime ( ) } Измен. ссылка: { BRED } { lesson_url } { RESET } ' )
appendLog ( f ' Replacing link { lesson_url_original } with { lesson_url } ' )
2021-04-07 23:57:02 +03:00
os . system ( f ' start { lesson_url } ' )
else :
i = 0
2021-04-24 03:08:43 +03:00
if i == 0 :
lesson_url = lesson_url . replace ( f " https://zoom.us/j/ " , " zoommtg://zoom.us/join?action=join&confno= " )
2021-04-07 23:57:02 +03:00
while i < 10 :
lesson_url = lesson_url . replace ( f " https://us0 { i } web.zoom.us/j/ " , " zoommtg://zoom.us/join?action=join&confno= " )
i + = 1
lesson_url = lesson_url . replace ( " ?pwd= " , " &pwd= " )
if getConfig ( " debug " ) :
2021-04-24 03:08:43 +03:00
print ( f ' { nowtime ( ) } Ориг. ссылка: { BRED } { lesson_url_original } { RESET } ' )
print ( f ' { nowtime ( ) } Измен. ссылка: { BRED } { lesson_url } { RESET } ' )
appendLog ( f ' Replacing link { lesson_url_original } with { lesson_url } ' )
2021-04-07 23:57:02 +03:00
os . system ( f ' xdg-open " { lesson_url } " ' )
2021-04-24 03:08:43 +03:00
except Exception as exep :
appendLog ( f ' Failed to open lesson { lesson_name } in Zoom: { exep } ' )
2021-04-07 23:57:02 +03:00
try :
webbrowser . open ( lesson_url )
2021-04-24 03:08:43 +03:00
except Exception as exp :
print ( f ' { nowtime ( ) } Открыть конференцию { CYAN } { lesson_name } { RESET } не удалось ни напрямую, ни в браузере. ' )
appendLog ( f ' Failed to open lesson { lesson_name } in both browser and Zoom: { exp } ' )
2021-04-07 23:57:02 +03:00
2021-01-21 14:00:58 +02:00
easteregg_number = randint ( 1 , 100000 )
2021-04-24 03:08:43 +03:00
2021-01-21 14:00:58 +02:00
if easteregg_number == 69420 :
2021-04-24 03:08:43 +03:00
appendLog ( ' Easteregg summoned ' )
2021-01-21 14:00:58 +02:00
webbrowser . open ( ' https://www.pornhub.com/view_video.php?viewkey=ph5f3eb1e206aa8 ' )
2021-04-24 03:08:43 +03:00
2021-01-21 14:00:58 +02:00
print ( f ' { nowtime ( ) } Ждём { BRED } 10 секунд { RESET } до отслеживания Zoom... ' )
time . sleep ( 10 )
2021-04-07 23:57:02 +03:00
retries = 0
2021-04-24 03:08:43 +03:00
destroy = False
2021-04-07 23:57:02 +03:00
2021-01-21 14:00:58 +02:00
while not getState ( ) :
2021-01-15 23:01:23 +02:00
if getConfig ( " debug " ) :
2021-04-24 03:08:43 +03:00
print ( f ' { nowtime ( ) } Конференция задерживается, ждём... ( { getState ( ) } ) ' )
appendLog ( ' Lesson delay found ' )
2021-01-21 14:00:58 +02:00
time . sleep ( 5 )
2021-04-07 23:57:02 +03:00
retries + = 1
if retries == 36 :
2021-04-24 03:08:43 +03:00
tgsend ( getConfig ( " telegram_enabled " ) , f " ⚠ Задержка конференции * { lesson_name } * превысила 3 минуты { profilename } " )
print ( f ' { nowtime ( ) } Задержка конференции { CYAN } { lesson_name } { RESET } превысила { BRED } 3 { RESET } минуты ' )
appendLog ( f ' Lesson delay exceeded: { retries } retries ' )
2021-04-07 23:57:02 +03:00
if retries == 120 :
2021-04-24 03:08:43 +03:00
tgsend ( getConfig ( " telegram_enabled " ) , f " ⚠ Задержка конференции * { lesson_name } * превысила 10 минут { profilename } " )
print ( f ' { nowtime ( ) } Задержка конференции { CYAN } { lesson_name } { RESET } превысила { BRED } 10 { RESET } минут ' )
appendLog ( f ' Lesson delay exceeded: { retries } retries ' )
if retries == 360 :
if getConfig ( " debug " ) :
tgsend ( getConfig ( " telegram_enabled " ) , f " ⚠ Задержка конференции * { lesson_name } * превысила 30 минут, конференция сбошена { profilename } " )
print ( f ' { nowtime ( ) } Задержка конференции { CYAN } { lesson_name } { RESET } превысила { BRED } 30 { RESET } минут, конференция сброшена ' )
else :
tgsend ( getConfig ( " telegram_enabled " ) , f " ⚠ Задержка конференции * { lesson_name } * превысила 30 минут, конференция сбошена { profilename } " )
print ( f ' { nowtime ( ) } Задержка конференции { CYAN } { lesson_name } { RESET } превысила { BRED } 30 { RESET } минут, конференция сброшена ' )
appendLog ( f ' Lesson delay exceeded: { retries } retries ' )
playSound ( " ended " )
if lesson_obs :
record_now = False
time . sleep ( 3 )
try :
obs_process . terminate ( )
except Exception as exp :
appendLog ( f ' Failed to stop OBS process: { exp } ' )
if getConfig ( " debug " ) :
print ( f ' { nowtime ( ) } Н е удалось остановить процесс OBS. ' )
if not lesson_repeat :
del lessons_list [ lessons_list . index ( les ) ]
saveJson ( files_folder + ' lessons.json ' , lessons_list )
if getConfig ( " debug " ) :
print ( f ' { nowtime ( ) } Конференция { CYAN } { lesson_name } { RESET } в { BRED } { lesson_time } { RESET } удалена. ' )
print ( f ' \n { BBLACK } ================================================ { RESET } \n \n ' )
firstshow = True
lessons_count = lessons_count + 1
destroy = True
break
2021-04-07 23:57:02 +03:00
2021-01-21 14:00:58 +02:00
continue
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
record_now = False
lesson_duration = 0
firstshow = True
2021-04-24 03:08:43 +03:00
if lesson_obs and not destroy :
2021-01-21 14:00:58 +02:00
try :
if getConfig ( " debug " ) :
print ( f ' { nowtime ( ) } Импортированы клавиши старта и остановки записи ( { YELLOW } { getConfig ( " start " ) } { RESET } и { YELLOW } { getConfig ( " stop " ) } { RESET } ). ' )
start = getConfig ( " start " )
stop = getConfig ( " stop " )
except :
start = ' shift+f7 '
stop = ' shift+f8 '
if getConfig ( " debug " ) :
print ( f ' { nowtime ( ) } Используем стандартные клавиши старта и остановки записи ( { YELLOW } { start } { RESET } и { YELLOW } { stop } { RESET } ). ' )
i = 0
2021-04-24 03:08:43 +03:00
while True and not destroy :
2021-01-21 14:00:58 +02:00
while i < 3 :
if getState ( ) :
2021-04-24 03:08:43 +03:00
if firstshow :
try :
2021-01-21 14:00:58 +02:00
start_time_unix = int ( time . time ( ) )
2021-04-24 03:08:43 +03:00
lesson_start = datetime . now ( )
except :
pass
print ( f ' { nowtime ( ) } Захвачена текущая конференция в Zoom. ' )
playSound ( " started " )
tgsend ( getConfig ( " telegram_enabled " ) , f " ▶ Зашёл на конференцию * { lesson_name } * в * { nowtime ( False , False , False ) } * { profilename } " )
appendLog ( f ' joined lesson { lesson_name } at { nowtime ( False , False , False ) } ' )
rpc . onLesson ( lesson_name , start_time_unix )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
if lesson_obs :
2021-04-24 03:08:43 +03:00
try :
obs_process = subprocess . Popen ( getConfig ( " obs_exe " ) , cwd = getConfig ( " obs_core " ) )
appendLog ( f ' Sent instruction to open OBS ' )
time . sleep ( 5 )
except Exception as exp :
appendLog ( f ' Failed to open OBS: { exp } ' )
print ( f ' { nowtime ( ) } Н е удалось открыть OBS для записи. ' )
else :
if getConfig ( " debug " ) :
print ( f ' { nowtime ( ) } Н е включаем OBS для записи. ' )
2021-01-21 14:00:58 +02:00
2021-04-24 03:08:43 +03:00
firstshow = False
if lesson_obs :
if not record_now :
keyboard . press ( start )
time . sleep ( .25 )
keyboard . release ( start )
record_now = True
print ( f ' { nowtime ( ) } Сигнал записи OBS отправлен. ' )
playSound ( " recordstart " )
2021-01-21 14:00:58 +02:00
2021-04-24 03:08:43 +03:00
lesson_duration = ( datetime . now ( ) - lesson_start ) . total_seconds ( )
if getConfig ( " debug " ) :
print ( f ' { nowtime ( ) } Zoom подключён. Конференция идёт уже { BGREEN } { str ( lesson_duration ) } сек { RESET } . ( { BGREEN } { str ( round ( lesson_duration / 60 , 2 ) ) } мин { RESET } .) ' )
time . sleep ( 5 )
continue
2021-01-21 14:00:58 +02:00
else :
i + = 1
2021-04-24 03:08:43 +03:00
appendLog ( f ' CptHost.exe not found, trying again in 10 seconds ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
2021-04-24 03:08:43 +03:00
print ( f ' { nowtime ( ) } { BRED } Конференция не обнаружена! { RESET } Повторная проверка через { BRED } 10 { RESET } секунд... ' )
2021-01-21 14:00:58 +02:00
time . sleep ( 10 )
continue
2021-01-15 23:01:23 +02:00
if getConfig ( " debug " ) :
2021-01-21 14:00:58 +02:00
print ( f ' { nowtime ( ) } Zoom отключился. Процесс { BRED } CptHost.exe { RESET } более не существует. ' )
2021-01-15 23:01:23 +02:00
2021-04-24 03:08:43 +03:00
appendLog ( f ' CptHost.exe not found, Zoom disconnected ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
2021-04-24 03:08:43 +03:00
tgsend ( getConfig ( " telegram_enabled " ) , f " ◀ Конференция * { lesson_name } * длилась * { str ( round ( lesson_duration / 60 , 2 ) ) } * мин. " )
print ( f ' { nowtime ( ) } Конференция длилась { BGREEN } { str ( lesson_duration ) } сек { RESET } . ( { BGREEN } { str ( round ( lesson_duration / 60 , 2 ) ) } мин { RESET } .) ' )
2021-01-21 14:00:58 +02:00
else :
2021-04-24 03:08:43 +03:00
tgsend ( getConfig ( " telegram_enabled " ) , f " ◀ Конференция * { lesson_name } * длилась * { str ( int ( lesson_duration / 60 ) ) } * мин. " )
print ( f ' { nowtime ( ) } Конференция длилась { BGREEN } { str ( lesson_duration ) } сек { RESET } . ( { BGREEN } { str ( int ( lesson_duration / 60 ) ) } мин { RESET } .) ' )
appendLog ( f ' Lesson { lesson_name } duration was { str ( int ( lesson_duration / 60 ) ) } m. ( { str ( lesson_duration ) } s.) ' )
2021-01-21 14:00:58 +02:00
playSound ( " ended " )
2021-01-15 23:01:23 +02:00
if lesson_obs :
keyboard . press ( stop )
time . sleep ( .25 )
keyboard . release ( stop )
print ( f ' { nowtime ( ) } Сигнал остановки записи через OBS отправлен. ' )
2021-01-21 14:00:58 +02:00
playSound ( " recordstop " )
2021-01-15 23:01:23 +02:00
record_now = False
time . sleep ( 3 )
2021-04-24 03:08:43 +03:00
2021-01-15 23:01:23 +02:00
try :
obs_process . terminate ( )
2021-04-24 03:08:43 +03:00
except Exception as exp :
appendLog ( f ' Failed to stop OBS process: { exp } ' )
2021-01-15 23:01:23 +02:00
if getConfig ( " debug " ) :
print ( f ' { nowtime ( ) } Н е удалось остановить процесс OBS. ' )
if not lesson_repeat :
2021-01-21 14:00:58 +02:00
del lessons_list [ lessons_list . index ( les ) ]
2021-01-15 23:01:23 +02:00
saveJson ( files_folder + ' lessons.json ' , lessons_list )
2021-04-24 03:08:43 +03:00
appendLog ( f ' Lesson named { lesson_name } removed ' )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
2021-04-24 03:08:43 +03:00
print ( f ' { nowtime ( ) } Конференция { CYAN } { lesson_name } { RESET } в { BRED } { lesson_time } { RESET } удалена. ' )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
print ( f ' \n { BBLACK } ================================================ { RESET } \n \n ' )
2021-01-15 23:01:23 +02:00
firstshow = True
lessons_count = lessons_count + 1
break
2021-04-24 03:08:43 +03:00
2021-01-21 14:00:58 +02:00
record_now = False
2021-04-24 03:08:43 +03:00
retries = 0
destroy = False
2021-01-21 14:00:58 +02:00
lessons_list = getLessons ( )
2021-04-24 03:08:43 +03:00
2021-01-21 14:00:58 +02:00
except KeyboardInterrupt :
2021-04-24 03:08:43 +03:00
appendLog ( ' Lessons waiting reset ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
2021-04-24 03:08:43 +03:00
print ( f ' { nowtime ( ) } Ожидание конференции сброшено. ' )
2021-01-21 14:00:58 +02:00
else :
print ( ' ' )
2021-04-24 03:08:43 +03:00
2021-01-21 14:00:58 +02:00
time . sleep ( 1 )
pass
2021-01-15 23:01:23 +02:00
time . sleep ( 3 )
2021-04-24 03:08:43 +03:00
appendLog ( ' Could not find any more lessons today ' )
print ( f ' { nowtime ( ) } Конференций нет или же все в списке закончились. ' )
2021-01-15 23:01:23 +02:00
if lessons_count > 0 :
if getConfig ( " shutdown_enabled " ) :
2021-01-21 14:00:58 +02:00
if getConfig ( " end_mode " ) == ' shutdown ' :
try :
2021-04-24 03:08:43 +03:00
tgsend ( getConfig ( " telegram_enabled " ) , f " ⚠ Конференции кончились, автовыключение { profilename } через { str ( getConfig ( ' shutdown_timeout ' ) ) } мин... " )
2021-01-21 14:00:58 +02:00
print ( f ' { nowtime ( ) } Ваш ПК автоматически выключится через { BRED } { str ( getConfig ( " shutdown_timeout " ) ) } мин { RESET } . ' )
2021-04-24 03:08:43 +03:00
appendLog ( f ' Shutting PC down in { str ( getConfig ( " shutdown_timeout " ) ) } ' )
2021-01-21 14:00:58 +02:00
playSound ( " shutdown " )
end_unix = int ( time . time ( ) ) + getConfig ( " shutdown_timeout " ) * 60
rpc . shutdown ( end_unix )
shutdown = inputimeout ( prompt = f ' { nowtime ( ) } Нажмите { CYAN } Enter { RESET } чтобы предотвратить выключение ПК... ' , timeout = getConfig ( " shutdown_timeout " ) * 60 )
2021-04-24 03:08:43 +03:00
appendLog ( ' Shutdown aborted ' )
2021-01-21 14:00:58 +02:00
clear ( )
except TimeoutOccurred :
clear ( )
print ( f ' { nowtime ( ) } Время вышло, выключаем ваш ПК... ' )
time . sleep ( 3 )
tgsend ( getConfig ( " telegram_enabled " ) , f " ⚠ Время таймаута исткело, выключаем ваш ПК... " )
time . sleep ( 5 )
2021-04-24 03:08:43 +03:00
appendLog ( ' Shutting PC down ' )
2021-01-21 14:00:58 +02:00
os . system ( " shutdown /s /t 1 " )
# elif getConfig("end_mode") == 'restart':
# from datetime import datetime, time
# from time import sleep
# runTime = "00:00"
# startTime = time(*(map(int, runTime.split(':'))))
# tomorrow = date.today()+timedelta(days=1)
# timestamp = (tomorrow - date(1970, 1, 1)).total_seconds()
# while startTime.total_seconds() > timestamp: #(date.today() + timedelta(days=1)).time():
# sleep(2)
2021-01-15 23:01:23 +02:00
if source == ' deamon ' :
2021-04-24 03:08:43 +03:00
appendLog ( f ' Waiting for any input ' )
rpc . lessonEnded ( )
2021-01-21 14:00:58 +02:00
exit = input ( f ' { nowtime ( ) } Программа завершена! Нажмите { CYAN } Enter { RESET } чтобы выйти... ' )
rpc . disconnect ( )
2021-01-15 23:01:23 +02:00
clear ( )
sys . exit ( )
elif source == ' menu ' :
2021-04-24 03:08:43 +03:00
appendLog ( f ' Waiting for any input ' )
rpc . lessonEnded ( )
2021-01-21 14:00:58 +02:00
exit = input ( f ' { nowtime ( ) } Программа завершена! Нажмите { CYAN } Enter { RESET } чтобы вернуться в меню... ' )
rpc . inMenu ( )
2021-01-15 23:01:23 +02:00
clear ( )
2021-01-21 14:00:58 +02:00
os . system ( " title AutoZoom (Главная) " )
2021-01-15 23:01:23 +02:00
return
except KeyboardInterrupt :
if source == ' deamon ' :
2021-04-24 03:08:43 +03:00
appendLog ( f ' Deamon stopped, waiting for any input ' )
rpc . lessonEnded ( )
2021-01-21 14:00:58 +02:00
exit = input ( f ' { nowtime ( ) } Программа остановлена! Нажмите { CYAN } Enter { RESET } чтобы выйти... ' )
rpc . disconnect ( )
2021-01-15 23:01:23 +02:00
clear ( )
sys . exit ( )
elif source == ' menu ' :
2021-04-24 03:08:43 +03:00
appendLog ( f ' Deamon stopped, waiting for any input ' )
rpc . lessonEnded ( )
2021-01-21 14:00:58 +02:00
exit = input ( f ' { nowtime ( ) } Программа остановлена! Нажмите { CYAN } Enter { RESET } чтобы вернуться в меню... ' )
rpc . inMenu ( )
2021-01-15 23:01:23 +02:00
clear ( )
return
if __name__ == ' __main__ ' :
2021-01-21 14:00:58 +02:00
os . system ( " title AutoZoom (Демон) " )
2021-01-15 23:01:23 +02:00
import sys
clear ( )
2021-04-07 23:57:02 +03:00
main ( )