/
maybeyoou
/
123as
Обзор
Документация
Войти
/
maybeyoou
/
123as
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
github/workflows/meta.yml
89 строк
2 KB
maybeyoou
Create: meta.yml
30 июн 2026, 03:16
Верифицирован
30 июн 2026, 03:16
4f3ab61
Код
Авторство
О чём код?
name: YouTube Metadata Fetch on: push: paths: - id.txt workflow_dispatch: jobs: meta: runs-on: ubuntu-latest steps: - name: Checkout repo uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install yt-dlp run: | python -m pip install --upgrade pip pip install yt-dlp - name: Read IDs and fetch metadata run: | python - << 'EOF' import json import subprocess from pathlib import Path ids_file = Path("id.txt") output_file = Path("data.txt") if not ids_file.exists(): raise SystemExit("id.txt not found") video_ids = [line.strip() for line in ids_file.read_text().splitlines() if line.strip()] results = [] for vid in video_ids: url = vid if not vid.startswith("http"): url = f"https://www.youtube.com/watch?v={vid}" cmd = [ "yt-dlp", "-J", url ] try: raw = subprocess.check_output(cmd) info = json.loads(raw) metadata = { "id": info.get("id"), "title": info.get("title"), "uploader": info.get("uploader"), "upload_date": info.get("upload_date"), "duration": info.get("duration"), "view_count": info.get("view_count"), "url": url } results.append(metadata) except Exception as e: results.append({ "id": vid, "error": str(e) }) output_file.write_text(json.dumps(results, indent=2, ensure_ascii=False)) print("Saved metadata for", len(results), "videos") EOF - name: Commit results run: | git config user.name "github-actions" git config user.email "github-actions@github.com" git add data.txt git commit -m "Update video metadata" || echo "No changes to commit" git push