m8chaa commited on
Commit
999e223
·
verified ·
1 Parent(s): 2da63f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -23
app.py CHANGED
@@ -1003,28 +1003,28 @@ users_watch = users_collection_ref.on_snapshot(on_snapshot)
1003
  # scheduler.add_job(update_watch_list, 'interval', hours=24)
1004
  # scheduler.start()
1005
 
1006
- # # Startup event to initialize the watch list
1007
- # @app.on_event("startup")
1008
- # async def startup_event():
1009
- # global gDrive_watch_list
1010
- # # Fetch all users and initialize the watch list
1011
- # users = users_collection_ref.get()
1012
- # for user in users:
1013
- # user_data = user.to_dict()
1014
- # if 'gDrive_metadata' in user_data and 'uploaded' in user_data['gDrive_metadata']:
1015
- # gDrive_watch_list[user.id] = user_data['gDrive_metadata']['uploaded']
1016
 
1017
- # # Initial update of watch list channels
1018
- # update_watch_list()
1019
-
1020
- # # Shutdown event to clean up resources
1021
- # @app.on_event("shutdown")
1022
- # async def shutdown_event():
1023
- # global watch_list_channels
1024
- # # Close all channels
1025
- # for channel_id, channel_info in watch_list_channels.items():
1026
- # close_channel(channel_id, channel_info['resourceId'])
1027
 
1028
- # # Stop the Firebase listener and the scheduler
1029
- # users_watch.unsubscribe()
1030
- # scheduler.shutdown()
 
1003
  # scheduler.add_job(update_watch_list, 'interval', hours=24)
1004
  # scheduler.start()
1005
 
1006
+ # Startup event to initialize the watch list
1007
+ @app.on_event("startup")
1008
+ async def startup_event():
1009
+ global gDrive_watch_list
1010
+ # Fetch all users and initialize the watch list
1011
+ users = users_collection_ref.get()
1012
+ for user in users:
1013
+ user_data = user.to_dict()
1014
+ if 'gDrive_metadata' in user_data and 'uploaded' in user_data['gDrive_metadata']:
1015
+ gDrive_watch_list[user.id] = user_data['gDrive_metadata']['uploaded']
1016
 
1017
+ # Initial update of watch list channels
1018
+ update_watch_list()
1019
+
1020
+ # Shutdown event to clean up resources
1021
+ @app.on_event("shutdown")
1022
+ async def shutdown_event():
1023
+ global watch_list_channels
1024
+ # Close all channels
1025
+ for channel_id, channel_info in watch_list_channels.items():
1026
+ close_channel(channel_id, channel_info['resourceId'])
1027
 
1028
+ # Stop the Firebase listener and the scheduler
1029
+ users_watch.unsubscribe()
1030
+ scheduler.shutdown()