Hi guys,
I'm moving my SAB installation over to a new mac mini running Mountain Lion and I could really use a hand writing some replacement scripts, as my old .bat scripts obviously do not work with OSX, however I don't know python. Could some kind soul help me write some new ones?
Here they are:
Audio
@echo off
xcopy %1 "S:\Media\Music\iTunes\iTunes Media\Automatically Add to iTunes\"%3\ /s/e
the new file structure is: /Volumes/Share-1/Media/Music/iTunes/iTunes Media/Automatically Add to iTunes/
Comics
@echo off
xcopy %1 C:\Users\Ryan\Dropbox\Downloads\%3\ /s/e
the new file structure is: Users/Ryan/Dropbox/Comics/
Thanks, I really appreciate the help.
Ryan
Help with writing some python scripts
Forum rules
Help us help you:
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.
Re: Help with writing some python scripts
Python is great, but you don't need it for these oneliners: just a "cp --recursive ..." (or "mv") should do. And replayce %1 with $1.
My first guess:
cp --recursive $1 "/Volumes/Share-1/Media/Music/iTunes/iTunes Media/Automatically Add to iTunes/"$3
As always: first issue the command from the command line. Experiment with it. If it works, put it in a .sh file. Test it. If it works, run the script from SABnzbd.
My first guess:
cp --recursive $1 "/Volumes/Share-1/Media/Music/iTunes/iTunes Media/Automatically Add to iTunes/"$3
As always: first issue the command from the command line. Experiment with it. If it works, put it in a .sh file. Test it. If it works, run the script from SABnzbd.
Re: Help with writing some python scripts
Thanks for the advice, I'm grateful! Unfortunately I didn't really understand what you jus said lol but I will try the script you suggested
Re: Help with writing some python scripts
I've come up with the following script, but it's still not working. Could someone tell me what I'm doing wrong? I'm pulling my hair out here!
and the error I'm getting is:
Thanks!
import sys,os,distutils.dir_util
origin = sys.argv[1]
destination = ""
if sys.argv[2].lower() == "comics":
destination = "/Users/Ryan/Dropbox/Comics"
elif sys.argv[2].lower() == "music":
destination = "/Volumes/Share/Media/Music/iTunes/iTunes Media/Automatically Add to iTunes"
else:
sys.exit("Usage: larry.py sourcepath [comics | music]")
distutils.dir_util.copy_tree(origin, destination)
and the error I'm getting is:
So, I moved on to shell, and came up with two separate scripts:Exit(1) Usage: larry.py sourcepath [comics | music]
and#!/bin/bash
mv $1 /Volumes/Share/Media/Music/iTunes/iTunes Media/Automatically Add to iTunes/
But those both simply return the error:#!/bin/bash
cp $1 /Users/Ryan/Comics/
Can anyone help me figure this out?Cannot run script.
Thanks!
Re: Help with writing some python scripts
Does /bin/bash exist on your system?
Your Python script doesn't have a first "magic line", something like:
#!/usr/bin/python
Also your Python script doesn't use indentation for the "then" and "else" parts of "if" statements.
Your Python script doesn't have a first "magic line", something like:
#!/usr/bin/python
Also your Python script doesn't use indentation for the "then" and "else" parts of "if" statements.
Re: Help with writing some python scripts
A friend managed to help me figure it out
import sys,os,distutils.dir_util
# Args as found in docs at: http://wiki.sabnzbd.org/user-scripts
# 1 The final directory of the job (full path)
origin = sys.argv[1]
# 2 The original name of the NZB file
# 3 Clean version of the job name (no path info and ".nzb" removed)
# 4 Indexer's report number (if supported)
# 5 User-defined category
category = sys.argv[5]
# 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+21
destination = ""
if category.lower() == "comics":
destination = "/Users/Ryan/Dropbox/Comics"
elif category.lower() == "music":
destination = "/Volumes/Share/Media/Music/iTunes/iTunes Media/Automatically Add to iTunes"
else:
print("Origin: " + origin)
print("Category: " + category)
sys.exit("Script failed!")
distutils.dir_util.copy_tree(origin, destination)
import sys,os,distutils.dir_util
# Args as found in docs at: http://wiki.sabnzbd.org/user-scripts
# 1 The final directory of the job (full path)
origin = sys.argv[1]
# 2 The original name of the NZB file
# 3 Clean version of the job name (no path info and ".nzb" removed)
# 4 Indexer's report number (if supported)
# 5 User-defined category
category = sys.argv[5]
# 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+21
destination = ""
if category.lower() == "comics":
destination = "/Users/Ryan/Dropbox/Comics"
elif category.lower() == "music":
destination = "/Volumes/Share/Media/Music/iTunes/iTunes Media/Automatically Add to iTunes"
else:
print("Origin: " + origin)
print("Category: " + category)
sys.exit("Script failed!")
distutils.dir_util.copy_tree(origin, destination)
Re: Help with writing some python scripts
Ah, unfortunately while the comic portion of the script is working, the audio one is not. I'm getting the "script failed!" Error... I don't want to keep bothering my friend, can anyone help? I thought it might be the spaces in the patch (iTunes media and automatically add to iTunes) so I changed them to 'iTunes media', etc but it hasn't made any difference.
Anyone have any ideas?
Anyone have any ideas?
Re: Help with writing some python scripts
No worries, I fixed it wrong category!