Kangarooo

https://pastebin.com/1JmZUcTt

Nov 10th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. This paste contains 2 files! Save both files in the root of your webfolder to get it working.
  3. Run it like http://my.domain.com/rss.php?search=vivaldi
  4. */
  5.  
  6. <?php
  7. /*
  8. ************************************
  9. Filename: rss.php (can be anything you like)
  10. Description: Uses ?search= GET parameter to search The Pirate Bay and displays results as RSS feed.
  11. *************************************
  12. */
  13. $PirateDomain = 'https://thepiratebay.se'; // No trailing slash please!
  14. $search  = (isset($_GET['search']))? $_GET['search']:'';
  15. if ($search) {
  16.     $content = file_get_contents($PirateDomain.'/search/'.$search);
  17.     if (preg_match('/<table id="searchResult">.*?<\/table>/is', $content, $table)) {
  18.         preg_match_all('/<div class="detName">.*?<a href="(.*?)".*?>(.*?)<\/a>.*?<a href="magnet:([^"]*).*?Uploaded (.{1,20}), Size (.{1,30}),.*?class="detDesc".*?>(.*?)<\/a>.*?<td .*?>([0-9]{1,8}).*?<td .*?>([0-9]{1,8})/is', $table[0], $matches, PREG_SET_ORDER);
  19.     }
  20.     unset($content);
  21. }
  22.  
  23. header("Content-type: text/xml");
  24. ?>
  25. <?xml version="1.0" encoding="ISO-8859-1"?>
  26. <rss version="2.0">
  27.     <channel>
  28.         <title>Unofficial Pirate Bay RSS - <?php echo $search; ?></title>
  29.         <link><?php echo $PirateDomain; ?></link>
  30.         <description>Pirate Bay scraper</description>
  31.         <language>en-us</language>
  32.         <?php
  33.         if (isset($matches)) {
  34.             foreach ($matches as $match) {
  35.                 echo '<item>';
  36.                 echo '<title>'.$match[2].'</title>';
  37.                 echo '<description>Size: '.html_entity_decode($match[5]).', Uploaded by: '.html_entity_decode($match[6]).', Seeders: '.html_entity_decode($match[7]).', Leechers: '.html_entity_decode($match[8]).'</description>';
  38.                 echo '<link>'.$PirateDomain.$match[1].'</link>';
  39.                 echo '<pubDate>'.html_entity_decode($match[4]).'</pubDate>';
  40.                 echo '<enclosure url="http'.(isset($_SERVER['HTTPS'])? 's':'').'://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].'/rss_magnet.php?magnet='.urlencode($match[3]).'" type="application/x-bittorrent" length="10000" />';
  41.                 echo "</item>\n";
  42.             }
  43.         }
  44.         ?>
  45.     </channel>
  46. </rss>
  47.  
  48. <?php
  49. /*
  50. ************************************
  51. Filename: rss_magnet.php
  52. Description: Relocates magnet links (as a hack because RSS doesn't work with magnet links)
  53. *************************************
  54. */
  55. $magnet  = (isset($_GET['magnet']))? $_GET['magnet']:'';
  56. if ($magnet) {
  57.     header('Location: magnet:'.urldecode($magnet));
  58. } else {
  59.     die('No link provided');
  60. }
  61. ?>
Add Comment
Please, Sign In to add comment