'google-alerts-api' library issues fix

in utopian-io •  3 months ago  (edited)

google alerts
image source

Repository

https://github.com/adasq/google-alerts-api
PR: https://github.com/adasq/google-alerts-api/pull/20

Bug Fixes

What is Google Alerts?

For those who are not familiar with Google Alerts - it is a simple service which lets you create kind of "Internet Watcher" for given search terms.

Some of the search term you can create a watcher for:

  • "STEEM OR SBD OR steemit"
  • "blockchain"
  • "Donald Trump"

Go google.com/alerts and give it a try.

Background

The only one problem with the service, is that Google does not provide a public API for it.

That is why I created an nodejs wrapper for the service which allows you to manage your alerts within npm package.

I have been writing about the service almost a year ago. At the time, I faced a problem with authentication process. This time, Google has changed alert model, so it required additional changes to the library - which is the scope of the contribution. Entire process of creating, fetching and modifying alerts has changed. The problem itself was raised on this github issue by package user.

The way Google serializes alerts for the sake of HTTP communication is really tough to read. Here is an example:

[null,"4f94515ec736ef62:b52a401d5c6c8ac9:com:en:PL:R",[null,null,null,[null,"alert-name-1563002419139","com",[null,"en","PN"],null,null,null,1,1],null,3,[[null,2,"",[],1,"pl-US",1,null,null,null,null,"17179601335058889169",null,null,"AB2Xq4iZz5W9Zn52jEZBZ33Fl0P_zbtix3qoKQ8"]],null,null,[3]]]

Awful, huh?

In order to build human readable alert object there needs to be defined special mappers:

image.png

Such mappers says us, where given alert attribute (name, id, etc.) are being located. I.e. alert's name (NAME_LOC = '1.2.0') stands for:

  1. Go to array element with index 1.
  2. Inside the array search for array located on index 2.
  3. Inside found array, on the first position (index 0) there is an alert name.

Almost all of them has been updated due to the google changes. What is more, in order to get alerts I had to change the way an alerts state is being parsed:

image.png

Modifying / creating API requests has been updated as well. More details in PR.

What is more, a complete set of test for modifing alerts has been added (sorry for an incorrect screenshot indention)

image.png

We are no longer able to authenticate within mail / password, so a new function for generating cookies has been added.

See unit test:

image.png

How to get SID, HSID and SSID? Entire process is described in README.md:

According to the PR changes, version 0.4.2 has been published to the npm registry.

GitHub Account

https://github.com/adasq

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

It's really a shame for google to not expose an API for that. You're doing a great job. This requires constant maintenance everytime google changes things in their website structure, and looks like you're keeping up.

--

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Thank you for your review, @emrebeyler! Keep up the good work!

Hi, @adasq!

You just got a 0.07% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.

Hi @adasq!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @adasq!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!