feat: persistent /movies volume, nginx location, build_catalog.sh

This commit is contained in:
Hermes committed 2026-08-08 02:53:58 +02:00
1 parent 9a700f8a2b
commit 2306974e1a
5 files changed
+87 -1

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
FROM nginx:alpine FROM nginx:alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY . /usr/share/nginx/html COPY . /usr/share/nginx/html
RUN mkdir -p /usr/share/nginx/html/movies
+79
View File
@@ -0,0 +1,79 @@
#!/usr/bin/env bash
# Сборка catalog.json из папок фильмов.
# Запускать НА spb-easy-dale (где смонтирован volume):
# bash /data/coolify/applications/e9ghwyp5n5kyfshk55krbhki/build_catalog.sh
#
# Структура (ты заливаешь по SSH в MOVIES_DIR):
# <id>/
# poster.jpg (обложка, имя неважно, берётся первая .jpg/.png)
# *.torrent (торрент, берётся первый .torrent)
# meta.txt (поля через "key: value", см. ниже)
#
# meta.txt поддерживает: title, original_title, year, genre(через запятую),
# rating, description. Если meta.txt нет — берётся <id> как title.
set -euo pipefail
MOVIES_DIR="/data/coolify/applications/e9ghwyp5n5kyfshk55krbhki/movies"
OUT="$MOVIES_DIR/catalog.json"
[[ -d "$MOVIES_DIR" ]] || { echo "Нет папки $MOVIES_DIR"; exit 1; }
python3 - "$MOVIES_DIR" "$OUT" <<'PY'
import sys, os, json, datetime
movies_dir, out = sys.argv[1], sys.argv[2]
movies = []
for entry in sorted(os.listdir(movies_dir)):
d = os.path.join(movies_dir, entry)
if not os.path.isdir(d) or entry.startswith('.'):
continue
meta = {'id': entry}
# читаем meta.txt
metafile = os.path.join(d, 'meta.txt')
if os.path.exists(metafile):
for line in open(metafile, encoding='utf-8'):
line = line.strip()
if not line or ':' not in line:
continue
k, v = line.split(':', 1)
k, v = k.strip().lower(), v.strip()
if k in ('genre',):
meta['genre'] = [x.strip() for x in v.split(',') if x.strip()]
elif k in ('year',):
meta['year'] = int(v)
elif k in ('rating',):
meta['rating'] = float(v)
elif k in ('title', 'original_title', 'description'):
meta[k] = v
# обложка
poster = None
for f in os.listdir(d):
if f.lower().endswith(('.jpg', '.jpeg', '.png', '.webp')):
poster = f; break
if poster:
meta['poster'] = f"movies/{entry}/{poster}"
# торрент
torrent = None
for f in os.listdir(d):
if f.lower().endswith('.torrent'):
torrent = f; break
if torrent:
meta['torrent'] = f"movies/{entry}/{torrent}"
# fallback title
if 'title' not in meta:
meta['title'] = entry
movies.append(meta)
catalog = {
'name': 'Мой видеокаталог',
'updated': datetime.date.today().isoformat(),
'movies': movies,
}
with open(out, 'w', encoding='utf-8') as f:
json.dump(catalog, f, ensure_ascii=False, indent=2)
print(f'Готово: {len(movies)} фильм(ов) -> {out}')
for m in movies:
print(' -', m.get('title'), m.get('year', ''))
PY
View File
Whitespace-only changes.
+6
View File
@@ -23,6 +23,12 @@ server {
try_files $uri =404; try_files $uri =404;
} }
# Папка фильмов (persistent volume, монтируется в /movies)
location /movies/ {
add_header Access-Control-Allow-Origin * always;
try_files $uri $uri/ =404;
}
location / { location / {
try_files $uri $uri/ =404; try_files $uri $uri/ =404;
} }
+1 -1
View File
@@ -23,7 +23,7 @@
var content = comp.activity.render().find('.main__content'); var content = comp.activity.render().find('.main__content');
content.html('<div class="mymovies"><div class="movies-grid"></div></div>'); content.html('<div class="mymovies"><div class="movies-grid"></div></div>');
fetch(base() + 'catalog.json') fetch(base() + 'movies/catalog.json')
.then(function (r) { return r.json(); }) .then(function (r) { return r.json(); })
.then(function (data) { .then(function (data) {
comp.activity.loader(false); comp.activity.loader(false);