|
|
@ -88,6 +88,14 @@ class Shortener: |
|
|
|
# we checking which service is used, because some services doesn't require |
|
|
|
# we checking which service is used, because some services doesn't require |
|
|
|
# any authentication, or have only one domain on which it working |
|
|
|
# any authentication, or have only one domain on which it working |
|
|
|
if self.api == 'yourls': |
|
|
|
if self.api == 'yourls': |
|
|
|
|
|
|
|
self._yourls_init(settings) |
|
|
|
|
|
|
|
elif self.api == 'isgd' or self.api == 'vgd': |
|
|
|
|
|
|
|
self._gd_init() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.session, self.proxy = _config_requests(settings) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _yourls_init(self, settings): |
|
|
|
if not settings['short_url']: |
|
|
|
if not settings['short_url']: |
|
|
|
PBinCLIError("YOURLS: An API URL is required") |
|
|
|
PBinCLIError("YOURLS: An API URL is required") |
|
|
|
self.apiurl = settings['short_url'] |
|
|
|
self.apiurl = settings['short_url'] |
|
|
@ -100,18 +108,16 @@ class Shortener: |
|
|
|
self.auth_args = {} |
|
|
|
self.auth_args = {} |
|
|
|
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)") |
|
|
|
elif self.api == 'isgd' or self.api == 'vgd': |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _gd_init(self): |
|
|
|
if self.api == 'isgd': |
|
|
|
if self.api == 'isgd': |
|
|
|
self.apiurl = 'https://is.gd/' |
|
|
|
self.apiurl = 'https://is.gd/' |
|
|
|
else: |
|
|
|
else: |
|
|
|
self.apiurl = 'https://v.gd/' |
|
|
|
self.apiurl = 'https://v.gd/' |
|
|
|
|
|
|
|
|
|
|
|
self.useragent = 'Mozilla/5.0 (compatible; pbincli - https://github.com/r4sas/pbincli/)' |
|
|
|
self.useragent = 'Mozilla/5.0 (compatible; pbincli - https://github.com/r4sas/pbincli/)' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.session, self.proxy = _config_requests(settings) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getlink(self, url): |
|
|
|
def getlink(self, url): |
|
|
|
# that is api -> function mapper for running service-related function when getlink() used |
|
|
|
# that is api -> function mapper for running service-related function when getlink() used |
|
|
|
servicesList = { |
|
|
|
servicesList = { |
|
|
|