MCPcopy
hub / github.com/alexta69/metube / delete_cookies

Function delete_cookies

app/main.py:1030–1054  ·  view source on GitHub ↗
(request)

Source from the content-addressed store, hash-verified

1028
1029@routes.post(config.URL_PREFIX + 'delete-cookies')
1030async def delete_cookies(request):
1031 has_uploaded_cookies = os.path.exists(COOKIES_PATH)
1032 configured_cookiefile = config.YTDL_OPTIONS.get('cookiefile')
1033 has_manual_cookiefile = isinstance(configured_cookiefile, str) and configured_cookiefile and configured_cookiefile != COOKIES_PATH
1034
1035 if not has_uploaded_cookies:
1036 if has_manual_cookiefile:
1037 return web.Response(
1038 status=400,
1039 text=serializer.encode({
1040 'status': 'error',
1041 'msg': 'Cookies are configured manually via YTDL_OPTIONS (cookiefile). Remove or change that setting manually; UI delete only removes uploaded cookies.'
1042 })
1043 )
1044 return web.Response(status=400, text=serializer.encode({'status': 'error', 'msg': 'No uploaded cookies to delete'}))
1045
1046 os.remove(COOKIES_PATH)
1047 config.remove_runtime_override('cookiefile')
1048 success, msg = config.load_ytdl_options()
1049 if not success:
1050 log.error(f'Cookies file deleted, but failed to reload YTDL_OPTIONS: {msg}')
1051 return web.Response(status=500, text=serializer.encode({'status': 'error', 'msg': f'Cookies file deleted, but failed to reload YTDL_OPTIONS: {msg}'}))
1052
1053 log.info('Cookies file deleted')
1054 return web.Response(text=serializer.encode({'status': 'ok'}))
1055
1056@routes.get(config.URL_PREFIX + 'cookie-status')
1057async def cookie_status(request):

Callers

nothing calls this directly

Calls 7

existsMethod · 0.80
removeMethod · 0.80
load_ytdl_optionsMethod · 0.80
errorMethod · 0.80
infoMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected