Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Changes to Support Python 3.x #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions FakeDetector.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
# The status "FAILURE/BAD" is passed to other scripts and informs them
# about failure.
#
# PP-Script version: 1.7.
# PP-Script version: 2.0.
#
# For more info and updates please visit forum topic at
# http://nzbget.net/forum/viewtopic.php?f=8&t=1394.
#
# NOTE: This script requires Python to be installed on your system (tested
# only with Python 2.x; may not work with Python 3.x).
# only with Python 3.x).


##############################################################################
Expand All @@ -63,9 +63,9 @@
import sys
import subprocess
import re
import urllib2
import base64
from xmlrpclib import ServerProxy
import urllib.request, urllib.error, urllib.parse
from xmlrpc.client import ServerProxy
from base64 import b64encode
import shlex
import traceback

Expand Down Expand Up @@ -215,7 +215,7 @@ def list_all_rars(dir):
print('command: %s' % command)
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out_tmp, err = proc.communicate()
out += out_tmp
out += out_tmp.decode()
result = proc.returncode
if verbose:
print(out_tmp)
Expand Down Expand Up @@ -292,14 +292,16 @@ def call_nzbget_direct(url_command):

# Building http-URL to call the method
httpUrl = 'http://%s:%s/jsonrpc/%s' % (host, port, url_command);
request = urllib2.Request(httpUrl)
request = urllib.request.Request(httpUrl)

authString = '%s:%s' % (username, password)
base64string = b64encode(authString.encode()).decode("ascii")

base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)

# Load data from NZBGet
response = urllib2.urlopen(request)
data = response.read()
response = urllib.request.urlopen(request)
data = response.read().decode('utf-8')

# "data" is a JSON raw-string
return data
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ The status "FAILURE/BAD" is passed to other scripts and informs them about failu

For more info and support please visit forum topic [PP-Script FakeDetector](http://nzbget.net/forum/viewtopic.php?f=8&t=1394).

NOTE: This script requires Python to be installed on your system (tested only with Python 2.x; may not work with Python 3.x).
NOTE: This script requires Python 3.x to be installed on your system (Python 2.x is deprecated and no longer supported).