|
|
@ -2,22 +2,28 @@ import requests |
|
|
|
from requests import HTTPError |
|
|
|
from requests import HTTPError |
|
|
|
from pbincli.utils import PBinCLIError |
|
|
|
from pbincli.utils import PBinCLIError |
|
|
|
|
|
|
|
|
|
|
|
class PrivateBin: |
|
|
|
def _config_requests(settings=None): |
|
|
|
def __init__(self, settings=None): |
|
|
|
|
|
|
|
self.server = settings['server'] |
|
|
|
|
|
|
|
self.headers = {'X-Requested-With': 'JSONHttpRequest'} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if settings['proxy']: |
|
|
|
if settings['proxy']: |
|
|
|
self.proxy = {settings['proxy'].split('://')[0]: settings['proxy']} |
|
|
|
proxy = {settings['proxy'].split('://')[0]: settings['proxy']} |
|
|
|
else: |
|
|
|
else: |
|
|
|
self.proxy = {} |
|
|
|
proxy = {} |
|
|
|
|
|
|
|
|
|
|
|
if settings['no_insecure_warning']: |
|
|
|
if settings['no_insecure_warning']: |
|
|
|
from requests.packages.urllib3.exceptions import InsecureRequestWarning |
|
|
|
from requests.packages.urllib3.exceptions import InsecureRequestWarning |
|
|
|
requests.packages.urllib3.disable_warnings(InsecureRequestWarning) |
|
|
|
requests.packages.urllib3.disable_warnings(InsecureRequestWarning) |
|
|
|
|
|
|
|
|
|
|
|
self.session = requests.Session() |
|
|
|
session = requests.Session() |
|
|
|
self.session.verify = not settings['no_check_certificate'] |
|
|
|
session.verify = not settings['no_check_certificate'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return session, proxy |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PrivateBin: |
|
|
|
|
|
|
|
def __init__(self, settings=None): |
|
|
|
|
|
|
|
self.server = settings['server'] |
|
|
|
|
|
|
|
self.headers = {'X-Requested-With': 'JSONHttpRequest'} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.session, self.proxy = _config_requests(settings) |
|
|
|
|
|
|
|
|
|
|
|
def post(self, request): |
|
|
|
def post(self, request): |
|
|
|
result = self.session.post( |
|
|
|
result = self.session.post( |
|
|
@ -95,17 +101,7 @@ class Shortener: |
|
|
|
else: |
|
|
|
else: |
|
|
|
PBinCLIError("YOURLS: either username and password or token are required. Otherwise set to default (None)") |
|
|
|
PBinCLIError("YOURLS: either username and password or token are required. Otherwise set to default (None)") |
|
|
|
|
|
|
|
|
|
|
|
if settings['proxy']: |
|
|
|
self.session, self.proxy = _config_requests(settings) |
|
|
|
self.proxy = {settings['proxy'].split('://')[0]: settings['proxy']} |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
self.proxy = {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if settings['no_insecure_warning']: |
|
|
|
|
|
|
|
from requests.packages.urllib3.exceptions import InsecureRequestWarning |
|
|
|
|
|
|
|
requests.packages.urllib3.disable_warnings(InsecureRequestWarning) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.session = requests.Session() |
|
|
|
|
|
|
|
self.session.verify = not settings['no_check_certificate'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getlink(self, url): |
|
|
|
def getlink(self, url): |
|
|
|
if self.api == 'yourls': |
|
|
|
if self.api == 'yourls': |
|
|
|