> For the complete documentation index, see [llms.txt](https://cloakedkeys.gitbook.io/ofsc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cloakedkeys.gitbook.io/ofsc/getting-started/config-options/options/script-options.md).

# Script Options

[Scripts](/ofsc/using-the-scraper/scripts.md)

## After Action Script (`after_action_script`)

A script that runs after an action for a user has completed. This script can be configured via the `--after-action-script` command-line argument or the `after_action_script` setting in the program's configuration.

### **Trigger Conditions**

* Runs after each model is downloaded in the main scraper
  * Including in daemon-mode
* Runs after each model like/unlike process is finished
  * Including in daemon-mode
* Runs after each model's metadata is processed in metadata mode.
* Runs after each model is processed in manual mode
* Runs for each unique model, after the current cart is downloaded in check mode
* Runs for each model after scrape paid is process,
  * Note: modeldeleted or models without a active account would be ran together as one unit

### **Data Sent**

As a JSON dictionary, typically via standard input (stdin).

* `username`: username (string)
* `action` : action ran (string)
* `model_id`: model\_id (integer).
* `media`: media dictionary from API, with `final_path` added, and whether they were downloaded or not
* `posts`: posts dictionary from API.
* `userdata`: a dictionary from the users API.

***

## Post Script (`post_script`)

A script that runs after all actions for all users have completed. This script can be configured via the `--post-script` command-line argument or the `post_script` setting in the program's configuration.

### **Trigger Conditions**

* Once all models are downloaded or liked in scrape mode
* After each cycle in daemon mode
* Once all the posts from manual mode are completed
* After the current cart downloads are processed in check mode, and after the after\_action\_script is processed for each user.
* After all metadata for all users is processed in metadata mode.

### **Data Sent**

As a JSON dictionary, typically via standard input (stdin).

* `like_processed`: A list of users who have successfully completed the 'like' action.
* `like_unprocessed`: A list of users who are queued for the 'like' action but were not processed.
* `unlike_processed`: A list of users who have successfully completed the 'unlike' action.
* `unlike_unprocessed`: A list of users who are queued for the 'unlike' action but were not processed.
* `download_processed`: A list of users whose content has been successfully downloaded.
* `download_unprocessed`: A list of users whose content is queued for download but were not processed.
* `scrape_paid_processed`: A list of users who were successfully processed during the 'scrape\_paid' action
* `scrape_paid_unprocessed`: A list of users who are queued for the 'scrape\_paid' scrape action but but were not processed.

***

## Naming Script (`naming_script`)

A script that dynamically generates the final filename or full path for a downloaded media item. This script can be configured via the `--naming-script` command-line argument or the `naming_script` setting in the program's configuration.

### **Trigger Conditions**

* For each individual media item, this script runs while its temporary filename is being generated.
* It is executed again after the temporary file has been downloaded, and before the file is renamed to its final destination.
* **As a special case, the script also runs before generating filenames for text files when using the `--text` or `--text-only` option.**

### **Data Sent**

As a JSON dictionary, typically via standard input (stdin)

* `media`: A dictionary representing the media item
* `post`: The dictionary representing the post associated with the media item.
* `dir`: The calculated directory path (string).
* `file`: The calculated filename (string).
* `dir_format`: The current directory format string (string from config).
* `file_format`: The current file format string (string from config).
* `metadata`: The current metadata format setting (string from config).
* `username`: The model's username (string).
* `model_id`: The model's ID (integer).
* `post_id`: The ID of the post associated with the media (integer).
* `media_id`: The ID of the media item (integer).
* `media_type`: The type of media
* `value`: The value associated with the media
* `date`: The formatted date related to the media/post (string)
* `response_type`: The response type of the media (string).
* `label`: A string representing associated labels
* `download_type`: The type of download

### **Expected Output**

The script is expected to print the desired the **full desired path** to standard output (stdout). The scraper will then use this output to rename or move the downloaded file

***

## After Download Script (`after_download_script`)

A script that runs after a download has completed. This script can be configured via the `--after-download-script` command-line argument or the `after_download_script` setting in the program's configuration.

### **Trigger Conditions**

* It executes after a download has successfully been downloaded

### **Data Sent**

a single string

* The final filepath of the download

***

## Skip Download Script (`skip_download_script`)

A script that determines whether to skip or continue a download. This script can be configured via the `--skip-download-script` command-line argument or the `skip_download_script` setting in the program's configuration.

### **Trigger Conditions**

* It executes before the download process begins for each individual media item.
* It's asked once per file per run. For a DRM video it's asked per track, and if it skips one track the whole video is skipped.

### **Data Sent**

As a JSON dictionary, typically via standard input (stdin).

* `username`: The model's username (string).
* `model_id`: The model's ID (integer).
* `post_id`: The ID of the post associated with the media (integer).
* `media_id`: The ID of the media item (integer).
* `media`: dictionary representing the media item to be downloaded.
* `post`: A dictionary representing the post associated with the media item.
* `total_size`: The total size of the download in bytes (integer).

### **Expected Output**

The script is expected to return a string via standard output (stdout).

| Output                             | What happens                                                                                                                                         |
| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `false` (any case) or nothing      | The file is **skipped for this run only**. It's counted as skipped, not saved as downloaded, and the script is asked about it again on the next run. |
| `skip-permanent` (any case)        | The file is **skipped for good**. It's saved as downloaded with no file, and the script isn't asked about it again.                                  |
| anything else, or the script fails | The download **proceeds**.                                                                                                                           |

> ℹ️ **Before 3.16.6, `false` and nothing also saved the file as downloaded, so it was never asked about again.** To keep that behaviour, print `skip-permanent`.

### **Undoing permanent skips**

* `--retry-permanent-skips` on a normal run asks the script again about the files it skipped for good, for the creators in that run.
* `ofscraper db --unmark-permanent-skips` un-marks them without running a download. Narrow it with the creator options, `--post-id` or `--media-id`. Only permanent skips are touched; real downloads stay marked.

***

## How scripts run

* **UTF-8 (all scripts):** Python scripts run in Python's UTF-8 mode, and output is read as UTF-8, so non-English names come through intact on Windows.

The naming, skip-download and after-download scripts also behave like this:

* **The answer is used as soon as the script exits,** even if it started a program that keeps running in the background. OF-Scraper waits a moment for the rest of the output, then logs a warning.
* **Programs the script starts are stopped** once it exits, times out or is cancelled, and when OF-Scraper exits. `nohup` and `&` don't keep a program running. On Linux and macOS, a program started in its own session (for example with `setsid`) is left running; on Windows, none is.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://cloakedkeys.gitbook.io/ofsc/getting-started/config-options/options/script-options.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
