Skip to content

Commit

Permalink
Add option to show either magnet or torrent links in feed, closes #13
Browse files Browse the repository at this point in the history
  • Loading branch information
stevygee committed Aug 19, 2015
1 parent 317fadc commit bbd047f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
2 changes: 2 additions & 0 deletions config-sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
define('MINIMUM_FILESIZE', 3); /* in GB */
define('MAXIMUM_FILESIZE', 19); /* in GB */

define('FEED_DOWNLOAD_LINK', 'both'); /* torrent, magnet, both */

$sites = array( /* prioritize sites to search */
'extratorrent',
'kickasstorrents'
Expand Down
28 changes: 19 additions & 9 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,29 @@
$item->appendChild( $torrentContentLength );
}

if ($film->torrentFile) {
$enclosure = $xml->createElement( "enclosure" );
$enclosure->setAttribute( "url", $film->torrentFile );
if ($film->torrentSize) $enclosure->setAttribute( "length", $film->torrentSize );
$enclosure->setAttribute( "type", "application/x-bittorrent" );
$item->appendChild( $enclosure );
if ((!$film->torrentFile && !$film->torrentMagnet) ||
(FEED_DOWNLOAD_LINK === 'torrent' && !$film->torrentFile) ||
(FEED_DOWNLOAD_LINK === 'magnet' && !$film->torrentMagnet) ) {
continue;
}

$enclosure = $xml->createElement( "enclosure" );
if ($film->torrentSize) $enclosure->setAttribute( "length", $film->torrentSize );
$enclosure->setAttribute( "type", "application/x-bittorrent" );
$link = $xml->createElement( "link" );

$link = $xml->createElement( "link" );
if ((FEED_DOWNLOAD_LINK === 'both' || FEED_DOWNLOAD_LINK === 'torrent') && $film->torrentFile) {
$enclosure->setAttribute( "url", $film->torrentFile );
$link->appendChild( new DOMText( $film->torrentFile ) );
$item->appendChild( $link );
} else if (FEED_DOWNLOAD_LINK === 'magnet' && $film->torrentMagnet) {
$enclosure->setAttribute( "url", $film->torrentMagnet );
$link->appendChild( new DOMText( $film->torrentMagnet ) );
}

if ($film->torrentMagnet) {
$item->appendChild( $enclosure );
$item->appendChild( $link );

if ((FEED_DOWNLOAD_LINK === 'both' || FEED_DOWNLOAD_LINK === 'magnet') && $film->torrentMagnet) {
$torrentMagnetURI = $xml->createElement( "torrent:magnetURI" );
$torrentMagnetURI->appendChild( new DOMText( $film->torrentMagnet ) );
$item->appendChild( $torrentMagnetURI );
Expand Down

0 comments on commit bbd047f

Please sign in to comment.