How to create torrent file from magnet link using java?











up vote
0
down vote

favorite
3












So I wanted to work on a new Java project that converts magnet URIs into .torrent files, however I can't find a way to do that, basically I broke a magnet URI into pieces :



The used URI :



magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves+of+Grass+by+Walt+Whitman.epub&tr=udp%3A%2F%2Ftracker.example4.com%3A80&tr=udp%3A%2F%2Ftracker.example5.com%3A80&tr=udp%3A%2F%2Ftracker.example3.com%3A6969&tr=udp%3A%2F%2Ftracker.example2.com%3A80&tr=udp%3A%2F%2Ftracker.example1.com%3A1337


The breaking down :




magnet:?



xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36



dn=Leaves+of+Grass+by+Walt+Whitman.epub



tr=udp%3A%2F%2Ftracker.example4.com%3A80



tr=udp%3A%2F%2Ftracker.example5.com%3A80



tr=udp%3A%2F%2Ftracker.example3.com%3A6969



tr=udp%3A%2F%2Ftracker.example2.com%3A80



tr=udp%3A%2F%2Ftracker.example1.com%3A1337




from what I gathered using this link, The torrent file contains the files , lengths and paths of the required files but I can't seem to get that from the magnet URI.



Thanks in advance.










share|improve this question
























  • @MarsAtomic SHA-1 "encrypted"?
    – Kayaman
    Feb 19 at 20:13






  • 1




    @MarsAtomic no, not really. Are you saying he should reverse a SHA-1 hash? And are you saying that without any hint of sarcasm?
    – Kayaman
    Feb 19 at 20:18










  • I think so, I have found that the hashsums are SHA-1 encoded
    – Tarek Mohamed
    Feb 19 at 20:22






  • 1




    Well, now you'll find out that hashes are one-way, meaning you can't "decode" them.
    – Kayaman
    Feb 19 at 20:25















up vote
0
down vote

favorite
3












So I wanted to work on a new Java project that converts magnet URIs into .torrent files, however I can't find a way to do that, basically I broke a magnet URI into pieces :



The used URI :



magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves+of+Grass+by+Walt+Whitman.epub&tr=udp%3A%2F%2Ftracker.example4.com%3A80&tr=udp%3A%2F%2Ftracker.example5.com%3A80&tr=udp%3A%2F%2Ftracker.example3.com%3A6969&tr=udp%3A%2F%2Ftracker.example2.com%3A80&tr=udp%3A%2F%2Ftracker.example1.com%3A1337


The breaking down :




magnet:?



xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36



dn=Leaves+of+Grass+by+Walt+Whitman.epub



tr=udp%3A%2F%2Ftracker.example4.com%3A80



tr=udp%3A%2F%2Ftracker.example5.com%3A80



tr=udp%3A%2F%2Ftracker.example3.com%3A6969



tr=udp%3A%2F%2Ftracker.example2.com%3A80



tr=udp%3A%2F%2Ftracker.example1.com%3A1337




from what I gathered using this link, The torrent file contains the files , lengths and paths of the required files but I can't seem to get that from the magnet URI.



Thanks in advance.










share|improve this question
























  • @MarsAtomic SHA-1 "encrypted"?
    – Kayaman
    Feb 19 at 20:13






  • 1




    @MarsAtomic no, not really. Are you saying he should reverse a SHA-1 hash? And are you saying that without any hint of sarcasm?
    – Kayaman
    Feb 19 at 20:18










  • I think so, I have found that the hashsums are SHA-1 encoded
    – Tarek Mohamed
    Feb 19 at 20:22






  • 1




    Well, now you'll find out that hashes are one-way, meaning you can't "decode" them.
    – Kayaman
    Feb 19 at 20:25













up vote
0
down vote

favorite
3









up vote
0
down vote

favorite
3






3





So I wanted to work on a new Java project that converts magnet URIs into .torrent files, however I can't find a way to do that, basically I broke a magnet URI into pieces :



The used URI :



magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves+of+Grass+by+Walt+Whitman.epub&tr=udp%3A%2F%2Ftracker.example4.com%3A80&tr=udp%3A%2F%2Ftracker.example5.com%3A80&tr=udp%3A%2F%2Ftracker.example3.com%3A6969&tr=udp%3A%2F%2Ftracker.example2.com%3A80&tr=udp%3A%2F%2Ftracker.example1.com%3A1337


The breaking down :




magnet:?



xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36



dn=Leaves+of+Grass+by+Walt+Whitman.epub



tr=udp%3A%2F%2Ftracker.example4.com%3A80



tr=udp%3A%2F%2Ftracker.example5.com%3A80



tr=udp%3A%2F%2Ftracker.example3.com%3A6969



tr=udp%3A%2F%2Ftracker.example2.com%3A80



tr=udp%3A%2F%2Ftracker.example1.com%3A1337




from what I gathered using this link, The torrent file contains the files , lengths and paths of the required files but I can't seem to get that from the magnet URI.



Thanks in advance.










share|improve this question















So I wanted to work on a new Java project that converts magnet URIs into .torrent files, however I can't find a way to do that, basically I broke a magnet URI into pieces :



The used URI :



magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves+of+Grass+by+Walt+Whitman.epub&tr=udp%3A%2F%2Ftracker.example4.com%3A80&tr=udp%3A%2F%2Ftracker.example5.com%3A80&tr=udp%3A%2F%2Ftracker.example3.com%3A6969&tr=udp%3A%2F%2Ftracker.example2.com%3A80&tr=udp%3A%2F%2Ftracker.example1.com%3A1337


The breaking down :




magnet:?



xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36



dn=Leaves+of+Grass+by+Walt+Whitman.epub



tr=udp%3A%2F%2Ftracker.example4.com%3A80



tr=udp%3A%2F%2Ftracker.example5.com%3A80



tr=udp%3A%2F%2Ftracker.example3.com%3A6969



tr=udp%3A%2F%2Ftracker.example2.com%3A80



tr=udp%3A%2F%2Ftracker.example1.com%3A1337




from what I gathered using this link, The torrent file contains the files , lengths and paths of the required files but I can't seem to get that from the magnet URI.



Thanks in advance.







java bittorrent torrent magnet-uri






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 19 at 20:04









the_storyteller

1,1811118




1,1811118










asked Feb 19 at 19:57









Tarek Mohamed

1617




1617












  • @MarsAtomic SHA-1 "encrypted"?
    – Kayaman
    Feb 19 at 20:13






  • 1




    @MarsAtomic no, not really. Are you saying he should reverse a SHA-1 hash? And are you saying that without any hint of sarcasm?
    – Kayaman
    Feb 19 at 20:18










  • I think so, I have found that the hashsums are SHA-1 encoded
    – Tarek Mohamed
    Feb 19 at 20:22






  • 1




    Well, now you'll find out that hashes are one-way, meaning you can't "decode" them.
    – Kayaman
    Feb 19 at 20:25


















  • @MarsAtomic SHA-1 "encrypted"?
    – Kayaman
    Feb 19 at 20:13






  • 1




    @MarsAtomic no, not really. Are you saying he should reverse a SHA-1 hash? And are you saying that without any hint of sarcasm?
    – Kayaman
    Feb 19 at 20:18










  • I think so, I have found that the hashsums are SHA-1 encoded
    – Tarek Mohamed
    Feb 19 at 20:22






  • 1




    Well, now you'll find out that hashes are one-way, meaning you can't "decode" them.
    – Kayaman
    Feb 19 at 20:25
















@MarsAtomic SHA-1 "encrypted"?
– Kayaman
Feb 19 at 20:13




@MarsAtomic SHA-1 "encrypted"?
– Kayaman
Feb 19 at 20:13




1




1




@MarsAtomic no, not really. Are you saying he should reverse a SHA-1 hash? And are you saying that without any hint of sarcasm?
– Kayaman
Feb 19 at 20:18




@MarsAtomic no, not really. Are you saying he should reverse a SHA-1 hash? And are you saying that without any hint of sarcasm?
– Kayaman
Feb 19 at 20:18












I think so, I have found that the hashsums are SHA-1 encoded
– Tarek Mohamed
Feb 19 at 20:22




I think so, I have found that the hashsums are SHA-1 encoded
– Tarek Mohamed
Feb 19 at 20:22




1




1




Well, now you'll find out that hashes are one-way, meaning you can't "decode" them.
– Kayaman
Feb 19 at 20:25




Well, now you'll find out that hashes are one-way, meaning you can't "decode" them.
– Kayaman
Feb 19 at 20:25












2 Answers
2






active

oldest

votes

















up vote
1
down vote













It's impossible to recreate the .torrent file from the magnet link alone.



The way torrent clients gets the .torrent file from a magnet link is:




  • Get a peer list from the tracker(s) and/or from the DHT.

  • Connect to peers and download the .torrent metadata using
    BEP9 - Extension for Peers to Send Metadata Files.






share|improve this answer





















  • Thank you for your comment, okay so,let me rephrase my question, using Java , how can I connect to peers and get the meta data if I have the magnet link ?
    – Tarek Mohamed
    Feb 20 at 9:34










  • Implementing the above means implementing a almost complete bittorrent client - i.e. it's most probably easier to find a way to use a existing, already finished client.
    – Encombe
    Feb 20 at 11:39










  • I have searched for already made torrent clients ( like this one ) , but it is too complicated for me to get the meta data grabbing part.
    – Tarek Mohamed
    Feb 20 at 12:52










  • It is complicated and there is no way around that. As a alternative, you maybe can use a online service: btcache.me btso.pw itorrents.org magnet2torrent.me torrage.info thetorrent.org magnet2torrent.com
    – Encombe
    Feb 20 at 15:22


















up vote
0
down vote













not really clean but..



Runtime.getRuntime().exec(new String{"cmd", "/c","start firefox " + mag});



// needs firefox and a default torrent handler.
// mag = magnet string






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48873300%2fhow-to-create-torrent-file-from-magnet-link-using-java%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    It's impossible to recreate the .torrent file from the magnet link alone.



    The way torrent clients gets the .torrent file from a magnet link is:




    • Get a peer list from the tracker(s) and/or from the DHT.

    • Connect to peers and download the .torrent metadata using
      BEP9 - Extension for Peers to Send Metadata Files.






    share|improve this answer





















    • Thank you for your comment, okay so,let me rephrase my question, using Java , how can I connect to peers and get the meta data if I have the magnet link ?
      – Tarek Mohamed
      Feb 20 at 9:34










    • Implementing the above means implementing a almost complete bittorrent client - i.e. it's most probably easier to find a way to use a existing, already finished client.
      – Encombe
      Feb 20 at 11:39










    • I have searched for already made torrent clients ( like this one ) , but it is too complicated for me to get the meta data grabbing part.
      – Tarek Mohamed
      Feb 20 at 12:52










    • It is complicated and there is no way around that. As a alternative, you maybe can use a online service: btcache.me btso.pw itorrents.org magnet2torrent.me torrage.info thetorrent.org magnet2torrent.com
      – Encombe
      Feb 20 at 15:22















    up vote
    1
    down vote













    It's impossible to recreate the .torrent file from the magnet link alone.



    The way torrent clients gets the .torrent file from a magnet link is:




    • Get a peer list from the tracker(s) and/or from the DHT.

    • Connect to peers and download the .torrent metadata using
      BEP9 - Extension for Peers to Send Metadata Files.






    share|improve this answer





















    • Thank you for your comment, okay so,let me rephrase my question, using Java , how can I connect to peers and get the meta data if I have the magnet link ?
      – Tarek Mohamed
      Feb 20 at 9:34










    • Implementing the above means implementing a almost complete bittorrent client - i.e. it's most probably easier to find a way to use a existing, already finished client.
      – Encombe
      Feb 20 at 11:39










    • I have searched for already made torrent clients ( like this one ) , but it is too complicated for me to get the meta data grabbing part.
      – Tarek Mohamed
      Feb 20 at 12:52










    • It is complicated and there is no way around that. As a alternative, you maybe can use a online service: btcache.me btso.pw itorrents.org magnet2torrent.me torrage.info thetorrent.org magnet2torrent.com
      – Encombe
      Feb 20 at 15:22













    up vote
    1
    down vote










    up vote
    1
    down vote









    It's impossible to recreate the .torrent file from the magnet link alone.



    The way torrent clients gets the .torrent file from a magnet link is:




    • Get a peer list from the tracker(s) and/or from the DHT.

    • Connect to peers and download the .torrent metadata using
      BEP9 - Extension for Peers to Send Metadata Files.






    share|improve this answer












    It's impossible to recreate the .torrent file from the magnet link alone.



    The way torrent clients gets the .torrent file from a magnet link is:




    • Get a peer list from the tracker(s) and/or from the DHT.

    • Connect to peers and download the .torrent metadata using
      BEP9 - Extension for Peers to Send Metadata Files.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Feb 19 at 20:30









    Encombe

    1,4631919




    1,4631919












    • Thank you for your comment, okay so,let me rephrase my question, using Java , how can I connect to peers and get the meta data if I have the magnet link ?
      – Tarek Mohamed
      Feb 20 at 9:34










    • Implementing the above means implementing a almost complete bittorrent client - i.e. it's most probably easier to find a way to use a existing, already finished client.
      – Encombe
      Feb 20 at 11:39










    • I have searched for already made torrent clients ( like this one ) , but it is too complicated for me to get the meta data grabbing part.
      – Tarek Mohamed
      Feb 20 at 12:52










    • It is complicated and there is no way around that. As a alternative, you maybe can use a online service: btcache.me btso.pw itorrents.org magnet2torrent.me torrage.info thetorrent.org magnet2torrent.com
      – Encombe
      Feb 20 at 15:22


















    • Thank you for your comment, okay so,let me rephrase my question, using Java , how can I connect to peers and get the meta data if I have the magnet link ?
      – Tarek Mohamed
      Feb 20 at 9:34










    • Implementing the above means implementing a almost complete bittorrent client - i.e. it's most probably easier to find a way to use a existing, already finished client.
      – Encombe
      Feb 20 at 11:39










    • I have searched for already made torrent clients ( like this one ) , but it is too complicated for me to get the meta data grabbing part.
      – Tarek Mohamed
      Feb 20 at 12:52










    • It is complicated and there is no way around that. As a alternative, you maybe can use a online service: btcache.me btso.pw itorrents.org magnet2torrent.me torrage.info thetorrent.org magnet2torrent.com
      – Encombe
      Feb 20 at 15:22
















    Thank you for your comment, okay so,let me rephrase my question, using Java , how can I connect to peers and get the meta data if I have the magnet link ?
    – Tarek Mohamed
    Feb 20 at 9:34




    Thank you for your comment, okay so,let me rephrase my question, using Java , how can I connect to peers and get the meta data if I have the magnet link ?
    – Tarek Mohamed
    Feb 20 at 9:34












    Implementing the above means implementing a almost complete bittorrent client - i.e. it's most probably easier to find a way to use a existing, already finished client.
    – Encombe
    Feb 20 at 11:39




    Implementing the above means implementing a almost complete bittorrent client - i.e. it's most probably easier to find a way to use a existing, already finished client.
    – Encombe
    Feb 20 at 11:39












    I have searched for already made torrent clients ( like this one ) , but it is too complicated for me to get the meta data grabbing part.
    – Tarek Mohamed
    Feb 20 at 12:52




    I have searched for already made torrent clients ( like this one ) , but it is too complicated for me to get the meta data grabbing part.
    – Tarek Mohamed
    Feb 20 at 12:52












    It is complicated and there is no way around that. As a alternative, you maybe can use a online service: btcache.me btso.pw itorrents.org magnet2torrent.me torrage.info thetorrent.org magnet2torrent.com
    – Encombe
    Feb 20 at 15:22




    It is complicated and there is no way around that. As a alternative, you maybe can use a online service: btcache.me btso.pw itorrents.org magnet2torrent.me torrage.info thetorrent.org magnet2torrent.com
    – Encombe
    Feb 20 at 15:22












    up vote
    0
    down vote













    not really clean but..



    Runtime.getRuntime().exec(new String{"cmd", "/c","start firefox " + mag});



    // needs firefox and a default torrent handler.
    // mag = magnet string






    share|improve this answer

























      up vote
      0
      down vote













      not really clean but..



      Runtime.getRuntime().exec(new String{"cmd", "/c","start firefox " + mag});



      // needs firefox and a default torrent handler.
      // mag = magnet string






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        not really clean but..



        Runtime.getRuntime().exec(new String{"cmd", "/c","start firefox " + mag});



        // needs firefox and a default torrent handler.
        // mag = magnet string






        share|improve this answer












        not really clean but..



        Runtime.getRuntime().exec(new String{"cmd", "/c","start firefox " + mag});



        // needs firefox and a default torrent handler.
        // mag = magnet string







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 10 at 21:26









        Mikhail Zerafa

        1




        1






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48873300%2fhow-to-create-torrent-file-from-magnet-link-using-java%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine