1337x.to 的非官方 API
项目描述
✖️非官方 Python API Wrapper 1337x
这是 1337x 的非官方 API。它支持 1337x 的所有代理和 1337x 的几乎所有功能。您可以搜索、获取趋势、热门和流行的种子。此外,您可以浏览某个类别的种子。它还支持按类别过滤结果,支持排序和缓存。
目录
安装
-
通过PyPi安装
pip install 1337x
-
从源安装
git clone https://github.com/hemantapkh/1337x && cd 1337x && python setup.py sdist && pip install dist/*
入门指南
快速示例
1. 搜索种子
>>> from py1337x import py1337x
# Using 1337x.tw and saving the cache in Desktop which expires after 500 seconds
>>> torrents = py1337x(proxy='1337x.tw', cache='/home/user/Desktop/cache', cacheTime=500)
>>> torrents.search('harry potter')
{'items': [...], 'currentPage': 1, 'itemCount': 20, 'pageCount': 50}
# Searching harry potter in category movies and sort by seeders in descending order
>>> torrents.search('harry potter', category='movies', sortBy='seeders', order='desc')
{'items': [...], 'currentPage': 1, 'itemCount': 40, 'pageCount': 50}
# Viewing the 5th page of the result
>>> torrents.search('harry potter', page=5)
{'items': [...], 'currentPage': , 'itemCount': 20, 'pageCount': 50}
2. 获取热门种子
>>> from py1337x import py1337x
# Using the default proxy (1337x.to) Without using cache
>>> torrents = py1337x()
# Today's trending torrents of all category
>>> torrents.trending()
{'items': [...], 'currentPage': 1, 'itemCount': 50, 'pageCount': 1}
# Trending torrents this week of all category
>>> torrents.trending(week=True)
{'items': [...], 'currentPage': 1, 'itemCount': 50, 'pageCount': 1}
# Todays trending anime
>>> torrents.trending(category='anime')
{'items': [...], 'currentPage': 1, 'itemCount': 50, 'pageCount': 1}
# Trending anime this week
>>> torrents.trending(category='anime', week=True)
{'items': [...], 'currentPage': 1, 'itemCount': 50, 'pageCount': 1}
3. 获取种子信息
>>> from py1337x import py1337x
# Using 11337x.st and passing the cookie since 11337x.st is cloudflare protected
>>> torrents = py1337x('11337x.st', cookie='<cookie>')
# Getting the information of a torrent by its link
>>> torrents.info(link='https://www.1337xx.to/torrent/258188/h9/')
{'name': 'Harry Potter and the Half-Blood Prince', 'shortName': 'Harry Potter', 'description': "....", 'category': 'Movies', 'type': 'HD', 'genre': ['Adventure', 'Fantasy', 'Family'], 'language': 'English', 'size': '3.0 GB', 'thumbnail': '...', 'images': [...], 'uploader': ' ...', 'uploaderLink': '...', 'downloads': '5310', 'lastChecked': '44 seconds ago', 'uploadDate': '4 years ago', 'seeders': '36', 'leechers': '3', 'magnetLink': '...', 'infoHash': '...'}
# Getting the information of a torrent by its link
>>> torrents.info(torrentId='258188')
{'name': 'Harry Potter and the Half-Blood Prince', 'shortName': 'Harry Potter', 'description': "....", 'category': 'Movies', 'type': 'HD', 'genre': ['Adventure', 'Fantasy', 'Family'], 'language': 'English', 'size': '3.0 GB', 'thumbnail': '...', 'images': [...], 'uploader': ' ...', 'uploaderLink': '...', 'downloads': '5310', 'lastChecked': '44 seconds ago', 'uploadDate': '4 years ago', 'seeders': '36', 'leechers': '3', 'magnetLink': '...', 'infoHash': '...'}
详细文档
可用属性
from py1337x import py1337x
torrents = py1337x(proxy='1337x.st', cookie='<cookie>', cache='py1337xCache', cacheTime=86400, backend='sqlite')
代理人
如果默认域在您的国家/地区被禁止,您可以使用 1337x 的替代域。
曲奇饼
一些代理受 Cloudflare 保护。对于此类代理,您需要传递一个 cookie 值。要获取 cookie,请从浏览器转到受保护的站点,解决验证码并复制cf_clearance
.
Firefox: Inspect element > Storage > Cookies
Chrome: Inspect element > Application > Storage > Cookies
缓存
Py1337x 使用requests-cache进行缓存来存储数据,以便可以更快地处理未来对该数据的请求。cache
可以是以下任何一种。
- 一个布尔值:
True
使用缓存和False
不使用缓存。(默认不使用缓存) - 用于存储缓存的目录。
缓存时间
默认情况下,缓存会在一天后过期。您可以通过设置自定义来更改缓存过期时间cacheTime
。
后端
用于存储缓存的后端可以是以下任何一种。
-
'sqlite'
:SQLite 数据库(默认) -
'redis'
: Redis 缓存 (requires redis
) -
'mongodb'
: MongoDB 数据库 (requires pymongo
) -
'gridfs'
: MongoDB 数据库上的 GridFS 集合 (requires pymongo
) -
'dynamodb'
: Amazon DynamoDB 数据库 (requires boto3
) -
'memory'
: 非持久缓存,仅将响应存储在内存中
可用方法
from py1337x import py1337x
torrents = py1337x()
方法 | 描述 | 论据 |
---|---|---|
torrents.search(查询) | 搜索种子 | self, query: Keyword to search for , page (默认为 1): Page to view , category (可选): category , sortBy (可选):排序方式, Order (可选): order |
torrents.trending() | 获取热门种子 | self, category (可选): category , week (默认为 False): True for weekely, False for daily |
torrents.top() | 获取顶级种子 | 自我, 类别(可选):类别 |
torrents.popular(类别) | 获取流行的种子 | 自我, 类别:类别, 周(默认为 False): True for weekely, False for daily |
torrents.browse(类别) | 浏览特定类别的浏览 | 自我, 类别:类别, 页面(默认为 1): Page to view |
torrents.info(链接或 torrentId) | 获取种子信息 | 自我, 链接: Link of a torrent 或torrentId: ID of a torrent |
可用类别
'movies'
'tv'
'games'
'music'
'apps'
'anime'
'documentaries'
'xxx'
'others'
可用的排序方法
'time'
'size'
'seeders'
'leechers'
可用排序顺序
'desc'
(降序)'asc'
(升序)
贡献
非常感谢您所做的任何贡献。
- 分叉项目
- 创建您的功能分支 (
git checkout -b feature/AmazingFeature
) - 提交您的更改 (
git commit -m 'Add some AmazingFeature'
) - 推送到分支 (
git push origin feature/AmazingFeature
) - 打开拉取请求
感谢为此项目做出贡献的每一位贡献者。
使用此 API 的项目
- Torrent Hunt - 用于搜索种子的 Telegram 机器人。
想在这里列出您的项目吗?只需提出拉取请求。
执照
根据 MIT 许可证分发。有关更多信息,请参阅许可证。
作者/维护者:Hemanta Pokharel | 优酷:@H9Youtube
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。