Skip to main content

YggTorrentScraper

PyPI version Codacy Badge Maintainability Build Status codecov

Installation

pip install yggtorrentscraper

OR

clone this repository and

pip install -r requirements.txt

python setup.py install

Dependencies

Usage

Initialization

Actual cloudflare bypassers like https://github.com/VeNoMouS/cloudscraper seem to have some difficulties for now.

The easiest solution is to set « cf_clearance » cookie manually, you can find it in your browser.

import requests
from yggtorrentscraper import YggTorrentScraper

cookie = requests.cookies.create_cookie(
    name="cf_clearance",
    value="1b23f59d619777532aea667960d00269fc49517e-1589279876-0-150",
)
session = requests.session()

session.cookies.set_cookie(cookie)

scraper = YggTorrentScraper(session)

Selenium version

from yggtorrentscraper import YggTorrentScraperSelenium
from selenium import webdriver


options = webdriver.ChromeOptions()
options.add_argument("--log-level=3")
options.add_argument("--disable-blink-features")
options.add_argument("--disable-blink-features=AutomationControlled")
options.add_experimental_option("excludeSwitches", ["enable-logging"])

driver = webdriver.Chrome("D:\chromedriver.exe", options=options)

scraper = YggTorrentScraperSelenium(driver=driver)

#OR

scraper = YggTorrentScraperSelenium(driver_path="D:\chromedriver.exe")

Change TLD

YggTorrent TLD is change regularly, you can specify it at YggTorrentScraper construction with optionnal parameters yggtorrent_tld

from yggtorrentscraper import set_yggtorrent_tld

set_yggtorrent_tld("new_tld")

Session is requiered to download torrent

Login (optionnal)

I highly recommend you to not use your main account, YggTorrent ban bots

Requiered only for download torrent's file

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

Search torrents

Return url's results torrent for specified search

torrents_url = scraper.search({name : "walking dead s08"})

"""

https://www2.yggtorrent.ch/torrent/filmvidâ–’o/sâ–’rie-tv/227730-the+walking+dead+s08+complete+vostfr+proper+720p+hdtv+x264-expm5
https://www2.yggtorrent.ch/torrent/filmvidâ–’o/sâ–’rie-tv/227752-the+walking+dead+s08+complete+vostfr+proper+hdtv+xvid-expm5
https://www2.yggtorrent.ch/torrent/filmvidâ–’o/sâ–’rie-tv/227763-the+walking+dead+s08+vostfr+web-dl+x264-ark01
https://www2.yggtorrent.ch/torrent/filmvidâ–’o/sâ–’rie-tv/227764-the+walking+dead+s08+vostfr+720p+amzn+web-dl+dd5+1+h264-ark01
https://www2.yggtorrent.ch/torrent/filmvidâ–’o/sâ–’rie-tv/227765-the+walking+dead+s08+vostfr+1080p+amzn+web-dl+ddp5+1+h264-ark01

...

"""

Search an torrents by uploader

Return url's results torrent for specified search

torrents_url = scraper.search({name : "walking dead s09", "uploader" : 'brandit'})

Search torrents with sorted results

Return url's results torrent for specified search

YggTorrent's sorting is bugged, in general the results are sorted but sometimes you can find some torrents at a wrong position

  • sort : name/publish_date/size/completed/seed/leech
  • order : asc/desc
torrents_url = scraper.search({"name": "blue oyster cult", "sort": "completed", "order": "desc"})

Search by category, subcategory and options_index

Complete categories tree is available in file categories.py

parameters = {
    "name": "walking dead",
    "category": "films_&_videos",
    "subcategory": "serie_tv",
    "options": {
        "langue": {"francais_(vff/truefrench)"},
        "episode": {"saison_complete"},
        "qualite": {"bluray_[full]"},
    },
}


research = scraper.search(parameters)

Most completed

Return url's of most completed (top 100) downloaded torrents

most_completed = scraper.most_completed()

"""

https://www2.yggtorrent.ch/torrent/filmvideo/serie-tv/440445-game-of-thrones-s08e02-multi-1080p-amzn-web-dl-dd5-1-x264-ark01
https://www2.yggtorrent.ch/torrent/application/windows/316475-microsoft-toolkit-v2-6-4-activateur-office-2016---2019-windows-10
https://www2.yggtorrent.ch/torrent/filmvideo/animation/431851-asterix-le-secret-de-la-potion-magique-2018-french-1080p-hdlight-x264-ac3-toxic
https://www2.yggtorrent.ch/torrent/application/windows/330032-windows-microsoft-office-2019-build-10730-20102-activation-francais
https://www2.yggtorrent.ch/torrent/filmvideo/serie-tv/436928-game-of-thrones-s08e01-multi-1080p-amzn-web-dl-dd5-1-h264-ark01

...

"""

Details

Get torrent's details

torrent = scraper.extract_details('https://www2.yggtorrent.ch/torrent/filmvideo/serie-tv/440445-game-of-thrones-s08e02-multi-1080p-amzn-web-dl-dd5-1-x264-ark01')

print(torrent)

"""

Name      : Game.of.Thrones.S08E02.MULTi.1080p.AMZN.WEB-DL.DD5.1.x264-ARK01
Url       : N/A (Not authentified)
Uploaded  : 2019-04-22 06:10:00
Size      : 1.40Go
Uploader  : Anonyme
Completed : 37157
Seeders   : 2254
Leechers  : 2

Files (1) :

Comments (15) :

"""

print(torrent.__str__(files=True, comments=True))

"""
Name      : Game.of.Thrones.S08E02.MULTi.1080p.AMZN.WEB-DL.DD5.1.x264-ARK01
Url       : N/A
Uploaded  : 2019-04-22 06:10:00
Size      : 1.40Go
Uploader  : Anonyme
Completed : 37157
Seeders   : 2254
Leechers  : 2

Files (1) :
size      :
file_name :Game.of.Thrones.S08E02.MULTi.1080p.AMZN.WEB-DL.DD5.1.x264-ARK01.mkv"}


Comments (15) :
Author : Beleg_5
Posted : 10 jours
Text   : Merci beaucoup.

Author : StephZher
Posted : 20 jours
Text   : Merci c'est cool !

...

"""

Download

Download torrent's file (.torrent), requiered to be logged

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

    torrent = scraper.extract_details('https://www2.yggtorrent.ch/torrent/filmvideo/serie-tv/440445-game-of-thrones-s08e02-multi-1080p-amzn-web-dl-dd5-1-x264-ark01')

    scraper.download_from_torrent(torrent)

    """
    OR
    """

    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")

Logout (optionnal)

scraper.logout()

TODO

  • More tests, find non bugged search (especially for sort tests)

Test

Declare environment variables (requiered for login, download tests)

  • YGGTORRENT_IDENTIFIANT
  • YGGTORRENT_PASSWORD
pip install tox

tox

Metadata

Release files for yggtorrentscraper 1.2.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yggtorrentscraper 1.2.12
File Size Uploaded Provenance Actions
yggtorrentscraper-1.2.12.tar.gz 20.3 kB Without provenance Details for yggtorrentscraper-1.2.12.tar.gz

Release files / yggtorrentscraper-1.2.12.tar.gz

Download URL yggtorrentscraper-1.2.12.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8768390fc9851312e8a40bf80dbaed01face1ca1f4dbd78d6f3beddc3f21e8bb
BLAKE2b-256 checksum
How to use checksums
ee48274ef429dc0b262ab3f877bd7e240412e7b068fa42cab2a11572deda453b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1

Security for yggtorrentscraper 1.2.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page