From f0bde4c7d99bf44da9f6f1815c909f2b9b92358b Mon Sep 17 00:00:00 2001 From: Arial-Z Date: Thu, 16 Nov 2023 23:27:22 +0100 Subject: [PATCH 1/3] Fix seasonal script folder --- .github/workflows/main.yml | 4 ++-- seasonal-animes-download.sh | 30 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b3ad3c3..b044df5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,7 +39,7 @@ jobs: context: ./ file: ./Dockerfile build-args: | - "BRANCH_NAME=stable" + "BRANCH_NAME=latest" platforms: linux/amd64,linux/arm64 push: true - tags: ${{ secrets.DOCKER_HUB_USERNAME }}/plex-romaji-renamer:stable + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/plex-romaji-renamer:latest diff --git a/seasonal-animes-download.sh b/seasonal-animes-download.sh index 611f5cd..52be160 100755 --- a/seasonal-animes-download.sh +++ b/seasonal-animes-download.sh @@ -4,34 +4,34 @@ export LC_ALL=en_US.UTF-8 SCRIPT_FOLDER=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) media_type=seasonal -source "$SCRIPT_FOLDER/.env" +source "$SCRIPT_FOLDER/config/.env" source "$SCRIPT_FOLDER/functions.sh" # check if files and folder exist -if [ ! -d "$SCRIPT_FOLDER/data" ] #check if exist and create folder for json data +if [ ! -d "$SCRIPT_FOLDER/config/data" ] #check if exist and create folder for json data then - mkdir "$SCRIPT_FOLDER/data" + mkdir "$SCRIPT_FOLDER/config/data" fi -if [ ! -d "$SCRIPT_FOLDER/tmp" ] #check if exist and create folder for json data +if [ ! -d "$SCRIPT_FOLDER/config/tmp" ] #check if exist and create folder for json data then - mkdir "$SCRIPT_FOLDER/tmp" + mkdir "$SCRIPT_FOLDER/config/tmp" fi -:> "$SCRIPT_FOLDER/data/seasonal.tsv" +:> "$SCRIPT_FOLDER/config/seasonal.tsv" #SCRIPT printf "%s - Starting script\n\n" "$(date +%H:%M:%S)" | tee -a "$LOG" download-anime-id-mapping printf "%s - checking current season\n" "$(date +%H:%M:%S)" | tee -a "$LOG" -curl -s -L -A "Mozilla/5.0 (X11; Linux x86_64)" "https://livechart.me/" -o "$SCRIPT_FOLDER/tmp/this-season.html" -season=$(awk -v IGNORECASE=1 -v RS=']*>/,"");print;exit}' "$SCRIPT_FOLDER/tmp/this-season.html" | awk '{print $1}'| tr '[:lower:]' '[:upper:]') -year=$(awk -v IGNORECASE=1 -v RS=']*>/,"");print;exit}' "$SCRIPT_FOLDER/tmp/this-season.html" | awk '{print $2}') +curl -s -L -A "Mozilla/5.0 (X11; Linux x86_64)" "https://livechart.me/" -o "$SCRIPT_FOLDER/config/tmp/this-season.html" +season=$(awk -v IGNORECASE=1 -v RS=']*>/,"");print;exit}' "$SCRIPT_FOLDER/config/tmp/this-season.html" | awk '{print $1}'| tr '[:lower:]' '[:upper:]') +year=$(awk -v IGNORECASE=1 -v RS=']*>/,"");print;exit}' "$SCRIPT_FOLDER/config/tmp/this-season.html" | awk '{print $2}') printf "%s - Current season : %s %s\n\n" "$(date +%H:%M:%S)" "$season" "$year" | tee -a "$LOG" printf "%s - Creating seasonal list\n" "$(date +%H:%M:%S)" | tee -a "$LOG" printf "%s\t - Downloading anilist season list\n" "$(date +%H:%M:%S)" | tee -a "$LOG" curl -s 'https://graphql.anilist.co/' \ -X POST \ -H 'content-type: application/json' \ ---data '{ "query": "{ Page(page: 1, perPage: '"$DOWNLOAD_LIMIT"') { pageInfo { hasNextPage } media(type: ANIME, seasonYear: '"$year"' season: '"$season"', format: TV, sort: POPULARITY_DESC) { id } } }" }' | jq '.data.Page.media[] | .id' > "$SCRIPT_FOLDER/tmp/seasonal-anilist.tsv" +--data '{ "query": "{ Page(page: 1, perPage: '"$DOWNLOAD_LIMIT"') { pageInfo { hasNextPage } media(type: ANIME, seasonYear: '"$year"' season: '"$season"', format: TV, sort: POPULARITY_DESC) { id } } }" }' | jq '.data.Page.media[] | .id' > "$SCRIPT_FOLDER/config/tmp/seasonal-anilist.tsv" printf "%s\t - Done\n" "$(date +%H:%M:%S)" | tee -a "$LOG" printf "%s\t - Sorting seasonal list\n" "$(date +%H:%M:%S)" | tee -a "$LOG" while read -r anilist_id @@ -45,21 +45,21 @@ do printf "%s\t\t - Seasonal invalid TVDB ID for Anilist : %s\n" "$(date +%H:%M:%S)" "$anilist_id" | tee -a "$LOG" continue else - tvdb_season=$(jq --arg anilist_id "$anilist_id" '.[] | select( .anilist_id == $anilist_id ) | .tvdb_season' -r "$SCRIPT_FOLDER/tmp/list-animes-id.json") - tvdb_epoffset=$(jq --arg anilist_id "$anilist_id" '.[] | select( .anilist_id == $anilist_id ) | .tvdb_epoffset' -r "$SCRIPT_FOLDER/tmp/list-animes-id.json") + tvdb_season=$(jq --arg anilist_id "$anilist_id" '.[] | select( .anilist_id == $anilist_id ) | .tvdb_season' -r "$SCRIPT_FOLDER/config/tmp/list-animes-id.json") + tvdb_epoffset=$(jq --arg anilist_id "$anilist_id" '.[] | select( .anilist_id == $anilist_id ) | .tvdb_epoffset' -r "$SCRIPT_FOLDER/config/tmp/list-animes-id.json") if [[ "$tvdb_season" -eq 1 ]] && [[ "$tvdb_epoffset" -eq 0 ]] then - printf "%s\n" "$tvdb_id" >> "$SCRIPT_FOLDER/data/seasonal.tsv" + printf "%s\n" "$tvdb_id" >> "$SCRIPT_FOLDER/config/data/seasonal.tsv" printf "%s\t\t - New seasonal anime adding to list : Anilist id : %s / tvdb id : %s\n" "$(date +%H:%M:%S)" "$anilist_id" "$tvdb_id" | tee -a "$LOG" else printf "%s\t\t - Sequel seasonal anime not adding to list : Anilist id : %s / tvdb id : %s\n" "$(date +%H:%M:%S)" "$anilist_id" "$tvdb_id" | tee -a "$LOG" fi fi -done < "$SCRIPT_FOLDER/tmp/seasonal-anilist.tsv" +done < "$SCRIPT_FOLDER/config/tmp/seasonal-anilist.tsv" printf "%s - Done\n\n" "$(date +%H:%M:%S)" | tee -a "$LOG" -tvdb_list=$(awk '{printf("%s,",$0)}' "$SCRIPT_FOLDER/data/seasonal.tsv" | sed 's/,\s*$//') +tvdb_list=$(awk '{printf("%s,",$0)}' "$SCRIPT_FOLDER/config/data/seasonal.tsv" | sed 's/,\s*$//') printf "%s - Wrinting seasonal collection\n" "$(date +%H:%M:%S)" | tee -a "$LOG" printf "%s - Seasonal list : tvdb id added : %s\n" "$(date +%H:%M:%S)" "$tvdb_list"| tee -a "$LOG" printf "collections:\n seasonal animes download:\n tvdb_show: %s\n sync_mode: append\n sonarr_add_missing: true\n build_collection: false\n" "$tvdb_list" > "$DOWNLOAD_ANIMES_COLLECTION" From e3d05c53228304b331246d1bea5ce15ba32104fa Mon Sep 17 00:00:00 2001 From: Arial-Z Date: Fri, 17 Nov 2023 18:40:26 +0100 Subject: [PATCH 2/3] Add settings for anilist tags percentage --- default.env | 2 ++ functions.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/default.env b/default.env index 97c0d57..83f1a34 100644 --- a/default.env +++ b/default.env @@ -43,6 +43,8 @@ MAIN_TITLE_ENG=No SORT_TITLE_ENG=No # Use the native name as original_title instead of the romaji/english one (Yes/No) ORIGINAL_TITLE_NATIVE=Yes +#Grab anilist tags higher or equal than percentage (0-100) +ANILIST_TAGS_P=70 # Download poster (Yes/No) POSTER_DOWNLOAD=Yes # Download seasons poster (Yes/No) diff --git a/functions.sh b/functions.sh index 58cea01..07eacbd 100644 --- a/functions.sh +++ b/functions.sh @@ -192,7 +192,7 @@ function get-mal-score () { fi } function get-tags () { - (jq '.data.Media.genres | .[]' -r "$SCRIPT_FOLDER/config/data/anilist-$anilist_id.json" && jq '.data.Media.tags | .[] | select( .rank >= 70 ) | .name' -r "$SCRIPT_FOLDER/config/data/anilist-$anilist_id.json") | awk '{print $0}' | paste -sd ',' + (jq --arg anilist_tags_p "$ANILIST_TAGS_P" '.data.Media.genres | .[]' -r "$SCRIPT_FOLDER/config/data/anilist-$anilist_id.json" && jq '.data.Media.tags | .[] | select( .rank >= "$anilist_tags_p" ) | .name' -r "$SCRIPT_FOLDER/config/data/anilist-$anilist_id.json") | awk '{print $0}' | paste -sd ',' } function get-studios() { if awk -F"\t" '{print $2}' "$SCRIPT_FOLDER/config/$OVERRIDE" | grep -q -w "$anilist_id" From 41fc05f990b3f6be05fd2e6a836174bd932c7f6e Mon Sep 17 00:00:00 2001 From: Arial-Z <100593180+Arial-Z@users.noreply.github.com> Date: Fri, 17 Nov 2023 18:43:18 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a71a378..e1c4261 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Here what will be imported for each of your animes : sort_title: "Yuru Camp△" # original_title : English title or Native Title (from Anilist) original_title: "ゆるキャン△" - # Genre ands tags from Anilist (genres, and tag above > 65%) + # Genre ands tags from Anilist (genres, and tag above > 70% can be changed in settings) genre.sync: Anime,Slice of Life,CGDCT,Iyashikei # Airing status add as a label : Planned, Airing or Ended (from Anilist) label: Planned @@ -86,7 +86,7 @@ plex_token=zadazdzadazdazdazdazdazd # Run the animes script (Yes/No) -RUN_ANIMES_SCRIPTS=Yes +RUN_ANIMES_SCRIPT=Yes # Plex animes library name need to be in a double quote (Needed for the animes script) ANIME_LIBRARY_NAME="Animes" # Path to the created animes metadata file (Needed for the animes script) @@ -94,14 +94,14 @@ METADATA_ANIMES=$SCRIPT_FOLDER/pmm/metadata-animes.yml # Run the movies script (Yes/No) -RUN_MOVIES_SCRIPTS=No +RUN_MOVIES_SCRIPT=No # Plex movies animes library name need to be in a double quote (Needed for the movies script) MOVIE_LIBRARY_NAME="Animes Movies" # Path to the created movies metadata file (Needed for the movies script) METADATA_MOVIES=$SCRIPT_FOLDER/pmm/metadata-animes-movies.yml # Run the seasonal download script (Yes/No) -RUN_SEASONAL_SCRIPTS=No +RUN_SEASONAL_SCRIPT=No # Number of animes added to the sesonal animes auto-download collection (Needed for the seasonal-animes-download.sh script) DOWNLOAD_LIMIT=20 # Path to the created seasonal-animes-download file (Needed for the seasonal-animes-download.sh script) @@ -124,6 +124,8 @@ MAIN_TITLE_ENG=No SORT_TITLE_ENG=No # Use the native name as original_title instead of the romaji/english one (Yes/No) ORIGINAL_TITLE_NATIVE=Yes +#Grab anilist tags higher or equal than percentage (0-100) +ANILIST_TAGS_P=70 # Download poster (Yes/No) POSTER_DOWNLOAD=Yes # Download seasons poster (Yes/No)