# वीडियो IDs की एक फ़ाइल को समृद्ध करें

एक YouTube ID फ़ाइल को मेटाडाटा JSON और CSV में बदल देता है, जिसमें एक परिणाम प्रति वीडियो होता है। FlashData CLI के साथ Python या Bash का उपयोग करें।

कैनोनिकल संदर्भ: https://flashdata.dev/hi/docs/guides/bulk-metadata-recipe
समीक्षित: 2026-11-05 द्वारा FlashData

<a id="prepare"></a>

## शुरू करने से पहले

उपयोग FlashData CLI v.1.2.1 पर PATH, प्लस Python 3.10+ (केवल मानक पुस्तकालय), या Bash साथ jq और OpenSSL. दोनों संस्करण अपलोड, नौकरी वसूली और परिणाम-भाग पुनर्प्राप्ति के लिए CLI का उपयोग करते हैं। Windows पर, Git Bash का उपयोग Bash संस्करण के लिए किया जाता है।

आपको youtube_metadata अनुमति और उपलब्ध क्रेडिट के साथ मालिक API कुंजी की आवश्यकता है। अपने बचे मालिक लॉगिन का उपयोग करें, या एक बार auth login चलाएं और अपने छिपे हुए प्रॉम्प्ट पर कुंजी दर्ज करें। एजेंट अपने गुप्त स्टोर से FLASHDATA_API_KEY की आपूर्ति कर सकते हैं।

ये उदाहरण डिफ़ॉल्ट CLI प्रोफ़ाइल और राज्य निर्देशिका का उपयोग करते हैं। उसी खाते को रखें और पुनर्प्राप्ति के लिए राज्य बचा लिया। यदि auth status अस्थायी पहुंच दिखाता है, तो Bulk शुरू करने से पहले इसका दावा करें।

### अगर आपके पास कोई सेव्ड मालिक लॉगिन नहीं है

```bash
flashdata auth login
```

### इस दो-वीडियो उदाहरण की पहुंच और लागत की जांच करें

```bash
flashdata --version
flashdata auth status --json
flashdata account balance --json
flashdata account pricing --source youtube_metadata --request-count 2 --json
flashdata account limits --json
```

- [CLI स्थापित करें](https://flashdata.dev/hi/docs/guides/flashdata-cli/reference.md#install)
- [API कुंजी लें](https://flashdata.dev/app/api-keys)
- [एजेंट ट्रायल और खाता लिंक करना](https://flashdata.dev/hi/docs/guides/agent-onboarding/reference.md)

<a id="input"></a>

## 1. वीडियो तैयार करें IDs

थोक संवर्धन फ़ोल्डर बनाएं और वहां video-ids.txt को सहेजें। उस फ़ोल्डर में एक टर्मिनल खोलें। एक 11-character ID प्रति लाइन का उपयोग करें, एक हेडर, खाली लाइन या पूर्ण YouTube URLs के बिना।

एक तैयारी स्क्रिप्ट चुनें और इसे video-ids.txt के बगल में सहेजें। यह अवैध और डुप्लिकेट IDs को अस्वीकार करता है, फिर prepared/. के तहत एक सामान्यीकृत इनपुट स्नैपशॉट, मेटाडाटा विकल्प और रन ID को बचाता है। इनपुट ऑर्डर संरक्षित है।

### bulk-enrichment/video-ids.txt

```text
jNQXAC9IVRw
dQw4w9WgXcQ
```

### Python

#### bulk-enrichment/prepare.py

```python
# Save as bulk-enrichment/prepare.py. Python 3.10+, standard library only.
import hashlib
import json
import os
import re
import sys
from pathlib import Path
from subprocess import run, CalledProcessError, DEVNULL

ROOT = Path(__file__).resolve().parent
try:
    os.umask(0o077)
    run_id = sys.argv[1]
    if not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9_.:@+-]{0,159}", run_id):
        raise ValueError("Choose a valid, stable run ID.")
    ids = (ROOT / "video-ids.txt").read_text(encoding="utf-8-sig").splitlines()
    ids = [line.strip() for line in ids]
    if not ids or any(not re.fullmatch(r"[A-Za-z0-9_-]{11}", value) for value in ids):
        raise ValueError("Use one 11-character video ID per line, with no blank rows or URLs.")
    if len(set(ids)) != len(ids):
        raise ValueError("Remove duplicate IDs before submitting; they would be processed separately.")
    data = ("\n".join(ids) + "\n").encode("utf-8")
    prepared = ROOT / "prepared"
    prepared.mkdir(mode=0o700)  # Refuse to overwrite an existing input snapshot.
    (prepared / "video-ids.txt").write_bytes(data)
    (prepared / "options.json").write_text(json.dumps({
        "include_formats": False, "include_chapters": False,
    }, indent=2), encoding="utf-8")
    if os.name == "nt":
        # The CLI requires a private options file, including on Windows.
        command = """
$ErrorActionPreference = 'Stop'
$path = [System.IO.Path]::GetFullPath("./prepared/options.json")
$user = [System.Security.Principal.WindowsIdentity]::GetCurrent().User
$acl = [System.Security.AccessControl.FileSecurity]::new()
$acl.SetAccessRuleProtection($true, $false)
$acl.AddAccessRule([System.Security.AccessControl.FileSystemAccessRule]::new($user, 'FullControl', 'Allow'))
[System.IO.File]::SetAccessControl($path, $acl)
"""
        run(["powershell.exe", "-NoProfile", "-NonInteractive", "-Command", command],
            cwd=ROOT, stdin=DEVNULL, check=True, capture_output=True)
    plan = {"run_id": run_id, "source": "youtube_metadata", "input_count": len(ids),
            "input_sha256": hashlib.sha256(data).hexdigest()}
    (prepared / "plan.json").write_text(json.dumps(plan, indent=2), encoding="utf-8")
    print("Prepared", len(ids), "unique videos for", run_id)
except (IndexError, OSError, ValueError, CalledProcessError) as error:
    print(str(error), file=sys.stderr)
    sys.exit(1)
```

#### थोक संवर्धन से भागो/

```bash
python prepare.py videos-001
```


### Bash

#### स्थानीय उपकरण की जाँच करें

```bash
jq --version
openssl version
```

#### bulk-enrichment/prepare.sh

```bash
#!/usr/bin/env bash
# Save as bulk-enrichment/prepare.sh.
set -euo pipefail
trap 'exit 1' ERR
umask 077
cd -- "$(dirname -- "$0")"
case "$(uname -s)" in
  MINGW*|MSYS*|CYGWIN*) jq() { command jq --binary "$@"; } ;;
esac
run_id=${1:?Usage: bash prepare.sh videos-001}
[[ "$run_id" =~ ^[A-Za-z0-9][A-Za-z0-9_.:@+-]{0,159}$ ]] || exit 2
# Validate before creating the snapshot; normalize BOM, CRLF and surrounding spaces.
ids=$(jq -Rsc '
  sub("^\uFEFF"; "") | split("\n")
  | if .[-1] == "" then .[:-1] else . end
  | map(gsub("^\\s+|\\s+$"; ""))
  | if length == 0 or any(.[]; test("^[A-Za-z0-9_-]{11}$") | not)
    then error("Use one 11-character ID per line, with no blank rows or URLs.")
    elif length != (unique | length)
    then error("Remove duplicate IDs before submitting.")
    else . end
' video-ids.txt)
mkdir prepared
printf '%s' "$ids" | jq -r '.[]' > prepared/video-ids.txt
printf '%s\n' '{"include_formats":false,"include_chapters":false}' > prepared/options.json
case "$(uname -s)" in
  MINGW*|MSYS*|CYGWIN*)
    powershell.exe -NoProfile -NonInteractive -Command '
      $ErrorActionPreference = "Stop"
      $path = [System.IO.Path]::GetFullPath("./prepared/options.json")
      $user = [System.Security.Principal.WindowsIdentity]::GetCurrent().User
      $acl = [System.Security.AccessControl.FileSecurity]::new()
      $acl.SetAccessRuleProtection($true, $false)
      $acl.AddAccessRule([System.Security.AccessControl.FileSystemAccessRule]::new($user, "FullControl", "Allow"))
      [System.IO.File]::SetAccessControl($path, $acl)
    ' </dev/null ;;
esac
hash=$(openssl dgst -sha256 prepared/video-ids.txt | awk '{print $NF}')
printf '%s' "$ids" | jq --arg run "$run_id" --arg hash "$hash" '
  {run_id:$run, source:"youtube_metadata", input_count:length, input_sha256:$hash}
' > prepared/plan.json
jq '"Prepared \(.input_count) unique videos for \(.run_id)"' -r prepared/plan.json
```

#### थोक संवर्धन से भागो/

```bash
bash prepare.sh videos-001
```



<a id="plan"></a>

### क्या तैयार है?

Expect Prepared 2 वीडियो-001 के लिए अद्वितीय वीडियो। तैयार / अपरिवर्तित रखें मेटाडाटा include_formats: false और include_chapters: false का उपयोग करता है। प्रत्येक स्वीकृत वीडियो एक अलग बिलेबल आइटम है; डुप्लिकेट लाइनों को अलग से संसाधित किया जाएगा, इसलिए यह नुस्खा उन्हें जमा करने से पहले बंद हो जाता है।

एक रन ID का उपयोग करें जिसका उपयोग आप एक अलग कार्य के लिए नहीं किया है। इस कार्य के लिए वीडियो-001 को बनाए रखने और पुनर्प्राप्ति। एक नया रन ID एक जानबूझकर नए डेटासेट या रीफ्रेश के लिए है।

- [मेटाडाटा क्षेत्र चुनें](https://flashdata.dev/hi/docs/guides/video-metadata-recipe/reference.md#fields)

<a id="submit"></a>

## 2. परिणाम जमा करना और इकट्ठा करना

इसे चलाने से पहले process.py या process.sh को बल्क-इनरिचमेंट में सेव करें। CLI एक Bulk नौकरी बनाता है, तैयार IDs को अपलोड करता है, प्रत्येक परिणाम को bulk-results.ndjson में संसाधित करना शुरू कर देता है। 30 मिनट के बाद स्थानीय प्रतीक्षा बंद हो जाती है; स्वीकृत सर्वर कार्य जारी रहता है।

प्रत्येक प्रयास को प्रयास के तहत अपना फ़ोल्डर प्राप्त होता है /, CLI रसीद, त्रुटि और बचाया रन के साथ। ready.txt नवीनतम पूर्ण परिणाम के लिए अंक। Exit 2 का मतलब है कि पूर्ण परिणामों में असफल वीडियो शामिल हैं; उन पंक्तियों को निर्यात और निरीक्षण करना जारी रखें।

### Python

#### bulk-enrichment/process.py

```python
# Save as bulk-enrichment/process.py. Requires the FlashData CLI on PATH.
import hashlib
import json
import os
import sys
import tempfile
from pathlib import Path
from subprocess import run, DEVNULL

ROOT = Path(__file__).resolve().parent


def read_json(path):
    return json.loads(path.read_text(encoding="utf-8"))


def main(action):
    os.umask(0o077)
    plan = read_json(ROOT / "prepared/plan.json")
    ids = ROOT / "prepared/video-ids.txt"
    if hashlib.sha256(ids.read_bytes()).hexdigest() != plan["input_sha256"]:
        raise ValueError("The prepared input changed. Restore it before recovery.")
    # Use the same default profile and state directory as auth login/status.
    flags = ["--json", "--non-interactive"]
    def cli(*args):
        return run(["flashdata", *args, *flags], cwd=ROOT, stdin=DEVNULL,
                   capture_output=True, text=True, encoding="utf-8")
    if action == "status":
        result = cli("runs", "show", plan["run_id"])
        if result.returncode:
            raise ValueError(result.stderr)
        saved = json.loads(result.stdout)["data"]
        print(json.dumps({k: saved.get(k) for k in
                          ("id", "remoteId", "status", "stage", "errorCode")}, indent=2))
        if saved.get("remoteId"):
            result = cli("bulk", "get", saved["remoteId"])
            print(result.stdout or result.stderr)
            return result.returncode
        return 0
    if action not in ("submit", "recover"):
        raise ValueError("Choose submit, status or recover.")
    attempts = ROOT / "attempts"
    attempts.mkdir(exist_ok=True)
    directory = Path(tempfile.mkdtemp(prefix="run-", dir=attempts))
    output = str(directory / "bulk-results.ndjson")
    if action == "submit":
        args = ["bulk", "run", "--source", plan["source"], "--input", str(ids),
                "--options", str(ROOT / "prepared/options.json"), "--run-id", plan["run_id"]]
    else:
        args = ["runs", "recover", plan["run_id"]]
    result = cli(*args, "--output", output, "--timeout", "30m")
    (directory / "receipt.json").write_text(result.stdout, encoding="utf-8")
    (directory / "error.json").write_text(result.stderr, encoding="utf-8")
    (directory / "exit-code.txt").write_text(str(result.returncode))
    print("Attempt:", directory.relative_to(ROOT))
    # bulk_item_failures still includes a complete result file with failed rows.
    code = json.loads(result.stderr).get("error", {}).get("code") if result.stderr.strip() else None
    if result.returncode and code != "bulk_item_failures":
        raise ValueError("Collection stopped. Inspect error.json; recover the same run.")
    saved = cli("runs", "show", plan["run_id"])
    (directory / "run.json").write_text(saved.stdout, encoding="utf-8")
    if saved.returncode or not Path(output).is_file():
        raise ValueError("Could not save the run record and results together.")
    record = json.loads(saved.stdout)
    data = record.get("data", {})
    if (not record.get("ok") or data.get("status") != "succeeded"
            or data.get("id") != plan["run_id"] or data.get("source") != plan["source"]
            or data.get("inputFileHash") != plan["input_sha256"]):
        raise ValueError("Inspect the run/input binding before exporting.")
    pointer = ROOT / "ready.next"
    pointer.write_text(directory.relative_to(ROOT).as_posix(), encoding="utf-8")
    pointer.replace(ROOT / "ready.txt")
    print("Results ready for export." if code is None else "Results ready; inspect failed video rows.")
    return 2 if code == "bulk_item_failures" else 0


if __name__ == "__main__":
    try:
        sys.exit(main(sys.argv[1]))
    except (IndexError, KeyError, OSError, ValueError) as error:
        print(str(error), file=sys.stderr)
        sys.exit(1)
```

#### तैयार फ़ाइल की प्रक्रिया

```bash
python process.py submit
```


### Bash

#### bulk-enrichment/process.sh

```bash
#!/usr/bin/env bash
# Save as bulk-enrichment/process.sh. Requires the FlashData CLI on PATH.
set -euo pipefail
umask 077
cd -- "$(dirname -- "$0")"
case "$(uname -s)" in
  MINGW*|MSYS*|CYGWIN*) jq() { command jq --binary "$@"; } ;;
esac
action=${1:?Usage: bash process.sh submit|status|recover}
plan=prepared/plan.json
run_id=$(jq -er '.run_id' "$plan")
hash=$(openssl dgst -sha256 prepared/video-ids.txt | awk '{print $NF}')
jq -e --arg hash "$hash" '.source == "youtube_metadata" and .input_sha256 == $hash' "$plan" >/dev/null
# Keep the same default profile and state directory as auth login/status.
cli=(flashdata --json --non-interactive)
if [[ "$action" == status ]]; then
  saved=$("${cli[@]}" runs show "$run_id")
  printf '%s' "$saved" | jq '.data | {id,remoteId,status,stage,errorCode}'
  remote=$(printf '%s' "$saved" | jq -r '.data.remoteId // empty')
  [[ -z "$remote" ]] || "${cli[@]}" bulk get "$remote"
  exit 0
fi
case "$action" in
  submit) args=(bulk run --source youtube_metadata --input prepared/video-ids.txt
    --options prepared/options.json --run-id "$run_id") ;;
  recover) args=(runs recover "$run_id") ;;
  *) echo 'Choose submit, status or recover.' >&2; exit 2 ;;
esac
mkdir -p attempts
directory=$(mktemp -d attempts/run-XXXXXX)
exit_code=0
"${cli[@]}" "${args[@]}" --output "$directory/bulk-results.ndjson" --timeout 30m \
  > "$directory/receipt.json" 2> "$directory/error.json" || exit_code=$?
printf '%s' "$exit_code" > "$directory/exit-code.txt"
echo "Attempt: $directory"
code=$(jq -r '.error.code // empty' "$directory/error.json")
if [[ "$exit_code" != 0 && "$code" != bulk_item_failures ]]; then
  echo "Collection stopped. Inspect $directory/error.json; recover the same run." >&2
  exit 1
fi
"${cli[@]}" runs show "$run_id" > "$directory/run.json"
test -f "$directory/bulk-results.ndjson"
jq -e --arg run "$run_id" --arg hash "$hash" '
  .ok and .data.status == "succeeded" and .data.id == $run
  and .data.source == "youtube_metadata" and .data.inputFileHash == $hash
' "$directory/run.json" >/dev/null
printf '%s\n' "$directory" > ready.next
mv ready.next ready.txt
echo 'Results ready for export.'
[[ "$code" != bulk_item_failures ]] || { echo 'Inspect failed video rows.'; exit 2; }
```

#### तैयार फ़ाइल की प्रक्रिया

```bash
bash process.sh submit
```



<a id="status"></a>

### किसी अन्य टर्मिनल से प्रगति की जाँच करें

एक ही CLI खाते के साथ थोक संवर्धन से भागो। स्टेटस एक्शन सेव्ड रन दिखाता है और इसकी दूरस्थ Bulk जॉब को पढ़ता है जब एक ID उपलब्ध होता है। यह काम नहीं करता है या फिर से शुरू नहीं करता है।

#### Python

##### वर्तमान प्रगति पढ़ें

```bash
python process.py status
```


#### Bash

##### वर्तमान प्रगति पढ़ें

```bash
bash process.sh status
```



<a id="output"></a>

## 3. Reconcile और निर्यात

export.py या export.sh को अन्य लिपियों के बगल में सहेजें, फिर इसे चलाएं। यह सहेजे गए रन और इनपुट हैश की जाँच करता है, फिर शून्य-आधारित इंडेक्स और video_id द्वारा हर परिणाम से मेल खाता है। परिणाम भाग ऑर्डर से बाहर आ सकते हैं। मिसिंग, डुप्लिकेट या गलत पंक्तियों ने निर्यात को रोक दिया।

निर्यातक प्रत्येक पंक्ति के लिए पूर्ण मेटाडाटा ऑब्जेक्ट, त्रुटि और रिपोर्ट उपयोग को बनाए रखता है। विफल वीडियो metadata: null के साथ दिखाई देते हैं। यह छोटा उदाहरण परिणामों को स्मृति में लोड करता है; एक बड़े डेटासेट के लिए Bulk फ़ाइल प्रोसेसिंग में स्ट्रीमिंग ऑडिट का उपयोग करें।

### Python

#### bulk-enrichment/export.py

```python
# Save as bulk-enrichment/export.py. Local files only; no API calls.
import csv
import hashlib
import json
import os
import re
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parent
try:
    os.umask(0o077)
    directory = (ROOT / "ready.txt").read_text(encoding="utf-8").strip()
    if not re.fullmatch(r"attempts/run-[A-Za-z0-9_-]+", directory):
        raise ValueError("Use the ready.txt written by process.py or process.sh.")
    directory = ROOT / directory
    def read_json(path):
        return json.loads(path.read_text(encoding="utf-8"))
    plan = read_json(ROOT / "prepared/plan.json")
    raw = (ROOT / "prepared/video-ids.txt").read_bytes()
    ids = raw.decode("utf-8").splitlines()
    saved = read_json(directory / "run.json")
    run = saved["data"]
    digest = hashlib.sha256(raw).hexdigest()
    if (not saved.get("ok") or run.get("status") != "succeeded" or run.get("kind") != "bulk:run"
            or run.get("id") != plan["run_id"] or run.get("source") != "youtube_metadata"
            or run.get("inputFileHash") != digest or plan["input_sha256"] != digest
            or plan["input_count"] != len(ids) or not run.get("remoteId")):
        raise ValueError("The saved run does not match this input file.")
    # This recipe loads a small file into memory to validate it before writing exports.
    records = {}
    with (directory / "bulk-results.ndjson").open(encoding="utf-8") as source:
        for line in source:
            row = json.loads(line)
            index = row.get("index")
            if (type(index) is not int or not 0 <= index < len(ids) or index in records
                    or row.get("video_id") != ids[index] or row.get("source") != "youtube_metadata"
                    or row.get("status") not in ("completed", "failed")):
                raise ValueError("Unknown, duplicate or mismatched result row.")
            metadata = None
            if row["status"] == "completed":
                results = row.get("results")
                if (not isinstance(results, list) or len(results) != 1
                        or not isinstance(results[0], dict) or results[0].get("videoId") != ids[index]):
                    raise ValueError("Completed metadata does not match its video.")
                metadata = results[0]
            records[index] = {
                "index": index, "video_id": ids[index], "status": row["status"],
                "metadata": metadata, "error": row.get("error"), "usage": row.get("usage"),
            }
    if len(records) != len(ids):
        raise ValueError("Missing result rows. Recover the same run before exporting.")
    videos = [records[index] for index in range(len(ids))]
    failed = [v["video_id"] for v in videos if v["status"] == "failed"]
    output = ROOT / "export"
    output.mkdir(mode=0o700)  # Never overwrite an earlier export.
    (output / "videos.json").write_text(json.dumps(videos, ensure_ascii=False, indent=2), encoding="utf-8")
    def cell(value):
        if value is None:
            return ""
        if not isinstance(value, str):
            value = json.dumps(value, ensure_ascii=False, separators=(",", ":"))
        # Keep remote text from being interpreted as a spreadsheet formula.
        return "'" + value if re.match(r"^[ \t\r\n]*[=+@-]|^[\t\r\n]", value) else value
    with (output / "videos.csv").open("x", encoding="utf-8", newline="") as target:
        writer = csv.writer(target)
        writer.writerow(["index", "video_id", "status", "title", "duration", "error"])
        for video in videos:
            metadata = video["metadata"] or {}
            writer.writerow([cell(v) for v in (video["index"], video["video_id"], video["status"],
                            metadata.get("title"), metadata.get("duration"), video["error"])])
    (output / "failed-video-ids.txt").write_bytes("".join(v + "\n" for v in failed).encode("utf-8"))
    summary = {"run_id": plan["run_id"], "bulk_id": run["remoteId"], "input_count": len(ids),
               "completed": len(ids) - len(failed), "failed": len(failed), "coverage_complete": True}
    (output / "summary.json").write_text(json.dumps(summary, indent=2), encoding="utf-8")
    print(json.dumps(summary, indent=2))
    print("Saved export/videos.json, videos.csv and failed-video-ids.txt")
    sys.exit(2 if failed else 0)
except (OSError, ValueError, KeyError, TypeError) as error:
    print(str(error), file=sys.stderr)
    sys.exit(1)
```

#### स्थानीय रूप से निर्यात करें · कोई API कॉल नहीं

```bash
python export.py
```


### Bash

#### bulk-enrichment/export.sh

```bash
#!/usr/bin/env bash
# Save as bulk-enrichment/export.sh. Local files only; no API calls.
set -euo pipefail
trap 'exit 1' ERR
umask 077
cd -- "$(dirname -- "$0")"
case "$(uname -s)" in
  MINGW*|MSYS*|CYGWIN*) jq() { command jq --binary "$@"; } ;;
esac
directory=$(cat ready.txt)
[[ "$directory" =~ ^attempts/run-[A-Za-z0-9_-]+$ ]] || exit 1
hash=$(openssl dgst -sha256 prepared/video-ids.txt | awk '{print $NF}')
jq -e --slurpfile plan prepared/plan.json --arg hash "$hash" '
  .ok and .data.status == "succeeded" and .data.kind == "bulk:run"
  and .data.id == $plan[0].run_id and .data.source == "youtube_metadata"
  and .data.inputFileHash == $hash and $plan[0].input_sha256 == $hash
  and (.data.remoteId | type == "string" and length > 0)
' "$directory/run.json" >/dev/null
# Validate the complete small-sample result before creating export/.
videos=$(jq -sc --rawfile input prepared/video-ids.txt --slurpfile plan prepared/plan.json '
  ($input | split("\n") | .[:-1]) as $ids
  | if $plan[0].input_count != ($ids | length) or length != ($ids | length)
      or any(.[]; (.index | type != "number" or . != floor)
        or .source != "youtube_metadata" or (.status != "completed" and .status != "failed"))
    then error("Missing rows or unexpected source/status/index.")
    else sort_by(.index) end
  | if map(.index) != [range(0; $ids | length)]
      or any(.[]; .video_id != $ids[.index])
    then error("Unknown, duplicate or mismatched rows.")
    elif any(.[]; .status == "completed" and
      ((.results | type != "array" or length != 1) or .results[0].videoId != .video_id))
    then error("Completed metadata does not match its video.")
    else map({index, video_id, status,
      metadata:(if .status == "completed" then .results[0] else null end), error, usage}) end
' "$directory/bulk-results.ndjson")
mkdir export
printf '%s\n' "$videos" | jq . > export/videos.json
jq -r '
  def cell: if . == null then ""
    else (if type == "string" then . else tojson end)
      | if test("^[ \\t\\r\\n]*[=+@-]|^[\\t\\r\\n]") then "'"'"'" + . else . end end;
  (["index","video_id","status","title","duration","error"],
   (.[] | [.index,.video_id,.status,.metadata.title,.metadata.duration,.error] | map(cell)))
  | @csv
' export/videos.json > export/videos.csv
jq -r '.[] | select(.status == "failed") | .video_id' export/videos.json > export/failed-video-ids.txt
jq --slurpfile plan prepared/plan.json --slurpfile run "$directory/run.json" '
  {run_id:$plan[0].run_id, bulk_id:$run[0].data.remoteId, input_count:length,
   completed:([.[] | select(.status == "completed")] | length),
   failed:([.[] | select(.status == "failed")] | length), coverage_complete:true}
' export/videos.json > export/summary.json
cat export/summary.json
echo 'Saved export/videos.json, videos.csv and failed-video-ids.txt'
jq -e '.failed == 0' export/summary.json >/dev/null || exit 2
```

#### स्थानीय रूप से निर्यात करें · कोई API कॉल नहीं

```bash
bash export.sh
```


- [बाध्य स्मृति के साथ एक बड़ी फ़ाइल ऑडिट करें](https://flashdata.dev/hi/docs/guides/bulk/reference.md#audit)

<a id="files"></a>

### निर्यात की गई फ़ाइलों का उपयोग करें

सफलता सारांश को प्रिंट करती है और फ़ाइल नाम बचाती है। एक्स्पोर्ट निकास 0 जब हर वीडियो सफल हो गया, 2 जब कुछ विफल हो गया, या 1 जब सत्यापन या लेखन विफल हो गया। एक मौजूदा निर्यात/ संरक्षित है; इसे स्थानीय रूप से पुन: प्रस्तुत करने के बजाय पढ़ें।

| निर्यात के तहत फ़ाइल | इसके लिए उपयोग करें |
| --- | --- |
| videos.json | अपने ऐप या एजेंट वर्कफ़्लो में आयात करें। पंक्तियां इनपुट ऑर्डर, मेटाडाटा, त्रुटियों और उपयोग को बनाए रखती हैं। |
| videos.csv | एक स्प्रेडशीट में शीर्षक, अवधि और विफलताओं की समीक्षा करें। फ़ॉर्मूला की तरह पाठ एक apostrophe के साथ prefixed है; JSON मूल पाठ को बरकरार रखता है। |
| summary.json | कवरेज और completed/failed गिनती की जाँच करें, जो रन ID और Bulk ID से जुड़ा हुआ है। |
| failed-video-ids.txt | एक अन्य भुगतान अनुरोध पर निर्णय लेने से पहले केवल असफल वीडियो की पुष्टि की गई। जब सब सफल हो गया तो खाली हो गया। |

#### Python

##### सहेजे गए सारांश और मेटाडाटा को पढ़ें

```bash
python -m json.tool export/summary.json
python -m json.tool export/videos.json
```


#### Bash

##### सहेजे गए सारांश और मेटाडाटा को पढ़ें

```bash
jq . export/summary.json
jq . export/videos.json
```



<a id="expected"></a>

### एक असफल वीडियो के साथ उदाहरण परिणाम

illustrated videos.json अंश। एक पूर्ण Bulk नौकरी में विफल वीडियो हो सकते हैं। एक सफल परिणाम के रूप में असफल वीडियो का इलाज न करें या चुपचाप इसे अपने डेटासेट से छोड़ दें।

#### export/videos.json

```json
[
  {
    "index": 0,
    "video_id": "jNQXAC9IVRw",
    "status": "completed",
    "metadata": {
      "videoId": "jNQXAC9IVRw",
      "title": "Example video",
      "duration": 19
    },
    "error": null,
    "usage": null
  },
  {
    "index": 1,
    "video_id": "dQw4w9WgXcQ",
    "status": "failed",
    "metadata": null,
    "error": {
      "code": "example_video_unavailable"
    },
    "usage": null
  }
]
```


<a id="recover"></a>

## उसी नौकरी को पुनर्प्राप्त करें

यदि प्रतीक्षा बंद हो जाती है या परिणामस्वरूप भाग पढ़ा नहीं जा सकता है, तो पुनः प्राप्त करें। यह मौजूदा नौकरी को एक नए प्रयास फ़ोल्डर में एकत्र करता है और पूरी पुनर्प्राप्ति के बाद केवल ready.txt को अपडेट करता है। यह प्रतिस्थापन कार्य को अपलोड या प्रस्तुत नहीं करता है। फिर अगर निर्यात/ अभी तक नहीं बनाया गया है तो निर्यातक चलाएं।

| सहेजा गया परिणाम | अगली कार्रवाई |
| --- | --- |
| bulk_item_failures | failed-video-ids.txt निर्यात और समीक्षा करें। सभी सफल वीडियो को दोहराना नहीं है। |
| partial_result | आंशिक फ़ाइल को संरक्षित करें। निर्यात से पहले सभी भागों को पुनः प्राप्त करने के लिए उसी रन को पुनर्प्राप्त करें। |
| running / finalizing | बाद में उसी रन ID, प्रोफाइल और स्टेट डायरेक्टरी का उपयोग करके पुनर्प्राप्त करें। |
| paused | स्थिति में pauseReason पढ़ें, कारण को ठीक करें, फिर स्पष्ट रूप से फिर से शुरू करें कि Bulk ID कंट्रोल गाइड का उपयोग करके। |
| awaiting_upload / bulk_input_required | सहेजे गए ड्राफ्ट का निरीक्षण करें। मूल तैयार फ़ाइल को अपलोड करें और मौजूदा Bulk ID शुरू करें; वसूली इन कार्यों को फिर से नहीं चलाती है। |
| Uncertain प्रस्तुतीकरण या कोई दूरस्थ ID | चलाने के लिए और बचाया त्रुटि और Bulk जॉब्स को पुनः प्रयास करने से पहले निरीक्षण करें। एक नया रन ID एक और काम कर सकता है। |
| गलतफहमी, लापता पंक्तियों या इनपुट हैश mismatch | कोई निर्यात स्वीकार नहीं किया जाता है। तैयार स्नैपशॉट, सेव्ड रन और परिणाम फ़ाइल की जाँच करें; लापता मेटाडाटा का आविष्कार नहीं करें। |

### Python

#### Inspect, फिर मौजूदा काम को पुनर्प्राप्त करें

```bash
python process.py status
python process.py recover
```


### Bash

#### Inspect, फिर मौजूदा काम को पुनर्प्राप्त करें

```bash
bash process.sh status
bash process.sh recover
```


- [अपलोड, रोकें और फिर से शुरू नियंत्रण](https://flashdata.dev/hi/docs/guides/bulk/reference.md#controls)
- [Bulk नौकरियां](https://flashdata.dev/app/bulk-jobs)
- [Bulk समापन बिंदु संदर्भ](https://flashdata.dev/hi/docs/reference/bulk-processing/reference.md)

<a id="next"></a>

## इस स्नैपशॉट को सहेजें या इसे जानबूझकर ताज़ा करें

24-घंटे की अवधारण खिड़की के भीतर पूरा परिणाम बचाओ। आपका निर्यात पुन: उपयोग के लिए स्थानीय फाइलें बना रहा है। बाद में मेटाडाटा को ताज़ा करने के लिए, एक नए काम करने वाले फ़ोल्डर का उपयोग करें और ID को चलाएं, और पहले नए अनुरोध लागत की समीक्षा करें।

- [अपने स्वयं के रिकॉर्ड में वापस मेटाडाटा में शामिल हों](https://flashdata.dev/hi/docs/guides/enrich-youtube-videos/reference.md)
- [पुनर्प्राप्ति टाइम्सटैम्प्ड कैप्शन](https://flashdata.dev/hi/docs/guides/timestamped-captions-recipe/reference.md)
