kaltura-uploader


Namekaltura-uploader JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/zoharbabin/kaltura_uploader
SummaryA robust Python tool for uploading files to Kaltura with chunked and adaptive upload support, automatic MIME type detection, and entry creation.
upload_time2025-01-08 01:37:05
maintainerNone
docs_urlNone
authorZohar Babin
requires_python>=3.10
licenseMIT
keywords kaltura upload chunked adaptive video media file cli
VCS
bugtrack_url
requirements python-dotenv python-magic colorlog requests requests-toolbelt KalturaApiClient lxml
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Kaltura Uploader

**A robust Python CLI tool and library for uploading files to Kaltura with chunked (and adaptive) upload support, automatic MIME type detection, and seamless entry creation for media, documents, and data.**

![GitHub License](https://img.shields.io/badge/license-MIT-green.svg)
![Python Versions](https://img.shields.io/badge/python-3.10+-blue.svg)
![Platform](https://img.shields.io/badge/platform-linux%20%7C%20macos-lightgrey)

## Table of Contents

- [Features](#features)
- [Installation](#installation)
  - [Install from PyPI](#install-from-pypi)
  - [Install from Git Clone](#install-from-git-clone)
- [CLI Usage](#cli-usage)
  - [Basic Command](#basic-command)
  - [CLI Arguments and Options](#cli-arguments-and-options)
  - [Common Examples](#common-examples)
  - [Environment Variables](#environment-variables)
- [Using as a Library](#using-as-a-library)
  - [Quick Example](#quick-example)
  - [Advanced Example](#advanced-example)
- [Logging and Security](#logging-and-security)
- [Contributing](#contributing)
- [License](#license)

---

## Features

1. **Chunked Uploading**  
   - Automatically splits files into configurable chunk sizes, reducing the chance of timeouts or large transfer failures.
   - Supports adaptive chunking to dynamically adjust the chunk size based on current upload speed.

2. **Retry Mechanism**  
   - Built-in retries (with exponential backoff) on transient network failures, ensuring more resilient uploads.

3. **Automatic MIME Detection**  
   - Uses [`python-magic`](https://github.com/ahupp/python-magic) if available for accurate MIME detection based on file contents.
   - Falls back to standard extension-based detection if `python-magic` is not installed.

4. **Entry Creation**  
   - Creates the appropriate Kaltura entry type (Media, Document, or Data) based on detected MIME type:
     - **Media**: Video, Audio, or Image
     - **Document**: PDFs, Office docs, SWF, etc.
     - **Data**: All other file types

5. **Direct Download URL**  
   - Automatically constructs a direct serve (CDN) URL for the uploaded entry.

6. **Category Assignment**  
   - Optionally assigns the uploaded file to specific Kaltura categories.

7. **Rich Logging**  
   - Dual-mode logging to console (with optional color via `colorlog`) and JSON files for easy log ingestion.
   - Scrubs sensitive Kaltura session tokens from all logs to prevent accidental leakage.

---

## Installation

The Kaltura Uploader supports **Python 3.10+**. 

### Install from PyPI

The fastest way to get started is to install from [PyPI](https://pypi.org/):

```bash
pip install kaltura-uploader
```

Once installed, you’ll have access to the `kaltura_uploader` CLI.  

### Install from Git Clone

Alternatively, you can clone this repo and install locally:

1. **Clone the Repository**

   ```bash
   git clone https://github.com/zoharbabin/kaltura_uploader.git
   cd kaltura_uploader
   ```

2. **Create a Virtual Environment (recommended)**

   ```bash
   python3 -m venv venv
   source venv/bin/activate
   ```

3. **Install the Package**

   ```bash
   pip install .
   ```

   *or* use editable mode to work on the code while installed:

   ```bash
   pip install -e .
   ```

4. **(Optional) Install Dev/Test Requirements**

   If you plan to run tests or contribute:

   ```bash
   pip install -r requirements.txt
   ```

---

## CLI Usage

After installation, a console command named `kaltura_uploader` becomes available. (If you installed locally in a virtual environment, make sure your environment is activated.)

### Basic Command

```bash
kaltura_uploader /path/to/file.mp4
```

> **Note**: By default, the tool reads Kaltura credentials (`partner_id` and `admin_secret`) from environment variables. See [Environment Variables](#environment-variables) below.

### CLI Arguments and Options

```text
usage: kaltura_uploader [-h] [--access_control_id ACCESS_CONTROL_ID]
                        [--conversion_profile_id CONVERSION_PROFILE_ID]
                        [--dl_url_extra_params DL_URL_EXTRA_PARAMS]
                        [--json_log_file JSON_LOG_FILE]
                        [--chunk_size CHUNK_SIZE]
                        [--adaptive] [--target_time TARGET_TIME]
                        [--min_chunk_size MIN_CHUNK_SIZE]
                        [--max_chunk_size MAX_CHUNK_SIZE]
                        [--category_id CATEGORY_ID] [--tags TAGS]
                        [--verbose]
                        [--partner_id_env PARTNER_ID_ENV]
                        [--admin_secret_env ADMIN_SECRET_ENV]
                        file_path

Upload a file to Kaltura, create the correct entry type (Media/Document/Data),
and log results.

positional arguments:
  file_path             Path to the file to upload.

optional arguments:
  -h, --help            show this help message and exit
  --access_control_id ACCESS_CONTROL_ID
                        Access control ID to apply on the created entry
                        (default=0).
  --conversion_profile_id CONVERSION_PROFILE_ID
                        Conversion profile ID to apply on the created entry
                        (default=0).
  --dl_url_extra_params DL_URL_EXTRA_PARAMS
                        Additional URL parameters appended as '?...' if non-empty.
  --json_log_file JSON_LOG_FILE
                        Path to JSON log file (default=`kaltura_upload.log`).
  --chunk_size CHUNK_SIZE
                        Initial chunk size in KB (default=2048, ~2MB).
  --adaptive            Enable adaptive chunking based on upload speed.
  --target_time TARGET_TIME
                        Target upload time per chunk in seconds (default=5).
  --min_chunk_size MIN_CHUNK_SIZE
                        Minimum chunk size in KB when adaptive chunking (default=1024).
  --max_chunk_size MAX_CHUNK_SIZE
                        Maximum chunk size in KB when adaptive chunking (default=102400).
  --category_id CATEGORY_ID
                        Assign the entry to this Kaltura category if > 0.
  --tags TAGS           Comma-separated tags to attach to the entry.
  --verbose             Enable verbose (DEBUG) logging in console.
  --partner_id_env PARTNER_ID_ENV
                        Name of environment variable containing Kaltura partner ID
                        (default=KALTURA_PARTNER_ID).
  --admin_secret_env ADMIN_SECRET_ENV
                        Name of environment variable containing Kaltura admin secret
                        (default=KALTURA_ADMIN_SECRET).
```

### Common Examples

1. **Minimal CLI Usage**  
   ```bash
   export KALTURA_PARTNER_ID="12345"
   export KALTURA_ADMIN_SECRET="my_admin_secret"

   kaltura_uploader /path/to/video.mp4
   ```
   - Uploads `video.mp4`, uses chunk size of ~2MB, defaults to media entry type if MIME is recognized as video.

2. **Specifying Category and Tags**  
   ```bash
   kaltura_uploader /path/to/presentation.pdf \
       --category_id 678 \
       --tags "presentation,slides"
   ```
   - Uploads `presentation.pdf`, recognized as `document` type.  
   - Automatically assigns it to category 678 and adds tags `presentation,slides`.

3. **Adaptive Chunking**  
   ```bash
   kaltura_uploader /path/to/big_video.mov --adaptive --target_time 10
   ```
   - Starts with a 2MB chunk size, but adjusts automatically per chunk to aim for a 10-second upload time each chunk.

4. **Saving Logs to a Custom File**  
   ```bash
   kaltura_uploader /path/to/my_file.mp4 \
       --json_log_file /var/log/kaltura/kaltura_upload.json
   ```
   - Writes logs in JSON format to `/var/log/kaltura/kaltura_upload.json`.  
   - Console logs are colored (if `colorlog` is installed).

5. **Override Default Environment Variable Names**  
   ```bash
   export MY_PARTNER_ID="55555"
   export MY_ADMIN_SECRET="some_secret_here"

   kaltura_uploader /path/to/image.jpg \
       --partner_id_env MY_PARTNER_ID \
       --admin_secret_env MY_ADMIN_SECRET
   ```
   - Reads credentials from `MY_PARTNER_ID` and `MY_ADMIN_SECRET` instead of the default `KALTURA_PARTNER_ID` / `KALTURA_ADMIN_SECRET`.

### Environment Variables

By default, `kaltura_uploader` looks for two environment variables:

- `KALTURA_PARTNER_ID`: The numeric Kaltura **partner ID**.
- `KALTURA_ADMIN_SECRET`: The **admin secret** associated with that partner ID.

You can also store them in a `.env` file (supported by [python-dotenv](https://pypi.org/project/python-dotenv/)):

```bash
# .env file in your project
KALTURA_PARTNER_ID=12345
KALTURA_ADMIN_SECRET=my_admin_secret
```

Then simply run:

```bash
kaltura_uploader /path/to/video.mp4
```

The tool will load these automatically at runtime.

---

## Using as a Library

In addition to the CLI, `kaltura_uploader` can be imported into Python scripts to programmatically upload files, create entries, and retrieve direct-serve URLs.

### Quick Example

```python
from kaltura_uploader import KalturaUploader

# Provide credentials (commonly from env variables).
partner_id = 12345
admin_secret = "my_admin_secret"

# Initialize the uploader
uploader = KalturaUploader(
    partner_id=partner_id,
    admin_secret=admin_secret,
    chunk_size_kb=2048,        # ~2MB
    verbose=True,              # Enable debug logging
    adaptive_chunking=False,   # Disable or enable adaptive chunking
)

# Upload a file and get the Kaltura upload token
upload_token_id = uploader.upload_file("/path/to/video.mp4")

# Create an entry in Kaltura (automatically determines if it's media/doc/data)
entry_id = uploader.create_kaltura_entry(
    upload_token_id,
    file_path="/path/to/video.mp4",
    tags="example,video",
    access_control_id=0,       # Could be any valid ID if needed
    conversion_profile_id=0,
)

# Optionally assign category
uploader.assign_category(entry_id, 678)

# Get the direct download (CDN) URL
dl_url = uploader.get_direct_serve_url(entry_id, "video.mp4")
print("Entry ID:", entry_id)
print("Direct Download URL:", dl_url)
```

### Advanced Example

```python
import os
from kaltura_uploader import KalturaUploader, configure_logging

# Suppose you store your credentials in environment variables or .env
partner_id = int(os.getenv("KALTURA_PARTNER_ID", "12345"))
admin_secret = os.getenv("KALTURA_ADMIN_SECRET", "some_secret")

# Optionally configure logging with a custom JSON file path
configure_logging(json_file_path="kaltura_upload.log", verbose=True)

# Initialize an uploader with adaptive chunking
uploader = KalturaUploader(
    partner_id=partner_id,
    admin_secret=admin_secret,
    chunk_size_kb=1024,
    verbose=True,
    adaptive_chunking=True,
    target_upload_time=10,
    min_chunk_size_kb=1024,    # 1MB
    max_chunk_size_kb=204800,  # 200MB
)

# Upload, create an entry, and assign category
try:
    file_path = "/path/to/very_large_video.mov"
    token_id = uploader.upload_file(file_path)
    entry_id = uploader.create_kaltura_entry(
        token_id,
        file_path,
        tags="large,upload,example",
        access_control_id=10,
        conversion_profile_id=999
    )
    uploader.assign_category(entry_id, 777)

    direct_url = uploader.get_direct_serve_url(entry_id, os.path.basename(file_path))
    print(f"Successfully uploaded! Entry ID: {entry_id}\nDirect URL: {direct_url}")
except Exception as e:
    print(f"An error occurred: {e}")
```

---

## Logging and Security

1. **Dual Logging**  
   - Writes human-readable logs to the console (with optional coloring via `colorlog`) and JSON logs to a specified file (defaults to `kaltura_upload.log`).

2. **Scrubbing Kaltura Sessions**  
   - The API admin secret is excluded from the log.  
   - The Kaltura session token (`ks`) is automatically replaced with `ks=<REDACTED>` in all log messages to prevent accidental credential leakage.

---

## Contributing

We welcome all contributions, including:

- **Bug Reports**: [Open an issue](https://github.com/zoharbabin/kaltura_uploader/issues) if you find a bug or want to request an enhancement.
- **Pull Requests**: If you want to add features or fix bugs, fork the repository and open a PR. We’ll review and help merge your changes.
- **Discussions**: Feel free to start or join a discussion to brainstorm ideas or get help.

**Steps for contributing**:
1. Fork and clone the repository.
2. Create a new branch for your feature or bug fix.
3. Write tests for your changes in the `tests/` directory.
4. Ensure `pytest` or `unittest` passes all tests.
5. Commit and push your changes to GitHub.
6. Open a pull request against the `main` branch.

---

## License

This project is licensed under the [MIT License](LICENSE).  
You are free to use, modify, and distribute this software in accordance with the MIT license terms.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/zoharbabin/kaltura_uploader",
    "name": "kaltura-uploader",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "kaltura, upload, chunked, adaptive, video, media, file, cli",
    "author": "Zohar Babin",
    "author_email": "zohar.babin@kaltura.com",
    "download_url": "https://files.pythonhosted.org/packages/4c/9f/3940d896c5a6f7e7a1cf178cbc519460a12473171dbe39a330d11c38409f/kaltura_uploader-0.1.2.tar.gz",
    "platform": null,
    "description": "# Kaltura Uploader\n\n**A robust Python CLI tool and library for uploading files to Kaltura with chunked (and adaptive) upload support, automatic MIME type detection, and seamless entry creation for media, documents, and data.**\n\n![GitHub License](https://img.shields.io/badge/license-MIT-green.svg)\n![Python Versions](https://img.shields.io/badge/python-3.10+-blue.svg)\n![Platform](https://img.shields.io/badge/platform-linux%20%7C%20macos-lightgrey)\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation](#installation)\n  - [Install from PyPI](#install-from-pypi)\n  - [Install from Git Clone](#install-from-git-clone)\n- [CLI Usage](#cli-usage)\n  - [Basic Command](#basic-command)\n  - [CLI Arguments and Options](#cli-arguments-and-options)\n  - [Common Examples](#common-examples)\n  - [Environment Variables](#environment-variables)\n- [Using as a Library](#using-as-a-library)\n  - [Quick Example](#quick-example)\n  - [Advanced Example](#advanced-example)\n- [Logging and Security](#logging-and-security)\n- [Contributing](#contributing)\n- [License](#license)\n\n---\n\n## Features\n\n1. **Chunked Uploading**  \n   - Automatically splits files into configurable chunk sizes, reducing the chance of timeouts or large transfer failures.\n   - Supports adaptive chunking to dynamically adjust the chunk size based on current upload speed.\n\n2. **Retry Mechanism**  \n   - Built-in retries (with exponential backoff) on transient network failures, ensuring more resilient uploads.\n\n3. **Automatic MIME Detection**  \n   - Uses [`python-magic`](https://github.com/ahupp/python-magic) if available for accurate MIME detection based on file contents.\n   - Falls back to standard extension-based detection if `python-magic` is not installed.\n\n4. **Entry Creation**  \n   - Creates the appropriate Kaltura entry type (Media, Document, or Data) based on detected MIME type:\n     - **Media**: Video, Audio, or Image\n     - **Document**: PDFs, Office docs, SWF, etc.\n     - **Data**: All other file types\n\n5. **Direct Download URL**  \n   - Automatically constructs a direct serve (CDN) URL for the uploaded entry.\n\n6. **Category Assignment**  \n   - Optionally assigns the uploaded file to specific Kaltura categories.\n\n7. **Rich Logging**  \n   - Dual-mode logging to console (with optional color via `colorlog`) and JSON files for easy log ingestion.\n   - Scrubs sensitive Kaltura session tokens from all logs to prevent accidental leakage.\n\n---\n\n## Installation\n\nThe Kaltura Uploader supports **Python 3.10+**. \n\n### Install from PyPI\n\nThe fastest way to get started is to install from [PyPI](https://pypi.org/):\n\n```bash\npip install kaltura-uploader\n```\n\nOnce installed, you\u2019ll have access to the `kaltura_uploader` CLI.  \n\n### Install from Git Clone\n\nAlternatively, you can clone this repo and install locally:\n\n1. **Clone the Repository**\n\n   ```bash\n   git clone https://github.com/zoharbabin/kaltura_uploader.git\n   cd kaltura_uploader\n   ```\n\n2. **Create a Virtual Environment (recommended)**\n\n   ```bash\n   python3 -m venv venv\n   source venv/bin/activate\n   ```\n\n3. **Install the Package**\n\n   ```bash\n   pip install .\n   ```\n\n   *or* use editable mode to work on the code while installed:\n\n   ```bash\n   pip install -e .\n   ```\n\n4. **(Optional) Install Dev/Test Requirements**\n\n   If you plan to run tests or contribute:\n\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n---\n\n## CLI Usage\n\nAfter installation, a console command named `kaltura_uploader` becomes available. (If you installed locally in a virtual environment, make sure your environment is activated.)\n\n### Basic Command\n\n```bash\nkaltura_uploader /path/to/file.mp4\n```\n\n> **Note**: By default, the tool reads Kaltura credentials (`partner_id` and `admin_secret`) from environment variables. See [Environment Variables](#environment-variables) below.\n\n### CLI Arguments and Options\n\n```text\nusage: kaltura_uploader [-h] [--access_control_id ACCESS_CONTROL_ID]\n                        [--conversion_profile_id CONVERSION_PROFILE_ID]\n                        [--dl_url_extra_params DL_URL_EXTRA_PARAMS]\n                        [--json_log_file JSON_LOG_FILE]\n                        [--chunk_size CHUNK_SIZE]\n                        [--adaptive] [--target_time TARGET_TIME]\n                        [--min_chunk_size MIN_CHUNK_SIZE]\n                        [--max_chunk_size MAX_CHUNK_SIZE]\n                        [--category_id CATEGORY_ID] [--tags TAGS]\n                        [--verbose]\n                        [--partner_id_env PARTNER_ID_ENV]\n                        [--admin_secret_env ADMIN_SECRET_ENV]\n                        file_path\n\nUpload a file to Kaltura, create the correct entry type (Media/Document/Data),\nand log results.\n\npositional arguments:\n  file_path             Path to the file to upload.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --access_control_id ACCESS_CONTROL_ID\n                        Access control ID to apply on the created entry\n                        (default=0).\n  --conversion_profile_id CONVERSION_PROFILE_ID\n                        Conversion profile ID to apply on the created entry\n                        (default=0).\n  --dl_url_extra_params DL_URL_EXTRA_PARAMS\n                        Additional URL parameters appended as '?...' if non-empty.\n  --json_log_file JSON_LOG_FILE\n                        Path to JSON log file (default=`kaltura_upload.log`).\n  --chunk_size CHUNK_SIZE\n                        Initial chunk size in KB (default=2048, ~2MB).\n  --adaptive            Enable adaptive chunking based on upload speed.\n  --target_time TARGET_TIME\n                        Target upload time per chunk in seconds (default=5).\n  --min_chunk_size MIN_CHUNK_SIZE\n                        Minimum chunk size in KB when adaptive chunking (default=1024).\n  --max_chunk_size MAX_CHUNK_SIZE\n                        Maximum chunk size in KB when adaptive chunking (default=102400).\n  --category_id CATEGORY_ID\n                        Assign the entry to this Kaltura category if > 0.\n  --tags TAGS           Comma-separated tags to attach to the entry.\n  --verbose             Enable verbose (DEBUG) logging in console.\n  --partner_id_env PARTNER_ID_ENV\n                        Name of environment variable containing Kaltura partner ID\n                        (default=KALTURA_PARTNER_ID).\n  --admin_secret_env ADMIN_SECRET_ENV\n                        Name of environment variable containing Kaltura admin secret\n                        (default=KALTURA_ADMIN_SECRET).\n```\n\n### Common Examples\n\n1. **Minimal CLI Usage**  \n   ```bash\n   export KALTURA_PARTNER_ID=\"12345\"\n   export KALTURA_ADMIN_SECRET=\"my_admin_secret\"\n\n   kaltura_uploader /path/to/video.mp4\n   ```\n   - Uploads `video.mp4`, uses chunk size of ~2MB, defaults to media entry type if MIME is recognized as video.\n\n2. **Specifying Category and Tags**  \n   ```bash\n   kaltura_uploader /path/to/presentation.pdf \\\n       --category_id 678 \\\n       --tags \"presentation,slides\"\n   ```\n   - Uploads `presentation.pdf`, recognized as `document` type.  \n   - Automatically assigns it to category 678 and adds tags `presentation,slides`.\n\n3. **Adaptive Chunking**  \n   ```bash\n   kaltura_uploader /path/to/big_video.mov --adaptive --target_time 10\n   ```\n   - Starts with a 2MB chunk size, but adjusts automatically per chunk to aim for a 10-second upload time each chunk.\n\n4. **Saving Logs to a Custom File**  \n   ```bash\n   kaltura_uploader /path/to/my_file.mp4 \\\n       --json_log_file /var/log/kaltura/kaltura_upload.json\n   ```\n   - Writes logs in JSON format to `/var/log/kaltura/kaltura_upload.json`.  \n   - Console logs are colored (if `colorlog` is installed).\n\n5. **Override Default Environment Variable Names**  \n   ```bash\n   export MY_PARTNER_ID=\"55555\"\n   export MY_ADMIN_SECRET=\"some_secret_here\"\n\n   kaltura_uploader /path/to/image.jpg \\\n       --partner_id_env MY_PARTNER_ID \\\n       --admin_secret_env MY_ADMIN_SECRET\n   ```\n   - Reads credentials from `MY_PARTNER_ID` and `MY_ADMIN_SECRET` instead of the default `KALTURA_PARTNER_ID` / `KALTURA_ADMIN_SECRET`.\n\n### Environment Variables\n\nBy default, `kaltura_uploader` looks for two environment variables:\n\n- `KALTURA_PARTNER_ID`: The numeric Kaltura **partner ID**.\n- `KALTURA_ADMIN_SECRET`: The **admin secret** associated with that partner ID.\n\nYou can also store them in a `.env` file (supported by [python-dotenv](https://pypi.org/project/python-dotenv/)):\n\n```bash\n# .env file in your project\nKALTURA_PARTNER_ID=12345\nKALTURA_ADMIN_SECRET=my_admin_secret\n```\n\nThen simply run:\n\n```bash\nkaltura_uploader /path/to/video.mp4\n```\n\nThe tool will load these automatically at runtime.\n\n---\n\n## Using as a Library\n\nIn addition to the CLI, `kaltura_uploader` can be imported into Python scripts to programmatically upload files, create entries, and retrieve direct-serve URLs.\n\n### Quick Example\n\n```python\nfrom kaltura_uploader import KalturaUploader\n\n# Provide credentials (commonly from env variables).\npartner_id = 12345\nadmin_secret = \"my_admin_secret\"\n\n# Initialize the uploader\nuploader = KalturaUploader(\n    partner_id=partner_id,\n    admin_secret=admin_secret,\n    chunk_size_kb=2048,        # ~2MB\n    verbose=True,              # Enable debug logging\n    adaptive_chunking=False,   # Disable or enable adaptive chunking\n)\n\n# Upload a file and get the Kaltura upload token\nupload_token_id = uploader.upload_file(\"/path/to/video.mp4\")\n\n# Create an entry in Kaltura (automatically determines if it's media/doc/data)\nentry_id = uploader.create_kaltura_entry(\n    upload_token_id,\n    file_path=\"/path/to/video.mp4\",\n    tags=\"example,video\",\n    access_control_id=0,       # Could be any valid ID if needed\n    conversion_profile_id=0,\n)\n\n# Optionally assign category\nuploader.assign_category(entry_id, 678)\n\n# Get the direct download (CDN) URL\ndl_url = uploader.get_direct_serve_url(entry_id, \"video.mp4\")\nprint(\"Entry ID:\", entry_id)\nprint(\"Direct Download URL:\", dl_url)\n```\n\n### Advanced Example\n\n```python\nimport os\nfrom kaltura_uploader import KalturaUploader, configure_logging\n\n# Suppose you store your credentials in environment variables or .env\npartner_id = int(os.getenv(\"KALTURA_PARTNER_ID\", \"12345\"))\nadmin_secret = os.getenv(\"KALTURA_ADMIN_SECRET\", \"some_secret\")\n\n# Optionally configure logging with a custom JSON file path\nconfigure_logging(json_file_path=\"kaltura_upload.log\", verbose=True)\n\n# Initialize an uploader with adaptive chunking\nuploader = KalturaUploader(\n    partner_id=partner_id,\n    admin_secret=admin_secret,\n    chunk_size_kb=1024,\n    verbose=True,\n    adaptive_chunking=True,\n    target_upload_time=10,\n    min_chunk_size_kb=1024,    # 1MB\n    max_chunk_size_kb=204800,  # 200MB\n)\n\n# Upload, create an entry, and assign category\ntry:\n    file_path = \"/path/to/very_large_video.mov\"\n    token_id = uploader.upload_file(file_path)\n    entry_id = uploader.create_kaltura_entry(\n        token_id,\n        file_path,\n        tags=\"large,upload,example\",\n        access_control_id=10,\n        conversion_profile_id=999\n    )\n    uploader.assign_category(entry_id, 777)\n\n    direct_url = uploader.get_direct_serve_url(entry_id, os.path.basename(file_path))\n    print(f\"Successfully uploaded! Entry ID: {entry_id}\\nDirect URL: {direct_url}\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n```\n\n---\n\n## Logging and Security\n\n1. **Dual Logging**  \n   - Writes human-readable logs to the console (with optional coloring via `colorlog`) and JSON logs to a specified file (defaults to `kaltura_upload.log`).\n\n2. **Scrubbing Kaltura Sessions**  \n   - The API admin secret is excluded from the log.  \n   - The Kaltura session token (`ks`) is automatically replaced with `ks=<REDACTED>` in all log messages to prevent accidental credential leakage.\n\n---\n\n## Contributing\n\nWe welcome all contributions, including:\n\n- **Bug Reports**: [Open an issue](https://github.com/zoharbabin/kaltura_uploader/issues) if you find a bug or want to request an enhancement.\n- **Pull Requests**: If you want to add features or fix bugs, fork the repository and open a PR. We\u2019ll review and help merge your changes.\n- **Discussions**: Feel free to start or join a discussion to brainstorm ideas or get help.\n\n**Steps for contributing**:\n1. Fork and clone the repository.\n2. Create a new branch for your feature or bug fix.\n3. Write tests for your changes in the `tests/` directory.\n4. Ensure `pytest` or `unittest` passes all tests.\n5. Commit and push your changes to GitHub.\n6. Open a pull request against the `main` branch.\n\n---\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).  \nYou are free to use, modify, and distribute this software in accordance with the MIT license terms.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A robust Python tool for uploading files to Kaltura with chunked and adaptive upload support, automatic MIME type detection, and entry creation.",
    "version": "0.1.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/zoharbabin/kaltura_uploader/issues",
        "Documentation": "https://github.com/zoharbabin/kaltura_uploader#readme",
        "Homepage": "https://github.com/zoharbabin/kaltura_uploader"
    },
    "split_keywords": [
        "kaltura",
        " upload",
        " chunked",
        " adaptive",
        " video",
        " media",
        " file",
        " cli"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a691b60f68d92cb7a414088388df6a189c9cadffc4308f5f4a195df28d04fac7",
                "md5": "0ed671f9038d15273eb7cb94463a10f7",
                "sha256": "ef4fb7c14c7e4d13249d8d4132496c3bed8365f74b9e87755c774ba334b3eeed"
            },
            "downloads": -1,
            "filename": "kaltura_uploader-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0ed671f9038d15273eb7cb94463a10f7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 21196,
            "upload_time": "2025-01-08T01:37:04",
            "upload_time_iso_8601": "2025-01-08T01:37:04.085796Z",
            "url": "https://files.pythonhosted.org/packages/a6/91/b60f68d92cb7a414088388df6a189c9cadffc4308f5f4a195df28d04fac7/kaltura_uploader-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c9f3940d896c5a6f7e7a1cf178cbc519460a12473171dbe39a330d11c38409f",
                "md5": "ebe22650726bf4aae5cd9751317b5fee",
                "sha256": "ba7040563caa656475dee697867c29dd752b4708042ddcefa72a2ddca021e858"
            },
            "downloads": -1,
            "filename": "kaltura_uploader-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ebe22650726bf4aae5cd9751317b5fee",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 21630,
            "upload_time": "2025-01-08T01:37:05",
            "upload_time_iso_8601": "2025-01-08T01:37:05.543301Z",
            "url": "https://files.pythonhosted.org/packages/4c/9f/3940d896c5a6f7e7a1cf178cbc519460a12473171dbe39a330d11c38409f/kaltura_uploader-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-08 01:37:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zoharbabin",
    "github_project": "kaltura_uploader",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "python-dotenv",
            "specs": []
        },
        {
            "name": "python-magic",
            "specs": []
        },
        {
            "name": "colorlog",
            "specs": []
        },
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "requests-toolbelt",
            "specs": []
        },
        {
            "name": "KalturaApiClient",
            "specs": []
        },
        {
            "name": "lxml",
            "specs": []
        }
    ],
    "lcname": "kaltura-uploader"
}
        
Elapsed time: 4.84022s