PGFernandes.pt

Tool Maker

0 notes

RSS to WebHooks

image

“Is hard to keep tracking all your Tv Series?”
Why not code a script to do that for you and notifies you on new releases.
Ok, I also wanted to play with RSS and WebHooks and that would be perfect to this project.

Idea: I will check a RSS feed for new items and notify of those changes.
For notifications I will use: desktop popups, slack (webhook) & discord (webhook).

So this is how I setup the script:

Configs:

I found a website that releases that information, every time an episode is out but they have lots of tv shows on that list and I only want some of them.

  • Solution: Have a config file where I select witch ones I want.

“<name of the show / part of the name on the feed>”: {
 "slack": [ "https://hooks.slack.com/services/…“],
 "discord”: [ “https://discordapp.com/api/webhooks/…”  ],
 "popup”: <if you want to popup a notification on desktop>,
 "open": <if you want to open in your default program>,
 "color": “<color related to the show>”,
 "pic": “<img that represents this show>”,
 "link": “<for the infos about this show>”,
 "epd": <current epd>

as an example for this post, I will be using one anime called “Boruto”:

image


RSS Feed:

RSS (Rich Site Summary; originally RDF Site Summary; often called Really Simple Syndication) is a type of web feed[2] which allows users to access updates to online content in a standardized, computer-readable format.

For the RSS feed reader, I’m using this awesome lib “feedparser

def downloadFeed(settings):
rss = feedparser.parse(settings[“rss”][“url”])
for post in rss.entries:
   for serie in settings[“series”]:
       if serie in post.title:

From there I:
# clean/parse the title so I can get the episode for that serie
# check if the episode is bigger then the current one on the configs
# return the clean feed to next phase


Actions:

- Slack & Discord WebHooks

These platforms have the ability of setup webhooks and send especial formatted messages (First picture, right Discord and left Slack)

WebHook:
is an HTTP callback: an HTTP POST that occurs when something happens; a simple event-notification via HTTP POST. A web application implementing WebHooks will POST a message to a URL when certain things happen.


- Open & Desktop Notifications:

I made so I can select 2 more options on the config file, “open” and “popup”.
For the “open with default program”, I found a simple solution:

image

For the “popup notifications”, I’m using “pync” that let you customize the popup with text and links and other fields.

image


- Timer / AutoRun

Now you just setup a timer to run it. So I’m using “crontab”

*/15 * * * * [script here] > [log file] 

This will run every 15mins and save a log if anything goes bad.

… and that’s it! a Simple way to keep track of your Tv Shows.

I still have some ideas for this project and there still room to improve it, but is a nice base for future project using RSS and Webhooks.



Have a nice day

Filed under RSS webhook discord slack dev