FAQ  •  Register  •  Login

Scanning for updated files setting appears ignored

<<

Gonzakpo

Serviio newbie

Posts: 3

Joined: Sat Aug 04, 2012 9:29 pm

Post Mon Aug 06, 2012 1:30 am

Re: Scanning for updated files setting appears ignored

Ok. I see. If we have to wait for Mac OS X to adopt Java 7 this will take loooong hahaha :P
<<

norm

Serviio lover

Posts: 67

Joined: Tue Apr 09, 2013 3:18 pm

Post Sat Apr 27, 2013 6:18 am

Re: Scanning for updated files setting appears ignored

Just in case anyone is interested. I came up with a similar solution to manonmoon only using inotifywait from the inotify-tools suite and python. The python script attached queries serviio REST api to update the library if the library was not already being updated and if the filename was not the same as last updated.

Download, unzip and copy my pc5dczc_lib_update.py (attached) to somewhere on your Linux/NAS box. Eg /usr/bin or somewhere ;). Then paste in the following in to "pc5dczc_auto_refresh.sh"...

  Code:
#!/bin/sh
#
# Automatically updates serviio library
# if library update is not already running uses serviio REST api
# requires inotifytools and python 2.x
# written by norm at forum.serviio.org
#

VideoFolder="/i-data/md0/video" # your video files location
MusicFolder="/i-data/md0/music" # your music files location
PhotoFolder="/i-data/md0/photo" # your image files location
time_between_refresh=90 # minimum time between library refresh. Sleep Xs set to let file operations end.
script_location="/usr/bin" # directory where pc5dczc_lib_update.py is located
name="inotifywait" # do not modify

Background()
{
    if [ ! -x "$(which inotifywait)" ] || [ ! -x "$(which python)" ]; then
        echo "inotifywait or python binaries are missing"
        exit 1
    fi
   inotifywait -mr --timefmt '%H%M%S' --format '%T %f' -e move -e delete -e create  "$1" |
   while read tm file; do
      current=$(date +'%H%M%S')
      delta=`expr $current - $tm`
      if [ $delta -lt 2 -a $delta -gt -2 ]; then
         sleep $time_between_refresh # sleep Xs set to let file operations end
         python "${script_location}/pc5dczc_lib_update.py" "${file}"
      fi
   done
}

case $1 in
   start)
      Background $VideoFolder&
      Background $MusicFolder&
      Background $PhotoFolder&
      echo "Starting Serviio auto refresh ..."
      ;;
   stop)
      killall $name
      echo "Stopping $0"
      ;;
   status)
      _pids=$(pidof $name)
      if test -n "$_pids"; then
         echo "$name is running, pid:"
         pidof $name
      else
         echo "$name not running"
      fi
      ;;
   *)
      echo "use $0 [ start | stop | status ]"
      ;;
esac


I hope that helps someone.

Cheers,

Norm :D
Attachments
pc5dczc_lib_update.zip
Zipped pc5dczc_lib_update.py
(1.04 KiB) Downloaded 171 times
Previous

Return to Serviio Support & Help

Who is online

Users browsing this forum: No registered users and 56 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.