Skip to content

Commit

Permalink
fixed subscriptions query
Browse files Browse the repository at this point in the history
  • Loading branch information
Egsago-n committed Dec 5, 2023
1 parent 073747b commit 1ce9daf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
> [!CAUTION]
> Iterating through subscriptions or recommended videos is currently broken.
<p align="center">
<img width="300" src="https://github.com/Egsagon/PHUB/blob/master/assets/logo.svg">
</p>
Expand Down
15 changes: 10 additions & 5 deletions src/phub/objects/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import logging
from functools import cached_property
from typing import TYPE_CHECKING, Self, Literal
from typing import TYPE_CHECKING, Self, Literal, Generator

from .. import utils
from .. import consts
from . import User, Image

if TYPE_CHECKING:
from ..core import Client
from . import Feed, HTMLQuery, SubQuery
from . import Feed, HTMLQuery, User

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -137,14 +137,19 @@ def liked(self) -> HTMLQuery:
return HTMLQuery(self.client, f'users/{self.name}/videos/favorites')

@cached_property
def subscriptions(self) -> SubQuery:
def subscriptions(self) -> Generator[User, None, None]:
'''
Get the account subscriptions.
'''

from . import SubQuery
page = self.client.call(f'users/{self.name}/subscriptions')

return SubQuery(self.client, f'users/{self.name}/subscriptions')
for url, avatar in consts.re.get_users(page.text):

obj = User.get(self.client, utils.concat(consts.HOST, url))
obj._cached_avatar_url = avatar # Inject image url

yield obj

@cached_property
def feed(self) -> Feed:
Expand Down

0 comments on commit 1ce9daf

Please sign in to comment.