2012-11-16, 01:15
(2012-07-05, 22:25)bwqbbq Wrote: Awesome plug-in! I've added support to CouchPotato and sent a pull request for it. You should probably work on the documentation though, not all of the API calls are described on Github :p
I was also wondering if you could add support for nzbget? Aside from SABnzbd, it's the other major usenet client and I actually prefer it because it is so lightweight and uses a lot less resources. I've had a look at your plug-in and I've cooked up a quick code sample for the things you need. Would be great if you could add support for it!
Code:from xmlrpclib import ServerProxy
rpc = ServerProxy('http://nzbget:tegbzn6789@localhost:6789/xmlrpc')
# add nzb
#
rpc.append(nzb_name, 'movies', False, standard_b64encode(filedata.strip()))
# wait for the nzb to get added to nzbget
#
groups = rpc.listgroups()
while len(groups) == 0:
groups = rpc.listgroups()
last_group = len(groups) - 1
while os.path.basename(groups[last_group]['NZBFilename']) != nzb_name:
last_group = last_group - 1
if last_group <= 0:
last_group = len(groups) - 1
groups = rpc.listgroups()
first_id = groups[last_group]['FirstID']
last_id = groups[last_group]['LastID']
# add to top of queue
rpc.editqueue("GroupMoveTop", 0, "", last_id)
files = rpc.listfiles(first_id, last_id)
# you can loop through these and check the filename with files[index]['Filename']
Awesome work!
I expanded a bit on this, and made a PoC to delete all non-rar files,
using bits of your code, and bits of Popeye's code.
It is not usable but shows, that what we want, can be done.
The API provides all the things we need I believe and can be found at:
http://nzbget.sourceforge.net/RPC_API_reference
I am no Python coder however, and I fear this is about as far as I can get with this.
I delete the non-rar files in the wrong place, but for this PoC, it served the purpose.
If anyone is willing to expand even further on this, please feel free!
I would love to have Pneumatic interface with nzbget,
as SABnzbd+ only gets about 6MB/s max (when I get lucky) on my Synology DS212+ whereas nzbget can max my linespeed @ 11~12MB/s
This is no issue for streaming normal 720p, but for 1080i MPEG2 RAW series, this poses somewhat of a long waitingtime before the episode actually starts to play.
The only reason I still have SABnzbd+ installed, is for Pneumatic..
Code:
import re
RE_PART_X = r'(\S*?\.part\d{1,3}\.rar)'
RE_PART01_X = '(\S*?\.part0{0,2}1\.rar)'
RE_R_X = r'(\S*?\.[rs]\d{2,3})'
RE_RAR_X = r'(\S*?\.rar)'
RE_PART = '\.part\d{2,3}\.rar$'
RE_PART01 = '\.part0{1,2}1\.rar$'
RE_R = '\.[rs]\d{2,3}$'
def sorted_rar_nzf_file_list(nzf_list):
file_list = []
if len(nzf_list) > 0:
for nzf in nzf_list:
partrar = re.findall(RE_PART, nzf['Filename'])
rrar = re.findall(RE_R, nzf['Filename'])
if ((nzf['Filename'].endswith(".rar") and not partrar) or partrar or rrar):
file_list.append(nzf['Filename'])
else:
partrar_x = re.search(RE_PART_X, nzf['Filename'])
rrar_x = re.search(RE_R_X, nzf['Filename'])
rarrar_x = re.search(RE_RAR_X, nzf['Filename'])
out = None
if (rarrar_x and not partrar_x):
out = rarrar_x.group(1)
elif partrar_x:
out = partrar_x.group(1)
elif rrar_x:
out = rrar_x.group(1)
#Print info on non-rar files
print nzf['Filename']
print nzf['ID']
#Delete the non-rar files
rpc.editqueue("FileDelete", 0, "", nzf['ID'])
if len(file_list) > 1:
file_list.sort(key=lambda x: x)
return file_list
from xmlrpclib import ServerProxy
rpc = ServerProxy('http://nzbget:[email protected]:6789/xmlrpc')
groups = rpc.listgroups()
last_group = len(groups) - 1
#for i in groups:
# print i['NZBNicename']
#Select the ID of the test group (NZB)
number=0
for t in groups:
if t['NZBNicename'] == "Boardwalk.Empire.S01.1080p.BluRay.X264-BiRDHOUSE":
selected_group = number
number+=1
nzbid = groups[selected_group]['NZBID']
nzbname = groups[selected_group]['NZBNicename']
first_id = groups[selected_group]['FirstID']
last_id = groups[selected_group]['LastID']
#Use own Category
rpc.editqueue("GroupSetCategory", 0, "pneumatic", first_id)
#Disable PostProcessing
rpc.editqueue("GroupSetParameter", 0, "PostProcess=no", last_id)
#List all files in group
files = rpc.listfiles(first_id, last_id)
#for i in files:
# print i['Filename']
# print i['ID']
#Do the Regex Processing
sorted_rar_nzf_file_list(files)