### Python Environment Setup Source: https://github.com/arial-z/romaji-renamer/blob/main/README.md Commands to create a virtual environment and install the necessary Python dependencies for the script. ```bash cd into the script folder python3 -m venv romaji-renamer-venv source romaji-renamer-venv/bin/activate pip install plexapi python-dotenv ``` -------------------------------- ### Install and Run Manually Source: https://context7.com/arial-z/romaji-renamer/llms.txt Steps to set up the Python environment and execute the script natively. ```bash # Clone the repository git clone https://github.com/Arial-Z/Romaji-Renamer.git cd Romaji-Renamer # Create virtual environment and install dependencies python3 -m venv romaji-renamer-venv source romaji-renamer-venv/bin/activate pip install plexapi python-dotenv # Copy and configure environment file cp config/default.env config/.env # Run the script bash romaji-renamer.sh ``` -------------------------------- ### Kometa Configuration Example Source: https://github.com/arial-z/romaji-renamer/blob/main/README.md Example of how to add the metadata path to your Kometa config.yml file. This ensures Kometa can find the anime metadata. ```yaml Animes: metadata_files: - file: config/metadata-animes.yml ``` -------------------------------- ### Configuration Environment Variables Source: https://github.com/arial-z/romaji-renamer/blob/main/README.md Example of the .env file configuration required to connect the script to a Plex server. ```env #Url of the Plex server (Needed) plex_url=http://127.0.0.1:32400 #Plex token (Needed) plex_token=zadazdzadazdazdazdazdazd # Run the animes script (Yes/No) RUN_ANIMES_SCRIPT=Yes # Plex animes library name need to be in a double quote (Needed for the animes script) ANIME_LIBRARY_NAME="Animes" ``` -------------------------------- ### Manage Docker Container Source: https://context7.com/arial-z/romaji-renamer/llms.txt Commands to start the service and monitor logs. ```bash # Start the container docker-compose up -d # View logs docker logs romaji-renamer ``` -------------------------------- ### Kometa Metadata Configuration Example Source: https://github.com/arial-z/romaji-renamer/blob/main/README.md Example of the YAML structure used by Kometa to import anime metadata, including titles, genres, labels, and season-specific ratings. ```yml # TVDB_ID for Kometa to import 421069: # Title : either Romaji title or English title (in settings) (from Anilist) title: |- [Oshi no Ko] # Sort Title : either Romaji title or English title (in settings) (from Anilist) sort_title: |- [Oshi no Ko] # original_title : English title or Native Title (from Anilist) original_title: |- Oshi No Ko # Anilist genre ands tags (genres, and tag above > 70% can be changed in settings) or from MAL genres, demographics and themes genre.sync: Drama,Mystery,Psychological,Supernatural,Acting,Tragedy,Idol,Revenge,Twins,Male Protagonist,Urban,Reincarnation,Pregnancy,Detective,Seinen,Tsundere,Boys' Love,Female Protagonist,Coming of Age,Anti-Hero,Time Skip,Orphan,Age Regression,Ensemble Cast,Filmmaking # Add label to build collections and overlays Anilist Airing status (Planned, Airing or Ended) Anime Award winner and Anilist userlist status label: AA Winner,Planned,Completed label.remove: Airing,Ended,Watching,Dropped,Paused,Planning # Studio from Anilist studio: Doga Kobo # Season import seasons: # Season 1 import 1: # Title from Anilist (Romaji or English from the title setting) title: |- [Oshi no Ko] # Rating 1 from Anilist or MAL (in settings) user_rating: 8.4 # Add label score to use with kometa overlays and also add the season label (optionnal) label: Score,AA Winner,Completed,2023 Spring label.remove: Watching,Dropped,Paused,Planning # Season 2 import 2: # Title from Anilist (Romaji or English from the title setting) title: |- [Oshi no Ko] 2nd Season # Rating 1 from Anilist or MAL (in settings) user_rating: 8.5 # Add label score to use kometa overlays and also add the season label (optionnal) label: Score,Completed,2024 Summer label.remove: Watching,Dropped,Paused,Planning # Rating 1 : average rating of the seasons (Anilist or MAL) audience_rating: 8.4 # Rating 2 : average rating of the seasons (Anilist or MAL) critic_rating: 8.6 ``` -------------------------------- ### Docker Execution of Romaji-Renamer Source: https://context7.com/arial-z/romaji-renamer/llms.txt Run the Romaji-Renamer script using Docker. This command starts a container, runs the script, and then removes the container. Ensure volumes are mounted for persistent configuration and logs. ```bash # Docker: Use container restart policy or external scheduler docker run --rm arialz/romaji-renamer ``` -------------------------------- ### Configure Environment Variables Source: https://context7.com/arial-z/romaji-renamer/llms.txt Settings for Plex connectivity, library paths, and metadata preferences. ```bash # config/.env # Plex Server Connection (Required) plex_url=http://127.0.0.1:32400 plex_token=your_plex_token_here # Script Execution Flags RUN_ANIMES_SCRIPT=Yes RUN_MOVIES_SCRIPT=No RUN_SEASONAL_SCRIPT=No # Library Names (must match Plex exactly) ANIME_LIBRARY_NAME="Animes" MOVIE_LIBRARY_NAME="Animes Movies" # Output Paths - Docker uses $SCRIPT_FOLDER/pmm/, Python uses Kometa config path METADATA_ANIMES=$SCRIPT_FOLDER/pmm/metadata-animes.yml METADATA_MOVIES=$SCRIPT_FOLDER/pmm/metadata-animes-movies.yml DOWNLOAD_ANIMES_COLLECTION=$SCRIPT_FOLDER/pmm/seasonal-animes-download.yml ASSET_FOLDER=$SCRIPT_FOLDER/pmm/assets LOG_FOLDER=$SCRIPT_FOLDER/config/logs # Rating Configuration RATING_1_SOURCE=ANILIST # MAL or ANILIST RATING_1_TYPE=audience # audience, critic, or user RATING_2_SOURCE=MAL # MAL, ANILIST, or empty to disable RATING_2_TYPE=critic # audience, critic, user, or empty # Title Settings ALLOW_RENAMING=Yes # Enable/disable title changes MAIN_TITLE_ENG=No # Use English titles instead of Romaji SORT_TITLE_ENG=No # English sort titles ORIGINAL_TITLE_NATIVE=Yes # Native characters for original_title RENAME_SEASONS=Yes # Rename seasons to AniList titles REDUCE_TITLE_CAPS=Yes # Fix all-caps titles like "86 EIGHTY-SIX" # Tags and Genres DISABLE_TAGS=No TAG_SOURCE=ANILIST # MAL or ANILIST ADD_ANIME_TAG=Yes # Add "Anime" tag to all entries ANILIST_TAGS_P=70 # Minimum tag percentage (0-100) # Poster Settings POSTER_DOWNLOAD=Yes POSTER_SEASON_DOWNLOAD=Yes POSTER_SOURCE=ANILIST # MAL or ANILIST # Season Settings IGNORE_SEASONS=No # Skip season metadata SEASON_YEAR=No # Add season labels (Fall 2022, etc.) IGNORE_S1_ONLY_RATING=Yes # Skip season rating for single-season shows # Anime Awards ANIME_AWARDS=Yes # Track Crunchyroll Anime Awards ANIME_AWARDS_NO_FVA=Yes # Ignore foreign voice actor awards # AniList User Lists ANILIST_LISTS=No # Sync user watch status ANILIST_USERNAME=YourUsername ANILIST_LISTS_LEVEL=show # show, season, or both # Cache Settings DATA_CACHE_TIME=5 # Days to cache API data ``` -------------------------------- ### Configure Asset and Log Folders Source: https://github.com/arial-z/romaji-renamer/blob/main/README.md Specify the directories for Kometa assets and script logs. The default log folder is usually sufficient. ```bash ASSET_FOLDER=$SCRIPT_FOLDER/pmm/assets LOG_FOLDER=$SCRIPT_FOLDER/config/logs ``` -------------------------------- ### Configure Metadata and Script Paths Source: https://github.com/arial-z/romaji-renamer/blob/main/README.md Set the paths for anime metadata files and enable/disable script execution. Ensure paths are correct for your environment (Docker or Python). ```bash METADATA_ANIMES=$SCRIPT_FOLDER/pmm/metadata-animes.yml RUN_MOVIES_SCRIPT=No MOVIE_LIBRARY_NAME="Animes Movies" METADATA_MOVIES=$SCRIPT_FOLDER/pmm/metadata-animes-movies.yml RUN_SEASONAL_SCRIPT=No DOWNLOAD_LIMIT=20 DOWNLOAD_ANIMES_COLLECTION=$SCRIPT_FOLDER/pmm/seasonal-animes-download.yml ``` -------------------------------- ### Configure Anilist Lists and Cache Source: https://github.com/arial-z/romaji-renamer/blob/main/README.md Enable or disable the import of tags based on Anilist user lists (e.g., 'Completed', 'Watching') and specify the level at which these tags should be applied. Set the data cache time in days. ```bash ANILIST_LISTS=No ANILIST_USERNAME=Arialz ANILIST_LISTS_LEVEL=show DATA_CACHE_TIME=5 ``` -------------------------------- ### Configure Tagging and Poster Downloads Source: https://github.com/arial-z/romaji-renamer/blob/main/README.md Manage tag imports from MAL/ANILIST, including tag percentage thresholds and adding a default 'Anime' tag. Configure poster downloads for main shows and seasons, specifying the source. ```bash DISABLE_TAGS=No TAG_SOURCE=ANILIST ADD_ANIME_TAG=Yes ANILIST_TAGS_P=70 POSTER_DOWNLOAD=Yes POSTER_SEASON_DOWNLOAD=Yes POSTER_SOURCE=ANILIST ``` -------------------------------- ### Running the Romaji Renamer Script Source: https://github.com/arial-z/romaji-renamer/blob/main/README.md Demonstrates how to execute the romaji-renamer script using bash. It's recommended to run this script before Kometa if using CRON. ```bash bash path/to/romaji-renamer.sh ``` -------------------------------- ### Deploy with Docker Compose Source: https://context7.com/arial-z/romaji-renamer/llms.txt Use this configuration to run Romaji-Renamer as a containerized service. ```yaml # docker-compose.yml --- services: romaji-renamer: image: arialz/romaji-renamer container_name: romaji-renamer environment: - PUID=1000 - PGID=1000 - TZ=Europe/Paris volumes: - /path/to/script/config:/config:rw - /path/to/pmm/config:/pmm:rw restart: no ``` -------------------------------- ### Run Seasonal Anime Download Script Source: https://context7.com/arial-z/romaji-renamer/llms.txt Execute the seasonal anime download script manually. This command sets an environment variable to enable the script's functionality. ```bash RUN_SEASONAL_SCRIPT=Yes bash romaji-renamer.sh ``` -------------------------------- ### Run Seasonal Download Script Standalone Source: https://context7.com/arial-z/romaji-renamer/llms.txt Execute the seasonal download script as a standalone bash script. ```bash bash seasonal-animes-download.sh ``` -------------------------------- ### Configure Season and Award Settings Source: https://github.com/arial-z/romaji-renamer/blob/main/README.md Control how seasons are handled, including ignoring season titles/ratings and adding season year labels. Enable or disable the inclusion of Anime Awards winners. ```bash IGNORE_SEASONS=No SEASON_YEAR=No IGNORE_S1_ONLY_RATING=Yes ANIME_AWARDS=Yes ANIME_AWARDS_NO_FVA=Yes ``` -------------------------------- ### Fetch User Watch Lists with AniList GraphQL Source: https://context7.com/arial-z/romaji-renamer/llms.txt Retrieve a user's anime lists (Completed, Watching, Dropped, etc.) by querying the AniList GraphQL API. Replace 'YourUsername' with the target user's AniList username. The response provides mediaId values for each entry. ```bash curl -s 'https://graphql.anilist.co/' \ -X POST \ -H 'content-type: application/json' \ --data '{ \ "query": "{ \ MediaListCollection(userName: \"YourUsername\" type: ANIME) { \ lists { \ name \ entries { mediaId } \ } \ } \ }" \ }' ``` -------------------------------- ### Cron Automation for Romaji-Renamer Source: https://context7.com/arial-z/romaji-renamer/llms.txt Schedule the Romaji-Renamer script to run daily at 2 AM using cron. This ensures automatic updates before Kometa runs at 3 AM. Adjust the paths to your script and log file as needed. ```bash # Edit crontab crontab -e # Run daily at 2 AM (before Kometa at 3 AM) 0 2 * * * /path/to/romaji-renamer.sh >> /path/to/cron.log 2>&1 ``` -------------------------------- ### Fetch Currently Airing Anime with AniList GraphQL Source: https://context7.com/arial-z/romaji-renamer/llms.txt Query the AniList GraphQL API for currently airing anime, sorted by popularity. This is useful for tracking shows with upcoming episodes. The 'perPage' parameter can be adjusted for the number of results per page. ```bash curl -s 'https://graphql.anilist.co/' \ -X POST \ -H 'content-type: application/json' \ --data '{ \ "query": "{ \ Page(page: 1, perPage: 50) { \ pageInfo { hasNextPage } \ media(type: ANIME, status_in: RELEASING, sort: POPULARITY_DESC) { \ id \ } \ } \ }" \ }' ``` -------------------------------- ### Kometa Configuration for Anime Libraries Source: https://context7.com/arial-z/romaji-renamer/llms.txt Integrate generated metadata files into your Kometa configuration. This YAML snippet shows how to specify metadata file paths and asset directories for your 'Animes' and 'Animes Movies' libraries. ```yaml # Kometa config.yml libraries: Animes: metadata_files: - file: config/metadata-animes.yml settings: asset_directory: config/assets Animes Movies: metadata_files: - file: config/metadata-animes-movies.yml ``` -------------------------------- ### Fetch Anime Metadata with AniList GraphQL Source: https://context7.com/arial-z/romaji-renamer/llms.txt Use this GraphQL query to fetch detailed metadata for a specific anime, including titles, scores, genres, tags, studios, and release information. Ensure the 'content-type' header is set to 'application/json'. ```bash curl -s 'https://graphql.anilist.co/' \ -X POST \ -H 'content-type: application/json' \ --data '{ \ "query": "{ \ Media(type: ANIME, id: 21459) { \ relations { \ edges { \ relationType \ node { id type format title { romaji } status } \ } \ } \ title { romaji(stylised: false) english(stylised: false) native(stylised: false) } \ averageScore \ genres \ tags { name rank } \ studios { edges { node { name isAnimationStudio } } } \ startDate { year month } \ season \ seasonYear \ coverImage { extraLarge } \ status \ idMal \ } \ }" \ }' ``` -------------------------------- ### Download Anime ID Mapping Files Source: https://context7.com/arial-z/romaji-renamer/llms.txt Download anime ID mapping files from GitHub for TV shows, movies, and Crunchyroll Anime Awards data. These files are used for automatic ID resolution between different platforms. ```bash curl -s "https://raw.githubusercontent.com/Arial-Z/Animes-ID/main/list-animes-id.json" > config/tmp/list-animes-id.json ``` ```bash curl -s "https://raw.githubusercontent.com/Arial-Z/Animes-ID/main/list-movies-id.json" > config/tmp/list-movies-id.json ``` ```bash curl -s "https://raw.githubusercontent.com/Arial-Z/Animes-ID/main/cr-award/cr-award.json" > config/tmp/cr-award.json ``` -------------------------------- ### Query Anime ID Mapping File Source: https://context7.com/arial-z/romaji-renamer/llms.txt Use jq to query the downloaded anime ID mapping file for an AniList ID based on a TVDB ID. Specify the TVDB ID and optionally season, and offset parameters for precise matching. ```bash jq --arg tvdb_id "421069" \ '.[] | select(.tvdb_id == $tvdb_id) | select(.tvdb_season == "1" or .tvdb_season == "-1") | select(.tvdb_epoffset == "0") | .anilist_id' \ config/tmp/list-animes-id.json ``` -------------------------------- ### Fetch Seasonal Anime with AniList GraphQL Source: https://context7.com/arial-z/romaji-renamer/llms.txt Retrieve anime from a specific season and year using the AniList GraphQL API. This query is designed for features like seasonal downloads. Adjust 'seasonYear', 'season', and 'perPage' as needed. ```bash curl -s 'https://graphql.anilist.co/' \ -X POST \ -H 'content-type: application/json' \ --data '{ \ "query": "{ \ Page(page: 1, perPage: 20) { \ pageInfo { hasNextPage } \ media(type: ANIME, seasonYear: 2024, season: WINTER, format: TV, sort: POPULARITY_DESC) { \ id \ } \ } \ }" \ }' ``` -------------------------------- ### Configure Rating and Title Sources Source: https://github.com/arial-z/romaji-renamer/blob/main/README.md Define the sources for anime ratings (MAL/ANILIST) and types (audience/critic). Control title formatting, including the use of English, Romaji, and native titles, as well as capitalization. ```bash RATING_1_SOURCE=ANILIST RATING_1_TYPE=audience RATING_2_SOURCE=MAL RATING_2_TYPE=critic ALLOW_RENAMING=Yes MAIN_TITLE_ENG=No SORT_TITLE_ENG=No ORIGINAL_TITLE_NATIVE=Yes RENAME_SEASONS=Yes REDUCE_TITLE_CAPS=Yes ``` -------------------------------- ### Fetch MAL Anime Data with Jikan API Source: https://context7.com/arial-z/romaji-renamer/llms.txt Use the Jikan API to fetch anime data from MyAnimeList by its MAL ID. Note the rate limiting: 1 request per second, with a 30-second wait triggered by a 429 response. ```bash curl -s "https://api.jikan.moe/v4/anime/21" | jq '.' ``` -------------------------------- ### Run Romaji-Renamer Script Manually Source: https://context7.com/arial-z/romaji-renamer/llms.txt Execute the main Romaji-Renamer script to process your entire anime library. This command runs all configured scripts. ```bash # Run with all configured scripts bash romaji-renamer.sh ``` -------------------------------- ### Override Movie ID Configuration (TSV) Source: https://context7.com/arial-z/romaji-renamer/llms.txt Manually specify ID mappings for movies using a TSV file. The format includes IMDb ID, AniList ID, Title, Studio, and notes. Use TAB as the separator. 'ignore' can be used for the AniList ID to exclude a movie. ```tsv # config/override-ID-movies.tsv # imdb-id anilist-id Title Studio notes tt0110008 1030 Studio Ghibli Pompoko tt3666024 ignore Ignore this movie ``` -------------------------------- ### Kometa Seasonal Anime Download Collection Source: https://context7.com/arial-z/romaji-renamer/llms.txt This YAML configuration defines a Kometa collection named 'seasonal animes download' that automatically adds new seasonal anime to Sonarr. It specifies TVDB show IDs and enables Sonarr integration for missing episodes. ```yaml # seasonal-animes-download.yml (auto-generated) collections: seasonal animes download: tvdb_show: 421069, 439488, 445435 sync_mode: append sonarr_add_missing: true build_collection: false ``` -------------------------------- ### Kometa Anime Metadata YAML Format Source: https://context7.com/arial-z/romaji-renamer/llms.txt This YAML structure defines metadata for anime series, including titles, genres, studios, and season details. It's used by Kometa to update Plex libraries. Ensure the 'metadata' key is at the top level and anime IDs are used as keys. ```yaml # metadata-animes.yml # Romaji-Renamer v1.25.4 metadata: 421069: title: |- [Oshi no Ko] sort_title: |- [Oshi no Ko] original_title: |- 【推しの子】 genre.sync: Anime,Drama,Mystery,Psychological,Supernatural,Acting,Tragedy,Idol,Revenge,Seinen studio: Doga Kobo seasons: 1: title: |- [Oshi no Ko] user_rating: 8.4 label: Score,AA Winner,Completed,2023 Spring label.remove: Watching,Dropped,Paused,Planning 2: title: |- [Oshi no Ko] 2nd Season user_rating: 8.5 label: Score,Completed,2024 Summer label.remove: Watching,Dropped,Paused,Planning audience_rating: 8.4 critic_rating: 8.6 label: AA Winner,Ended,Completed label.remove: Airing,Planned,Watching,Dropped,Paused,Planning ``` -------------------------------- ### Override Anime ID Configuration (TSV) Source: https://context7.com/arial-z/romaji-renamer/llms.txt Manually specify ID mappings for anime that are not automatically matched using TSV files. The format includes TVDB ID, AniList ID, Title, Studio, season ignore flag, and notes. Use TAB as the separator. ```tsv # config/override-ID-animes.tsv (use TAB as separator) # tvdb-id anilist-id Title Studio ignore_seasons notes 114801 6702 A-1 Pictures yes Fairy Tail 79685 263 Hajime no Ippo 76013 627 Major 82099 ignore Ignore this entry completely ``` -------------------------------- ### Export Plex Anime Data to TSV Source: https://context7.com/arial-z/romaji-renamer/llms.txt This Python script connects to a Plex server, retrieves anime library details, and exports them to a TSV file. It extracts TVDB IDs, titles, folder names, and season information. Ensure your Plex URL, token, and anime library name are configured in a .env file. ```python from plexapi.server import PlexServer from dotenv import load_dotenv from os import environ from pathlib import Path import re # Load configuration basedir = Path(__file__).parent load_dotenv(Path(basedir, "config/.env")) url = environ.get('plex_url') token = environ.get('plex_token') ANIME_LIBRARY_NAME = environ.get('ANIME_LIBRARY_NAME') # Connect to Plex plex = PlexServer(url, token, timeout=300) animes = plex.library.section(ANIME_LIBRARY_NAME) # Export anime data # Output: config/tmp/plex_animes_export.tsv # Format: tvdb_id\ttitle\tfolder_name\tseason_list # Example: 421069\t[Oshi no Ko]\tOshi no Ko\t1,2 with open(Path(basedir, "config/tmp/plex_animes_export.tsv"), "w") as export_plex: for video in animes.search(): title = str(video.title) ids = str(video.guids) tvdbid = re.search(r"(?<=tvdb://)(\d+)", ids) if tvdbid: tvdb = str(tvdbid.group(1)) folder = Path(video.locations[0]).name seasons = ','.join(re.findall(r"\-(\d*)\>", str(video.seasons()))) export_plex.write(f"{tvdb}\t{title}\t{folder}\t{seasons}\n") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.