Advertisement
mathieugfortin

radarr subtitles Subs subfolder hardlink, idx, sub, srt

May 24th, 2022
1,349
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. shopt -s nullglob
  24. SAVEIFS=$IFS
  25. IFS=$(echo -en "\n\b")
  26. # set me
  27. SUBSSOURCEPATH="$SUBSSOURCEPATH/*.srt"
  28. for file in $SUBSSOURCEPATH
  29. do
  30.   BASENAME=$(basename "$file")
  31.   ln "${DESTINATION}/${MOVIENAME}.$BASENAME" "$file"
  32.   echo "Created symlink from source location: ${DESTINATION}/${MOVIENAME}.$(basename $file) to symlink location $file" >> $LOGFILE 2>&1
  33. done
  34. SUBSSOURCEPATH="$SUBSSOURCEPATH/*.idx"
  35. for file in $SUBSSOURCEPATH
  36. do
  37.   BASENAME=$(basename "$file")
  38.   ln "${DESTINATION}/${MOVIENAME}.$BASENAME" "$file"
  39.   echo "Created symlink from source location: ${DESTINATION}/${MOVIENAME}.$(basename $file) to symlink location $file" >> $LOGFILE 2>&1
  40. done
  41. SUBSSOURCEPATH="$SUBSSOURCEPATH/*.sub"
  42. for file in $SUBSSOURCEPATH
  43. do
  44.   BASENAME=$(basename "$file")
  45.   ln "${DESTINATION}/${MOVIENAME}.$BASENAME" "$file"
  46.   echo "Created symlink from source location: ${DESTINATION}/${MOVIENAME}.$(basename $file) to symlink location $file" >> $LOGFILE 2>&1
  47. done
  48. # restore $IFS
  49. IFS=$SAVEIFS
  50. shopt -u nullglob
  51.  
  52. echo "$(date "+%Y%m%d %T") : Ending subtitle subfolder work" >> $LOGFILE 2>&1
  53.  
  54.  
Advertisement
RAW Paste Data Copied
Advertisement