File tree 6 files changed +118
-131
lines changed
6 files changed +118
-131
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import requests
2
+ from .exceptions import BitlyApiNotWorking , BitlyException
3
+
4
+ __version__ = "1.0.1"
5
+ bitli_api = "https://api.ksprojects.me/bitly?url={}"
6
+
7
+
8
+ def shorten_url (url : str ) -> str :
9
+ try :
10
+ response = requests .get (bitli_api .format (url )).json ()
11
+ except Exception :
12
+ raise BitlyApiNotWorking
13
+ if response ['success' ] is True :
14
+ return response .get ('link' )
15
+ if response .get ('message' ):
16
+ raise BitlyException (response ['message' ])
17
+ raise BitlyApiNotWorking
Original file line number Diff line number Diff line change
1
+ class BitlyApiNotWorking (Exception ):
2
+ pass
3
+
4
+
5
+ class BitlyException (Exception ):
6
+ pass
Original file line number Diff line number Diff line change 1
- # bitly-api-python
2
- A Python wrapper for the bit.ly API
1
+ # <b >BitlyAPI</b >
2
+
3
+ - [ <b >Installation</b >] ( #installation )
4
+ - [ <b >Documentation</b >] ( #documentation )
5
+ - [ <b >Examples</b >] ( #examples )
6
+ - [ <b >Short Url</b >] ( #short-url )
7
+ - [ <b >Version</b >] ( #version )
8
+ - [ <b >Copyright</b >] ( #copyright )
9
+
10
+ <br >
11
+
12
+ # <b >Installation</b >
13
+
14
+ ``` shell
15
+ pip install bitly-api-python
16
+ ```
17
+
18
+ <br >
19
+
20
+ # <b >Documentation</b >
21
+
22
+ You can read our Documention on https://api.ksprojects.me/docs
23
+
24
+ <br >
25
+
26
+ # <b >Examples</b >
27
+
28
+ ## <b >Short Url</b >
29
+
30
+ ``` python
31
+ from BitlyAPI import shorten_url
32
+
33
+ url = " https://github.com/Krishna-Singhal"
34
+
35
+ shortened_url = shorten_url(url)
36
+ print (shortened_url)
37
+ ```
38
+
39
+ #### <b >Parameters</b >
40
+
41
+ Parameter | description
42
+ --------- | -----------
43
+ ` url ` | Long url
44
+
45
+ <br >
46
+
47
+ ## <b >Version</b >
48
+
49
+ ``` python
50
+ from BitlyAPI import __version__
51
+
52
+ print (__version__ )
53
+ ```
54
+
55
+ # <b >Copyright</b >
56
+
57
+ Copyright (C) 2022 by Krishna-Singhal, < https://github.com/Krishna-Singhal >.
58
+
59
+ All rights reserved.
Original file line number Diff line number Diff line change
1
+ [build-system ]
2
+ requires = [
3
+ " setuptools>=42" ,
4
+ " wheel"
5
+ ]
6
+ build-backend = " setuptools.build_meta"
Original file line number Diff line number Diff line change
1
+ import re
2
+ import setuptools
3
+
4
+ with open ("BitlyAPI/__init__.py" , encoding = "utf-8" ) as f :
5
+ version = re .findall (r"__version__ = \"(.+)\"" , f .read ())[0 ]
6
+
7
+ with open ("README.md" , "r" ) as fh :
8
+ long_description = fh .read ()
9
+
10
+ setuptools .setup (
11
+ name = "bitly-api-python" ,
12
+ version = version ,
13
+ author = "Krishna-Singhal" ,
14
+
15
+ description = "Wrapper for [Bitly API](https://api.ksprojects.me/bitly)" ,
16
+ long_description = long_description ,
17
+ long_description_content_type = "text/markdown" ,
18
+ url = "https://github.com/Krishna-Singhal/bitly-api-python" ,
19
+ project_urls = {
20
+ "Bug Tracker" : "https://github.com/Krishna-Singhal/bitly-api-python/issues" ,
21
+ },
22
+ classifiers = [
23
+ "Programming Language :: Python :: 3" ,
24
+ "License :: OSI Approved :: GNU General Public License v3 (GPLv3)" ,
25
+ "Operating System :: OS Independent" ,
26
+ ],
27
+ install_requires = ["requests" ],
28
+ packages = ['BitlyAPI' ],
29
+ python_requires = ">=3.6" ,
30
+ )
You can’t perform that action at this time.
0 commit comments