RSS Alerter

May 24, 2018
785
0
16
#1
Hi guys,

I had been working on my own replacement to wTorrent, and found your web UI, and I started using it immediately. It is definitely the best bittorrent web UI out there, by leaps and bounds.

I really like the RSS functionality, but I am trying to make some changes. I previously had a hacky python script that would check my RSS feeds, then email / web SMS me to let me know a new episode of some show was out. For the sake of integration, I have started using rutorrent's RSS downloader instead.

I've started work on this, and have it so I run a little shell_exec() line in the getTorrents() function of the RSS class. My two problems are this:
  • I don't have access to the <title> section of the RSS feed item at this time, so I get alerts with only the filename of the torrent (which is usually just a hash).
  • This works and alerts me when I right-click and select 'load' in an RSS feed, but I only want it to occur when an item is downloaded automatically. What function should I put the code in to achieve this?

Any help on these two problems would be greatly appreciated.

Many thanks for a great app
- mk429
 
May 25, 2018
833
0
16
#2
This works and alerts me when I right-click and select 'load' in an RSS feed, but I only want it to occur when an item is downloaded automatically. What function should I put the code in to achieve this?
You need to put your code into function checkFilters for this. Something like this (see comments inside):
Code:
public function checkFilters($rss,$info = null,$filters = null)
{
if($filters===null)
{
$filters = new rRSSFilterList();
$this->cache->get($filters);
}
if($info===null)
$info = $this->rssList->lst[$rss->hash];
foreach($filters->lst as $filter)
{
if($filter->isApplicable( $rss, $this->history ))
{
foreach($rss->items as $href=>$item)
{
if( !$this->history->wasLoaded($href) &&
$filter->checkItem($href, $item) )
{
$this->history->applyFilter( $filter->no );
// Place your code here. $item['title'] - for title, $item['description'] - for description, $href - for torrent url,
// $rss->channel['title'] for feed's title, $rss->url for feeds url etc.
// Warning! In theory fields 'title' and 'description' may be absent in $item (some error in feed, for example). As result,
// you need to use something like
// if(array_key_exists('description',$item))
// $desc = $item['description'];
// else
// $desc = '';
$this->getTorrents( $rss, $href,
$filter->start, $filter->addPath, $filter->directory, $filter->label, $filter->throttle, $filter->ratio, false );
if(WAIT_AFTER_LOADING)
sleep(WAIT_AFTER_LOADING);
}
}
}
}
}
 
May 25, 2018
928
0
16
#4
Wow, Novik65, that was a really complete answer! Thanks a million, it's working perfectly now.

I'll get to work on integrating it into the rssmanager interface, so people can choose their own command to run when a new torrent is added automatically from RSS. Once it's all working, I'll send a patch to you guys to have a look at, if you wanna include it smiley.gif
 
May 25, 2018
896
0
16
#5
Well, it isn't working as well as I had thought.

When I add a new filter in the RSS manager, I am alerted with the new torrents that match that filter. Unfortunately, any future matches to those filters do not result in me being alerted. Is this definitely the right place to be putting the code?

Code:
foreach($rss->items as $href=>$item)
{
if( !$this->history->wasLoaded($href) &&
$filter->checkItem($href, $item) )
{
$this->history->applyFilter( $filter->no );
// mk429 - o2sms hack
$t = 'untitled';
if(array_key_exists('title', $item))
$t = $item['title'];
exec("/bin/sh -c 'echo \"*** added ".$t."***\" >> /tmp/rss.log'");

$this->getTorrents( $rss, $href,
$filter->start, $filter->addPath, $filter->directory, $filter->label, $filter->throttle, $filter->ratio, false, $info );
if(WAIT_AFTER_LOADING)
sleep(WAIT_AFTER_LOADING);
}
}


Any help is very much appreciated.
 
May 25, 2018
833
0
16
#6
Definitely.
Code:
exec("sh -c 'echo \"*** added ".$t."***\" >> /tmp/rss.log'");
What if $t contain char `"`? And `>`? Write your code correctly. See function escapeshellarg etc.
 
May 25, 2018
960
0
16
#7
What if $t contain char `"`? And `>`? Write your code correctly. See function escapeshellarg etc
I am aware, and when I was actually calling the correct program, I was escaping properly. This is merely to test, and I have tried not using a parameter at all and merely writing to a file every time this piece of called. It logs when I add new filters, but not when those filters find new torrents...