Skip to content

Autodl IRSSI Notification Stream implementation

Abdul Malik edited this page Sep 3, 2022 · 3 revisions

1

So the goal is to display these notifications/feed shown in the autodo-irssi tab in the mobile application.

I've been researching about this by exploring the codebase of Novik/ruTorrent and the third-party plugin autodl-irssi to find a way for this implementation. I've faced an issue but also figured out a workaround that works pretty good, let me explain.

I went into the codebase of RuTorrent and found out the URL endpoint of the autodl-irssi feed buttons and also examined the code and found out the URL Endpoint to be

http://localhost:8080/plugins/autodl-irssi/command.php?type=autodl&arg1=whatsnew

The arg1 can be update, version, whatsnew basically the onclick function of all the buttons can be simulated through this URL endpoint. I used Postman to simulate these API calls and found out that, when I called this URL endpoint the Web Interface of RuTorrent was getting updated with new feed/notifications, BUT the feed/notifications were not being returned in a JSON format and instead they were being directly injected in the form of html by a function called rPlugin.prototype.attachPageToTabs() in RuTorrent's backend

2

3

4

So this was the issue and the workaround I came up with was :

  • Simulating the "whats new" command (or any other button) by using the endpoint given above, which will update RuTorrents web interface
  • Make a network call to the URL (localhost:8080) in our case and parse the notifications part using the html element's id or tag (a.k.a web scraping)

5

To implement this I thought of using the chaleno Flutter package however, I later realized this package can only be used to scrape static websites.

The other solution I could think of was to fork the autodl-irssi and write the code for the notifications to be returned in JSON format to the API call.

To make sure this change take place we would then have to either send a PR to the autodl-irssi plugin and make sure the original RuTorrent's repo is using the latest version or make a fork of RuTorrent's repo as well and edit the Docker container image to point to our fork and publish the new docker container image. This is tedious.

I went ahead with the initial solution that came in mind by figuring out a way to scrape dynamic websites. Here's how, we can load an invisible in-app browser in the flutter app, wait for it to initialize and then scrape the website loaded in the in-app browser. And that is exactly how I implemented the solution which can be seen here.

https://github.com/CCExtractor/rutorrent-flutter/blob/0ffb981302ede3f81fbd7b0272354b62c6527a6e/lib/ui/views/IRSSI/IRSSI_view.dart#L34-L52

Girl in a jacket