Giter VIP home page Giter VIP logo

ncoreparser's Introduction

Test pypi downloads license

Ncoreparser

Introduction

This module provides python API-s to manage torrents from ncore.pro eg.: search, download, rssfeed, etc..

Install

pip install ncoreparser

Examples

Search torrent

Get most seeded torrents from all category

from ncoreparser import Client, SearchParamWhere, SearchParamType, ParamSort, ParamSeq


if __name__ == "__main__":
    client = Client()
    client.login("<username>", "<password>")

    for t_type in SearchParamType:
        torrent = client.search(pattern="", type=t_type, number=1,
                                sort_by=ParamSort.SEEDERS, sort_order=ParamSeq.DECREASING)[0]
        print(torrent['title'], torrent['type'], torrent['size'], torrent['id'])

    client.logout()

Download torrent

This example download Forest gump torrent file and save it to temp folder

from ncoreparser import Client, SearchParamWhere, SearchParamType, ParamSort, ParamSeq


if __name__ == "__main__":
    client = Client()
    client.login("<username>", "<password>")


    torrent = client.search(pattern="Forrest gump", type=SearchParamType.HD_HUN, number=1,
                            sort_by=ParamSort.SEEDERS, sort_order=ParamSeq.DECREASING)[0]

    client.download(torrent, "/tmp")
    client.logout()

Download torrent by rssfeed

This example get all torrents and their informations from an ncore bookmark (rss feed)

from ncoreparser import Client


if __name__ == "__main__":
    client = Client()
    client.login("<username>", "<password>")

    torrents = client.get_by_rss("<rss url>")
    for torrent in torrents:
        print(torrent['title'], torrent['type'], torrent['size'], torrent['id'])

    client.logout()

Get torrents by activity

This example get all torrents and their informations from the Hit&run page

from ncoreparser import Client


if __name__ == "__main__":
    client = Client()
    client.login("<username>", "<password>")

    torrents = client.get_by_activity()
    for torrent in torrents:
        print(torrent['title'], torrent['type'], torrent['size'],
              torrent['id'], torrent['rate'], torrent['remaining'])

    client.logout()

Get recommended torrents

This example get all torrents and their informations from the recommended page

from ncoreparser import Client, SearchParamType


if __name__ == "__main__":
    client = Client()
    client.login("<username>", "<password>")

    torrents = client.get_recommended(type=SearchParamType.HD_HUN)
    for torrent in torrents:
        print(torrent['title'], torrent['type'], torrent['size'], torrent['id'])

    client.logout()

Async support

The library also supports async calls. It works same as the sync version, but you have to use the AsyncClient class.

import asyncio
from ncoreparser import AsyncClient, SearchParamWhere, SearchParamType, ParamSort, ParamSeq


async def main():
    client = AsyncClient()
    await client.login("<username>", "<password>")

    for t_type in SearchParamType:
        torrent = await client.search(pattern="", type=t_type, number=1,
                                      sort_by=ParamSort.SEEDERS, sort_order=ParamSeq.DECREASING)[0]
        print(torrent['title'], torrent['type'], torrent['size'], torrent['id'])

    await client.logout()


if __name__ == "__main__":
    asyncio.run(main())

ncoreparser's People

Contributors

ddanii avatar dependabot[bot] avatar radaron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

ddanii tkcshnr

ncoreparser's Issues

client.get_by_activity() returns 0 torrents

I checked the raw HTTP answer and it looks like there is an extra space so the regex won't find the pattern:
e.g.: <a href="torrents.php?action=details&id=2213705"
This can be fixed by changing the regexp to this: r'<a href=".?" onclick="torrent((.?)); return false;'

Poetry run non 0 if current version exists in Pypi

Currently there is no available feature in poetry to return 0 if PyPi version already exists.
It solved temporary, but current workflow solution can hide any other errors during package uploading/building.
poetry publish --build || true -> eg.: poetry publish --build --skip-existing

Test published pypi package

Add action to run the following:

  • Get latest ncoreparser release from PyPi (pip install)
  • Run some test with it (eg.: login, search etc..)

client.close() won't work correctly

  • Add cookie clear to client.close
  • Add flag to check is the session logged in or not. eg.: raise Credential error in case of call client.search before client.open
  • rename client.open -> client.login
  • rename client.close -> client.logout

Unused page parameter in search

In case of search function the page parameter was not increased in case of query.

 while item_count < number:
            url = URLs.DOWNLOAD_PATTERN.value.format(page="",
                                                     t_type=type.value,
                                                     sort=sort_by.value,
                                                     seq=sort_order.value,
                                                     pattern=pattern,
                                                     where=where.value)

page parameter must be used if the number parameter higher than 25 (default items in one page)

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.