Outils pour utilisateurs

Outils du site



Status: development stopped

IMPORTANT: Magnesia is no longer developed ! Using it in a production environment is strongly unwise and difficult.

The new project is called Magnyaa. Don't waste more time on this page ;-)

[ download ]

[ changelog ]

Magnesia r3 “Mit Viel Oktan und Frei von Blei”

  • _stat.php: extracting statistics directly from Nyaatorrents, output in JSON format
  • seeders, leechers, downloads, description jQuery-parsed from _stat.php (JSON exchange)
  • pages changed accordingly. “stat*.php” are now useless

Magnesia r2 “Lumen Per Lux”

  • urlencode magnet links (W3C HTML5 validation when “torrent error”)
  • htmlentities torrent names (W3C HTML5 validation, for example when “&” in torrent name)
  • export link: generate export file and send it; if export file exists and is younger than [3 days], send it.
  • minor style change: added separator for torrent details between info and stats
  • robots.txt, sitemap.php (plain text url list for tables)

Magnesia r1 “Back To Basic World Domination”

  • data storage in plain PHP files (as arrays), up to 1000 entries each “table”. (2 files: info and stat).
  • DuckDuckGo search
  • Admin-side database generation (bash-PHP script)
  • previous/next table navigation
  • index shows latest table content
  • a bit of a code cleanup and CSS
  • backup and restore script (zip archive)
  • builder (start at id 1, compare to Nyaa's RSS, then loop each id to retrieve data and form the info and stat PHP-array datafiles, reference working ids in id.txt file)
  • builder_nexttorrents (tail id.txt or prompt latest known id, compare to Nyaa's RSS, and then basically work like builder)
  • builder_refresh (check if id.txt is present, if yes use id to retrieve data and form stat PHP-array files; else prompt for id and do the same )

how Magnesia was born

At first Magnesia was a fork of Magnetik Nyaatorrents, but since it works so well it became the main project. The goal remains the same: provide a lightweight database mirror for a torrent index, Nyaatorrents, using magnet links. This can be useful in many scenarios, from website DDoS to state censorship.

installation and setup

Magnesia r1: upload, build/retrieve database, place it, profit.

In the packages there are “READMEs”. Read them :-)

You don't HAVE to build a database, you can simply download an export.zip from another trustworthy Magnesia mirror, rename it “data.zip” and extract it on your Magnesia mirror (using “zipper.php”). If you want to build your own database, get the “feeders” and use them on a GNU/Linux system (make sure to read the README ! :-/).

This software is provided “as-is”, without any warranties. The author of this software doesn't encourage counterfeit content distribution. The author cannot be held liable of any misuse of this software. The code is neutral, only a human can do illegal things with it. It is the user's sole responsibility for downloading and sharing illegal content. The information returned by the database can be inaccurate, obsolete or plain fake: automated processes can't always succeed. To comply with some countries' laws, the hostmaster can be asked to remove manually any information about an obviously illegal torrent in the database.


Magnesia, published under Creative Commons by-sa by Mitsu.

* included: torrent-rw, published under GNU GPL by Adrien Gibrat: https://github.com/adriengibrat/torrent-rw/


Bug report, feature requests, love declarations ? Head over here:


Technical specifications

User calls:

  • / → open data, put elements in array, reverse array, use first element's id as $lasttable, call content, parse, return listing
  • /?export → check if “export.zip” is older than 3 days. If no, redirect to it. If yes, delete it, regenerate it and redirect to it. (file contains the whole “data/” directory)
  • /?{anything}&export → no matter what: if export is present, do export and don't care about the rest.
  • /?table=X → use X as table, call content, parse return listing
  • /?nyaaid=Y → use Y, divide by 1000 and round to get X as table, call content, parse and return torrent details
  • /?table= or /?table=Z → no such table, head 404, return error and die.
  • /?table=X&nyaaid=Y → ignore GET['table'], care only about torrent details
  • /?nyaaid=Z → called table not exist → return error and die
  • /?nyaaid=Y → called table exist but no such torrent → return 404 “torrent not found” page


  • first: always 0, if actual is 0: don't return
  • previous: always actual-1, if actual is 0: don't return
  • actual: GET['table'] or latest if unspecified. If no such table, head 404, return error and die.
  • next: always actual+1, if actual is latest, don't return
  • latest: always “/”, if actual is latest, don't return

HTML shell:

<!DOCTYPE html>
<meta charset="UTF-8">
<meta name="description" content="{description}">
<meta name="robots" content="index, follow">
<style type="text/css">{css}</style>
<h1>{title h1}</h1>
<h2>{title h2}</h2>
<h3>{pagetype h3}</h3>
<form method="get" id="search" action="https://duckduckgo.com/">
    <input type="hidden" name="sites" value="{servername}">
    <input type="text" name="q" maxlength="255" placeholder="Search with DuckDuckGo&hellip;">
    <input type="submit" value="Search">

Data file structures:

Info shell:

$tid{nyaaid} = array('name'=>'{urlencode_name}','tname'=>'{urlencode_torrentname}','tsize'=>'{size in bytes}','btih'=>'{Bittorrent infohash}','cat'=>'{category}','add'=>'{torrent submission timestamp}','sub'=>'{submitter nickname}');

Info example:

$tid103115 = array('name'=>'2NE1%20%2d%20Fire%20%28Space%20ver%2e%29%2e720p%2eHDTV%2ex264%2dUAC%2emkv','tname'=>'2NE1%20%2d%20Fire%20%28Space%20ver%2e%29%2e720p%2eHDTV%2ex264%2dUAC%2emkv','tsize'=>'307605735','btih'=>'a6638c86cf11aa6fd825b40f13ad005bfcf3d7c9','cat'=>'Live Action Promotional Video','add'=>'1260489300','sub'=>'KoichiX');

Stat shell:

$tidstat{nyaaid} = array('se'=>'{seeders}','le'=>'{leechers}','dl'=>'{downloads}','up'=>'{update timestamp}');

Stat example:

$tidstat113015 = array('se'=>'0','le'=>'0','dl'=>'7213','up'=>'1339779393');
php/magnesia.txt · Dernière modification : 2013-05-11 00:20 de