vid: remove all vids if API down

This commit is contained in:
knoflook 2022-04-11 13:46:52 +02:00
parent 8c4a36791f
commit bac9bbd7b3
Signed by: knoflook
GPG Key ID: D6A1D0E8FC4FEF1C

View File

@ -102,8 +102,8 @@ def main():
v = peertube.VideoApi(client)
count = 100
page = 0
try:
response = v.videos_get(count=count, filter="local", tags_one_of="publish", start=page)
videos = response.to_dict()
total = videos['total']
videos = videos['data']
@ -148,6 +148,14 @@ def main():
post_name
) # create list of posts which have not been returned by peertube
except:
print("didn't get a response from peertube, instance might have been taken down or made private. removing all posts.")
output_dir = os.environ.get("OUTPUT_DIR")
if not os.path.exists(output_dir):
os.mkdir(output_dir)
existing_posts = os.listdir(output_dir)
for post in existing_posts:
print("deleted", post) # rm posts not returned
shutil.rmtree(os.path.join(output_dir, post))