Nyaa.si & sukebei.nyaa.si LXML fully ready

This commit is contained in:
Ferenc Nánási
2020-02-01 15:11:35 +01:00
parent bf01a922f0
commit 5c93e516ba
6 changed files with 126 additions and 87 deletions

View File

@@ -1,40 +1,51 @@
from NyaaPy import Pantsu, Nyaa
from NyaaPy import Nyaa
from pprint import pprint
from datetime import datetime
import json
import sys
import os
# Creating a folder for test_files
# ! not included in github project.
if not os.path.isdir("test_files"):
os.makedirs("test_files")
# pantsu = Pantsu()
nyaa = Nyaa()
# Get fresh torrents
dt_latest_torrents_begin = datetime.now()
latest_torrents = nyaa.last_uploads(100)
dt_latest_torrents_end = datetime.now()
with open("test_files/nyaa_latest_torrent_test.json", 'w') as f:
json.dump(latest_torrents, f)
# I'd like to watch Tenki no ko, but not uploaded yet.
# Search some nasty stuff
dt_search_begin = datetime.now()
test_search = nyaa.search("Kimi no Na wa")
test_search = nyaa.search("kimi no na wa")
dt_search_end = datetime.now()
# pprint(test_search)
with open("test_files/nyaa_search_test.json", 'w') as f:
json.dump(test_search, f)
# Get first torrent from found torrents
# print("First result torrent info:")
dt_single_torrent_begin = datetime.now()
single_torrent = nyaa.get(test_search[0]["id"])
dt_single_torrent_end = datetime.now()
#pprint(single_torrent)
with open("test_files/nyaa_single_torrent_test.json", 'w') as f:
json.dump(single_torrent, f)
dt_user_begin = datetime.now()
user_torrents = nyaa.get_user("Lilith-Raws")
user_torrents = nyaa.get_user("HorribleSubs")
dt_user_end = datetime.now()
#pprint(user_torrents)
with open("test_files/nyaa_single_user_test.json", 'w') as f:
json.dump(user_torrents, f)
print(
"Latest torrents time:",
(dt_latest_torrents_end - dt_latest_torrents_begin).microseconds / 1000,
"msec")
print(
"Test search time:",
(dt_search_end - dt_search_begin).microseconds/ 1000,
"Test search time:",
(dt_search_end - dt_search_begin).microseconds / 1000,
"msec"
)
print(
@@ -44,11 +55,6 @@ print(
)
print(
"Single user time:",
(dt_user_end - dt_user_begin ).microseconds / 1000,
(dt_user_end - dt_user_begin).microseconds / 1000,
"msec"
)
"""
print(pantsu.search(keyword='koe no katachi',
lang=["es", "ja"], category=[1, 3]))
"""