davidteather / TikTok-Api

The Unofficial TikTok API Wrapper In Python
https://davidteather.github.io/TikTok-Api
MIT License
4.92k stars 984 forks source link

Getting more than 50 videos from userLikedbyUsername? #231

Closed everestpipkin closed 4 years ago

everestpipkin commented 4 years ago

Hi everyone,

Thank you for the useful wrapper! I've been having fun toying with it.

Ran into a problem - I'm helping a friend archive their liked videos. I wrote a little script that goes through, gets the list of their likes, then downloads the associated files. It works perfectly - up to 50. At 51+, it hangs, then quits and doesn't return anything at all.

I went into the code and saw there were some hard parameters (maxCount in userLiked) set to 50, so I upped that but it doesn't solve the issue. I was wondering if it was related to #183 with the change of indexing meaning that the maxCursor parameter wasn't allowing for pagination. Wondering if you had any leads? I'm new to pyppeteer so perhaps its an easy fix?

Thank you!

issue-label-bot[bot] commented 4 years ago

Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.

duplicate-issues[bot] commented 4 years ago

Hey @everestpipkin,

We did a quick check and this issue looks very darn similar to

This could be a coincidence, but if any of these issues solves your problem then I did a good job :smile:

If not, the maintainers will get to this issue shortly.

Cheers, Your Friendly Neighborhood ProBot

everestpipkin commented 4 years ago

Just wanted to check in and see if anyone else had run into this or something similar - I've kept fiddling but have not made any progress on this at all on my end. Here is the code for making the info CSV - it works perfectly up to count=50, but count=51+ returns nothing.

from TikTokApi import TikTokApi
import requests
import pandas as pd

api = TikTokApi()

username = 'NAME'

def simple_dict(tiktok_dict):
  to_return = {}
  to_return['user_name'] = tiktok_dict['author']['uniqueId']
  to_return['user_id'] = tiktok_dict['author']['id']

  to_return['video_id'] = tiktok_dict['id']
  to_return['video_description'] = tiktok_dict['desc']
  to_return['video_created'] = tiktok_dict['createTime']
  to_return['video_link'] = 'https://www.tiktok.com/@{}/video/{}'.format(to_return['user_name'], to_return['video_id'])

  to_return['number_likes'] = tiktok_dict['stats']['diggCount']
  to_return['number_plays'] = tiktok_dict['stats']['playCount']

  to_return['music_title'] = tiktok_dict['music']['title']
  to_return['music_authorName'] = tiktok_dict['music']['authorName']

  to_return['video_down'] = tiktok_dict['video']['downloadAddr']

  return to_return

liked_videos = api.userLikedbyUsername(username, count=50, language='en', region='US', proxy=None)

liked_videos = [simple_dict(v) for v in liked_videos]
liked_videos_df = pd.DataFrame(liked_videos)
liked_videos_df.to_csv('{}_videos.csv'.format(username),index=False)
Coloradohusky commented 4 years ago

I have a similar issue, userLikedbyUsername only goes up to the amount of videos a user has liked, but I haven't experimented with more than 50 liked videos

davidteather commented 4 years ago

Seems to be fixed now probably due to #333