@@ -143,7 +143,9 @@ def syntax():
143
143
"description of the <Type> is used instead." + os .linesep + \
144
144
"* All remaining arguments are treated as URLs. You can also " + \
145
145
"delimit multiple" + os .linesep + "\t URLs in a single " + \
146
- "string/argument with the use of a comma (,)."
146
+ "string/argument with the use of a comma (,)." + os .linesep + \
147
+ "\t URLs can also be provided as the SAB_NOTIFICATION_PARAMETERS " + \
148
+ "environment variable."
147
149
148
150
149
151
def notify (ntype , title , body , urls , debug = None ):
@@ -154,7 +156,7 @@ def notify(ntype, title, body, urls, debug=None):
154
156
if debug is None :
155
157
debug = DEBUG_MODE
156
158
157
- # We use the Python interpreter that was also used by
159
+ # We use the Python interpreter that was also used by
158
160
# SABnzbd when it executed this script
159
161
cmd = [
160
162
sys .executable if sys .executable else "python" ,
@@ -206,8 +208,9 @@ def notify(ntype, title, body, urls, debug=None):
206
208
return True
207
209
208
210
if __name__ == "__main__" :
209
- # Simple parsing of the command line
210
- if len (sys .argv ) <= 4 :
211
+ # Simple parsing of the command line and env variable
212
+ notify_urls_string = os .environ .get ("SAB_NOTIFICATION_PARAMETERS" , None )
213
+ if len (sys .argv ) <= 3 and not notify_urls_string :
211
214
logger .error ('Not enough arguments specified.' )
212
215
print (syntax ())
213
216
exit (1 )
@@ -233,9 +236,14 @@ def notify(ntype, title, body, urls, debug=None):
233
236
# Store body (empty or not)
234
237
notify_body = sys .argv [3 ].strip ()
235
238
239
+ # Environment variable takes precedence over the command line parameter
236
240
# The URLs are complex and very depending on what we're notifying
237
241
# so we'll let Notify.py take care of them at this point.
238
- notify_urls = ',' .join ([ v .strip () for v in sys .argv [4 :]])
242
+ if notify_urls_string :
243
+ notify_urls = notify_urls_string .split ()
244
+ else :
245
+ notify_urls = sys .argv [4 :]
246
+ notify_urls = ',' .join ([v .strip () for v in notify_urls ])
239
247
240
248
# Perform Notification
241
249
exit (int (not notify (
0 commit comments