nichi


Namenichi JSON
Version 2.0.6 PyPI version JSON
download
home_pageNone
SummaryA TUI tool for organizing video files, converting VTT subtitles to SRT format, and translating SRT files using Google Gemini AI.
upload_time2025-08-31 22:11:18
maintainerNone
docs_urlNone
authorRafli
requires_python<4.0,>=3.10
licenseMIT
keywords video subtitles translation organization vtt srt gemini
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Video File Organizer with AI Translation

A TUI video file organizer with Google Gemini AI-powered translation capabilities for SRT subtitle files. This tool helps you organize your video files and translate subtitle files to any supported language with AI translation.

## Features

### Core Features

- **File Organization**: Organize video files by language and format
- **VTT to SRT Conversion**: Convert WebVTT subtitle files to SRT format
- **Interactive TUI**: Beautiful terminal user interface with Rich library

### AI Translation Features ✨

- **SRT Translation**: Translate subtitle files using Google Gemini AI
- **Batch Translation**: Translate multiple SRT files simultaneously
- **Smart Language Detection**: Automatically detect source language from filenames
- **Concurrent Processing**: Fast translation with concurrent batch processing
- **Error Handling**: Robust retry logic with exponential backoff
- **Progress Tracking**: Real-time progress indication with detailed statistics
- **20+ Language Support**: Support for major world languages

## Project Structure

```
.
├── LICENSE
├── README.md
├── pyproject.toml
├── poetry.lock
└── src
    ├── __init__.py
    ├── main.py
    └── nichi
        ├── __init__.py
        ├── config/
        │   ├── __init__.py
        │   └── config_manager.py
        ├── core/
        │   ├── __init__.py
        │   ├── converter.py
        │   ├── organizer.py
        │   ├── operations.py
        │   ├── srt_parser.py
        │   ├── timing_adjuster.py
        │   └── translator.py
        ├── exceptions/
        │   └── __init__.py
        ├── models/
        │   └── __init__.py
        ├── services/
        │   ├── __init__.py
        │   ├── gemini_translator.py
        │   └── jellyfin_parser.py
        └── ui/
            ├── __init__.py
            ├── tui.py
            ├── ui_components.py
            └── user_input.py
```

## Installation

### Via PyPI (Recommended)

```bash
pip install nichi
```

### From Source

#### 1. Install Dependencies

This project now uses Poetry for dependency management. If you don't have Poetry installed, you can install it by following the [official instructions](https://python-poetry.org/docs/#installation).

```bash
# Install dependencies with Poetry
poetry install
```

#### 2. Set up Google AI API Key

1. Visit [Google AI Studio](https://makersuite.google.com/app/apikey)
2. Create a new API key for Google Gemini
3. Create a `.env` file in your project root:

```bash
# Copy the example file
cp .env.example .env

# Edit .env and add your configuration
GOOGLE_AI_API_KEY=your_actual_api_key_here
GEMINI_MODEL_NAME=gemini-2.0-flash-exp
```

#### 3. Install the Package

```bash
# Activate the Poetry shell and run the application directly
poetry shell
python src/main.py

# Or run without activating the shell
poetry run python src/main.py

# To install in development mode
poetry install

# To build and install the package
poetry build
pip install dist/*.whl
```

## Usage

### Running the Application

```bash
# Run from current directory
python src/main.py

# Or if installed as package
nichi

# Show environment variables
python src/main.py --env
```

### Menu Options

1. **Convert VTT files to SRT format** - Convert WebVTT subtitle files to SRT format
2. **Organize MP4 and subtitle files into folders** - Group video files with their corresponding subtitle files
3. **Convert VTT files and then organize** - Perform both conversion and organization in sequence
4. **Show current directory contents** - Display the files in the current working directory
5. **Change working directory** - Navigate to a different directory
6. **Translate SRT file to another language** - Translate a single SRT file using Google Gemini AI
7. **Show available languages for translation** - Display all supported languages for translation
8. **Adjust subtitle timing** - Shift subtitle timing forward or backward
9. **Compare two Subtitle files** - Use git difftool to compare two SRT files
10. **Manage translation cache** - View and clear the translation cache
11. **Show environment variables** - Display relevant environment variables
12. **Exit** - Close the application

### Translation Features

The AI translation system offers:

- **Fast Processing**: Concurrent batch processing with configurable batch sizes (default: 200 entries)
- **Smart Retry**: Automatic retry with exponential backoff for failed requests
- **Progress Tracking**: Real-time progress bars with success/failure statistics
- **Language Auto-detection**: Automatically detects source language from filenames
- **Terminal User Interface**: Beautiful TUI with Rich library

## Supported Languages

| Code | Language | Code | Language   | Code | Language   |
| ---- | -------- | ---- | ---------- | ---- | ---------- |
| en   | English  | es   | Spanish    | fr   | French     |
| de   | German   | it   | Italian    | pt   | Portuguese |
| ru   | Russian  | ja   | Japanese   | ko   | Korean     |
| zh   | Chinese  | ar   | Arabic     | hi   | Hindi      |
| th   | Thai     | vi   | Vietnamese | nl   | Dutch      |
| sv   | Swedish  | da   | Danish     | no   | Norwegian  |
| fi   | Finnish  | pl   | Polish     | tr   | Turkish    |

## Configuration

### Environment Variables

Create a `.env` file with:

```bash

# Required Configuration
GOOGLE_AI_API_KEY=your_google_ai_api_key_here
GEMINI_MODEL_NAME=gemini-2.0-flash-exp

# Optional Configuration
# GOOGLE_AI_PROJECT_ID=your_project_id_here
# TRANSLATION_BATCH_SIZE=10
# DEFAULT_TARGET_LANGUAGE=id

# Optional Configuration (Gemini)
# GEMINI_MAX_RETRIES=3
# GEMINI_BASE_DELAY=1
# GEMINI_MAX_DELAY=60
```

## Performance

The translation system is optimized for speed:

- **Large Batches**: Processes 200 subtitle entries per batch by default
- **Concurrent Processing**: Handles up to 5 batches simultaneously
- **Smart Retry**: Exponential backoff prevents API rate limiting
- **Progress Tracking**: Real-time feedback on translation progress

## Troubleshooting

### Translation Not Available

If translation features are unavailable:

1. **Check API Key**: Ensure `.env` file exists with valid `GOOGLE_AI_API_KEY`
2. **Verify Installation**: Run `pip list | grep google-generativeai`
3. **Test Connection**: Check internet connectivity
4. **API Quota**: Verify your Google AI API has remaining quota

### Common Issues

**Encoding Errors**: The translator automatically handles UTF-8, Latin-1, and CP1252 encodings
**Rate Limiting**: The system includes automatic retry with exponential backoff
**Large Files**: For very large subtitle files, the system automatically splits them into manageable batches

## Security

- Keep your `.env` file secure and never commit it to version control
- Add `.env` to your `.gitignore` file
- API keys are only used for Google Gemini translation requests
- No subtitle content is stored or logged

## Development

### Code Structure

The project follows a clean architecture pattern:

- `config/` - Configuration management
- `core/` - Business logic and core functionality
- `exceptions/` - Custom exception classes
- `models/` - Data models and structures
- `services/` - External service integrations
- `ui/` - User interface components

### Code Quality

- Type hints for all functions and classes
- Comprehensive docstrings for all public interfaces
- Consistent naming conventions
- Modular design with clear separation of concerns

### Running Tests

```bash
# Run tests with Poetry
poetry run pytest
```

### Code Formatting

```bash
# Format code with black
poetry run black src/

# Sort imports with isort
poetry run isort src/
```

### Managing Dependencies

```bash
# Add a new dependency
poetry add package_name

# Add a new development dependency
poetry add --group dev package_name

# Update dependencies
poetry update

# Export dependencies to requirements.txt (if needed)
poetry export -o requirements.txt -f requirements.txt --without-hashes
```


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "nichi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "video, subtitles, translation, organization, vtt, srt, gemini",
    "author": "Rafli",
    "author_email": "hidayattul.rafli@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d7/14/a6dec65cd8e4657790166b5b76d72e547178046534bc0982a8b8205354eb/nichi-2.0.6.tar.gz",
    "platform": null,
    "description": "# Video File Organizer with AI Translation\n\nA TUI video file organizer with Google Gemini AI-powered translation capabilities for SRT subtitle files. This tool helps you organize your video files and translate subtitle files to any supported language with AI translation.\n\n## Features\n\n### Core Features\n\n- **File Organization**: Organize video files by language and format\n- **VTT to SRT Conversion**: Convert WebVTT subtitle files to SRT format\n- **Interactive TUI**: Beautiful terminal user interface with Rich library\n\n### AI Translation Features \u2728\n\n- **SRT Translation**: Translate subtitle files using Google Gemini AI\n- **Batch Translation**: Translate multiple SRT files simultaneously\n- **Smart Language Detection**: Automatically detect source language from filenames\n- **Concurrent Processing**: Fast translation with concurrent batch processing\n- **Error Handling**: Robust retry logic with exponential backoff\n- **Progress Tracking**: Real-time progress indication with detailed statistics\n- **20+ Language Support**: Support for major world languages\n\n## Project Structure\n\n```\n.\n\u251c\u2500\u2500 LICENSE\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 pyproject.toml\n\u251c\u2500\u2500 poetry.lock\n\u2514\u2500\u2500 src\n    \u251c\u2500\u2500 __init__.py\n    \u251c\u2500\u2500 main.py\n    \u2514\u2500\u2500 nichi\n        \u251c\u2500\u2500 __init__.py\n        \u251c\u2500\u2500 config/\n        \u2502   \u251c\u2500\u2500 __init__.py\n        \u2502   \u2514\u2500\u2500 config_manager.py\n        \u251c\u2500\u2500 core/\n        \u2502   \u251c\u2500\u2500 __init__.py\n        \u2502   \u251c\u2500\u2500 converter.py\n        \u2502   \u251c\u2500\u2500 organizer.py\n        \u2502   \u251c\u2500\u2500 operations.py\n        \u2502   \u251c\u2500\u2500 srt_parser.py\n        \u2502   \u251c\u2500\u2500 timing_adjuster.py\n        \u2502   \u2514\u2500\u2500 translator.py\n        \u251c\u2500\u2500 exceptions/\n        \u2502   \u2514\u2500\u2500 __init__.py\n        \u251c\u2500\u2500 models/\n        \u2502   \u2514\u2500\u2500 __init__.py\n        \u251c\u2500\u2500 services/\n        \u2502   \u251c\u2500\u2500 __init__.py\n        \u2502   \u251c\u2500\u2500 gemini_translator.py\n        \u2502   \u2514\u2500\u2500 jellyfin_parser.py\n        \u2514\u2500\u2500 ui/\n            \u251c\u2500\u2500 __init__.py\n            \u251c\u2500\u2500 tui.py\n            \u251c\u2500\u2500 ui_components.py\n            \u2514\u2500\u2500 user_input.py\n```\n\n## Installation\n\n### Via PyPI (Recommended)\n\n```bash\npip install nichi\n```\n\n### From Source\n\n#### 1. Install Dependencies\n\nThis project now uses Poetry for dependency management. If you don't have Poetry installed, you can install it by following the [official instructions](https://python-poetry.org/docs/#installation).\n\n```bash\n# Install dependencies with Poetry\npoetry install\n```\n\n#### 2. Set up Google AI API Key\n\n1. Visit [Google AI Studio](https://makersuite.google.com/app/apikey)\n2. Create a new API key for Google Gemini\n3. Create a `.env` file in your project root:\n\n```bash\n# Copy the example file\ncp .env.example .env\n\n# Edit .env and add your configuration\nGOOGLE_AI_API_KEY=your_actual_api_key_here\nGEMINI_MODEL_NAME=gemini-2.0-flash-exp\n```\n\n#### 3. Install the Package\n\n```bash\n# Activate the Poetry shell and run the application directly\npoetry shell\npython src/main.py\n\n# Or run without activating the shell\npoetry run python src/main.py\n\n# To install in development mode\npoetry install\n\n# To build and install the package\npoetry build\npip install dist/*.whl\n```\n\n## Usage\n\n### Running the Application\n\n```bash\n# Run from current directory\npython src/main.py\n\n# Or if installed as package\nnichi\n\n# Show environment variables\npython src/main.py --env\n```\n\n### Menu Options\n\n1. **Convert VTT files to SRT format** - Convert WebVTT subtitle files to SRT format\n2. **Organize MP4 and subtitle files into folders** - Group video files with their corresponding subtitle files\n3. **Convert VTT files and then organize** - Perform both conversion and organization in sequence\n4. **Show current directory contents** - Display the files in the current working directory\n5. **Change working directory** - Navigate to a different directory\n6. **Translate SRT file to another language** - Translate a single SRT file using Google Gemini AI\n7. **Show available languages for translation** - Display all supported languages for translation\n8. **Adjust subtitle timing** - Shift subtitle timing forward or backward\n9. **Compare two Subtitle files** - Use git difftool to compare two SRT files\n10. **Manage translation cache** - View and clear the translation cache\n11. **Show environment variables** - Display relevant environment variables\n12. **Exit** - Close the application\n\n### Translation Features\n\nThe AI translation system offers:\n\n- **Fast Processing**: Concurrent batch processing with configurable batch sizes (default: 200 entries)\n- **Smart Retry**: Automatic retry with exponential backoff for failed requests\n- **Progress Tracking**: Real-time progress bars with success/failure statistics\n- **Language Auto-detection**: Automatically detects source language from filenames\n- **Terminal User Interface**: Beautiful TUI with Rich library\n\n## Supported Languages\n\n| Code | Language | Code | Language   | Code | Language   |\n| ---- | -------- | ---- | ---------- | ---- | ---------- |\n| en   | English  | es   | Spanish    | fr   | French     |\n| de   | German   | it   | Italian    | pt   | Portuguese |\n| ru   | Russian  | ja   | Japanese   | ko   | Korean     |\n| zh   | Chinese  | ar   | Arabic     | hi   | Hindi      |\n| th   | Thai     | vi   | Vietnamese | nl   | Dutch      |\n| sv   | Swedish  | da   | Danish     | no   | Norwegian  |\n| fi   | Finnish  | pl   | Polish     | tr   | Turkish    |\n\n## Configuration\n\n### Environment Variables\n\nCreate a `.env` file with:\n\n```bash\n\n# Required Configuration\nGOOGLE_AI_API_KEY=your_google_ai_api_key_here\nGEMINI_MODEL_NAME=gemini-2.0-flash-exp\n\n# Optional Configuration\n# GOOGLE_AI_PROJECT_ID=your_project_id_here\n# TRANSLATION_BATCH_SIZE=10\n# DEFAULT_TARGET_LANGUAGE=id\n\n# Optional Configuration (Gemini)\n# GEMINI_MAX_RETRIES=3\n# GEMINI_BASE_DELAY=1\n# GEMINI_MAX_DELAY=60\n```\n\n## Performance\n\nThe translation system is optimized for speed:\n\n- **Large Batches**: Processes 200 subtitle entries per batch by default\n- **Concurrent Processing**: Handles up to 5 batches simultaneously\n- **Smart Retry**: Exponential backoff prevents API rate limiting\n- **Progress Tracking**: Real-time feedback on translation progress\n\n## Troubleshooting\n\n### Translation Not Available\n\nIf translation features are unavailable:\n\n1. **Check API Key**: Ensure `.env` file exists with valid `GOOGLE_AI_API_KEY`\n2. **Verify Installation**: Run `pip list | grep google-generativeai`\n3. **Test Connection**: Check internet connectivity\n4. **API Quota**: Verify your Google AI API has remaining quota\n\n### Common Issues\n\n**Encoding Errors**: The translator automatically handles UTF-8, Latin-1, and CP1252 encodings\n**Rate Limiting**: The system includes automatic retry with exponential backoff\n**Large Files**: For very large subtitle files, the system automatically splits them into manageable batches\n\n## Security\n\n- Keep your `.env` file secure and never commit it to version control\n- Add `.env` to your `.gitignore` file\n- API keys are only used for Google Gemini translation requests\n- No subtitle content is stored or logged\n\n## Development\n\n### Code Structure\n\nThe project follows a clean architecture pattern:\n\n- `config/` - Configuration management\n- `core/` - Business logic and core functionality\n- `exceptions/` - Custom exception classes\n- `models/` - Data models and structures\n- `services/` - External service integrations\n- `ui/` - User interface components\n\n### Code Quality\n\n- Type hints for all functions and classes\n- Comprehensive docstrings for all public interfaces\n- Consistent naming conventions\n- Modular design with clear separation of concerns\n\n### Running Tests\n\n```bash\n# Run tests with Poetry\npoetry run pytest\n```\n\n### Code Formatting\n\n```bash\n# Format code with black\npoetry run black src/\n\n# Sort imports with isort\npoetry run isort src/\n```\n\n### Managing Dependencies\n\n```bash\n# Add a new dependency\npoetry add package_name\n\n# Add a new development dependency\npoetry add --group dev package_name\n\n# Update dependencies\npoetry update\n\n# Export dependencies to requirements.txt (if needed)\npoetry export -o requirements.txt -f requirements.txt --without-hashes\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A TUI tool for organizing video files, converting VTT subtitles to SRT format, and translating SRT files using Google Gemini AI.",
    "version": "2.0.6",
    "project_urls": {
        "Repository": "https://github.com/hdytrfli/nichi"
    },
    "split_keywords": [
        "video",
        " subtitles",
        " translation",
        " organization",
        " vtt",
        " srt",
        " gemini"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "92ee1df9e607392eaf2585c77c661e6b53a0e14e6a3842ef772d2a3f7df81f40",
                "md5": "db5e2136ddd9c2427738e4af1c08c97c",
                "sha256": "6524d3680b835dedd4aca662a564ed336360bf701a2daa6dd982de3335575e5d"
            },
            "downloads": -1,
            "filename": "nichi-2.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "db5e2136ddd9c2427738e4af1c08c97c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 41930,
            "upload_time": "2025-08-31T22:11:17",
            "upload_time_iso_8601": "2025-08-31T22:11:17.028612Z",
            "url": "https://files.pythonhosted.org/packages/92/ee/1df9e607392eaf2585c77c661e6b53a0e14e6a3842ef772d2a3f7df81f40/nichi-2.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d714a6dec65cd8e4657790166b5b76d72e547178046534bc0982a8b8205354eb",
                "md5": "ab0791804559ea6949c2f37aeba9058e",
                "sha256": "db280b4efe4deb19614cb042c1c48f72abf7a10e0de8a0e0bd7ebaec1260578f"
            },
            "downloads": -1,
            "filename": "nichi-2.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "ab0791804559ea6949c2f37aeba9058e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 33301,
            "upload_time": "2025-08-31T22:11:18",
            "upload_time_iso_8601": "2025-08-31T22:11:18.397884Z",
            "url": "https://files.pythonhosted.org/packages/d7/14/a6dec65cd8e4657790166b5b76d72e547178046534bc0982a8b8205354eb/nichi-2.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-31 22:11:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hdytrfli",
    "github_project": "nichi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "nichi"
}
        
Elapsed time: 0.46740s