BBC Magnet Link

Started by dodos26, May 08, 2022, 02:27:36 PM

Previous topic - Next topic

dodos26

Link to the mod

BBC magnet link

Thanks for installing BBC Magnet Link!
Mod create by Dominik.

Version 1.0.4 for SMF 2.0.* & 2.1.*

With this mod you will get bbc for magnet links, making it possible for users to open them.
That's not all, because the modification will read the name of the torrent and display it instead of the link and in front of the name, he will add a nice information icon.
That's not all, because the modification will connect to trackers to get torrent data from them and then display the number of leech seeds and download next to the name.

The modification scans all trackers one by one, until it receives information from one of them or the list is over. Remember to set up good and proven trackers above. Prioritize http (s) trackers at the top of the list.
Also note that many service providers will not let you connect using the udp protocol. You will need to ask your service provider to allow it or run your own web server.

I decided to add this as a new mod because it's not hook only. Add one line of code in "subs.php". And it has a lot of key news.

1.0.3:
- The mod gains in this version an advanced settings system to personalize the settings for yourself.
- From now on, messages load at normal speed because jquery is used and the download of statistics is performed after loading the post.
- An update button has also been added.
- The add-on will also scan attachments in a post with a magnet link and will display the number of downloads next to the magnet link.
- Added the ability to indicate where the attachment data is to be downloaded from "[magnet=LINK TO POST]MAGNET LINK[/magnet]

1.0.4:
- Fixed: Issue with warnings in php logs not working in forum logs.

Work on 2.0.* perfect! Work also on 2.1.* perfect!







stefanop039

Hello, I would like to know if it is possible to remove (when the magnet link is displayed) the seeds, leeches and downloads, leaving only the name of the magnet link visible. See attached image.

thank


dodos26

#2
Quote from: stefanop039 on December 20, 2022, 11:05:47 AMHello, I would like to know if it is possible to remove (when the magnet link is displayed) the seeds, leeches and downloads, leaving only the name of the magnet link visible. See attached image.

thank



Yea, go to Soucres folder and find Subs-Magnet_Link.php and open it:

Next find:
function BBC_Magnet_Format
Replace the entire function with:
function BBC_Magnet_Format(&$input_magnet)
{
    global $txt, $modSettings;

    loadLanguage('bbc_magnet_link');
    if (!empty($input_magnet)) {
        if (preg_match("(^magnet)", $input_magnet)) {

            $input_magnet = html_entity_decode($input_magnet, ENT_QUOTES, "UTF-8");
            $input_magnet = urldecode($input_magnet);

            $input_magnet = str_replace(
                    array("á","é","í","ó","ú","ñ","Á","É","Í","Ó","Ú","Ñ"),
                        array("á","é","í","ó","ú","ń","Á","É","Í","Ó","Ú","Ń"), $input_magnet);

            preg_match('#magnet:\?xt=urn:btih:(?<hash>.*?)&dn=(?<filename>.*?)&tr=(?<trackers>.*?)$#', $input_magnet, $magnet_parts);

            if (!empty($magnet_parts['trackers'])) {

                $magnet_parts['trackers'] = explode('&', str_replace('tr=','', $magnet_parts['trackers']));

                $magnet_parts['trackers'] = array_values($magnet_parts['trackers']);

                if (!empty($magnet_parts['trackers'][0])) {

                    if (!empty($magnet_parts['hash']) && !empty($magnet_parts['filename'])) {

                        $data = '<img class="magnet_link" title="'. $magnet_parts['filename'] .'">
                            <strong>
                                <a href="'. $input_magnet .'" title="'. $magnet_parts['filename'] .'" target="_self">'. $magnet_parts['filename'] .'</a>
                            </strong><br>';
                       
                    } else    $data = '<img class="magnet_link" title="'. $txt['magnet_link_error_bad_magnet_link'] .'"> <strong>'. $txt['magnet_link_error_bad_magnet_link'] .'.</strong><br>';
                } else    $data = '<img class="magnet_link" title="'. $txt['magnet_link_error_no_http_trackers'] .'"> <strong>'. $txt['magnet_link_error_no_http_trackers'] .'.</strong><br>';
            } else $data = '<img class="magnet_link" title="'. $txt['magnet_link_error_lack_trackers'] .'"> <strong>'. $txt['magnet_link_error_lack_trackers'] .'.</strong><br>';
        } else $data = '<img class="magnet_link" title="'. $txt['magnet_link_error_not_magnet_link'] .'"> <strong>'. $txt['magnet_link_error_not_magnet_link'] .'.</strong><br>';
    } else $data = '<img class="magnet_link" title="'. $txt['magnet_link_error_no_input_data'] .'"> <strong>'. $txt['magnet_link_error_no_input_data'] .'.</strong><br>';

    return $data;
}

Or download attach and replace the file. This will not negatively affect the ability to uninstall from the package manager.


It should work on a quick launch and I didn't notice any problems. I will add this as an option to the official release as soon as I manage to solve a problem with a new feature I want to add.


stefanop039

Thanks a lot, everything perfect, I downloaded and replaced the attachment

dodos26

1.0.3:
- The mod gains in this version an advanced settings system to personalize the settings for yourself.
- From now on, messages load at normal speed because jquery is used and the download of statistics is performed after loading the post.
- An update button has also been added.
- The add-on will also scan attachments in a post with a magnet link and will display the number of downloads next to the magnet link.
- Added the ability to indicate where the attachment data is to be downloaded from "[magnet=LINK TO POST]MAGNET LINK[/magnet]

dodos26

1.0.4:
- Fixed: Issue with warnings in php logs (bug fixed) not appearing in forum logs.

Advertisement: