Advertisement
Ordep

Radarr/Sonarr postprocess subtitle script

Jan 26th, 2022
1,178
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. #>> $LOGFILE 2>&1
  4. LOGFILE="/config/logs/subtitle.log"
  5. #LOGFILE="/mnt/cache/cache_only/appdata/radarr/logs/subtitle.log"
  6. SUBSSOURCEPATH="$radarr_moviefile_sourcefolder/Subs"
  7. DESTINATION="$radarr_movie_path"
  8. MOVIENAME="$radarr_moviefile_relativepath"
  9.  
  10. echo "$(date "+%Y%m%d %T") : Starting subtitle subfolder work" >> $LOGFILE 2>&1
  11. #echo "SUBSSOURCEPATH = $SUBSSOURCEPATH" >> $LOGFILE 2>&1
  12. #echo "$DESTINATION : DESTINATION" >> $LOGFILE 2>&1
  13. #echo "$MOVIENAME : MOVIENAME" >> $LOGFILE 2>&1
  14.  
  15. if [ -d "$SUBSSOURCEPATH" ];
  16. then
  17.     echo "Subs directory exists" >> $LOGFILE 2>&1
  18. else
  19.     echo "No ${SUBSSOURCEPATH} directory, exiting" >> $LOGFILE 2>&1
  20.     exit 0
  21. fi
  22.  
  23. SUBSSOURCEPATH="$SUBSSOURCEPATH/*.srt"
  24. shopt -s nullglob
  25. SAVEIFS=$IFS
  26. IFS=$(echo -en "\n\b")
  27. # set me
  28. for file in $SUBSSOURCEPATH
  29. do
  30.   #echo "$f"
  31.   BASENAME=$(basename "$file")
  32.   #echo "Source : ${file}" >> $LOGFILE 2>&1
  33.   #echo "BASENAME = $BASENAME"
  34.   #echo "Destination: ${DESTINATION}/${MOVIENAME}.$BASENAME " >> $LOGFILE 2>&1
  35.   mv "${file}" "${DESTINATION}/${MOVIENAME}.$BASENAME"
  36.   ln -s "${DESTINATION}/${MOVIENAME}.$BASENAME" "$file"
  37.   echo "Created symlink from source location: ${DESTINATION}/${MOVIENAME}.$(basename $file) to symlink location $file" >> $LOGFILE 2>&1
  38. done
  39. # restore $IFS
  40. IFS=$SAVEIFS
  41. shopt -u nullglob
  42.  
  43. echo "$(date "+%Y%m%d %T") : Ending subtitle subfolder work" >> $LOGFILE 2>&1
  44.  
  45.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement