-
Notifications
You must be signed in to change notification settings - Fork 89
Open
Description
I have no idea if this is necessary or not
from tiktok_downloader import Tikmate, snaptik, tikdown, VideoInfo, ttdownloader, tikwm, mdown
class TikScrape:
def __init__(self):
self.downloadtypes = [Tikmate, snaptik, tikdown, VideoInfo, ttdownloader, tikwm, mdown]
def downloadTok(self, link, path, type=0):
if type >= len(self.downloadtypes): # if the type is not in the list of download types, raise an error
# raise Exception("Invalid service selected OR every service failed, exiting.")
return False
try:
loader = self.downloadtypes[type]() # load the service selected in type, initally "Tikmate", then the rest of the services in self.downloadtypes, which are listed in order of reliability
vidInfo = loader.get_media(link)
if vidInfo != []: # if the service returned a video, download the video and return True
vidInfo[0].download(path)
return True
else:
raise Exception(f"Service {self.downloadtypes[type].__name__} returned nothing, possibly due to rate limiting or malformated link.")
# if the service returned nothing, raise an error to try the next one
except Exception as e: # if the service failed, try the next one
print(f"Service {self.downloadtypes[type].__name__} failed, automatically retrying with service {self.downloadtypes[type+1].__name__}. \nReason error: {e}")
# say it failed, then try the next one
self.downloadTok(link, path, type=type+1)
x = TikScrape()
x.downloadTok("LINK", "tiktok.mp4")Metadata
Metadata
Assignees
Labels
No labels