[Music]
hello everyone welcome back to mr.
random generator today I will be showing
the program that I've made which is an
URL shortener that works on Mac menu bar
and the great thing about that program
is it was not created by using Xcode it
is purely created by using Python and
amazing libraries such as Gramps and pi
shorteners so now we can move on to the
code as you can see the code is fairly
simple and short and it uses actually a
few libraries to begin with we first
import rumps which is a the core of this
project it's basically enables us to
create many bar applications without
using Xcode and it's for structure wise
you generally click create a class an
application class and you define the
behaviors inside that using functions
and stuff so next up we are using a
clipboard library and to understand it
better I first need to introduce you to
the working principle behind code so our
program is
running in the following way first the
users the copies an URL that he or she
wants to short then he opens up the
application on top and hit shorten and
after that we just go over to clipboard
and fetch the copy devera and we make
some operations and shorten touch we are
basically and again copy it back onto
the clipboard so when the user pastes it
it just tastes the shortened version and
to you know handle this copy and paste
operations we basically need the
clipboard library and as for the
validators it's just basically you are
not check we need to do so if the user
copied correct URL tries to shorten the
correct formatting and stuff like that
after that we use apply shortness
library which is again an awesome
library it does include actually does
provide almost I think every shortener
that C you could possibly use so again
it's really good and as for our code
feel important two things to mention
here as you can see we have parameter
list shortness
and those shortness does not require any
API key API secret or login credentials
whatsoever you can commit it to convert
your long URL into the shorter version
so by default our program uses those and
if you want to add another shorteners
provided by the pi shortness and again
they provide a lot of them you can just
use them and ok so moving forward we do
have a choose function which actually is
responsible for the picking the chosen
shortener and using that it basically in
our app we have a drop-down and in that
drop-down a user was able to choose to
me choose the shortener that wants to
use so we just fetch it and put it in
the chosen shorten of arrival so as we
move forward we have a D to shorten
method itself again it's really a simple
method we just define our shortener
right there and we fetch the retrieve
the URL and from our clipboard that user
copied and check if it's valid and we do
that by using the again validators
library and if that is valid we check
that if the user chooses a service again
shortener service if it if nothing is
chosen it just our application just
throws a notification you know the in
the max right on the right side the
notification pops up I will show you in
a minute
it just pops that and if not the so if
user choose any services that is defined
in our if statements we just copy into
our clipboard the short version
shortened version which is using again
the refugee our and again something gets
happened and the URL is not valid so we
just do another notification that the
provided URL is actually in but okay so
this part is actually the part where I
included the I include only the
parameter lists shortness in the
drop-down menu so if you can if you
should replaced those parameter lists
shorteners but by the epoch by available
shortener you will get the whole range
of partners that is available to you in
right there we define our application I
can design just simple I can that I
created that shows up on the menu bar
right there so yeah we define that and
in our menu we just add shortener
service drop down right here again the
shortened menu items is an item full of
the many items and the nun thing the nun
thing is actually a bit of interesting
thing when you just let me open
something yeah do you see those lines
those lines are actually created by
giving the known nun parameter right
and after debts is done we just run our
application so again it's just a simple
code and now let's run the application
and see how it works
so we just run it and see that a little
short like and it just pops right there
we have a few of options quit shorten I
should choose short new source let's go
ahead and I choose one that's a tiny URL
so just to get that website I open the
randomness calm and create some random
your ass let's copy that again copy and
you just it shortened so it should
shorten up you are help and if you paste
it again you see that it shortens to the
specified shortener service which is a
tiny URL in our case okay so that's all
for this video you can always check out
the github link that I provided for this
project
feel free to make any changes that you
want and also don't forget to check out
the awesome library that I have used and
if you liked the video don't forget to
like and hit subscribe button see you
next time thank you