Code Monkey home page Code Monkey logo

bitlyshortener's People

Contributors

impredicative avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bitlyshortener's Issues

get link stats

is it possible to get link's stats?
I'm interested to get a sort list by clicks of all generated links by the pool tokens
Will you implemented this?
Thanks for your amazing great job!

Support bit.ly links

Hello! I've used this library for months but I've always had a doubt: why doesn't it support bit.ly links but only j.mp ones? What would require to support other link formats as well?

[feature request] shorten URL with SSL

Would it be possible, to append an s to http:// somehow programmatically?

Because bit.ly provides ssl links only with the premium account (branded links) and otherwise it would be required to copy the generated URL and append an s manually.

If this could be added to the package, it would be pretty nice.

What do you think?

Support Python 3.6.9

Currently, bitlyshortener supports only Python 3.7+. Is there a reason for it? Can shortening happen serially if ThreadPoolExecutor throws an error?

Python 3.6.9 is still very much used, as being, for instance, the standard version in Ubuntu 18.04 LTS.

.usage() doesn't work

>>> shortener.usage()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Shortener' object has no attribute 'usage'

Package discontinued because Bitly lowered the free quota per token from 1000 to 50 per month

In November 2022, an email was received from Bitly advising that the new link quota per free token is lowered to 50 per month (from its previous value of 1000 per month). As per the email, this change is effective on December 8, 2022.

The new quota is so low as to not be useful. For this reason, the maintenance of this package is being discontinued, although the package should continue to function with the limited new quota.

Users can consider switching to dagdshort as an alternative.

Could not find a version that satisfies the requirement

Hey, I am trying to install this library inside a Docker container but I have always the same error:

Collecting bitlyshortener
  Could not find a version that satisfies the requirement bitlyshortener (from versions: )
No matching distribution found for bitlyshortener
root@8022d008f48a:/app# 

any idea by there?

[v0.3.0]object has no attribute 'session_post'

Hello,

I try to set up URL shortening in the following way:

Here I put the tokens_pool into [ ] brackets.

from bitlyshortener import Shortener
tokens_pool = ['my_general_access_token']  # is this correct?
shortener = Shortener(tokens=tokens_pool, max_cache_size=8192)
@usr_account.route("/account/createtable", methods=["POST"])
def account_createtable():
    form = CreateTableForm(request.form)
    if form.validate():
        tableid = DB.add_table(form.tablenumber.data, current_user.get_id())
        new_url = config.base_url + "newrequest/" + tableid
        short_url = shortener.shorten_urls(new_url)
        DB.update_table(tableid, short_url)
        return redirect(url_for('account.account'))
    return render_template("account.html", createtableform=form, tables=DB.get_tables(current_user.get_id()))

This gives me the following error:

https://gist.github.com/mark-schulze/3fff041cc761a8f019b42b4e51ac59bd

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api-ssl.bitly.com/v4/shorten

and

bitlyshortener.exc.RequestError: The response status code is 400 and so the request will not be reattempted. The error is: HTTPError: 400 Client Error: Bad Request for url: https://api-ssl.bitly.com/v4/shorten

I'm not sure if I properly bind in the access_token or what could cause the error.
If you could help me here, it would be great.

Thanks

[feature request] utf-8 support

Not sure if the bit.ly API supports this, but it would be great to be able to generate URLs also from letters like [ä,ö,ü,§,%,"], so having utf-8 support would be nice.

403 Client error Forbidden for URL

Hello,

I try to set up URL shortening in the following way:

from bitlyshortener import Shortener
tokens_pool = 'my_general_access_token'  # is this correct?
shortener = Shortener(tokens=tokens_pool, max_cache_size=8192)
@usr_account.route("/account/createtable", methods=["POST"])
def account_createtable():
    form = CreateTableForm(request.form)
    if form.validate():
        tableid = DB.add_table(form.tablenumber.data, current_user.get_id())
        new_url = config.base_url + "newrequest/" + tableid
        short_url = shortener.shorten_urls(new_url)
        DB.update_table(tableid, short_url)
        return redirect(url_for('account.account'))
    return render_template("account.html", createtableform=form, tables=DB.get_tables(current_user.get_id()))

This gives me the following error:

https://gist.github.com/mark-schulze/b02b9c77dd45046dc932eaf195e4bf34

requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api-ssl.bitly.com/v4/bitlinks

and

bitlyshortener.exc.RequestError: Exhausted all 30 attempts requesting response from 30 for long URL h. The error is: HTTPError: 403 Client Error: Forbidden for url: https://api-ssl.bitly.com/v4/bitlinks

I'm not sure if I properly bind in the access_token or what could cause the error.
If you could help me here, it would be great.

I do get another error, I post a separated issue for that.

Thanks

Bitly converted short url start with j.mp instead of amzn.to

When I tried to convert following url to short URL from bitly website
https://www.amazon.in/Surf-Excel-Matic-Detergent-Powder/dp/B00TS88UZW

I got short url like https://amzn.to/3ho0Inp this, but when I convert by using bitlyshortner library,

I am getting short url like this https://j.mp/2FbsN2Y, I know as per documentation this is also bitly shorter, but is it possible to shorter link as similar we get on bitly website?

I am able to achieve this by using their API in my python code, but I really like this library, so curious to know is it possible to do similar in this library?

TypeError: __init__() got an unexpected keyword argument 'initializer'

I'm trying to run a simple example:

>>> from bitlyshortener import Shortener
>>> import os
>>> tokens_pool = [ os.environ["BITLY_TOKEN"] ]
>>> shortener = Shortener(tokens=tokens_pool, max_cache_size=8192)

But I get the error:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
    shortener = Shortener(tokens=tokens_pool, max_cache_size=8192)
  File "/home/jmerelo/.pyenv/versions/3.7-dev/lib/python3.7/site-packages/bitlys
hortener/shortener.py", line 27, in __init__
    self._init_executor()
  File "/home/jmerelo/.pyenv/versions/3.7-dev/lib/python3.7/site-packages/bitlys
hortener/shortener.py", line 69, in _init_executor
    initializer=self._init_requests_session)
TypeError: __init__() got an unexpected keyword argument 'initializer'

Any idea?

ZeroDivisionError when long url is in cache

Tried processing only one long url twice:

  File "C:\python\lib\site-packages\bitlyshortener\shortener.py", line 270, in shorten_urls
    rate_per_second = num_short_urls / time_used
ZeroDivisionError: float division by zero

My manual solution editing "shortener.py" at line 270:

        try:
            rate_per_second = num_short_urls / time_used
        except ZeroDivisionError:
            rate_per_second = 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.