Advertisement
Guest User

Untitled

a guest
Jan 10th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. cat /usr/bin/removecommercials
  2. #!/bin/sh
  3. PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin
  4.  
  5. VIDEODIR=$1
  6. FILENAME=$2
  7. CHANID=$3
  8. STARTTIME=$4
  9. #exec > /tmp/removeCommercials$CHANID$STARTTIME
  10.  
  11.  
  12. echo "$CHANID $STARTTIME $FILENAME $VIDEODIR"
  13. # Sanity checking, to make sure everything is in order.
  14. if [ -z "$VIDEODIR" -o -z "$FILENAME" ]; then
  15. echo "Usage: $0 <VideoDirectory> <FileName>"
  16. exit 5
  17. fi
  18. if [ ! -f "$VIDEODIR/$FILENAME" ]; then
  19. echo "File does not exist: $VIDEODIR/$FILENAME"
  20. exit 6
  21. fi
  22. # The meat of the script. Flag commercials, copy the flagged commercials to
  23. # the cutlist, and transcode the video to remove the commercials from the
  24. # file.
  25. mythcommflag -f $VIDEODIR/$FILENAME
  26. echo "fin1"
  27. ERROR=$?
  28. if [ $ERROR -gt 126 ]; then
  29. echo "Commercial flagging failed for ${FILENAME} with error $ERROR"
  30. exit $ERROR
  31. fi
  32. echo "cutting"
  33. mythcommflag --gencutlist -f $VIDEODIR/$FILENAME
  34. ERROR=$?
  35. echo "cut'ed end"
  36. if [ $ERROR -ne 0 ]; then
  37. echo "Copying cutlist failed for $FILENAME $CHANID $STARTTIME with error $ERROR"
  38. exit $ERROR
  39. fi
  40. echo "transcodin"
  41. mythtranscode --honorcutlist --showprogress -i $VIDEODIR/$FILENAME -o $VIDEODIR/$FILENAME.tmp
  42. ERROR=$?
  43. echo "transcodid end "
  44. if [ $ERROR -ne 0 ]; then
  45. echo "Transcoding failed for ${FILENAME} with error $ERROR"
  46. exit $ERROR
  47. fi
  48. echo "cleaning up"
  49. mv $VIDEODIR/$FILENAME $VIDEODIR/$FILENAME.old
  50. mv $VIDEODIR/$FILENAME.tmp $VIDEODIR/$FILENAME
  51. rm $VIDEODIR/$FILENAME.old
  52.  
  53.  
  54. mythcommflag -f $VIDEODIR/${FILENAME} --rebuild
  55. mythcommflag --clearcutlist -f $VIDEODIR/$FILENAME
  56.  
  57.  
  58. if [ $ERROR -eq 0 ]; then
  59. echo "cutlist cleared properly"
  60. # Fix the database entry for the file
  61. cat << EOF | mysql mythconverg
  62. UPDATE
  63. recorded
  64. SET
  65. cutlist = 0,
  66. filesize = $(ls -l $VIDEODIR/$FILENAME | awk '{print $5}')
  67. WHERE
  68. basename = '$FILENAME';
  69.  
  70. EOF
  71.  
  72.  
  73. echo "cleared in db"
  74.  
  75. cat << EOF | mysql mythconverg
  76.  
  77. DELETE FROM
  78. recordedmarkup
  79. WHERE
  80. CONCAT( chanid, starttime ) IN (
  81. SELECT
  82. CONCAT( chanid, starttime )
  83. FROM
  84. recorded
  85. WHERE
  86. basename = '$FILENAME'
  87. );
  88.  
  89. EOF
  90. exit 0
  91. else
  92. echo "Clearing cutlist failed for ${FILENAME} with error $ERROR"
  93. rm -f $VIDEODIR/$FILENAME.tmp
  94. exit $ERROR
  95. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement