Harkame / YggTorrentScraper

YggTorrent scraper
GNU General Public License v3.0
17 stars 3 forks source link

error for download torrent files #1

Closed mabed-fr closed 4 years ago

mabed-fr commented 4 years ago

Hello i have try with other torrent and not work.. It's a BUG ?

Python 3.7.3 (default, Apr  3 2019, 05:39:12) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> from yggtorrentscraper import YggTorrentScraper
>>> import os
>>> import subprocess
>>> 
>>> scraper = YggTorrentScraper(requests.session())
>>> scraper.login(identifiant='xxx', password='xxx')
True
>>> scraper.download_from_torrent_url
KeyboardInterrupt
>>> scraper.download_from_torrent_url('https://www2.yggtorrent.ch/torrent/filmvideo/serie-tv/440445-game-of-thrones-s08e02-multi-1080p-amzn-web-dl-dd5-1-x264-ark01')
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 57, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 841, in _validate_conn
    conn.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 301, in connect
    conn = self._new_conn()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 168, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f7bacc21dd8>: Failed to establish a new connection: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www2.yggtorrent.chhttps', port=443): Max retries exceeded with url: //www2.yggtorrent.ch/torrent/filmvideo/serie-tv/440445-game-of-thrones-s08e02-multi-1080p-amzn-web-dl-dd5-1-x264-ark01 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f7bacc21dd8>: Failed to establish a new connection: [Errno -2] Name or service not known'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/dist-packages/yggtorrentscraper/yggtorrentscraper.py", line 405, in download_from_torrent_url
    response = self.session.get(YGGTORRENT_BASE_URL + torrent_url)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='www2.yggtorrent.chhttps', port=443): Max retries exceeded with url: //www2.yggtorrent.ch/torrent/filmvideo/serie-tv/440445-game-of-thrones-s08e02-multi-1080p-amzn-web-dl-dd5-1-x264-ark01 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f7bacc21dd8>: Failed to establish a new connection: [Errno -2] Name or service not known'))
Harkame commented 4 years ago

Hi, YggTorrent have change their tld from .gg to .pe, I will fix it in the day and I will also add the possibility to change it programaticaly

mabed-fr commented 4 years ago

thank you, just change TLD on yggtorrentscraper.py ?

Harkame commented 4 years ago

Yep, its working for get functions like most_completed, extract_details, etc but not for download, I think itsbecause login process have change, i'm checking that

mabed-fr commented 4 years ago

Yes i understand th eproblem is not the TLD but the login process ?

Harkame commented 4 years ago

For the download yes

Harkame commented 4 years ago

I hope its fixed, just make sure you are using YggTorrentScraper 1.1.10

This example should work

import requests
from yggtorrentscraper  import YggTorrentScraper

scraper = YggTorrentScraper(requests.session())

if(scraper.login('myidentifiant', 'mypassword')):
    print("Login success")

    scraper.download_from_torrent_url('https://www2.yggtorrent.ch/torrent/filmvideo/serie-tv/440445-game-of-thrones-s08e02-multi-1080p-amzn-web-dl-dd5-1-x264-ark01')
else:
    print("Login failed")
mabed-fr commented 4 years ago

Perfect !