2025-07-29 16:24:44 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
# Module: default
|
|
|
|
|
# Author: cache
|
|
|
|
|
# Created on: 10.5.2020
|
|
|
|
|
# License: AGPL v.3 https://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
import galdPl
|
2025-07-29 16:46:47 +02:00
|
|
|
import requests
|
2025-07-29 18:24:01 +02:00
|
|
|
import re
|
2025-07-29 16:46:47 +02:00
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
def get_json_files_from_folder(folder):
|
|
|
|
|
base_url = "https://git.gald.site/gald/galdistream/src/branch/main/resources/"
|
|
|
|
|
url = base_url + folder
|
|
|
|
|
r = requests.get(url, timeout=10)
|
|
|
|
|
r.raise_for_status()
|
2025-07-29 18:24:01 +02:00
|
|
|
|
|
|
|
|
# Hledáme JSON soubory pomocí regex
|
|
|
|
|
json_pattern = r'href="(/gald/galdistream/src/branch/main/resources/[^"]*\.json)"'
|
|
|
|
|
matches = re.findall(json_pattern, r.text)
|
|
|
|
|
|
2025-07-29 16:46:47 +02:00
|
|
|
files = []
|
2025-07-29 18:24:01 +02:00
|
|
|
for match in matches:
|
|
|
|
|
# Extrahujeme pouze název souboru
|
|
|
|
|
file_name = match.split("/")[-1]
|
|
|
|
|
files.append(file_name)
|
2025-07-29 16:46:47 +02:00
|
|
|
return files
|
|
|
|
|
|
|
|
|
|
def update_json_db():
|
|
|
|
|
base_url_raw = "https://git.gald.site/gald/galdistream/raw/branch/main/resources/"
|
|
|
|
|
folders = ["movies", "series"]
|
|
|
|
|
all_files = []
|
|
|
|
|
for folder in folders:
|
|
|
|
|
try:
|
2025-07-29 16:56:19 +02:00
|
|
|
files = get_json_files_from_folder(folder)
|
|
|
|
|
all_files += [f"{folder}/{file}" for file in files]
|
2025-07-29 16:46:47 +02:00
|
|
|
except Exception as e:
|
|
|
|
|
print(f"Chyba při získávání souborů ze složky {folder}: {e}")
|
|
|
|
|
for file in all_files:
|
|
|
|
|
url = base_url_raw + file
|
|
|
|
|
local_path = "resources/" + file
|
|
|
|
|
try:
|
|
|
|
|
r = requests.get(url, timeout=10)
|
|
|
|
|
r.raise_for_status()
|
|
|
|
|
os.makedirs(os.path.dirname(local_path), exist_ok=True)
|
|
|
|
|
with open(local_path, "wb") as f:
|
|
|
|
|
f.write(r.content)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(f"Chyba při stahování {file}: {e}")
|
2025-07-29 16:24:44 +02:00
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2025-07-29 16:46:47 +02:00
|
|
|
update_json_db()
|
2025-07-29 16:24:44 +02:00
|
|
|
galdPl.router(sys.argv[2][1:])
|