forked from breakdowns/slam-mirrorbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Add more shorteners: linkvertise, shorte and bitly -Minor fixes Co-authored-by: Juned KH <[email protected]> Signed-off-by: anas <[email protected]>
- Loading branch information
Showing
6 changed files
with
101 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import requests | ||
import random | ||
import base64 | ||
import pyshorteners | ||
from urllib.parse import quote | ||
from urllib3 import disable_warnings | ||
from bot import SHORTENER, SHORTENER_API | ||
|
||
|
||
def short_url(longurl): | ||
if "shorte.st" in SHORTENER: | ||
disable_warnings() | ||
return requests.get(f'http://api.shorte.st/stxt/{SHORTENER_API}/{longurl}', verify=False).text | ||
elif "linkvertise" in SHORTENER: | ||
url = quote(base64.b64encode(longurl.encode("utf-8"))) | ||
linkvertise = [ | ||
f"https://link-to.net/{SHORTENER_API}/{random.random() * 1000}/dynamic?r={url}", | ||
f"https://up-to-down.net/{SHORTENER_API}/{random.random() * 1000}/dynamic?r={url}", | ||
f"https://direct-link.net/{SHORTENER_API}/{random.random() * 1000}/dynamic?r={url}", | ||
f"https://file-link.net/{SHORTENER_API}/{random.random() * 1000}/dynamic?r={url}"] | ||
return random.choice(linkvertise) | ||
elif "bitly.com" in SHORTENER: | ||
s = pyshorteners.Shortener(api_key=SHORTENER_API) | ||
bitly = s.bitly.short(longurl) | ||
return bitly | ||
else: | ||
return requests.get(f'https://{SHORTENER}/api?api={SHORTENER_API}&url={longurl}&format=text').text |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.