Giter Site home page Giter Site logo

rafostar / shell-rss-torrent Goto Github PK

View Code? Open in Web Editor NEW
26.0 5.0 6.0 53 KB

Download torrents from RSS feeds with a simple shell script

License: MIT License

Shell 100.00%
rss-torrent download-torrents transmission-rss torrent-rss torrent-rss-feed anime-downloader anime-rss nyaa-rss anidex-rss download-anime-automatically

shell-rss-torrent's Introduction

shell-rss-torrent

Download torrents from RSS feeds with a simple shell script. Easy on CPU and memory, no compiling required. Perfect for embedded devices with Linux.

Requires:

  • libXML2 (xmllint binary)
  • wget

By default the script will download torrents using wget into a specified directory and is intended to be used with a torrent client that supports importing new torrent files from a watch dir (e.g. Transmission). This behaviour can be altered with a custom config file. Script supports passing torrents links into any other app, therefore making it compatible with a wide range of clients.

Remember to mark this script as executable after download (chmod +x ./shell-rss-torrent).

Specify path to the watch dir in config file with <watchdir>. You can optionally use <history> with a path to the file that will store this script download history, so the script won't download the same torrent on the next run.

To make this script work on OpenWRT you need to install libxml2-utils (available in official OpenWRT packages). If you plan to use the optional <time-max> tag, then full version of GNU date is required (OpenWRT coreutils-date package). The script should work with the simplified busybox version of wget, but the full version will support more websites.

Usage

The script will parse all queries inside user created config.xml file. Launch the script while providing the path to the configuration file.

./shell-rss-torrent "/path/to/config.xml"

The config file must be a valid XML file. You have to escape specific characters inside it.

Character Replacement
" &quot;
' &apos;
< &lt;
> &gt;
& &amp;

You can run this script periodically by setting a Cron job:

*/10 * * * * /path/to/shell-rss-torrent "/path/to/config.xml" > /dev/null

Supported search queries

<contains>     - torrent name that includes a specified text
<starts-with>  - torrent name starting with a specified text

All search queries are case sensitive. Add ignore-case="1" attribute for case-insensitive search.

Find a single torrent using multiple search queries by placing them inside <multi> tag.

Custom download command

It is possible to pass the torrent/magnet link obtained with the script to custom download application instead of default wget. To do this add <downloader> tag with the command line args in the root of your config file.

Examples:

<downloader>wget -U "$UA" -P "$WatchDir"</downloader> - use wget (default)
<downloader>transmission-remote -a</downloader>       - add torrent to transmission
<downloader print="1">tget</downloader>               - use tget app to download

These are only examples. Inside this tag can be any command you want. Please note that the script will append the torrent link to the end of written command (after space). You can optionally use these variables inside downloader command:

  • $UA - user agent
  • $WatchDir - path to watchir set in config
  • $HistoryPath - path to torrent history file set in config
  • $FeedsCount - total number of feeds in config
  • $FeedUrl - link to current feed set in config
  • $Title - item title tag value

Time related variables (only available when <time-max> was set in config file):

  • $TimeMax - max elapsed time set in config
  • $PubDate - item pubDate tag value
  • $TorrentEpoch - value of $PubDate converted to seconds in local time
  • $CurrentEpoch - current epoch time (in seconds)
  • $Elapsed - time in seconds elapsed from item release

If you want to run downloader with its output to the command line use <downloader print="1"> tag.

Config example

<config>
  <watchdir>/tmp/watchdir</watchdir>
  <history>/tmp/download_history</history>
  <feed url="https://example.com/rss1">
    <contains>King Kong</contains>
    <contains ignore-case="1">STAR WARS</contains>
    <starts-with>The Terminator</starts-with>
  </feed>
  <feed user="login" pass="password" url="https://example.com/rss2">
    <contains>Blade Runner</contains>
    <starts-with ignore-case="1">BATman</starts-with>
    <multi>
      <contains>Back to the Future</contains>
      <contains>BluRay</contains>
      <contains>1080p</contains>
    </multi>
  </feed>
</config>

shell-rss-torrent's People

Contributors

rafostar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

shell-rss-torrent's Issues

Only the first multi is seen

Portion of my config file :

  <feed url="https://eztv.re/ezrss.xml">
    <multi>
      <contains>The Orville</contains>
      <contains>1080p</contains>
      <contains>HEVC</contains>
      <contains>x265</contains>
      <contains>MeGusta</contains>
    </multi>
    <multi>
      <contains>Anarchists</contains>
      <contains>1080p</contains>
      <contains>HEVC</contains>
      <contains>x265</contains>
      <contains>MeGusta</contains>
    </multi>
    <multi>
      <contains>Barry</contains>
      <contains>1080p</contains>
      <contains>HEVC</contains>
      <contains>x265</contains>
      <contains>MeGusta</contains>
    </multi>
</feed>

Only the first multi is seen

Total feeds in config: 1
feed 1: https://eztv.re/ezrss.xml
   multi 1: The Orville, found: 0

Is this intentional , or am I doing something wrong ?
Thanks.

[Feature request] "or" operant

Would it be possible to add an "or" operant to the search queries?

Something like

    <multi>
    <starts-with ignore-case="1">Cowboy Bob Show</starts-with>
    <possible ignore-case="1">HDTV</possible>
    <possible ignore-case="1">SDTV</possible>
    </multi>

The preceding would download the first "Cowboy Bob Show" found with either "HDTV" or "SDTV" in its description.

    <multi>
    <starts-with ignore-case="1">Cooking with Cookie</starts-with>
    <if-present ignore-case="1">XViD</if-present>
    <if-present ignore-case="1">x264</if-present>
    </multi>

The preceding would download the first "Cooking with Cookie" found with either "XViD" or "x264" in its description.

    <multi>
    <starts-with ignore-case="1">Police Drama</starts-with>
    <may-have ignore-case="1">GroupName1</may-have>
    <may-have ignore-case="1">GroupName2</may-have>
    </multi>

The preceding would download the first "Police Drama" found from either "GroupName1" or "GroupName2"

    <multi>
    <starts-with ignore-case="1">The Epidermis Adventures</starts-with>
    <optional ignore-case="1">720p</optional>
    <optional ignore-case="1">1080p</optional>
    </multi>

The preceding would download the first "The Epidermis Adventures" found with "720p" or "1080p" in its description.

Basically, I'm requesting similar functionality to the regex (choice1|choice2)

<optional>, <may-have>, <if-present>, <possible> are just some ideas I spitballed up.

 

Explanation: This has nothing to do with your fine script - it works an absolute treat!

The issue arises when the RSS feeds aren't properly propagated and the particular TV show I've got scheduled in shell-rss-torrent doesn't appear in the feed SRT is set to watch, or (I've seen this more than once) the publishing group "takes the day (or week) off"

Having an "or" condition where it grabs the first title it finds from multiple vectors would add much to this script.

 

I just want to watch the shows - I'm not married to any particular group or resolution (but I have a playstation, so I am particular about the playability of the media)

Invalid config file

Hi,

Thanks for your script.

I have a problem with the config file.
I copied the bash script as it is, no modification...
Hten I created a xml file like this :

<config>
  <watchdir> /var/www/html/uploads</watchdir>
<history> /tmp/download_history</history>
  <feed url="myRSSfeed">
<contains ignore-case="1">Pack</contains>
    </feed>
</config>

but i get :
Error: invalid config file

Did i make any mistake in writing the xml ?

Thanks for you help

Download all in feed.

I have a personal bookmark feed. Is there anyway to tell the script to download all the torrents in the feed? I tried * in contains variable but it doesn't work.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.