Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Danipulok committed Jan 14, 2025
1 parent 210b34f commit 46a5133
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ while next_qs:

```python
from pixivpy3 import AppPixivAPI

aapi = AppPixivAPI()
json_result = aapi.illust_ranking()
for illust in json_result.illusts[:3]:
Expand All @@ -177,9 +178,10 @@ for illust in json_result.illusts[:3]:
2. Change deprecated SPAI call to Public-API call

```python
from pixivpy3 import AppPixivAPI
from pixivpy3 import AppPixivAPI, enums

api = AppPixivAPI()
rank_list = api.illust_ranking('day')
rank_list = api.illust_ranking(enums.RankingMode.DAY)
print(rank_list)

# more fields about response: https://github.com/upbit/pixivpy/wiki/sniffer
Expand Down Expand Up @@ -210,6 +212,7 @@ from pixivpy3 import enums
from pixivpy3.utils import ParsedJson
from pixivpy3.api import BasePixivAPI


class AppPixivAPI(BasePixivAPI):

# 返回翻页用参数
Expand Down Expand Up @@ -288,12 +291,12 @@ class AppPixivAPI(BasePixivAPI):
# sort: [date_desc, date_asc]
# start_date/end_date: 2020-06-01
def search_novel(
self,
word: str,
search_target=enums.SearchTarget.PARTIAL_MATCH_FOR_TAGS,
sort=enums.Sort.DATE_DESC,
start_date=None,
end_date=None,
self,
word: str,
search_target=enums.SearchTarget.PARTIAL_MATCH_FOR_TAGS,
sort=enums.Sort.DATE_DESC,
start_date=None,
end_date=None,
) -> ParsedJson: ...

def search_user(self, word: str, sort=enums.Sort.DATE_DESC, duration=None) -> ParsedJson: ...
Expand Down Expand Up @@ -360,6 +363,7 @@ class AppPixivAPI(BasePixivAPI):

```python
from pixivpy3 import AppPixivAPI, enums

api = AppPixivAPI()

# 作品推荐
Expand Down Expand Up @@ -434,9 +438,11 @@ json_result = api.novel_comments(16509454, include_total_comments=True)
print(f"Total comments = {json_result.total_comments}")
for comment in json_result.comments:
if comment.parent_comment:
print(f"{comment.user.name} replied to {comment.parent_comment.user.name} at {comment.date} : {comment.comment}")
text = f"{comment.user.name} replied to {comment.parent_comment.user.name} at {comment.date} : {comment.comment}"
print(text)
else:
print(f"{comment.user.name} at {comment.date} : {comment.comment}")
text = f"{comment.user.name} at {comment.date} : {comment.comment}"
print(text)
```

## Package Publishing Instructions
Expand Down
4 changes: 3 additions & 1 deletion example_bypass_sni.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def main():

# api.login(_USERNAME, _PASSWORD)
print(api.auth(refresh_token=_REFRESH_TOKEN))
json_result = api.illust_ranking(enums.RankingMode.DAY, date=(datetime.now() - timedelta(days=5)).strftime("%Y-%m-%d"))
date = datetime.now() - timedelta(days=5)
date_str = date.strftime("%Y-%m-%d")
json_result = api.illust_ranking(enums.RankingMode.DAY, date=date_str)

print("Printing image titles and tags with English tag translations present when available")

Expand Down

0 comments on commit 46a5133

Please sign in to comment.