Error on PostProcessing Script

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
msiskind
Newbie
Newbie
Posts: 6
Joined: August 5th, 2012, 1:57 pm

Error on PostProcessing Script

Post by msiskind »

Hello All,

I am trying to follow this for Headphone Post-Processing
http://forums.sabnzbd.org/viewtopic.php?f=9&t=6113
but it will not work

I get Exit(-1) Cannot run script /home/masd/.sabnzbd/PostProcessingScripts/mp3organizer

I am on Ubuntu 12 running SABnzbd and Headphones. My SB postprocessing script works (but that is the default one)

Any assistance would be greatly appreciated.

Thanks
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Help With Categories

Post by shypike »

Does your script have its X bit set?
clinton hall
Newbie
Newbie
Posts: 22
Joined: August 4th, 2012, 8:35 pm

Re: Error on PostProcessing Script

Post by clinton hall »

In addition to setting the X bit, if you had at any point copied the code and created the script in wordpad/notepad before sending this over to Ubuntu, you can try doing a dos2unix conversion on the script to remove any CRLF (dos line feeds) that can cause issues.

Essentially I had the same error on a CouchPotato postprocess script after editing in wordpad and this was resolved using dos2unix.
msiskind
Newbie
Newbie
Posts: 6
Joined: August 5th, 2012, 1:57 pm

Re: Error on PostProcessing Script

Post by msiskind »

if by x bit you mean the chmod +x [filename] then yes...

I copied the script as listed on the page noted above --- http://forums.sabnzbd.org/viewtopic.php?f=9&t=6113

do i still need to do the dos2unix?

BTW - i am a total n00b when it comes to all of this... Thanks in advance
clinton hall
Newbie
Newbie
Posts: 22
Joined: August 4th, 2012, 8:35 pm

Re: Error on PostProcessing Script

Post by clinton hall »

dos2unix won't hurt any of your files, and it is built in to Linux, so I would try it and see if that resolves the issue.
The command is just "dos2unix scriptname.extension"

Which script on the link you posted are you using and what is the file name you have used for this script?

How did you copy the script? Did you actually download a file (I didn't see any attachments) or did you copy the text and paste this into a text/script editor?
msiskind
Newbie
Newbie
Posts: 6
Joined: August 5th, 2012, 1:57 pm

Re: Error on PostProcessing Script

Post by msiskind »

the script file is the first one http://forums.sabnzbd.org/viewtopic.php ... 113#p42873 so the third post in the full thread.

the name of my file is mp3organizer.sh

I copied the text from the code box and have verified that all is there
clinton hall
Newbie
Newbie
Posts: 22
Joined: August 4th, 2012, 8:35 pm

Re: Error on PostProcessing Script

Post by clinton hall »

Ok, try navigating to your postprocess directory (in Ubuntu terminal) and run the following command
./mp3organizer.sh

You should get "Doh! You have to pass a directory...."
If so, it indicates that the script is executable and working.
While you are there, just run the following commands
dos2unix mp3organizer.sh
./mp3organizer.sh

Do you still get the same output message?

When you say above, that you copied text from the code box... What did you paste it into? Was this in Ubuntu or in Windows? Did you paste into word pad/notepad or some other editor?
msiskind
Newbie
Newbie
Posts: 6
Joined: August 5th, 2012, 1:57 pm

Re: Error on PostProcessing Script

Post by msiskind »

I did the ./mp3organizer.sh and it did come back as Doh! So it does work.. Yeah!!

I copied the text into Ubuntu into their default Text Editor.

So here is my Code

Code: Select all

    #!/bin/bash


    # Where is your music?
    music_collection="$HOME/Music"


    # SABNZBD usage
    # 1) Edit music_collection setting above if your music isn't in the "normal" place
    # 2) Set this up as an SABNZBD Post Processing script

    # GENERAL usage
    # 1) Edit music_collection setting above if your music isn't in the "normal" place
    # 2) run in a terminal as: ./mp3organizer /path_to/where_the_new_music_files/are
    # Note that the path can't have any spaces.

    # NOTES AND ADVANCED USAGE
    # File with bad tags are stored to /[Your_music_collection]/unknown

    # See the Advanced Options settings if you want to:
    # a) Make backup copies
    # b) Move instead of copy file from the new music location

    # =============================================================================================
    # ADVANCED / OPTIONAL SETTINGS
    # Want all the files copied somewhere else too?
    #backup_dir="$HOME/mp3organizer_backups"

    # Set to "copy" or "move" to make the script either copy files to your music collection and leave
    # the originals where they were or move them to your music collection.
    mode="move"

    # If you want the unknown files to be saved somewhere else, or to change where this script
    # keeps temporary files, change these:
    unknown_dir="$music_collection/unknown"
    working_dir="/media/MoviesMusic/mp3organizer_temporary_files"


    # =============================================================================================
    # EVERYTHING BELOW HERE IS AS IT SHOULD BE. DONT MESS WITH IT

    # Make sure that a folder has been passed to the script
    if [ -z "$1" ];then
      echo "Doh!  You have to pass a directory where the music is you want to organize!"
      exit
    else   
      echo "Working from supplied directory"
      echo "$1"
       new_music="$1"
    fi

    # Make sure if a folder has been passed that it actuall exists
    if [ ! -d "$new_music" ];then    
      echo "Can't find the search directory $new_music"
      echo "For SABNZBD, in the admin go to Settings > Switches and set REPLACE SPACES WITH UNDERSCORSES"
      exit
    fi

    # Check other folders exist and make them if necessary
    if [ ! -d "$working_dir" ];then    
      echo "Creating $working_dir"
      mkdir $working_dir
    fi

    if [ ! -d "$music_collection" ];then    
      echo "Creating $music_collection"
      mkdir $music_collection
    fi

    if [ ! -d "$unknown_dir" ];then    
      echo "Creating $unknown_dir"
      mkdir $unknown_dir
    fi

    if [ ! -d "$backup_dir" ];then    
      echo "Creating $backup_dir"
      mkdir $backup_dir
    fi

    # Copy or Move the new music files to our temporary working area to be processed
    if [ "$mode" = 'move' ]; then
      find $new_music -iname "*.mp3" -exec mv {} $working_dir \;
    else
      find $new_music -iname "*.mp3" -exec cp {} $working_dir \;
    fi

    cd $working_dir

    # Work on each file one at a time
    for F in ./*
    do
       if [ -f "$F" ];then            
        # use mminfo to get the track info
        # LOTS of stuff going on here. Have to remove leading space, special chars and pad track to 0x etc.
        # Someone smart could do this a lot more elegantly than this!
          artist=`mminfo "$F"|grep artist|awk -F: '{print $2}'|sed 's/^ *//g'|sed 's/[^a-zA-Z0-9\ \-\_]//g'`
          title=`mminfo "$F"|grep title|awk -F: '{print $2}'|sed 's/^ *//g'|sed 's/[^a-zA-Z0-9\ \-\_]//g'`
          album=`mminfo "$F"|grep album|awk -F: '{print $2}'|sed 's/^ *//g'|sed 's/[^a-zA-Z0-9\ \-\_]//g'`
          trackno=`mminfo "$F"|grep trackno|awk -F: '{print $2}'|sed 's/^ *//g'| awk '{printf "%02d\n", $1;}'`

         echo "============================"
          echo "artist:" $artist
          echo "title:" $title
          echo "album:" $album
          echo "trackno:" $trackno

          # If we have an artist, album and title then we know where to nicely put this file
             if [  -n "$artist"  ] && [ -n "$album" ] && [  -n "$title"  ];then
              # This is what we are going to call the file
                  filename="$trackno - $title.mp3";
                  if [ -n  "$backup_dir" ];then
                       cp "$F" "$backup_dir/"
                  fi
                  # If the right directory structure exists - awesome. Move the file.
                   if [ -d "$music_collection/$artist/$album" ];then    
                      mv "$F" "$music_collection/$artist/$album/$filename"  
                   else
                     # If not, build the whole file structure. Won't do any harm to try and create an artist directory that
                     # is already there - so not even checking for that.
                      mkdir "$music_collection/$artist"
                      mkdir "$music_collection/$artist/$album"
                      mv "$F" "$music_collection/$artist/$album/$filename"
                   fi
             else
            # Don't know who it's by, what album, or what track, so moving it to UNKNOWN
               mv "$F" "$unknown_dir/"
                echo -e "UNKNOWN: $F \n"
             fi
       fi
    done
My music is in "the usually location", so that folder is correct...

Hopefully this will continue to help you help me... Thanks again
clinton hall
Newbie
Newbie
Posts: 22
Joined: August 4th, 2012, 8:35 pm

Re: Error on PostProcessing Script

Post by clinton hall »

Ok.. so you did this all in Ubuntu. That rules out the CRLF mistake I had that casued a similar issue (the whole dos2unix thing)

I have just created this script on my QNAP NAS and verified that this does indeed run from SABnzbd. (later I'll have to find and delete what appears to be some very crap music that I just downloaded!)

Just to rule out any other permission issues try this
chmod 777 mp3organizer.sh

Then try a download and see if it runs.

Oh, and what version of SABnzbd are you running?
msiskind
Newbie
Newbie
Posts: 6
Joined: August 5th, 2012, 1:57 pm

Re: Error on PostProcessing Script

Post by msiskind »

SABnzbd Version: 0.7.0Beta3

i did the chmod 777 and it did not make a difference...

So i decided to delete my postprossing script and then redid it and got the same results

is it the beta version of SABnzbd that is doing this?
clinton hall
Newbie
Newbie
Posts: 22
Joined: August 4th, 2012, 8:35 pm

Re: Error on PostProcessing Script

Post by clinton hall »

I tested this on SABnzbd 0.7.3, but I am not aware of any beta versions that had problems running post processing scripts. Certainly you could try upgrading to 0.7.3 if you feel the urge.

Another test to do is to create the script in another directory (try /home/masd/postprocess) and not from within the .sab directory. Then point SABnzbd postprocessing (in the folders config page) to that new location, restart SABnzbd and try another download...

On that note, have you tried restarting SABnzbd since you modified/created this script? If not, could be a quick test.
msiskind
Newbie
Newbie
Posts: 6
Joined: August 5th, 2012, 1:57 pm

Re: Error on PostProcessing Script

Post by msiskind »

okay.. so i moved it back to the default for sickbeard, where i knew sb worked (i never tried before) and the same result. I also tried it after restarting SAB after all the changes, but still got the same issues.

If i wanted to upgrade to non beta, how would i do that? i am a n00b at this whole thing, and i tried to do the auto find, but it did not say anything about being behind on commits or anything...
clinton hall
Newbie
Newbie
Posts: 22
Joined: August 4th, 2012, 8:35 pm

Re: Error on PostProcessing Script

Post by clinton hall »

How did you install SABnzbd? If you installed a "package" then you would need to find out the update method for that package. If you installed git and did a git pull, then you should be able to do another git pull to update to the latest.
natethegreat141990
Newbie
Newbie
Posts: 4
Joined: July 3rd, 2012, 5:12 pm
Location: Acworth Ga

Re: Error on PostProcessing Script

Post by natethegreat141990 »

Ok I had this problem also and the solution to me if everything else is correct is the line that says " #backup_dir="$HOME/mp3organizer_backups" you will want to take out the # in front of that. Due to that the program does not know to read that line. Try that and let me know thanks.
Post Reply