
#  __  __            _____          _   _ 
# |  \/  |   /\     |  __ \   /\   | \ | |
# | \  / |  /  \    | |  | | /  \  |  \| |
# | |\/| | / /\ \   | |  | |/ /\ \ | . ` |
# | |  | |/ ____ \ _| |__| / ____ \| |\  |
# |_|  |_/_/    \_(_)_____/_/    \_\_| \_|


#     ___     ____    ___          _           #
#    / _ |   / __/___/ _/__ ____  (_)__ ____   #
#   / __ |_ / _// __/ _/ _ `/ _ \/ / _ `/ _ \  #
#  /_/ |_(_)___/_/ /_/ \_,_/_//_/_/\_,_/_//_/  #
################################################
#          last modified 2022.07.15            #



import os
from datetime import datetime
import time
import sys

def GetDate(name):
    try:
        stamp=str.split(name,'-')[1][:-3]        
        return stamp
    except:
        return "date failed,date failed"

def HowOld(name):
    ts=time.time()
    difference=int(ts)-int(GetDate(name))
    dd=difference/86400
    return int(dd)


#pubpath=""
#service=input("1-BBB or 2-SL?")
#if(service=="1"):
#pubpath="/var/bigbluebutton/published/presentation"
#elif(service=="2"):
pubpath="/mnt/scalelite-recordings/var/bigbluebutton/published/presentation"
#else:
#    sys.exit()
    
OldMeaning=90
#OldMeaning=1000
#OldMeaning=input("How Many Days Old Is Old Enough To Kill It?")
#try:
#    OldMeaning=int(OldMeaning)
#except:
#    OldMeaning=1000
namess=os.listdir(pubpath)

print("--------------------published files--------------------")
for z in range(len(namess)):
    age=HowOld(namess[z])    
    if(age>=OldMeaning):
        print(age)
        print("Too Old")
        command="rm -rf "+pubpath+"/"+namess[z]
        print(command)
        os.popen(command)
        
