Skip to content

Commit

Permalink
Support "Get More" when using H5 (#97)
Browse files Browse the repository at this point in the history
* feat: h5 supports "get more"

* ci: update dependabot.yml

* relock

* fix dependabot syntax

* relock

---------

Co-authored-by: JamzumSum <[email protected]>
  • Loading branch information
github-actions[bot] and JamzumSum authored Mar 26, 2023
1 parent d426d8d commit f66ed5c
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 34 deletions.
9 changes: 5 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
day: saturday
interval: daily

- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
day: saturday
versioning-strategy: increase-if-necessary
versioning-strategy: increase-if-necessary
reviewers: [JamzumSum]

- package-ecosystem: npm
directory: "/"
schedule:
interval: weekly
day: saturday
versioning-strategy: increase-if-necessary
versioning-strategy: increase-if-necessary
reviewers: [JamzumSum]
54 changes: 29 additions & 25 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "aioqzone-feed"
version = "0.13.2.dev4"
version = "0.13.3.dev1"
description = "aioqzone plugin providing higher level api for processing feed."
authors = ["aioqzone <[email protected]>"]
license = "AGPL-3.0"
Expand All @@ -14,9 +14,20 @@ documentation = "https://aioqzone.github.io/aioqzone-feed"

[tool.poetry.dependencies]
python = "^3.8"
aioqzone = { version = "^0.12.10.dev7", source = "PyPI", allow-prereleases = true }
aioqzone = { version = "^0.12.11.dev2", source = "PyPI", allow-prereleases = true }
exceptiongroup = { version = ">=1.1.1", python = "<3.11" }

lxml = { version = "*", optional = false }
cssselect = { version = "*", optional = false }

numpy = { version = "*", optional = false }
pillow = { version = "*", optional = false }

# prepare for aioqzone v13
[tool.poetry.extras]
captcha = ["numpy", "pillow"] # equals to aioqzone[captcha]
web = ["lxml", "cssselect"] # equals to aioqzone[lxml]

# dependency groups
[tool.poetry.group.test]
optional = false
Expand Down Expand Up @@ -67,3 +78,7 @@ line_length = 99
[tool.black]
line-length = 99
target-version = ['py38']

[tool.pyright]
pythonVersion = "3.8"
pythonPlatform = "All"
11 changes: 10 additions & 1 deletion src/aioqzone_feed/api/feed/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
from .web import FeedWebApi as FeedApi
try:
import lxml
except ImportError:
# if lxml extras is not installed, use h5 api
from .h5 import FeedH5Api as FeedApi
else:
# in v12 the default manner is web api
from .web import FeedWebApi as FeedApi

del lxml
10 changes: 8 additions & 2 deletions src/aioqzone_feed/api/feed/h5.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ def drop_rule(self, feed: FeedData) -> bool:
log.debug(f"Dropped: {feed}")
return True

if feed.cellid.startswith("advertisement"):
log.info(f"advertisement rule hit: {feed.cellid}")
if feed.fid.startswith("advertisement"):
log.info(f"advertisement rule hit: {feed.fid}")
log.debug(f"Dropped: {feed}")
return True

Expand All @@ -183,6 +183,12 @@ def _dispatch_feed(self, feed: FeedData) -> None:
:param feed: feed
"""
if feed.summary.hasmore:
self.add_hook_ref(
"dispatch", self.shuoshuo(feed.fid, feed.userinfo.uin, feed.common.appid)
).add_done_callback(lambda t: self._dispatch_feed(t.result()))
return

model = FeedContent.from_feed(feed)

if self.drop_rule(feed):
Expand Down
6 changes: 6 additions & 0 deletions src/aioqzone_feed/api/feed/web.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
.. versionchanged:: 0.13.0
Import this module needs aioqzone extra ``lxml`` to be installed.
"""

import asyncio
import logging
import sys
Expand Down

0 comments on commit f66ed5c

Please sign in to comment.