Skip to content

Commit

Permalink
Merge pull request #40 from Arial-Z/dev
Browse files Browse the repository at this point in the history
Prepare new release
  • Loading branch information
Arial-Z authored Nov 20, 2024
2 parents fd73e32 + 58f450e commit a306b3f
Show file tree
Hide file tree
Showing 13 changed files with 622 additions and 185 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ LICENSE
.github
Dockerfile
docker-compose.yml
romaji-renamer-venv
venv
.env
config/tmp
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN echo "**** install system packages ****" \
&& apt-get update \
&& apt-get upgrade -y --no-install-recommends \
&& apt-get install -y tzdata --no-install-recommends \
&& apt-get install -y gcc g++ libxml2-dev libxslt-dev libz-dev libjpeg62-turbo-dev zlib1g-dev wget curl jq \
&& apt-get install -y gcc g++ libxml2-dev libxslt-dev libz-dev libjpeg62-turbo-dev zlib1g-dev wget curl jq gawk \
&& wget -O /tini https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-"$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
&& chmod +x /tini \
&& pip3 install --no-cache-dir --upgrade --requirement /requirements.txt \
Expand All @@ -20,4 +20,4 @@ RUN echo "**** install system packages ****" \
&& rm -rf /requirements.txt /tmp/* /var/tmp/* /var/lib/apt/lists/*
VOLUME /config
VOLUME /pmm
ENTRYPOINT ["/tini", "-s", "bash", "plex-romaji-renamer.sh", "--"]
ENTRYPOINT ["/tini", "-s", "bash", "romaji-renamer.sh", "--"]
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,20 @@ First you need a GNU/Linux OS to run bash script<br/>
Requirements: Plex Media Server, Plex-Meta-Manager, Python and JQ<br/>
- Install and configure Plex-Meta-Manager: https://github.com/meisnate12/Plex-Meta-Manager<br/>
- Install JQ is a json parser see: https://stedolan.github.io/jq/ (Present by default on unRAID 6.10.0 and later.)<br/>
- install python plexapi
```
pip install plexapi
```
- install python-dotenv
```
pip install python-dotenv
```

### Step 2 - Download and extract the script
Git clone the **main** branch or get lastest release : https://github.com/Arial-Z/Romaji-Renamer/releases/latest

### Step 3 - Configure the script
### Step 3 - Install python modules and configure the script
- Extract the script on a desired location.<br/>
- Navigate to its location.<br/>
- install python plexapi and python-dotenv with a virtual environment
```
cd into the script folder
python3 -m venv romaji-renamer-venv
source romaji-renamer-venv/bin/activate
pip install plexapi python-dotenv
```
- Copy default.env to config/.env<br/>
- cd into the config folder and edit .env to fill out the variables.<br/>
```env
Expand Down Expand Up @@ -171,7 +170,7 @@ DATA_CACHE_TIME=5
- Within your (PMM) config.yml add the following metadata_path, it should look like this with the default filepath:
```yml
Animes:
metadata_path:
metadata_files:
- file: config/metadata-animes.yml
```
Configuration finished.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

version=1.24
version=1.24+
38 changes: 28 additions & 10 deletions animes-renamer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,31 @@ fi
:> "$MATCH_LOG"
printf "%s - Starting animes script\n\n" "$(date +%H:%M:%S)" | tee -a "$LOG"

# Download animes mapping json data
# Download animes mapping json data & anilist userlist
download-anime-id-mapping
get-anilist-userlist

# export animes list from plex
printf "%s - Creating animes list\n" "$(date +%H:%M:%S)" | tee -a "$LOG"
printf "%s\t - Exporting Plex animes library\n" "$(date +%H:%M:%S)" | tee -a "$LOG"
python3 "$SCRIPT_FOLDER/plex_animes_export.py"
if [ -f "$SCRIPT_FOLDER/romaji-renamer-venv/bin/python3" ]
then
"$SCRIPT_FOLDER/romaji-renamer-venv/bin/python3" "$SCRIPT_FOLDER/plex_animes_export.py"
else
python3 "$SCRIPT_FOLDER/plex_animes_export.py"
fi
printf "%s\t - Done\n" "$(date +%H:%M:%S)" | tee -a "$LOG"

# create ID/animes.tsv
create-override
printf "%s\t - Sorting Plex animes library\n" "$(date +%H:%M:%S)" | tee -a "$LOG"
while IFS=$'\t' read -r tvdb_id anilist_id title_override studio override_seasons_ignore notes
while IFS= read -r line
do
tvdb_id=$(printf "%s" "$line" | awk -F"\t" '{print $1}')
anilist_id=$(printf "%s" "$line" | awk -F"\t" '{print $2}')
title_override=$(printf "%s" "$line" | awk -F"\t" '{print $3}')
studio=$(printf "%s" "$line" | awk -F"\t" '{print $4}')
override_seasons_ignore=$(printf "%s" "$line" | awk -F"\t" '{print $5}')
if ! awk -F"\t" '{print $1}' "$SCRIPT_FOLDER/config/ID/animes.tsv" | grep -q -w "$tvdb_id"
then
if awk -F"\t" '{print $1}' "$SCRIPT_FOLDER/config/tmp/plex_animes_export.tsv" | grep -q -w "$tvdb_id"
Expand Down Expand Up @@ -89,27 +100,34 @@ do
-X POST \
-H 'content-type: application/json' \
--data '{ "query": "{ Page(page: '"$ongoingpage"', perPage: 50) { pageInfo { hasNextPage } media(type: ANIME, status_in: RELEASING, sort: POPULARITY_DESC) { id } } }" }' > "$SCRIPT_FOLDER/config/tmp/ongoing-anilist.json" -D "$SCRIPT_FOLDER/config/tmp/anilist-limit-rate.txt"
if grep -q -w '"data": null' "$SCRIPT_FOLDER/config/tmp/ongoing-anilist.json"
then
rm "$SCRIPT_FOLDER/config/tmp/ongoing-anilist.json"
printf "%s - Error AniList API down, exiting\n" "$(date +%H:%M:%S)" | tee -a "$LOG"
exit 1
fi
rate_limit=0
rate_limit=$(grep -oP '(?<=x-ratelimit-remaining: )[0-9]+' "$SCRIPT_FOLDER/config/tmp/anilist-limit-rate.txt")
((wait_time++))
if [[ -z $rate_limit ]]
if [[ $wait_time == 4 ]]
then
printf "%s - Error can't download anilist data stopping script\n" "$(date +%H:%M:%S)" | tee -a "$LOG"
exit 1
elif [[ -z $rate_limit ]]
then
printf "%s\t - Cloudflare limit rate reached watiting 60s\n" "$(date +%H:%M:%S)" | tee -a "$LOG"
sleep 61
elif [[ $rate_limit -ge 3 ]]
then
sleep 0.8
sleep 1
printf "%s\t - done\n" "$(date +%H:%M:%S)" | tee -a "$LOG"
break
elif [[ $rate_limit -lt 3 ]]
then
printf "%s\t - Anilist API limit reached watiting 30s" "$(date +%H:%M:%S)" | tee -a "$LOG"
sleep 30
printf "%s\t - done\n" "$(date +%H:%M:%S)" | tee -a "$LOG"
break
elif [[ $wait_time == 4 ]]
then
printf "%s - Error can't download anilist data stopping script\n" "$(date +%H:%M:%S)" | tee -a "$LOG"
exit 1
fi
done
jq '.data.Page.media[].id' -r "$SCRIPT_FOLDER/config/tmp/ongoing-anilist.json" >> "$SCRIPT_FOLDER/config/tmp/ongoing-tmp.tsv" # store the mal ID of the ongoing show
Expand Down Expand Up @@ -139,7 +157,7 @@ do
fi
fi
done < "$SCRIPT_FOLDER/config/tmp/ongoing.tsv"
printf "%s\t - Done\n\n" "$(date +%H:%M:%S)"
printf "%s\t - Done\n" "$(date +%H:%M:%S)"
printf "%s - Done\n\n" "$(date +%H:%M:%S)"

# write PMM metadata file from ID/animes.tsv and jikan API
Expand Down
26 changes: 19 additions & 7 deletions config/default.env
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ SORT_TITLE_ENG=No
ORIGINAL_TITLE_NATIVE=Yes
# Rename season to the anilist title of that season (Yes/No)
RENAME_SEASONS=Yes
# Anilist have some full uppercase title, this settings will remove them "86 EIGHTY-SIX" > "86 Eighty-Six" (Yes/No)
REDUCE_TITLE_CAPS=Yes
# Disable anilist tags (Yes/No)
DISABLE_TAGS=No
# Add a default "Anime" tag to everything (Yes/No)
ADD_ANIME_TAG=Yes
#Grab anilist tags higher or equal than percentage (0-100)
ANILIST_TAGS_P=70
# Download poster (Yes/No)
Expand All @@ -67,13 +73,19 @@ POSTER_SEASON_DOWNLOAD=Yes
POSTER_SOURCE=ANILIST
# Ignore seasons title, rating and poster (Yes/No)
IGNORE_SEASONS=No
# Ignore season 1 if it's the only season (Yes/No)
IGNORE_S1=Yes
# Anilist have some full uppercase title, this settings will remove them "86 EIGHTY-SIX" > "86 Eighty-Six" (Yes/No)
REDUCE_TITLE_CAPS=Yes
#Add the anime season to the season label in plex (Fall 2022, Spring 2021, ...)
SEASON_YEAR=No
# Disable anilist tags
DISABLE_TAGS=No
# Ignore season rating for animmes with only 1 season (Yes/No)
IGNORE_S1_ONLY_RATING=Yes
# Add Anime Awards winner for seasons and shows
ANIME_AWARDS=Yes
# Ignore non japanese voice actor awards (Yes/No)
ANIME_AWARDS_NO_FVA=Yes
# Add tags based on userlists from anilist (Completed, wathcing) (Yes/No)
ANILIST_LISTS=No
# Anilist username
ANILIST_USERNAME=Arialz
# For Shows the level tags should be added ("show", "season" or "both")
ANILIST_LISTS_LEVEL=show
# Mal Data cache time (in days min : 1)
DATA_CACHE_TIME=5
DATA_CACHE_TIME=5
5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
version: "2.1"
services:
plex-romaji-renamer:
romaji-renamer:
image: arialz/romaji-renamer:dev
container_name: romaji-renamer
environment:
Expand All @@ -11,4 +10,4 @@ services:
volumes:
- /path/to/script/config:/config:rw
- /path/to/pmm/config:/pmm:rw
restart: no
restart: no
Loading

0 comments on commit a306b3f

Please sign in to comment.