forked from ruangrupa/konfluks
vid: remove all vids if API down
This commit is contained in:
parent
8c4a36791f
commit
bac9bbd7b3
@ -102,8 +102,8 @@ def main():
|
|||||||
v = peertube.VideoApi(client)
|
v = peertube.VideoApi(client)
|
||||||
count = 100
|
count = 100
|
||||||
page = 0
|
page = 0
|
||||||
|
try:
|
||||||
response = v.videos_get(count=count, filter="local", tags_one_of="publish", start=page)
|
response = v.videos_get(count=count, filter="local", tags_one_of="publish", start=page)
|
||||||
|
|
||||||
videos = response.to_dict()
|
videos = response.to_dict()
|
||||||
total = videos['total']
|
total = videos['total']
|
||||||
videos = videos['data']
|
videos = videos['data']
|
||||||
@ -148,6 +148,14 @@ def main():
|
|||||||
post_name
|
post_name
|
||||||
) # create list of posts which have not been returned by peertube
|
) # 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:
|
for post in existing_posts:
|
||||||
print("deleted", post) # rm posts not returned
|
print("deleted", post) # rm posts not returned
|
||||||
shutil.rmtree(os.path.join(output_dir, post))
|
shutil.rmtree(os.path.join(output_dir, post))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user