Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] AttributeError: 'DeferredItemListIterator' object has no attribute 'sorted_by' #56

Closed
paweenwat-man opened this issue Jul 16, 2023 · 1 comment
Labels
documentation Improvements or additions to documentation wontfix This will not be worked on

Comments

@paweenwat-man
Copy link

paweenwat-man commented Jul 16, 2023

To Reproduce

    with TikTokAPI() as api:
        utc = pytz.UTC
        challenge = api.challenge(tag_name)
        videos = takewhile(lambda video: video.create_time > utc.localize(SINCE_DATE), 
            dropwhile(lambda video: video.create_time > utc.localize(UNTIL_DATE), 
                challenge.videos.sorted_by(key=lambda video: video.create_time, reverse=True)))

Expected behavior
a sorted iterator of TikTok videos

Version Information
pydantic==2.0.3
pydantic_core==2.3.0
playwright==1.36.0
tiktokapipy==0.2.0.post2

System Information
OS: Windows 11 on desktop computer

Region Information
Thailand

@paweenwat-man paweenwat-man added the bug Something isn't working label Jul 16, 2023
@Russell-Newton
Copy link
Owner

This feature was removed in version 0.2.0. If I forgot to remove it from the documentation, then I'll have to remove it. TikTok supplies videos under a certain tag according to its algorithm, so there's no direct way to get the video list sorted by create time. The removed solution just sorted a fixed number of grabbed videos. To get the same effect you can use:

sorted(challenge.videos, key=...)

to collect all of the videos tagged with a challenge and sort them (this is a bad idea).

Or you can use:

sorted(challenge.videos.limit(20), key=...)

to collect the first 20 videos and sort them. This number can obviously be changed just by changing the limit parameter.

@Russell-Newton Russell-Newton added documentation Improvements or additions to documentation wontfix This will not be worked on and removed bug Something isn't working labels Jul 16, 2023
Russell-Newton added a commit that referenced this issue Jul 17, 2023
* #54 - Add "url" as a computed field for Video objects
* #56 - Remove "sorted_by" from the documentation
* #57 - Add a default error code value for unknown errors
RobertModus pushed a commit to RobertModus/TikTokPy that referenced this issue Jul 19, 2023
* Russell-Newton#54 - Add "url" as a computed field for Video objects
* Russell-Newton#56 - Remove "sorted_by" from the documentation
* Russell-Newton#57 - Add a default error code value for unknown errors
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
documentation Improvements or additions to documentation wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants