Compare commits
73 Commits
39ba101948
...
RFB4
| Author | SHA1 | Date | |
|---|---|---|---|
| 26eb5a9398 | |||
| a97a28de6f | |||
| 764c50e42d | |||
| d49244de54 | |||
| a9605be520 | |||
| 763df5cb43 | |||
| 662f88c68b | |||
| c438f69578 | |||
| 9bf3624c8c | |||
| 7b44ab3d5d | |||
| 6721951c34 | |||
| ea34b6521f | |||
| 5ab179e47b | |||
| 1839b8aec3 | |||
| f11b315d2f | |||
| 15367b05fc | |||
| 94d487fe88 | |||
| 049e2493b5 | |||
| 7e5ccdbb83 | |||
| 97045a0f72 | |||
| b301f1e918 | |||
| d86d1e5a4f | |||
| 6278a8e3df | |||
| 4ad11815a5 | |||
| cbcad5e525 | |||
| 48c5f552ec | |||
| b0511d51d3 | |||
| 6fa1ad3f35 | |||
| d821967f33 | |||
| b11dbdeae8 | |||
| 91c6eeddc5 | |||
| 842af85847 | |||
| 225e158c53 | |||
| 276ecdcb85 | |||
| adc067293f | |||
| 27a7ffcaad | |||
| 02582bdab0 | |||
| 4048f8fdfa | |||
| b0aba27764 | |||
| b27e02bb49 | |||
| ff3883aa36 | |||
| f72914a085 | |||
| 10baa5b2fb | |||
| 6a06d54aa4 | |||
| 58bfdce841 | |||
| 9fa68a165d | |||
| ee58ad868d | |||
| 5470df8da9 | |||
| 8fa3acf3f2 | |||
| 858ed5c6a7 | |||
| 09dfbef09a | |||
| c4de3c84fe | |||
| 000b304ed9 | |||
| 8f34737186 | |||
| 58bff8ba53 | |||
| 82f1450ff5 | |||
| 7a61c0bfb6 | |||
| d75f0e6407 | |||
| dcfcbb0958 | |||
| 629854c104 | |||
| 893d18ee23 | |||
| c9613f91a3 | |||
| 5ea03d2efc | |||
| bacee0e9b8 | |||
| 0844d577ff | |||
| d7c819357d | |||
| efa4812b09 | |||
| c62c8a31a6 | |||
| a13cb945c7 | |||
| 5083423660 | |||
| c30bc088c7 | |||
| d9ad941a80 | |||
| 84169208ab |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,3 +5,4 @@
|
||||
get_data_new copy 2.py
|
||||
get_data_new copy.py
|
||||
temp.json
|
||||
get_data_new copy 3.py
|
||||
302
PlayTypeID.json
Normal file
302
PlayTypeID.json
Normal file
@@ -0,0 +1,302 @@
|
||||
[
|
||||
{
|
||||
"PlayTypeID": 0,
|
||||
"PlayInfoSite": "-",
|
||||
"PlayInfo": "Пустое событие"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 1,
|
||||
"PlayInfoSite": "1 очко",
|
||||
"PlayInfo": "Штрафной бросок - попадание"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 2,
|
||||
"PlayInfoSite": "2 очка",
|
||||
"PlayInfo": "2х очковый бросок - попадание"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 3,
|
||||
"PlayInfoSite": "3 очка",
|
||||
"PlayInfo": "3х очковый бросок - попадание"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 4,
|
||||
"PlayInfoSite": "Мимо 1 очко",
|
||||
"PlayInfo": "Штрафной бросок - промах"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 5,
|
||||
"PlayInfoSite": "Мимо 2 очка",
|
||||
"PlayInfo": "2х очковый бросок - промах"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 6,
|
||||
"PlayInfoSite": "Мимо 3 очка",
|
||||
"PlayInfo": "3х очковый бросок - промах"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 7,
|
||||
"PlayInfoSite": "Замена",
|
||||
"PlayInfo": "Замена игроков"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 8,
|
||||
"PlayInfoSite": "Выход",
|
||||
"PlayInfo": "Выход на площадку"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 9,
|
||||
"PlayInfoSite": "Уход",
|
||||
"PlayInfo": "Ушел с площадки"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 10,
|
||||
"PlayInfoSite": "Потеря",
|
||||
"PlayInfo": "Потеря"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 11,
|
||||
"PlayInfoSite": "Пас-потеря",
|
||||
"PlayInfo": "Потеря мяча при передаче"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 12,
|
||||
"PlayInfoSite": "Пробежка",
|
||||
"PlayInfo": "Пробежка"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 13,
|
||||
"PlayInfoSite": "Заступ в аут",
|
||||
"PlayInfo": "Заступ в аут"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 14,
|
||||
"PlayInfoSite": "Зона",
|
||||
"PlayInfo": "Зона"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 15,
|
||||
"PlayInfoSite": "Двойное ведение",
|
||||
"PlayInfo": "Двойное ведение"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 16,
|
||||
"PlayInfoSite": "3 секунды",
|
||||
"PlayInfo": "3 секунды"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 17,
|
||||
"PlayInfoSite": "5 секунд",
|
||||
"PlayInfo": "5 секунд"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 18,
|
||||
"PlayInfoSite": "8 секунд",
|
||||
"PlayInfo": "8 секунд"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 19,
|
||||
"PlayInfoSite": "24 секунды",
|
||||
"PlayInfo": "24 секунды"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 20,
|
||||
"PlayInfoSite": "Потеря мяча",
|
||||
"PlayInfo": "Потеря мяча"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 21,
|
||||
"PlayInfoSite": "Начало четверти",
|
||||
"PlayInfo": "Начало четверти?"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 22,
|
||||
"PlayInfoSite": "",
|
||||
"PlayInfo": "Окончание четверти?"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 23,
|
||||
"PlayInfoSite": "Тайм-аут",
|
||||
"PlayInfo": "Тайм-аут"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 24,
|
||||
"PlayInfoSite": "",
|
||||
"PlayInfo": "неизвестно"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 25,
|
||||
"PlayInfoSite": "Пас",
|
||||
"PlayInfo": "Передача"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 26,
|
||||
"PlayInfoSite": "Перехват",
|
||||
"PlayInfo": "Перехват"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 27,
|
||||
"PlayInfoSite": "Блокшот",
|
||||
"PlayInfo": "Блокшот"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 28,
|
||||
"PlayInfoSite": "Подбор",
|
||||
"PlayInfo": "Подбор"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 29,
|
||||
"PlayInfoSite": "Быстрый отрыв",
|
||||
"PlayInfo": "Быстрый отрыв"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 30,
|
||||
"PlayInfoSite": "Бросок сверху",
|
||||
"PlayInfo": "Тип броска"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 31,
|
||||
"PlayInfoSite": "В прыжке",
|
||||
"PlayInfo": "Тип броска"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 32,
|
||||
"PlayInfoSite": "В проходе",
|
||||
"PlayInfo": "Тип броска"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 33,
|
||||
"PlayInfoSite": "Добивание",
|
||||
"PlayInfo": "Тип броска"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 34,
|
||||
"PlayInfoSite": "Навес",
|
||||
"PlayInfo": "Тип броска"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 35,
|
||||
"PlayInfoSite": "Бросок крюком",
|
||||
"PlayInfo": "Тип броска"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 40,
|
||||
"PlayInfoSite": "Фол P",
|
||||
"PlayInfo": "Фол персональный"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 41,
|
||||
"PlayInfoSite": "Фол U",
|
||||
"PlayInfo": "Фол неспортивный"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 42,
|
||||
"PlayInfoSite": "Фол T",
|
||||
"PlayInfo": "Фол технический"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 43,
|
||||
"PlayInfoSite": "Фол D",
|
||||
"PlayInfo": "Фол дисквалифицирующий"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 44,
|
||||
"PlayInfoSite": "Фол C",
|
||||
"PlayInfo": "Фол технический главному тренеру за его личное неспортивное поведение"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 45,
|
||||
"PlayInfoSite": "Фол В",
|
||||
"PlayInfo": "Фол технический главному тренеру по любой другой причине"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 47,
|
||||
"PlayInfoSite": "В нападении",
|
||||
"PlayInfo": "Тип фола"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 50,
|
||||
"PlayInfoSite": "Вбрасывание",
|
||||
"PlayInfo": "Тип фола"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 51,
|
||||
"PlayInfoSite": "1 бросок",
|
||||
"PlayInfo": "Назначение 1го штрафного броска"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 52,
|
||||
"PlayInfoSite": "2 броска",
|
||||
"PlayInfo": "Назначение 2х штрафных бросков"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 53,
|
||||
"PlayInfoSite": "3 броска",
|
||||
"PlayInfo": "Назначение 3х штрафных бросков"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 54,
|
||||
"PlayInfoSite": "Компенсация",
|
||||
"PlayInfo": "Обоюдное пробивание штрафных"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 59,
|
||||
"PlayInfoSite": "",
|
||||
"PlayInfo": "пробел для сайта"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 60,
|
||||
"PlayInfoSite": "Разминка команд",
|
||||
"PlayInfo": "Разминка команд"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 61,
|
||||
"PlayInfoSite": "Представление команд",
|
||||
"PlayInfo": "Представление команд"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 62,
|
||||
"PlayInfoSite": "Менее 3 минут до начала игры",
|
||||
"PlayInfo": "Менее 3 минут до начала игры"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 63,
|
||||
"PlayInfoSite": "Игра сейчас начнется",
|
||||
"PlayInfo": "Игра сейчас начнется"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 69,
|
||||
"PlayInfoSite": "Видеопросмотр",
|
||||
"PlayInfo": "Видеопросмотр?"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 70,
|
||||
"PlayInfoSite": "",
|
||||
"PlayInfo": "Возможно остановка игры?"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 71,
|
||||
"PlayInfoSite": "",
|
||||
"PlayInfo": "Возможно возобновление игры?"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 72,
|
||||
"PlayInfoSite": "Видеопросмотр",
|
||||
"PlayInfo": "Видеопросмотр?"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 73,
|
||||
"PlayInfoSite": "Старт видеотрансляции",
|
||||
"PlayInfo": "Старт видеотрансляции"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 74,
|
||||
"PlayInfoSite": "Конец видеотрансляции",
|
||||
"PlayInfo": "Конец видеотрансляции"
|
||||
},
|
||||
{
|
||||
"PlayTypeID": 100,
|
||||
"PlayInfoSite": "Матч завершен",
|
||||
"PlayInfo": "Матч завершен"
|
||||
}
|
||||
]
|
||||
@@ -1,3 +1,5 @@
|
||||

|
||||
|
||||
RFB Stat - это система для автоматического сбора баскетбольной статистики.
|
||||
Система состоит из двух основных компонентов:
|
||||
|
||||
|
||||
32
deploy.sh
32
deploy.sh
@@ -7,13 +7,15 @@ YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
show_help() {
|
||||
echo "Использование: $0 -t <домашняя команда> -r <релиз>"
|
||||
echo "Использование: $0 -t <домашняя команда> -r <релиз> [-l <лига>]"
|
||||
echo " -t Домашняя команда"
|
||||
echo " -r Релиз (тег или ветка в git)"
|
||||
echo " -l Лига (опционально)"
|
||||
echo " -h Показать эту справку"
|
||||
echo ""
|
||||
echo "Пример: $0 -t cska -r main"
|
||||
echo "Пример: $0 -t zenit -r Barabanov_TEST"
|
||||
echo "Пример: $0 -t zenit -r Barabanov_TEST -l vtb"
|
||||
echo "Пример: $0 -t avtodor -r main"
|
||||
echo ""
|
||||
exit 0
|
||||
}
|
||||
@@ -177,8 +179,12 @@ print('✓ Все основные пакеты успешно импортир
|
||||
# Функция создания systemd сервисов
|
||||
create_systemd_services() {
|
||||
local team="$1"
|
||||
local league="$2"
|
||||
|
||||
log_info "Создание отдельных systemd сервисов для команды: $team"
|
||||
if [ -n "$league" ]; then
|
||||
log_info "Лига: $league"
|
||||
fi
|
||||
|
||||
# Останавливаем и отключаем старые сервисы если они есть
|
||||
for service in rfb-data.service rfb-visual.service rfb-stat.service; do
|
||||
@@ -192,6 +198,12 @@ create_systemd_services() {
|
||||
fi
|
||||
done
|
||||
|
||||
# Формируем команду для data сервиса
|
||||
local data_command="/root/RFB/.venv/bin/python3 /root/RFB/get_data.py --team \"$team\""
|
||||
if [ -n "$league" ]; then
|
||||
data_command="$data_command --league \"$league\""
|
||||
fi
|
||||
|
||||
# Сервис для data
|
||||
local data_service_file="/etc/systemd/system/rfb-data.service"
|
||||
|
||||
@@ -205,7 +217,7 @@ Type=simple
|
||||
User=root
|
||||
WorkingDirectory=/root/RFB
|
||||
Environment=PATH=/root/RFB/.venv/bin
|
||||
ExecStart=/root/RFB/.venv/bin/python3 /root/RFB/get_data.py --team $team
|
||||
ExecStart=$data_command
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
StandardOutput=journal
|
||||
@@ -393,12 +405,14 @@ check_services_status() {
|
||||
main() {
|
||||
local team=""
|
||||
local release="main" # значение по умолчанию
|
||||
local league="" # новая переменная для лиги
|
||||
|
||||
# Обработка аргументов командной строки
|
||||
while getopts "t:r:h" opt; do
|
||||
while getopts "t:r:l:h" opt; do
|
||||
case $opt in
|
||||
t) team="$OPTARG" ;;
|
||||
r) release="$OPTARG" ;;
|
||||
l) league="$OPTARG" ;;
|
||||
h) show_help ;;
|
||||
*) log_error "Неверный аргумент"; exit 1 ;;
|
||||
esac
|
||||
@@ -406,6 +420,11 @@ main() {
|
||||
|
||||
log_info "Начало установки RFB Stat..."
|
||||
log_info "Команда: $team, Релиз: $release"
|
||||
if [ -n "$league" ]; then
|
||||
log_info "Лига: $league"
|
||||
else
|
||||
log_info "Лига: не указана (будет использовано значение по умолчанию)"
|
||||
fi
|
||||
|
||||
# Проверка прав root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
@@ -439,7 +458,7 @@ main() {
|
||||
check_port
|
||||
|
||||
# Создание systemd сервисов
|
||||
create_systemd_services "$final_team"
|
||||
create_systemd_services "$final_team" "$league"
|
||||
|
||||
log_info "Настройка завершена!"
|
||||
|
||||
@@ -456,6 +475,9 @@ main() {
|
||||
log_info "Установка завершена успешно!"
|
||||
log_info "Приложение должно быть доступно по адресу: http://${ip_address}:8501"
|
||||
log_info "Команда: $final_team"
|
||||
if [ -n "$league" ]; then
|
||||
log_info "Лига: $league"
|
||||
fi
|
||||
log_info "Режим: $release"
|
||||
log_info ""
|
||||
log_info "Для просмотра логов:"
|
||||
|
||||
4639
get_data.py
4639
get_data.py
File diff suppressed because it is too large
Load Diff
1515
get_data_new.py
1515
get_data_new.py
File diff suppressed because it is too large
Load Diff
3165
get_data_old.py
Normal file
3165
get_data_old.py
Normal file
File diff suppressed because it is too large
Load Diff
2113
get_data_old2.py
Normal file
2113
get_data_old2.py
Normal file
File diff suppressed because it is too large
Load Diff
190
visual.py
190
visual.py
@@ -19,7 +19,7 @@ st.set_page_config(
|
||||
page_icon="🏀",
|
||||
layout="wide",
|
||||
initial_sidebar_state="expanded",
|
||||
menu_items={"About": "версия 2.0 от 08.10.2025"},
|
||||
menu_items={"About": "версия 3.2 от 23.10.2025"},
|
||||
)
|
||||
REMOVE_PADDING_FROM_SIDES = """
|
||||
<style>
|
||||
@@ -203,8 +203,6 @@ def process_player_data(team_json, player_index):
|
||||
"time": str(player_data["AvgCarPlayedTime"]),
|
||||
}
|
||||
|
||||
|
||||
|
||||
return [season_total, season_avg, career_total, career_avg], player_data
|
||||
|
||||
|
||||
@@ -285,11 +283,7 @@ if "player2" not in st.session_state:
|
||||
st.session_state.player2 = None
|
||||
|
||||
|
||||
myhost = platform.node()
|
||||
if sys.platform.startswith("win"): # было: if platform == "win32":
|
||||
FOLDER_JSON = "JSON"
|
||||
else:
|
||||
FOLDER_JSON = "static"
|
||||
FOLDER_JSON = "static"
|
||||
|
||||
|
||||
def get_ip_address():
|
||||
@@ -414,9 +408,7 @@ def rewrite_file(filename: str, data: dict, directory: str = "JSON") -> None:
|
||||
|
||||
os.makedirs(directory, exist_ok=True)
|
||||
|
||||
host_prefix = _ipcheck()
|
||||
|
||||
filepath = os.path.join(directory, f"{host_prefix}{filename}.json")
|
||||
filepath = os.path.join(directory, f"{filename}.json")
|
||||
# print(filepath) # оставил как у тебя; можно заменить на logger.debug при желании
|
||||
|
||||
try:
|
||||
@@ -431,53 +423,51 @@ ip_check = read_match_id_json("match_id.json") or {}
|
||||
|
||||
prefix = _ipcheck()
|
||||
|
||||
load_data_from_json(f"{prefix}game_online")
|
||||
cached_game_online = st.session_state.get("game_online")
|
||||
load_data_from_json("game")
|
||||
cached_game_online = st.session_state.get("game")
|
||||
|
||||
load_data_from_json(f"{prefix}team1")
|
||||
load_data_from_json("api_game")
|
||||
cached_api_game = st.session_state.get("api_game")
|
||||
|
||||
load_data_from_json("team1")
|
||||
cached_team1 = st.session_state.get("team1")
|
||||
|
||||
load_data_from_json(f"{prefix}team2")
|
||||
load_data_from_json("team2")
|
||||
cached_team2 = st.session_state.get("team2")
|
||||
|
||||
load_data_from_json(f"{prefix}referee")
|
||||
load_data_from_json("referee")
|
||||
cached_referee = st.session_state.get("referee")
|
||||
|
||||
# standings — может не быть тега/файла
|
||||
league_tag = None
|
||||
if isinstance(cached_game_online, dict):
|
||||
league_tag = ((cached_game_online.get("result") or {}).get("league") or {}).get(
|
||||
"tag"
|
||||
)
|
||||
comp_name = (
|
||||
((cached_game_online.get("result") or {}).get("comp") or {})
|
||||
.get("name")
|
||||
.replace(" ", "_")
|
||||
)
|
||||
if isinstance(cached_api_game, dict):
|
||||
league_tag = (cached_api_game["result"].get("league") or {}).get("tag")
|
||||
comp_name = (cached_api_game["result"].get("comp") or {}).get("name").replace(" ", "_").replace("|", "")
|
||||
if league_tag:
|
||||
load_data_from_json(f"{prefix}standings_{league_tag}_{comp_name}")
|
||||
load_data_from_json(f"standings_{league_tag}_{comp_name}")
|
||||
cached_standings = (
|
||||
st.session_state.get(f"standings_{league_tag}_{comp_name}") if league_tag else None
|
||||
)
|
||||
load_data_from_json(f"{prefix}scores_quarter")
|
||||
|
||||
load_data_from_json("scores_quarter")
|
||||
cached_scores_quarter = st.session_state.get("scores_quarter")
|
||||
|
||||
load_data_from_json(f"{prefix}play_by_play")
|
||||
load_data_from_json("play_by_play")
|
||||
cached_play_by_play = st.session_state.get("play_by_play")
|
||||
|
||||
load_data_from_json(f"{prefix}team_stats")
|
||||
load_data_from_json("team_stats")
|
||||
cached_team_stats = st.session_state.get("team_stats")
|
||||
|
||||
load_data_from_json(f"{prefix}scores")
|
||||
load_data_from_json("scores")
|
||||
cached_scores = st.session_state.get("scores") or [] # важно!
|
||||
|
||||
load_data_from_json(f"{prefix}live_status")
|
||||
cached_live_status = st.session_state.get("live_status")
|
||||
load_data_from_json("api_live-status")
|
||||
cached_live_status = st.session_state.get("api_live-status")
|
||||
|
||||
load_data_from_json(f"{prefix}schedule")
|
||||
load_data_from_json("schedule")
|
||||
cached_schedule = st.session_state.get("schedule")
|
||||
|
||||
load_data_from_json(f"{prefix}team_comparison")
|
||||
load_data_from_json("team_comparison")
|
||||
cached_team_comparison = st.session_state.get("team_comparison")
|
||||
|
||||
|
||||
@@ -569,8 +559,8 @@ if isinstance(cached_play_by_play, list) and isinstance(cached_game_online, dict
|
||||
timeout1 = []
|
||||
timeout2 = []
|
||||
|
||||
if isinstance(cached_game_online, dict):
|
||||
result = cached_game_online.get("result") or {}
|
||||
if isinstance(cached_api_game, dict):
|
||||
result = cached_api_game["result"]
|
||||
plays = result.get("plays") or []
|
||||
|
||||
timeout1, timeout2 = [], []
|
||||
@@ -585,6 +575,7 @@ if isinstance(cached_game_online, dict):
|
||||
|
||||
t1 = result.get("team1") or {}
|
||||
t2 = result.get("team2") or {}
|
||||
|
||||
if t1.get("logo"):
|
||||
col1.image(t1["logo"], width=100)
|
||||
team1_name = t1.get("name") or ""
|
||||
@@ -618,18 +609,16 @@ if isinstance(cached_game_online, dict):
|
||||
col4_3.metric("TimeOuts", len(timeout1))
|
||||
col5_1.metric("TimeOuts", len(timeout2))
|
||||
|
||||
if isinstance(cached_live_status, list) and cached_live_status:
|
||||
foulsA = (cached_live_status[0] or {}).get("foulsA")
|
||||
foulsB = (cached_live_status[0] or {}).get("foulsB")
|
||||
if isinstance([cached_live_status], list) and cached_live_status:
|
||||
foulsA = (cached_live_status["result"] or {}).get("foulsA")
|
||||
foulsB = (cached_live_status["result"] or {}).get("foulsB")
|
||||
if foulsA is not None:
|
||||
col4_2.metric("Fouls", foulsA)
|
||||
if foulsB is not None:
|
||||
col5_2.metric("Fouls", foulsB)
|
||||
|
||||
|
||||
if isinstance(cached_game_online, dict) and (
|
||||
(cached_game_online.get("result") or {}).get("plays") or []
|
||||
):
|
||||
if isinstance(cached_game_online, dict) and (cached_game_online.get("plays") or []):
|
||||
col_1_col = [f"col_1_{i}" for i in range(1, period_max + 1)]
|
||||
col_2_col = [f"col_2_{i}" for i in range(1, period_max + 1)]
|
||||
count_q = 0
|
||||
@@ -838,6 +827,7 @@ columns_game = [
|
||||
if cached_team1 and cached_team2:
|
||||
team1_data = process_team_data(cached_team1, columns_game)
|
||||
team2_data = process_team_data(cached_team2, columns_game)
|
||||
|
||||
# Добавляем звездочку, если pts > PTS_Career_High
|
||||
def _get_first_number(x):
|
||||
"""Безопасно вытащить число из строки/значения (например '12 (60%)' -> 12)."""
|
||||
@@ -847,6 +837,7 @@ if cached_team1 and cached_team2:
|
||||
s = str(x)
|
||||
# заберём ведущие число/знак (поддержим +/-)
|
||||
import re
|
||||
|
||||
m = re.search(r"[-+]?\d+(\.\d+)?", s)
|
||||
return float(m.group(0)) if m else None
|
||||
except Exception:
|
||||
@@ -859,7 +850,8 @@ if cached_team1 and cached_team2:
|
||||
"blk": ["BLK_Career_High", "CareerHighBlocks", "career_high_blk"],
|
||||
"reb": ["REB_Career_High", "CareerHighRebound", "career_high_reb"],
|
||||
# если нужно — добавь ещё пары "df_column": ["possible_key1","possible_key2"...]
|
||||
}
|
||||
}
|
||||
|
||||
def _build_career_high_map(cached_team_list):
|
||||
"""Вернёт словарь: player_id -> {stat_key: value} для всех доступных максимумов."""
|
||||
out = {}
|
||||
@@ -882,7 +874,9 @@ if cached_team1 and cached_team2:
|
||||
def _ensure_id_column(df, cached_team_list):
|
||||
"""Присвоить игрокам id в том же порядке, что и в списке cached_team."""
|
||||
try:
|
||||
ids = [p.get("id") if isinstance(p, dict) else None for p in cached_team_list][:len(df)]
|
||||
ids = [
|
||||
p.get("id") if isinstance(p, dict) else None for p in cached_team_list
|
||||
][: len(df)]
|
||||
if "id" not in df.columns:
|
||||
df["id"] = ids
|
||||
else:
|
||||
@@ -918,17 +912,24 @@ if cached_team1 and cached_team2:
|
||||
df[col] = new_vals # теперь это текст для отображения
|
||||
|
||||
STAR_COLUMNS = [
|
||||
"pts", "ast", "stl", "blk", "reb",
|
||||
]
|
||||
"pts",
|
||||
"ast",
|
||||
"stl",
|
||||
"blk",
|
||||
"reb",
|
||||
]
|
||||
team1_data["_pts_num"] = pd.to_numeric(team1_data["pts"], errors="coerce")
|
||||
team1_data["_kpi_num"] = pd.to_numeric(team1_data["kpi"], errors="coerce")
|
||||
team2_data["_pts_num"] = pd.to_numeric(team2_data["pts"], errors="coerce")
|
||||
team2_data["_kpi_num"] = pd.to_numeric(team2_data["kpi"], errors="coerce")
|
||||
|
||||
def highlight_max_by_refcol(df, view_col, ref_col):
|
||||
ref = pd.to_numeric(df[ref_col], errors="coerce")
|
||||
mx = ref.max()
|
||||
return [("background-color: green" if (pd.notna(v) and v == mx and v > 0) else "")
|
||||
for v in ref]
|
||||
return [
|
||||
("background-color: green" if (pd.notna(v) and v == mx and v > 0) else "")
|
||||
for v in ref
|
||||
]
|
||||
|
||||
_mark_star_for_columns(team1_data, cached_team1, STAR_COLUMNS)
|
||||
_mark_star_for_columns(team2_data, cached_team2, STAR_COLUMNS)
|
||||
@@ -947,18 +948,34 @@ if cached_team1 and cached_team2:
|
||||
# .apply(highlight_max, subset="kpi")
|
||||
# )
|
||||
team1_styled = (
|
||||
team1_data[columns_game].style
|
||||
.apply(highlight_grey, axis=1)
|
||||
team1_data[columns_game]
|
||||
.style.apply(highlight_grey, axis=1)
|
||||
.apply(highlight_foul, subset="foul")
|
||||
.apply(lambda _: highlight_max_by_refcol(team1_data, "pts", "_pts_num"), axis=0, subset=["pts"])
|
||||
.apply(lambda _: highlight_max_by_refcol(team1_data, "kpi", "_kpi_num"), axis=0, subset=["kpi"])
|
||||
.apply(
|
||||
lambda _: highlight_max_by_refcol(team1_data, "pts", "_pts_num"),
|
||||
axis=0,
|
||||
subset=["pts"],
|
||||
)
|
||||
.apply(
|
||||
lambda _: highlight_max_by_refcol(team1_data, "kpi", "_kpi_num"),
|
||||
axis=0,
|
||||
subset=["kpi"],
|
||||
)
|
||||
)
|
||||
team2_styled = (
|
||||
team2_data[columns_game].style
|
||||
.apply(highlight_grey, axis=1)
|
||||
team2_data[columns_game]
|
||||
.style.apply(highlight_grey, axis=1)
|
||||
.apply(highlight_foul, subset="foul")
|
||||
.apply(lambda _: highlight_max_by_refcol(team2_data, "pts", "_pts_num"), axis=0, subset=["pts"])
|
||||
.apply(lambda _: highlight_max_by_refcol(team2_data, "kpi", "_kpi_num"), axis=0, subset=["kpi"])
|
||||
.apply(
|
||||
lambda _: highlight_max_by_refcol(team2_data, "pts", "_pts_num"),
|
||||
axis=0,
|
||||
subset=["pts"],
|
||||
)
|
||||
.apply(
|
||||
lambda _: highlight_max_by_refcol(team2_data, "kpi", "_kpi_num"),
|
||||
axis=0,
|
||||
subset=["kpi"],
|
||||
)
|
||||
)
|
||||
|
||||
def get_player_all_game(player_data_1):
|
||||
@@ -1227,8 +1244,8 @@ column_config_ref = {
|
||||
def highlight_teams(s):
|
||||
try:
|
||||
if s.iloc[0] in (
|
||||
cached_game_online["result"]["team1"]["teamId"],
|
||||
cached_game_online["result"]["team2"]["teamId"],
|
||||
cached_api_game["result"]["team1"]["teamId"],
|
||||
cached_api_game["result"]["team2"]["teamId"],
|
||||
):
|
||||
return ["background-color: #FF4B4B"] * len(s)
|
||||
else:
|
||||
@@ -1242,16 +1259,10 @@ if cached_standings:
|
||||
|
||||
def highlight_teams(s):
|
||||
try:
|
||||
t1 = (
|
||||
((cached_game_online or {}).get("result") or {})
|
||||
.get("team1", {})
|
||||
.get("teamId")
|
||||
)
|
||||
t2 = (
|
||||
((cached_game_online or {}).get("result") or {})
|
||||
.get("team2", {})
|
||||
.get("teamId")
|
||||
)
|
||||
t1 = (cached_api_game["result"] or {}).get("team1", {}).get("teamId")
|
||||
t2 = (cached_api_game["result"] or {}).get("team2", {}).get("teamId")
|
||||
if s.iloc[0] in (t1, t2):
|
||||
return ["background-color: #FF4B4B"] * len(s)
|
||||
if s.iloc[0] in (t1, t2):
|
||||
return ["background-color: #FF4B4B"] * len(s)
|
||||
except Exception:
|
||||
@@ -1282,7 +1293,7 @@ if cached_standings:
|
||||
column_config={"logo": st.column_config.ImageColumn("logo")},
|
||||
hide_index=True,
|
||||
height=610,
|
||||
width="content"
|
||||
width="content",
|
||||
)
|
||||
|
||||
|
||||
@@ -1348,7 +1359,7 @@ if isinstance(cached_scores_quarter, list) and len(cached_scores_quarter) >= 2:
|
||||
|
||||
|
||||
if isinstance(cached_play_by_play, list) and isinstance(cached_game_online, dict):
|
||||
plays = (cached_game_online.get("result") or {}).get("plays") or []
|
||||
plays = cached_game_online.get("plays") or []
|
||||
if plays:
|
||||
tab_temp_6.table(cached_play_by_play)
|
||||
|
||||
@@ -1858,8 +1869,7 @@ try:
|
||||
except (FileNotFoundError, json.JSONDecodeError):
|
||||
play_type_id = []
|
||||
|
||||
teams_section = ((cached_game_online or {}).get("result") or {}).get("teams") or {}
|
||||
|
||||
teams_section = (cached_game_online or {}).get("teams") or {}
|
||||
# Если teams_section — список (например, [{"starts": [...]}, {...}])
|
||||
if isinstance(teams_section, list):
|
||||
if len(teams_section) >= 2:
|
||||
@@ -1872,6 +1882,7 @@ if isinstance(teams_section, list):
|
||||
else:
|
||||
starts1 = []
|
||||
starts2 = []
|
||||
|
||||
# Если teams_section — словарь (обычно {"1": {...}, "2": {...}})
|
||||
elif isinstance(teams_section, dict):
|
||||
starts1 = (teams_section.get(1) or teams_section.get("1") or {}).get("starts") or []
|
||||
@@ -1917,6 +1928,41 @@ def get_event_time(row):
|
||||
return None
|
||||
|
||||
|
||||
teams_section = (cached_game_online or {}).get("teams") or {}
|
||||
|
||||
# Если teams_section — список (например, [{"starts": [...]}, {...}])
|
||||
if isinstance(teams_section, list):
|
||||
if len(teams_section) >= 2:
|
||||
starts1 = next(
|
||||
(t.get("starts") for t in teams_section if t["teamNumber"] == 1), None
|
||||
)
|
||||
starts2 = next(
|
||||
(t.get("starts") for t in teams_section if t["teamNumber"] == 2), None
|
||||
)
|
||||
else:
|
||||
starts1 = []
|
||||
starts2 = []
|
||||
# Если teams_section — словарь (обычно {"1": {...}, "2": {...}})
|
||||
elif isinstance(teams_section, dict):
|
||||
starts1 = (teams_section.get(1) or teams_section.get("1") or {}).get("starts") or []
|
||||
starts2 = (teams_section.get(2) or teams_section.get("2") or {}).get("starts") or []
|
||||
else:
|
||||
starts1 = []
|
||||
starts2 = []
|
||||
|
||||
teams_temp = sorted(
|
||||
[x for x in starts1 if isinstance(x, dict)], key=lambda x: x.get("playerNumber", 0)
|
||||
) + sorted(
|
||||
[x for x in starts2 if isinstance(x, dict)], key=lambda x: x.get("playerNumber", 0)
|
||||
)
|
||||
|
||||
list_fullname = [None] + [
|
||||
f"({x.get('displayNumber')}) {x.get('firstName','')} {x.get('lastName','')}".strip()
|
||||
for x in teams_temp
|
||||
if x.get("startRole") == "Player"
|
||||
]
|
||||
|
||||
plays = plays if 'plays' in locals() else []
|
||||
with tab_pbp:
|
||||
plays = ((cached_game_online or {}).get("result") or {}).get("plays") or []
|
||||
if plays:
|
||||
|
||||
Reference in New Issue
Block a user