Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
thelabcat committed Dec 19, 2024
1 parent f71053b commit a278969
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/cocorum/servicephp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,15 @@ def get_video_url(self, video_id):
elem = soup.find("div", attrs = {"class" : "fb-share-button share-fb"})
return elem.attrs["data-url"]

def get_videos(self, username = None, is_channel = False):
"""Get all the videos under a user, defaults to ourselves"""
def get_videos(self, username = None, is_channel = False, max_num = None):
"""Get the videos under a user or channel:
username: The name of the user or channel to search under.
Defaults to ourselves.
is_channel: Is this a channel instead of a userpage?
Defaults false.
max_num: The maximum number of videos to retrieve, from latest back.
Defaults to None, return all videos.
Note, rounded up to the nearest page."""

#default to the logged-in username
if not username:
Expand All @@ -1039,9 +1046,9 @@ def get_videos(self, username = None, is_channel = False):
videos = []
new_video_elems = True
pagenum = 1
while new_video_elems:
while new_video_elems and (not max_num or len(videos) < max_num):
#Get the next page of videos
soup = soupscrape_request(f"{url_start}?page={pagenum}")
soup = soupscrape_request(f"{url_start}?page={pagenum}", self.session_cookie)

#Search for video listings
new_video_elems = soup.find_all("div", attrs = {"class" : "videostream thumbnail__grid--item"})
Expand Down

0 comments on commit a278969

Please sign in to comment.