Skip to content

Commit 39ecdec

Browse files
committed
Update v0.0.7 improve docs and update latest python ✨
1 parent da4d914 commit 39ecdec

4 files changed

Lines changed: 20 additions & 19 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"""
1010

1111

12-
__version__ = "0.0.6"
12+
__version__ = "0.0.7"
1313
__author__ = "RknDeveloper"
1414
__license__ = "MIT License "
1515
__copyright__ = "Copyright (C) 2025-present RknDeveloper <https://github.com/RknDeveloper>"
1616

1717
from .shortly import Shortly
18-
from .exceptions import ShortlyError
18+
from .errors import ShortlyError
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import functools
1313
from .utils import LinkShortly
1414

15-
from .exceptions import (
15+
from .errors import (
1616
ShortlyValueError
1717
)
1818
from urllib.parse import urlparse
Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import aiohttp
1212
import asyncio
1313
import json
14-
from .exceptions import (
14+
from .errors import (
1515
ShortlyError,
1616
ShortlyInvalidLinkError,
1717
ShortlyLinkNotFoundError,
@@ -25,7 +25,7 @@ def __init__(self, api_key: str = None, base_site: str = None):
2525
self.api_key = api_key
2626
self.base_site = base_site
2727

28-
async def adlinkfy_convert(self, link, alias=None, silently=False, timeout=10):
28+
async def adlinkfy_convert(self, link, alias=None, silently=False, timeout=30):
2929
"""
3030
Shorten a URL using Link Shortly/All Adlinkfy API.
3131
@@ -35,7 +35,7 @@ async def adlinkfy_convert(self, link, alias=None, silently=False, timeout=10):
3535
link (str): The long URL you want to shorten.
3636
alias (str, optional): Custom alias for the short link. Default is None.
3737
silently (bool): If True, the function will directly return the original URL without raising errors.
38-
timeout (int, optional): Maximum seconds to wait for API response. Default is 10.
38+
timeout (int, optional): Maximum seconds to wait for API response. Default is 30.
3939
4040
Returns:
4141
str: The shortened URL returned by the API.
@@ -48,11 +48,12 @@ async def adlinkfy_convert(self, link, alias=None, silently=False, timeout=10):
4848
ShortlyJsonDecodeError: If API response is not valid JSON.
4949
ShortlyError: For other API-related errors.
5050
"""
51+
if silently:
52+
return link
53+
5154
api_url = f"https://{self.base_site}/api"
5255
params = {"api": self.api_key, "url": link}
53-
54-
if silently:
55-
return link
56+
5657
if alias:
5758
params["alias"] = alias
5859

@@ -93,7 +94,7 @@ async def adlinkfy_convert(self, link, alias=None, silently=False, timeout=10):
9394
except Exception as e:
9495
raise ShortlyError(f"An unexpected error occurred: {e}")
9596

96-
async def ouo_convert(self, link, alias=None, silently=False, timeout=10):
97+
async def ouo_convert(self, link, alias=None, silently=False, timeout=30):
9798
"""
9899
Shorten a URL using ouo.io API.
99100
@@ -107,7 +108,7 @@ async def ouo_convert(self, link, alias=None, silently=False, timeout=10):
107108
return link
108109

109110
# API endpoint
110-
api_url = f"http://{self.base_site}/api/{self.api_key}"
111+
api_url = f"https://{self.base_site}/api/{self.api_key}"
111112
params = {"s": link}
112113

113114
try:
@@ -127,7 +128,7 @@ async def ouo_convert(self, link, alias=None, silently=False, timeout=10):
127128
except Exception as e:
128129
raise ShortlyError(f"Ouo.io unexpected error: {e}")
129130

130-
async def shareus_convert(self, link, alias=None, silently=False, timeout=10):
131+
async def shareus_convert(self, link, alias=None, silently=False, timeout=30):
131132
"""
132133
Shorten a URL using Shareus.io API.
133134
@@ -137,7 +138,7 @@ async def shareus_convert(self, link, alias=None, silently=False, timeout=10):
137138
link (str): The long URL you want to shorten.
138139
alias (str, optional): Custom alias for the short link. Default is None.
139140
silently (bool): If True, the function will directly return the original URL without raising errors.
140-
timeout (int, optional): Maximum seconds to wait for API response. Default is 10.
141+
timeout (int, optional): Maximum seconds to wait for API response. Default is 30.
141142
142143
Returns:
143144
str: The shortened URL returned by the API.
@@ -201,7 +202,7 @@ async def shareus_convert(self, link, alias=None, silently=False, timeout=10):
201202
except Exception as e:
202203
raise ShortlyError(f"An unexpected error occurred: {e}")
203204

204-
async def tinyurl_convert(self, link, alias=None, silently=False, timeout=10):
205+
async def tinyurl_convert(self, link, alias=None, silently=False, timeout=30):
205206
"""
206207
Shorten a URL using TinyURL API - supports both old (no token) and new (with token) APIs
207208
"""
@@ -214,12 +215,12 @@ async def tinyurl_convert(self, link, alias=None, silently=False, timeout=10):
214215
else:
215216
return await self._tinyurl_old_api(link, alias, timeout)
216217

217-
async def _tinyurl_old_api(self, link, alias=None, timeout=10):
218+
async def _tinyurl_old_api(self, link, alias=None, timeout=30):
218219
"""
219220
Old TinyURL API (no token required)
220-
Docs: http://tinyurl.com/api-create.php
221+
Docs: https://tinyurl.com/api-create.php
221222
"""
222-
api_url = f"http://{self.base_site}/api-create.php"
223+
api_url = f"https://{self.base_site}/api-create.php"
223224
params = {"url": link}
224225

225226
if alias:
@@ -245,7 +246,7 @@ async def _tinyurl_old_api(self, link, alias=None, timeout=10):
245246
except Exception as e:
246247
raise ShortlyError(f"TinyURL unexpected error: {e}")
247248

248-
async def _tinyurl_new_api(self, link, alias=None, timeout=10):
249+
async def _tinyurl_new_api(self, link, alias=None, timeout=30):
249250
"""
250251
New TinyURL API (requires token)
251252
Docs: https://tinyurl.com/app/dev/api
@@ -322,7 +323,7 @@ async def _tinyurl_new_api(self, link, alias=None, timeout=10):
322323
except Exception as e:
323324
raise ShortlyError(f"TinyURL unexpected error: {e}")
324325

325-
async def bitly_convert(self, link, alias=None, silently=False, timeout=10):
326+
async def bitly_convert(self, link, alias=None, silently=False, timeout=30):
326327
"""
327328
Bitly API का उपयोग करके URL को छोटा (shorten) करें।
328329
Docs: https://dev.bitly.com/api-reference

0 commit comments

Comments
 (0)