Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[QUESTION] How to retrieve more than 30 videos #43

Closed
RenHong-HC opened this issue May 24, 2023 · 6 comments
Closed

[QUESTION] How to retrieve more than 30 videos #43

RenHong-HC opened this issue May 24, 2023 · 6 comments
Labels
question Further information is requested

Comments

@RenHong-HC
Copy link

RenHong-HC commented May 24, 2023

I have two needs now

  • Get all videos by username
  • Get all videos by tag

The code for the first case is as follows

        with TikTokAPI() as api:
            user = api.user("morifuntool", video_limit=2000)

            for video in user.videos:
                print(f"URL:https://www.tiktok.com/@morifuntool/video/{video.id},Time:{video.create_time}")

The video data can be obtained normally, but there are only 30 videos.
How can I get all videos?

The code for the second case is as follows

         with TikTokAPI() as api:
            challenge = api.challenge("OutfitIdeas")
            for video in challenge.videos:
                print(f"https://www.tiktok.com/@morifuntool/video/{video.id}")
                print(video.create_time)

The video data can be obtained normally, but there are only 40+ videos.
How can I get all videos?

@RenHong-HC RenHong-HC added the question Further information is requested label May 24, 2023
@Russell-Newton
Copy link
Owner

There currently isn't a great way to get all 40+ videos. The way that is currently implemented is to increase the scroll_down_time parameter in the API constructor. Set that to something like 10, and you'll collect more videos. The exact amount isn't deterministic though, unfortunately.

@RenHong-HC
Copy link
Author

@Russell-Newton Thank you for your reply,I will try this parameter

Russell-Newton added a commit that referenced this issue Jun 15, 2023
* Create functions for executing API calls of 4 kinds:
    * comment/list/ - video comments
    * post/item_list/ - user posts
    * challenge/item_list/ - popular videos tagged with a challenge
    * related/item_list/ - videos related to this one

* Opens up potential future resolutions for #35, #38, #40, #43, and #44
Russell-Newton added a commit that referenced this issue Jun 26, 2023
* Note that loading a User Page without API is still required

* Hopefully resolves #38, #40, #43
@Russell-Newton
Copy link
Owner

I think the changes I've been working on with v0.2 might fix this issue. It could be worth checking out:

pip install -U git+https://github.com/Russell-Newton/TikTokPy.git@v0.2-overhaul
I removed the scrolling parameters, but it should (fingers crossed) work without any API constructor parameters. You should be able to get away with:

with TikTokAPI() as api:
    user = api.user("tiktok")
    for video in user.videos:
        # do something

This should iterate over all of a user's videos. You can limit this using the video_limit parameter in api.user or using the limit method attached to user.videos (for video in user.videos.limit(30)).

@RenHong-HC if you would be willing to try out the WIP changes to see if it works, it could be very helpful for solving this issue. The changes work for me, but it's worth checking if it works for you.

@jasonxubw
Copy link

@Russell-Newton v0.2 resolved the issue. Thank you!!

@Russell-Newton
Copy link
Owner

Awesome! I'll close this issue once I release v0.2.

Repository owner deleted a comment Jul 5, 2023
@Russell-Newton
Copy link
Owner

This issue should be resolved in the official version 0.2.0 release. I'm closing this issue as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants