# newpct-scrapper

[![npm](https://img.shields.io/npm/v/newpct-scrapper.svg)](https://www.npmjs.com/package/newpct-scrapper)
[![Travis CI](https://gitlab.com/DanielRamosAcosta/newpct-scrapper/badges/master/build.svg)](https://gitlab.com/DanielRamosAcosta/newpct-scrapper/pipelines)
[![David](https://img.shields.io/david/DanielRamosAcosta/newpct-scrapper.svg)](https://david-dm.org/DanielRamosAcosta/newpct-scrapper)

Utilidad para sacar torrents de newpct

## Instalación

```
npm i -g newpct-scrapper
```

## Uso:

```
uso: newpct [options] <nombre de lo que quieras>
options:
  --no-filter     No filtra los resultados
  -h, --help      Mostrar la ayuda
  -v, --version   Mostrar la versión del paquete
  -r, --regex     Usar una expresión regular de javascript para filtrar
```

Por defecto abre el link al torrent en el navegador.

Ejemplo:

```
$ newpct buscando a dory
Buscando...
Búsqueda finalizada...
n  tamano   titulo
-  -------  ------------------------------------------------------------------------------------
1  19.4 GB  Buscando a Dory [BDremux 1080p][AC3 5.1 Castellano-DTS 5.1 Ingles+Subs][ES-EN]
2  8.0 GB   Buscando a Dory 3D SBS [BluRay 1080p][AC3 5.1 Castellano AC3 5.1-Ingles+Subs][ES-EN]
3  6.9 GB   Buscando a Dory [BluRay 1080p][AC3 5.1 Castellano DTS 5.1-Ingles+Subs][ES-EN]
4  4.0 GB   Buscando a Dory [MicroHD 1080p][AC3 5.1-Castellano-AC3 5.1 Ingles+Subs][ES-EN]
5  1.8 GB   Buscando a Dory [TS Screener][Español Castellano][2016]
6  1.8 GB   Buscando a Dory [BluRay Rip][AC3 5.1 Español Castellano][2016]
7  1.3 GB   Buscando A Dory 2016 [BRrip X264 MKV][Castellano]

? Numero del torrent que quieres: (1)
```

También se aceptan wildcards de expresiones regulares:

```
$ newpct mr.*robot.*temporada 2.*cap.201
Buscando...
Búsqueda finalizada...
n  tamano  titulo
-  ------  -----------------------------------------------------------------------
1  1.6 GB  MR Robot - Temporada 2 [HDTV 720p][Cap.201][AC3 5.1 Español Castellano]
2  1.2 GB  Mr. Robot - Temporada 2 [HDTV 720p][Cap.201][V.O. Subt. Castellano]
3  500 MB  MR Robot - Temporada 2 [HDTV][Cap.201][Español Castellano]
```

O usar expresiones regulares directamente, con el parámetro `-r`

```
$ newpct como entrenar --regex "como.+entrenar.+3D"
Buscando...
Búsqueda finalizada...
N  Título                                                                                                  Tamaño
-  ------------------------------------------------------------------------------------------------------  ------
1  Como entrenar a tu Dragon 2 3D HOU [BluRay 1080 px][AC3 5.1-DTS Castellano-AC3 5.1 Ingles+Subs][ES-EN]  13.6GB
```

## API

Este paquete también proporciona una API para buscar y obtener torrents.

* `newpctScrapper`
  * `.search(string) => Promise => [Torrent]`: Realiza una búsqueda y la devuelve un array de instancias de Torrent
  * `.Torrent => Class`: Una clase que se instancia para representar un torrent, tiene los siguientes métodos y propiedades:
    * `.title`: Título del torrent
    * `.size`: Tamaño del torrent en bytes
    * `.link`: Link a la página en la que se encuentra el torrent (no el torrent en sí)
    * `.url => Promise => String`: Obtiene el enlace al torrent directo
    * `.magnet => Promise => String`: Obtiene el enlace magnético del torrent
    * `.formatSize => String`: Obtiene el tamaño del torrent con formato (En Gb, Mb, etc...)


### Ejemplo

```javascript
const { search } = require('newpct-scrapper')

search('buscando a dory').then(torrents => {
  // Usamos el primero, por ejemplo
  torrents[0].url.then(url => {
    console.log(`Descarga el torrent aquí: ${url}`)
  })
})
```
