Giter Site home page Giter Site logo

Comments (6)

cyril-colin avatar cyril-colin commented on June 20, 2024

Hi, have you tried to override the default yggtorrent url ? Because yggtorrent url has changed.

const torrentSearch = require('torrent-search-api');

torrentSearch.overrideConfig('YggTorrent', {
  baseUrl: 'https://www2.yggtorrent.se/' // The new YGGtorrent url
});
torrentSearch.enableProvider('YggTorrent', 'USERNAME', 'PASSWORD');

torrentSearch.search('1080', 'Movies', 20).then(res => {
  console.log(res);
  torrentSearch.downloadTorrent(res[0], '/tmp/test.torrent').then(success => {
    console.log('downloaded', success);
  }).catch(err => console.error('ERR : ', err));
});

This code work for me (until the url change again... please check https://mamot.fr/@YggTorrent if you want to know the current yggtorrent url and avoid phishing web sites)

from torrent-search-api.

exasky avatar exasky commented on June 20, 2024

Wokay, your method works indeed.

In my code I overrided the getUrl & search method to fit my need, can't figure out why it isn't working. I only override the search & getUrl part, not the download part.
I'm giving you my code in case you have an idea...

const format = require('string-format');

export function yggTorrentProviderOverride(yggTorrentProvider: any) {
    yggTorrentProvider.baseUrl = 'https://www2.yggtorrent.se';
    yggTorrentProvider.searchUrl = '/engine/search?name={query}&description=&file=&uploader=&category={cat}&do=search&order={order}&sort={sort}&page={page}';

    yggTorrentProvider.getUrl = (queryString: YggQuery): string => {
        const cat = yggTorrentProvider.getCategoryValue(queryString.cat);
        if (cat === null) return null;

        queryString.cat = cat;

        let url =
            yggTorrentProvider.baseUrl + (cat.startsWith('url:') ? cat.substr(4) : yggTorrentProvider.searchUrl);


        url = format(url, queryString);
        url = url.replace(/ /g, '+');

        return url;
    };
    yggTorrentProvider.search = async (yggQuery: YggQuery) => {
        const pageLimit = 1;
        const url = yggTorrentProvider.getUrl(yggQuery);

        if (!url) {
            return Promise.resolve();
        }

        await yggTorrentProvider.ensureLogin();
        const result = await yggTorrentProvider.fetchAndParseUrl(url, pageLimit);
        const returnValue = await yggTorrentProvider.postProcess(result);
        return returnValue;
    };
    yggTorrentProvider.downloadTorrentBuffer = async (torrent: any) => {
        await yggTorrentProvider.ensureLogin();
        return yggTorrentProvider.request(torrent.link, { encoding: null }).then((r: any) => r.body);
    }
}

export class YggQuery {
    query: string;
    cat: string = 'all';
    order?: string = 'desc';
    sort?: string = 'publish_date';
    page?: number = 0;
}

from torrent-search-api.

cyril-colin avatar cyril-colin commented on June 20, 2024

Sorry I can't help you for now : I know this package only for 2 hours ^^

from torrent-search-api.

JimmyLaurent avatar JimmyLaurent commented on June 20, 2024

@exasky From what I seed, you're only trying to add order, sort, and page to the url, don't you ?

I tried you're code and except a minor change to work with the last release, everything seems to be ok.

Check this out and tell me:

const format = require('string-format');
const YggTorrentProvider = require('torrent-search-api/providers/yggtorrent');

function yggTorrentProviderOverride(yggTorrentProvider) {
  yggTorrentProvider.baseUrl = 'https://www2.yggtorrent.se';
  yggTorrentProvider.searchUrl =
    '/engine/search?name={query}&description=&file=&uploader=&category={cat}&do=search&order={order}&sort={sort}&page={page}';

  yggTorrentProvider.getUrl = queryString => {
    const cat = yggTorrentProvider.getCategoryValue(queryString.cat);
    if (cat === null) return null;

    queryString.cat = cat;

    let url =
      yggTorrentProvider.baseUrl +
      (cat.startsWith('url:') ? cat.substr(4) : yggTorrentProvider.searchUrl);

    url = format(url, queryString);
    url = url.replace(/ /g, '+');

    return url;
  };
  yggTorrentProvider.search = async yggQuery => {
    const pageLimit = 1;
    const url = yggTorrentProvider.getUrl(yggQuery);

    if (!url) {
      return Promise.resolve();
    }

    await yggTorrentProvider.ensureLogin();
    const result = await yggTorrentProvider.fetchAndParseUrl(url, pageLimit);
    const returnValue = await yggTorrentProvider.postProcess(result);
    return returnValue;
  };
  yggTorrentProvider.downloadTorrentBuffer = async torrent => {
    await yggTorrentProvider.ensureLogin();
    return yggTorrentProvider.request(torrent.link, { encoding: null }); // .then(r => r.body); <= not needed in the last release
  };
}

(async () => {
  try {
    const yggTorrentProvider = new YggTorrentProvider();
    yggTorrentProvider.setCredentials('login', 'password');

    yggTorrentProvider.isActive = true;
    yggTorrentProviderOverride(yggTorrentProvider);

    const torrents = await yggTorrentProvider.search({ cat:'', query:'blabla', order: 'seeds'});
    await yggTorrentProvider.downloadTorrent(torrents[0], 'blabla.torrent');
    console.log(torrents);
  } catch (e) {
    console.log(e);
  }
})();

from torrent-search-api.

JimmyLaurent avatar JimmyLaurent commented on June 20, 2024

Fixed in 2.1.1

from torrent-search-api.

exasky avatar exasky commented on June 20, 2024

Works like a charm !!
Thank you 😊

from torrent-search-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.