RSS auto-downloading with Transmission without Flexget (tested on v4)

I was very happy that I could download torrents on my cloud, but there was one thing missing. After multiple experiments ending by bricking the whole thing I finally got to the place, where I have v4 firmware, Transmission as deamon with RSS auto-downloder. And because this whole debricking journey wouldn’t be possible without this community, here’s my input.

To be honest, it should work on any firmware version, but I’ve tested it on v4 only. 

What you need: 

  • PHP (already working on cloud)

  • Transmission with deamon running (I used this  tutorial)

  • Cron (already working on cloud)

I’m pretty new to the whole thing, I just bought my device week ago. So because the new v4 firmware we can’t use Flexget (whatever it is) that helps us download torrents from RSS, we need something else. We already have PHP on board and I noticed we have cron running (I’m not sure if it’s been from the start or after I installed Transmission). Here’s how to take advantage of the above and make torrents from RSS possible without bloody Flexget :wink:

  1. Open SSH and connect to your cloud

  2. Install Transmission (I used this  tutorial)

  3. Go to your home dir or anywhere you like

    cd ~/

  4. Download chinese PHP script with wget:

    wget https://raw.githubusercontent.com/fengqi/Transmission-RSS/master/rss.php

  5. Edit the config section at the end of the file with any text editor

    nano rss.php

 Here is the list of RSS links (it can be more than one. Just delete all of them here and put yours. Remember to omit the comma after the last link.

$rss = array(
    'http://chdbits.org/torrentrss.php...',
    'http://totheglory.im/putrssmc.php...',
    'https://hdcmct.org/torrentrss.php...',
    'https://open.cd/torrentrss.php?.....',
    'https://mv.open.cd/torrentrss.php?..',
    'http://hdwing.com/rss.php?..........',
    'http://hdtime.org/torrentrss.php?...'
);

 Internal IP to your cloud (it’s better to use static local IP, I’m not sure if the name would work like on your computer)

$server = 'http://127.0.0.1';

 Access port to Transmission (if you haven’t change it, skip it)

$port = 9091;

 RPC path for Transmission (same here, skip it if you haven’t changed it)

$rpcPath = '/transmission/rpc';

 Credentials for your Transmission (empty by default)

$user = '';
$password = '';
  1. Save and exit

  2. Test your script with 

    php rss.php

 If all goes well, it should return a list of found links and added to Transmission, for example:

success add torrent: Two and a Half Men 12x09 Bouncy, Bouncy, Bouncy, Lyndsey 720p
success add torrent: The Big Bang Theory 8x12 The Space Probe Disintegration 720p
success add torrent: Forever 1x12 720p
success add torrent: The Mentalist 7x06 Green Light 720p
  1. Check your Transmission web UI if they are downloading.

  2. Now we can add the task to cron. Edit the cron with

    crontab -e

  3. You should see at least one line with Transmission daemon. We need to add another line, like

    */10 * * * * php ~/rss.php >> /var/log/rss.log 2>&1

 or the one without logs

*/10 * * * * php ~/rss.php

 This should run our script every 10 mins.

  1. If you want to change the period, feel free. You can use some tool to make the config for you, like:  http://www.cronmaker.com
  2. Enjoy!

Bare in mind that I’m not the author of the script, so I cannot change it. I am web developer, so I could, but it works for me so I didn’t need to. If someone will have any problems I could try and help you, feel free to comment.

1 Like

Thanks for the guide.

But by the looks of it, it looks like that the all the torrents in the entire RSS  feed are being downloaded?

how do you you control which shows etc you want to download?

I currrently use flexget on V3 and perhaps you might have come across some of my ports about that.

Flexget lets you specify the names of  shows and it only dowlods those from RSS feed.

So far I have been using uTorrent and  http://showrss.info. Here you can choose which shows you want to subscribe to and only those will be in your RSS. That way I have only TV shows I want. 

Here you always add all links from the RSS to Transmission. But like on uTorrent, if you add the same torrent you’ve already downloaded - nothing happens. By the time I watch or delete those shows it dissapers from the feed. Even if you srew something up and Transmission will have clear list it always checks if the downloaded file is there. And if so and it appears to be downloaded in 100% - it’s being added to the list as downloaded again.

Ok so you have to manage your shows via torrent running on your computer?
Personally I like flex get better if that’s the case. It’s automatic, no intervention needed from anywhere else to specify shows. Flexget and transmission both run on my wd cloud drive, so it’s fully independent of anything else. Checks and downloads shows by itself on my wd drive

Hello alirz1,

I don’t get it. What’s so more complicated in my solution?

First let’s say if you have v4 firmware you either have it my way or nothing, cause I don’t see any tutorial how to install bloody Flexget on v4.

Second, I’ve just seen your config file ( https://dl.dropboxusercontent.com/u/4883446/config.yml) and all you need to do is to pick shows and put it there. 

Well, here’s my screenshot from  http://showrss.info/:

(darn, now you know my fav shows :wink:)

I pick the show from list and even I can choose between normal and 720p quality (don’t mind if they will appear on the list to the right - they won’t in RSS).

After that I dont have to do  anything  for the end of days. It will download every new episode until the show is over.

About your solution, answer me that! You’re using this RSS:  http://kickass.to/tv/?rss=1

Sometimes after the season is complete there can be torrents like “copmplete season 2” for example - right now I found “Scorpion S01E01-13”. So if I download and watch all episodes one by one why would I need all of them together now? How do you avoid such torrents? Because there are no such in my RSS.

Well if yours works as you say I,e you enter your shows RSS feed one time and set it and forget it :). That is you don’t utorrent running on a pic or something to update the feed every time a new episode comes out then that’s perfect too.

I know what you are saying about v4 Fw I’m still on v3 because of needing flex get. My second backup wd drive is stock and on Fw 4. I think I will test your solution out soon.

As for flex get it’s based on plugins etc. it knows what’s it’s downloaded and so doesn’t re download the same episode again. I would say it’s 98-% accurate on that. As for season packs it’s also aware of that somehow and doesn’t download them unless you specify that.

How does your method avoid downloading the same shows episode if it appears with a different name slightly?

Ps we seem to have a lot of common fav shows :slight_smile:

Great. From my side I can tell that the downside of my solution is that ShowRss site doesn’t have all TV shows, but in such cases you can always build a custom RSS from Kickass or add any other feed you like. 

I have tried to follow you guide but I’m getting this error: 

PHP Warning: DOMDocument::loadXML(): Empty string supplied as input in /root/rss.php on line 138
PHP Warning: DOMDocument::loadXML(): Empty string supplied as input in /root/rss.php on line 138

 On line 138 I have this piece of code:

$xml->loadXML($content);

Maybe I’m doing something wrong?

Well, the script is trying to tell you, that RSS is empty. Can you paste your configuration?

EDIT: i have managed to solve the problem, it was caused by my modem/router (vodafone station 2)

Yes, here it is:

<?php
/**
 * Transmission simple RPC/0.1
 *
 * @author fengqi <lyf362345@gmail.com>
 * @link https://github.com/fengqi/transmission-rss
 */
class Transmission
{
    private $server;
    private $user;
    private $password;
    private $session_id;

    /**
     * ?^?^??^???^ǽ?^հ, ?^?^??^??^?^??^?^?置
     *
     * @param $server
     * @param string $port
     * @param string $rpcPath
     * @param string $user
     * @param string $password
     *
     * @return \Transmission
     */
    public function __construct($server, $port = '9091', $rpcPath = '/transmission/rpc', $user = '', $password = '')
    {
        $this->server = $server.':'.$port.$rpcPath;
        $this->user = $user;
        $this->password = $password;
        $this->session_id = $this->getSessionId();
    }

    /**
     * 添?^ʠ?^??^?, ?^??^?^??^د?^??^??^?^??^?^??^??^??^??^ȶ, ?^?^??^??^?^??^??^? base64 ?^??^?
     *
     * @param $url
     * @param bool $isEncode
     * @param array $options
     * @return mixed
     */
    public function add($url, $isEncode = false, $options = array())
    {
        return $this->request('torrent-add', array_merge($options, array(
            $isEncode ? 'metainfo' : 'filename' => $url,
        )));
    }

    /**
     * ?^η?^?^? Transmission ?^?^??^ʡ?^٨?^ʶ?^?^?
     *
     * @return mixed
     */
    public function status()
    {
        return $this->request("session-stats");
    }

    /**
     * ?^η?^?^? Transmission session-id, ?^?次 rpc 请?^??^ý?^?^??^?带?^? session-id
     *
     * @return string
     */
    public function getSessionId()
{
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $this->server);
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        curl_setopt($ch, CURLOPT_USERPWD, $this->user.':'.$this->password);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        $content = curl_exec($ch);
        curl_close($ch);
        preg_match("/<code>(X-Transmission-Session-Id: .*)<\/code>/", $content, $content);
        $this->session_id = $content[1];

        return $this->session_id;
    }

    /**
     * ?^ɧ?^? rpc 请?^?
     *
     * @param $method 请?^?类?^?^?/?^ֹ?^?, 详?^? $this->allowMethods
     * @param array $arguments ?^?^??^ʠ?^?^??^հ, ?^ϯ?^?^?
     * @return mixed
     */
    private function request($method, $arguments = array())
    {
        $data = array(
            'method' => $method,
            'arguments' => $arguments
        );

        $header = array(
            'Content-Type: application/json',
            'Authorization: Basic '.base64_encode(sprintf("%s:%s", $this->user, $this->password)),
            $this->session_id
        );

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $this->server);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        curl_setopt($ch, CURLOPT_USERPWD, $this->user.':'.$this->password);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        $content = curl_exec($ch);
        curl_close($ch);

        if (!$content) $content = json_encode(array('result' => 'failed'));
        return $content;

    }

    /**
     * ?^η?^?^? rss ?^?^??^??^??^?^?表
     *
     * @param $rss
     * @return array
     */
    function getRssItems($rss)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$items = array();
        foreach ($rss as $link) {
            curl_setopt($ch, CURLOPT_URL, $link);
            $content = curl_exec($ch);

            $xml = new DOMDocument();
            $xml->loadXML($content);
            $elements = $xml->getElementsByTagName('item');

            foreach ($elements as $item) {
                $link = $item->getElementsByTagName('enclosure')->item(0) != null ?
                        $item->getElementsByTagName('enclosure')->item(0)->getAttribute('url') :
                        $item->getElementsByTagName('link')->item(0)->nodeValue;

                $items[] = array(
                    'title' => $item->getElementsByTagName('title')->item(0)->nodeValue,
                    'link' => $link,
                );
            }
        }
        curl_close($ch);

        return $items;
    }
}

// ?^?^?置
$rss = array(
    'http://showrss.info/rss.php?user_id=222729&hd=1&proper=null'
);
$server = 'http://127.0.0.1';
$port = 9091;
$rpcPath = '/transmission/rpc';
$user = '';
$password = '';

$trans = new Transmission($server, $port, $rpcPath, $user, $password);
$torrents = $trans->getRssItems($rss);
foreach ($torrents as $torrent) {
    $response = json_decode($trans->add($torrent['link']));
    if ($response->result == 'success') {
        printf("%s: success add torrent: %s\n", date('Y-m-d H:i:s'), $torrent['title']);
    }
}

So I tried your script and indeed I get the same error. Funny thing, when I tried mine - same thing :cry:. Turned out I have problems with DNS. If you’ve done everything from my guide point by point your DNS failed between 4th and 7th point :smiley: Now even using wget to download script will fail. Try to ping some domain, like: 

ping google.com

 If it fails, that’s the problem. Because like in the guide I recommend you to put logs in cron my DNS have failed on 4am so the auto-downloader was worthless ever since :stuck_out_tongue:

For me restarting the network service helped:

/etc/init.d/networking restart

 Don’t worry, it takes about 1-2 mins and it doesn’t even break SSH connection.

If the ping still won’t work you have to fix DNS on your router. If you don’t want to use default you can always use the google ones:

8.8.8.8
8.8.4.4