Kylart / Nyaapi

Non-official api to access Nyaa.si and Nyaa.pantsu.cat (search, upload,...)
MIT License
108 stars 17 forks source link

Error: [Nyaapi]: The uploaded file must be a .torrent file but still works! #7

Closed animefn closed 5 years ago

animefn commented 5 years ago

Hi there,

Thanks a lot for this wonderful api.

I was trying to use this api as follows

`

newDest = './up/file.mkv'  
 opt = {
          announceList: [["http://nyaa.tracker.wf:7777/announce"]] // custom trackers (array of arrays of strings) (see [bep12](http://www.bittorrent.org/beps/bep_0012.html))
        }
    createTorrent(newDest, opt, function (err, torrent) {
      if (!err) {
        let n = 'somename.torrent';
        // `torrent` is a Buffer with the contents of the new .torrent file
        fs.writeFile(n, torrent, function(err, result) {
          if(err) console.log('error creating torrent file', err);
          else{
            si.upload({
              credentials: {
                username: 'myysername',
                password: 'mypassword'
              },
              torrent: n,//n is defined above
              name: 'a torrent name(without .torrent)',
              category: '1_2',
              description: 'my blablabla',
              information: 'mywebsite.com',
              complete: true
            })
              .then((data) => console.log(data))
              .catch((err) => console.log(err))

          }`

I'm trying to crate a torrent file then upload it directly to nyaa si.

This file created with createTorrent seems fine and usable and I even tried with files manually created with my torrent client. What is a bit weird is that I got the error but when I went to nyaa's website I saw that my file was uploaded.

Here's the full error I got:

Error: [Nyaapi]: The uploaded file must be a .torrent file. at Promise (C:\xampp\htdocs\node\final_pathselect_uploader\node_modules\nyaapi\src\si\upload.js:25:14) at new Promise (<anonymous>) at Object.upload (C:\xampp\htdocs\node\final_pathselect_uploader\node_modules\nyaapi\src\si\upload.js:15:10) at Object.<anonymous> (C:\xampp\htdocs\node\final_pathselect_uploader\n.js:2:4) at Module._compile (internal/modules/cjs/loader.js:776:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Function.Module.runMain (internal/modules/cjs/loader.js:829:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

Could you please help me with this? Thanks in advance

Kylart commented 5 years ago

Hello!

I just published a new version (2.0.8) that should fix this issue. Could you please retry and confirm it?

animefn commented 5 years ago

Can't thank you enough for fixing this issue so fast!! I did a couple of tests and it is working fine. I appreciate your efforts so much! Feel free to mark this as solved. Just a question out of curiosity, do you plan to add support for anidex as well?

Kylart commented 5 years ago

Thank you for reporting this issue and no problem, I took this opportunity to update the package and also clean it a bit. I'm glad it was fixed that fast too! 😄

As for Anidex (I believe you are talking about anidex.info), I never used it but it seems actually interesting. I developed this API mainly for a project of mine in which I wanted to integrate nyaa.si and pantsu. I'm looking for more networks to implement and Anidex could be one of those.

BUT, if I were to make a package for anidex, I would actually make another package for it since it's not related to nyaa. I will try and explore Anidex for a bit and see for myself if it would be a great thing to plan out!