Skip to content
This repository
Browse code

added ability to change priority of SABnzbd downloads

  • Loading branch information...
commit aa23a663bae0edddb54ca0ad85f760806e376efc 1 parent d1a4495
evilhero authored September 28, 2012
15  data/interfaces/default/config.html
@@ -122,14 +122,15 @@ <h1 class="clearfix"><img src="interfaces/default/images/icon_gear.png" alt="set
122 122
 	                        <label>SABnzbd Category:</label>
123 123
 	                        <input type="text" name="sab_category" value="${config['sab_cat']}" size="20">
124 124
 	                    </div>
  125
+                                <div class="row radio clearfix">
  126
+                                <label>SABNzbd Priority:</label>
  127
+<input type="radio" name="sab_priority" value="1" ${config['sab_priority_1']} /><label>default Priority</label>
  128
+<input type="radio" name="sab_priority" value="2" ${config['sab_priority_2']} /><label>Low Priority</label>
  129
+<input type="radio" name="sab_priority" value="3" ${config['sab_priority_3']} /><label>Normal Priority</label>
  130
+<input type="radio" name="sab_priority" value="4" ${config['sab_priority_4']} /><label>High Priority</label>
  131
+<input type="radio" name="sab_priority" value="5" ${config['sab_priority_5']} /><label>Paused</label>
  132
+                                </div>
125 133
                     </fieldset>
126  
-                    <fieldset>
127  
-                    		<legend>Downloads</legend>
128  
-                       	<div class="row">
129  
-                            <label>Comic Download Directory:</label>
130  
-                            <small>Full path where SAB downloads your comics. e.g. /Users/name/Downloads/comics</small>
131  
-                        </div>
132  
-                    </fieldset>                    
133 134
                 </td>
134 135
            
135 136
                 <td>
5  mylar/__init__.py
@@ -109,6 +109,7 @@
109 109
 SAB_PASSWORD = None
110 110
 SAB_APIKEY = None
111 111
 SAB_CATEGORY = None
  112
+SAB_PRIORITY = None
112 113
 
113 114
 NZBSU = False
114 115
 NZBSU_APIKEY = None
@@ -185,7 +186,7 @@ def initialize():
185 186
                 HTTP_PORT, HTTP_HOST, HTTP_USERNAME, HTTP_PASSWORD, HTTP_ROOT, LAUNCH_BROWSER, GIT_PATH, \
186 187
                 CURRENT_VERSION, LATEST_VERSION, CHECK_GITHUB, CHECK_GITHUB_ON_STARTUP, CHECK_GITHUB_INTERVAL, MUSIC_DIR, DESTINATION_DIR, \
187 188
                 DOWNLOAD_DIR, USENET_RETENTION, SEARCH_INTERVAL, INTERFACE, AUTOWANT_ALL, AUTOWANT_UPCOMING, \
188  
-                LIBRARYSCAN_INTERVAL, DOWNLOAD_SCAN_INTERVAL, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, BLACKHOLE, BLACKHOLE_DIR, \
  189
+                LIBRARYSCAN_INTERVAL, DOWNLOAD_SCAN_INTERVAL, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, SAB_PRIORITY, BLACKHOLE, BLACKHOLE_DIR, \
189 190
                 NZBSU, NZBSU_APIKEY, DOGNZB, DOGNZB_APIKEY, \
190 191
                 RAW, RAW_PROVIDER, RAW_USERNAME, RAW_PASSWORD, RAW_GROUPS, EXPERIMENTAL, \
191 192
                 PREFERRED_QUALITY, MOVE_FILES, RENAME_FILES, CORRECT_METADATA, FOLDER_FORMAT, FILE_FORMAT, REPLACE_CHAR, REPLACE_SPACES, \
@@ -247,6 +248,7 @@ def initialize():
247 248
         SAB_PASSWORD = check_setting_str(CFG, 'SABnzbd', 'sab_password', '')
248 249
         SAB_APIKEY = check_setting_str(CFG, 'SABnzbd', 'sab_apikey', '')
249 250
         SAB_CATEGORY = check_setting_str(CFG, 'SABnzbd', 'sab_category', '')
  251
+        SAB_PRIORITY = check_setting_int(CFG, 'SABnzbd', 'sab_priority', 0)
250 252
         
251 253
         NZBSU = bool(check_setting_int(CFG, 'NZBsu', 'nzbsu', 0))
252 254
         NZBSU_APIKEY = check_setting_str(CFG, 'NZBsu', 'nzbsu_apikey', '')
@@ -456,6 +458,7 @@ def config_write():
456 458
     new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
457 459
     new_config['SABnzbd']['sab_apikey'] = SAB_APIKEY
458 460
     new_config['SABnzbd']['sab_category'] = SAB_CATEGORY
  461
+    new_config['SABnzbd']['sab_priority'] = SAB_PRIORITY
459 462
 
460 463
     new_config['NZBsu'] = {}
461 464
     new_config['NZBsu']['nzbsu'] = int(NZBSU)
7  mylar/search.py
@@ -168,6 +168,11 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr):
168 168
     elif mylar.PREFERRED_QUALITY == 1: filetype = ".cbr"
169 169
     elif mylar.PREFERRED_QUALITY == 2: filetype = ".cbz"
170 170
 
  171
+    if mylar.SAB_PRIORITY == 1: sabpriority = "-100"
  172
+    elif mylar.SAB_PRIORITY == 2: sabpriority = "-1"
  173
+    elif mylar.SAB_PRIORITY == 3: sabpriority = "0"
  174
+    elif mylar.SAB_PRIORITY == 4: sabpriority = "1"
  175
+    elif mylar.SAB_PRIORITY == 5: sabpriority = "-2"
171 176
     # figure out what was missed via rss feeds and do a manual search via api
172 177
     #tsc = int(tot-1)
173 178
     findcomic = []
@@ -479,6 +484,8 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr):
479 484
                                         renameit = str(ComicNM) + " " + str(IssueNumber) + " (" + str(SeriesYear) + ")" + " " + "(" + str(comyear) + ")"
480 485
                                         renameit = renameit.replace(' ', repchar)
481 486
                                         renamer = renameit.replace(' ', repurlchar)
  487
+                                        nzo_prio = str(mylar.SAB_HOST) + "/api?mode=queue&name=priority&apikey=" + str(mylar.SAB_APIKEY) + "&value=" + str(slot_nzoid) + "&value2=" + str(sabpriority)
  488
+                                        urllib2.urlopen(nzo_prio);
482 489
                                         nzo_ren = str(mylar.SAB_HOST) + "/api?mode=queue&name=rename&apikey=" + str(mylar.SAB_APIKEY) + "&value=" + str(slot_nzoid) + "&value2=" + str(renamer)
483 490
                                         urllib2.urlopen(nzo_ren);
484 491
                                         logger.info(u"Renamed nzb file in SABnzbd queue to : " + str(renameit))

0 notes on commit aa23a66

Please sign in to comment.
Something went wrong with that request. Please try again.