(request)
| 1028 | |
| 1029 | @routes.post(config.URL_PREFIX + 'delete-cookies') |
| 1030 | async 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') |
| 1057 | async def cookie_status(request): |
nothing calls this directly
no test coverage detected