File size: 43,800 Bytes
2f158fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9a2c0f7
3ebdf67
10357bc
11d6b8d
094aba4
 
 
 
 
 
 
11d6b8d
094aba4
 
 
2f158fd
094aba4
c29dab5
 
 
 
094aba4
11d6b8d
094aba4
 
 
 
 
0b28a9a
094aba4
 
11d6b8d
094aba4
 
c951a1a
094aba4
2f158fd
31ba597
 
2f158fd
11d6b8d
 
2f158fd
11d6b8d
9fb903f
2f158fd
11d6b8d
2f158fd
 
 
9fb903f
4374e16
1f5c55e
2f158fd
 
a23a1ef
 
 
1f5c55e
2f158fd
a23a1ef
 
 
 
7ebae97
a23a1ef
11d6b8d
536a126
a23a1ef
094aba4
0e7f6b4
8e572bc
0e7f6b4
701d5bb
 
 
 
1f5c55e
 
 
 
162182c
1f5c55e
 
 
 
 
 
 
 
 
094aba4
1f5c55e
2f158fd
5a79cdb
784a25a
5a79cdb
7da3c2e
9fb903f
 
5690252
 
 
 
 
 
 
 
 
 
 
 
9fb903f
 
094aba4
eaa0384
 
 
 
 
 
 
 
 
094aba4
2f158fd
21ae364
2f158fd
 
 
094aba4
2f158fd
 
 
 
094aba4
eaa0384
 
4374e16
 
 
 
 
 
eaa0384
 
094aba4
eaa0384
 
 
 
 
 
094aba4
eaa0384
094aba4
 
 
 
eaa0384
 
 
 
 
 
 
094aba4
eaa0384
094aba4
 
 
 
eaa0384
11d6b8d
 
094aba4
 
 
 
162182c
eaa0384
 
 
 
 
 
 
 
 
 
 
 
094aba4
eaa0384
 
 
 
 
 
 
 
 
04924d9
eaa0384
094aba4
e1c7d49
5a79cdb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a23a1ef
 
 
 
094aba4
 
 
a23a1ef
 
 
 
778b14c
d540c56
2f158fd
21ae364
094aba4
 
2f158fd
094aba4
 
 
 
 
2f158fd
094aba4
2f158fd
 
59659fc
2f158fd
 
59659fc
ac64656
 
094aba4
 
 
ac64656
2f158fd
ac64656
094aba4
ac64656
2f158fd
ac64656
2f158fd
094aba4
 
 
 
 
 
2f158fd
094aba4
2f158fd
191b698
2f158fd
 
 
 
21ae364
 
d5e6fb2
a8c8e12
db93e80
094aba4
db93e80
585dc8e
21ae364
191b698
 
 
 
2f158fd
191b698
2f158fd
094aba4
 
191b698
2f158fd
191b698
2f158fd
094aba4
1f5c55e
2f158fd
1f5c55e
094aba4
2f158fd
21ae364
1f5c55e
 
 
 
d0a154d
2f158fd
 
 
 
094aba4
 
1f5c55e
2f158fd
1f5c55e
2f158fd
10357bc
 
 
 
 
 
 
 
7eaad9b
 
e41288a
 
 
 
7eaad9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10357bc
 
 
 
 
c951a1a
 
10357bc
27cc935
 
 
 
 
c951a1a
27cc935
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c951a1a
27cc935
 
 
 
 
 
 
 
10357bc
27cc935
 
 
 
 
 
 
 
 
094aba4
 
 
 
 
 
 
11d6b8d
 
8dc44d3
11d6b8d
 
 
 
 
2a67f81
094aba4
11d6b8d
 
b79ffd9
6cd4ef0
094aba4
 
 
 
b79ffd9
094aba4
 
 
11d6b8d
094aba4
11d6b8d
123890c
b35113b
11d6b8d
 
 
 
 
 
 
 
 
 
 
 
 
094aba4
11d6b8d
 
 
 
 
 
094aba4
 
 
 
11d6b8d
094aba4
 
 
 
 
 
 
a23a1ef
2f158fd
a23a1ef
094aba4
a23a1ef
 
 
 
 
094aba4
 
014cb14
1f5c55e
094aba4
 
 
 
 
 
11dfeb8
8e572bc
b35113b
 
 
 
 
 
 
d3492d3
b35113b
 
11dfeb8
b35113b
094aba4
b35113b
11dfeb8
 
b35113b
 
 
 
 
 
 
 
 
 
 
 
 
094aba4
b35113b
 
 
 
 
 
094aba4
 
 
 
 
2776229
10d14b6
3ebdf67
c29dab5
2776229
 
 
 
 
 
 
 
 
 
 
 
 
5696a9e
2776229
 
 
 
 
 
 
 
 
9fb903f
0d2eec6
 
 
 
9fb903f
 
f8839a8
 
 
 
 
0d2eec6
9fb903f
 
0d2eec6
 
 
 
f8839a8
9fb903f
 
 
0d2eec6
 
 
 
4374e16
 
 
 
 
 
 
367156e
0d2eec6
 
 
 
4374e16
 
 
 
 
 
 
0b28a9a
 
 
 
4374e16
0b28a9a
0d2eec6
 
 
 
4374e16
 
 
 
0d2eec6
 
 
 
f8839a8
9fb903f
927a494
9fb903f
927a494
9fb903f
f8839a8
1f5c55e
094aba4
1f5c55e
 
2f158fd
 
1f5c55e
 
 
 
2f158fd
1f5c55e
 
094aba4
1f5c55e
2f158fd
094aba4
 
 
 
 
2f158fd
 
 
1f5c55e
 
 
094aba4
2f158fd
 
 
 
 
 
 
 
1f5c55e
 
d0a154d
2f158fd
 
 
094aba4
 
1f5c55e
 
 
2f158fd
094aba4
1f5c55e
2f158fd
1f5c55e
094aba4
1f5c55e
094aba4
2f158fd
 
1f5c55e
 
2f158fd
094aba4
2f158fd
 
 
 
 
 
 
 
 
094aba4
 
 
 
1f5c55e
 
094aba4
1f5c55e
2f158fd
 
 
 
 
094aba4
1f5c55e
094aba4
162182c
1f5c55e
 
 
162182c
094aba4
 
2f158fd
 
094aba4
1f5c55e
094aba4
2f158fd
094aba4
 
 
 
 
2f158fd
 
094aba4
2f158fd
 
 
 
 
 
094aba4
2f158fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
094aba4
1f5c55e
094aba4
2f158fd
1f5c55e
2f158fd
 
094aba4
2f158fd
094aba4
2f158fd
 
094aba4
1f5c55e
 
094aba4
 
 
 
 
1f5c55e
2f158fd
094aba4
 
 
 
 
2f158fd
 
094aba4
1f5c55e
 
094aba4
 
 
 
1f5c55e
2f158fd
 
1f5c55e
 
 
094aba4
2f158fd
 
 
 
 
 
 
094aba4
 
2f158fd
 
094aba4
1f5c55e
094aba4
1f5c55e
 
2f158fd
 
 
 
094aba4
 
 
2f158fd
 
 
 
 
 
1f5c55e
094aba4
 
1f5c55e
2f158fd
 
 
094aba4
1f5c55e
 
 
094aba4
 
 
 
 
1f5c55e
2f158fd
 
1f5c55e
 
 
2f158fd
 
1f5c55e
 
2f158fd
 
094aba4
2f158fd
 
 
 
 
 
094aba4
 
2f158fd
 
 
 
094aba4
2f158fd
 
 
 
 
 
094aba4
 
2f158fd
 
094aba4
2f158fd
094aba4
2f158fd
 
 
 
 
 
 
 
 
 
094aba4
 
 
2f158fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
094aba4
2f158fd
 
 
 
094aba4
1f5c55e
094aba4
1f5c55e
2f158fd
1f5c55e
2f158fd
094aba4
 
 
 
 
 
2f158fd
 
 
 
 
d0a154d
2f158fd
 
 
 
094aba4
 
2f158fd
094aba4
2f158fd
 
094aba4
1f5c55e
094aba4
2f158fd
1f5c55e
2f158fd
 
 
 
 
 
 
 
1f5c55e
2f158fd
 
094aba4
2f158fd
 
 
094aba4
2f158fd
094aba4
2f158fd
 
094aba4
2f158fd
1f5c55e
094aba4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1f5c55e
 
 
094aba4
 
1f5c55e
2f158fd
 
1f5c55e
094aba4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1f5c55e
 
 
094aba4
 
 
2f158fd
 
1f5c55e
094aba4
 
 
 
 
 
 
 
 
 
 
 
 
 
2f158fd
 
1f5c55e
094aba4
 
 
 
 
 
 
 
 
 
 
 
 
 
2f158fd
 
1f5c55e
094aba4
 
 
 
 
 
 
 
 
 
 
 
 
 
2f158fd
 
1f5c55e
094aba4
 
 
 
 
 
 
 
 
 
 
 
 
 
2f158fd
 
1f5c55e
094aba4
 
 
 
 
 
 
 
 
 
 
 
 
 
e4bdde1
 
 
 
 
 
 
 
 
 
 
094aba4
e4bdde1
7ef63fe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2020-2023 (c) Randy W @xtdevs, @xtsea
#
# from : https://github.com/TeamKillerX
# Channel : @RendyProjects
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import asyncio
import aiohttp
import base64
import json
import logging
import os
import random
import re
from base64 import b64decode
from base64 import b64decode as kc
from datetime import datetime as dt
from io import BytesIO
from typing import *
from typing import Union

import g4f
from g4f.client import Client as BingClient
from g4f.cookies import set_cookies
from g4f.Provider import BingCreateImages, OpenaiChat, Gemini

import requests
from bardapi import Bard
from bs4 import BeautifulSoup
from dotenv import load_dotenv
from fastapi import Depends, FastAPI, Header, HTTPException, Query, Request
from fastapi.responses import JSONResponse, StreamingResponse
from gpytranslate import SyncTranslator
import httpx
from httpx import AsyncClient
from pymongo import MongoClient
from RyuzakiLib.hackertools.chatgpt import RendyDevChat
from RyuzakiLib.hackertools.gemini import GeminiLatest
from RyuzakiLib.mental import BadWordsList
from pyUltroid.fns.helper import async_searcher
from serpapi import GoogleSearch

from models import *

logging.basicConfig(level=logging.ERROR)
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

MONGO_URL = os.environ["MONGO_URL"]

load_dotenv()

SOURCE_UNSPLASH_URL = os.environ["SOURCE_UNSPLASH_URL"]
SOURCE_OCR_URL = os.environ["SOURCE_OCR_URL"]
SOURCE_ALPHA_URL = os.environ["SOURCE_ALPHA_URL"]
SOURCE_DALLE3XL_URL = os.environ["SOURCE_DALLE3XL_URL"]
SOURCE_PROTEUSV0_2_URL = os.environ["SOURCE_PROTEUSV0_2_URL"]
SOURCE_WAIFU_URL = "https://api.waifu.pics"
SOURCE_TIKTOK_WTF_URL = os.environ["SOURCE_TIKTOK_WTF_URL"]
SOURCE_TIKTOK_TECH_URL = os.environ["SOURCE_TIKTOK_TECH_URL"]
SOURCE_ASSISTANT_GOOGLE_AI = os.environ["SOURCE_ASSISTANT_GOOGLE_AI"]
SOURCE_OPENDALLE_URL = os.environ["SOURCE_OPENDALLE_URL"]
SOURCE_OPENAI_ACCESS_URL = os.environ["SOURCE_OPENAI_ACCESS_URL"]
DEVELOPER_ID = os.environ["DEVELOPER_ID"]

# api keys
REVERSE_IMAGE_API = os.environ["REVERSE_IMAGE_API"]
OCR_API_KEY = os.environ["OCR_API_KEY"]
ONLY_DEVELOPER_API_KEYS = os.environ["ONLY_DEVELOPER_API_KEYS"]
HUGGING_TOKEN = random.choice([os.getenv("HUGGINGTOKEN_1"), os.getenv("HUGGINGTOKEN_2"), os.getenv("HUGGINGTOKEN_3")])
ASSISTANT_GOOGLE_API_KEYS = os.environ["ASSISTANT_GOOGLE_API_KEYS"]
COOKIE_BARD_TOKEN = os.environ["COOKIE_BARD_TOKEN"]
BING_CLIENT = os.environ["BingClient"]

# unlocks
ORACLE_TOKEN = os.environ["ORACLE_TOKEN"]
TruAI = os.environ["TruAI"]

client_mongo = MongoClient(MONGO_URL)
db = client_mongo["tiktokbot"]
collection = db["users"]

description = """
~ Developed written and powered by
- Ryuzaki Library: [Library Here](https://github.com/TeamKillerX/RyuzakiLib)
"""

app = FastAPI(
    title="UFoP-API",
    description=description,
    version="0.1.0",
    terms_of_service="Use It Only For Personal Project Else I Need To Delete The Api",
    contact={
        "name": "🌀ʊʄ⊕ք🌀",
        "url": "https://t.me/UFoPInfo",
    },
    docs_url="/",
)

trans = SyncTranslator()


timeout = 100
contact_support = """
We are aware that this service is currently offline. This seems to be caused by the API
We are investigating and doing our best to get things back online as soon as possible.
Thank you for your patience

~ Contact Support @SoulOfSukuna
"""

internal_error = """
There has been an Internal error. We are aware of this error and notice that it can be
caused by your search terms being to explict, too confusing, or it can be caused by the API.
Please modify your search terms and/or try again later thank you for your understanding.

~ 🌀ʊʄ⊕ք🌀 Team
"""


def get_all_api_keys():
    user = collection.find({})
    api_keys = []
    for x in user:
        api_key = x.get("ryuzaki_api_key")
        if api_key:
            api_keys.append(api_key)
    return api_keys


def validate_api_key(api_key: str = Header(...)):
    USERS_API_KEYS = get_all_api_keys()
    if api_key not in USERS_API_KEYS:
        raise HTTPException(status_code=401, detail="Invalid API key")


def validate_api_key_only_devs(api_key: str = Header(...)):
    if api_key not in ONLY_DEVELOPER_API_KEYS:
        raise HTTPException(status_code=401, detail="Invalid API key")


RAMDOM_STATUS = [
    "Spammer",
    "Wanted",
    "Scammer",
    "Rogue_Agent",
    "PornBot_Prolly",
    "Fugitive",
    "SIMP",
]


def remove_sibyl_system_banned(user_id):
    update_doc = {
        "sibyl_ban": None,
        "reason_sibyl": None,
        "is_banned_sibly": None,
        "date_joined_sib": None,
        "sibyl_userid": None,
    }
    return collection.update_one(
        {"user_id": user_id}, {"$unset": update_doc}, upsert=True
    )


def new_sibyl_system_banned(user_id, name, reason, date_joined):
    update_doc = {
        "sibyl_ban": name,
        "reason_sibyl": reason,
        "is_banned_sibly": True,
        "date_joined_sib": date_joined,
        "sibyl_userid": user_id,
    }
    return collection.update_one(
        {"user_id": user_id}, {"$set": update_doc}, upsert=True
    )


def cybersecuritydb(user_id, mongo_url):
    update_doc = {"mongodb": mongo_url}
    return collection.update_one(
        {"user_id": user_id}, {"$set": update_doc}, upsert=True
    )


def get_sibyl_system_banned(user_id):
    user = collection.find_one({"user_id": user_id})
    if user:
        sibyl_name = user.get("sibyl_ban")
        reason = user.get("reason_sibyl")
        is_banned = user.get("is_banned_sibly")
        date_joined = user.get("date_joined_sib")
        sibyl_user_id = user.get("sibyl_userid")
        return sibyl_name, reason, is_banned, date_joined, sibyl_user_id
    else:
        return None, None, False, None, None


def get_all_banned():
    banned_users = []

    users = collection.find({})

    for user_id in users:
        reason = user_id.get("reason_sibyl")
        user_id = user_id.get("sibyl_userid")
        banned_users.append({"user_id": user_id, "reason": reason})
    return banned_users


@app.post("/ufop/translate", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
def get_translate(
    item: TranslateCustom,
):
    try:
        source = trans.detect(item.text)
        translation = trans(item.text, sourcelang=source, targetlang=item.setlang)
        return SuccessResponse(
            status="True",
            randydev={
                "translation": translation.text,
                "translation_original": item.text
            }
        )
    except:
        return SuccessResponse(
            status="False",
            randydev={"message": contact_support})


@app.get("/UFoP/blacklist-words")
def blacklist_words():
    try:
        BLACKLIST_WORDS = BadWordsList()
        results_all = BLACKLIST_WORDS.banned_by_google(
            file_txt="banned_by_google.txt", storage=True
        )
        return {"status": "true", "results": results_all}
    except Exception as e:
        return {"status": "false", "message": f"Internal server error: {str(e)}"}


@app.get("/UFoP/getbanlist")
def sibyl_get_all_banlist():
    banned_users = get_all_banned()
    return {"status": "True", "sukuna": {"results": banned_users}}


@app.delete(
    "/UFoP/bandel",
    response_model=SuccessResponse,
    responses={422: {"model": ErrorStatus}},
)
def sibyl_system_delete(
    item: SibylSystemDel, api_key: None = Depends(validate_api_key_only_devs)
):
    try:
        _, _, _, _, sibyl_user_id = get_sibyl_system_banned(item.user_id)

        if sibyl_user_id:
            remove_sibyl_system_banned(item.user_id)
            return SuccessResponse(
                status="True",
                randydev={
                    "message": f"Successfully removed {item.user_id} from the Sibyl ban list"
                },
            )
        else:
            return SuccessResponse(
                status="False", randydev={"message": "Not Found UserID"}
            )
    except Exception as e:
        return ErrorStatus(status="false", message=f"Internal server error: {str(e)}")


@app.post(
    "/UFoP/banner",
    response_model=SuccessResponse,
    responses={422: {"model": ErrorStatus}},
)
def sibyl_system_ban(
    item: SibylSystemBan, api_key: None = Depends(validate_api_key_only_devs)
):
    if item.user_id == DEVELOPER_ID:
        return {"status": "false", "message": "Only Developer"}

    try:
        date_joined = str(dt.now())
        sibyl_ban = random.choice(RAMDOM_STATUS)
        _, _, is_banned, _, sibyl_user_id = get_sibyl_system_banned(item.user_id)

        if sibyl_user_id is not None and is_banned:
            return SuccessResponse(
                status="False", randydev={"message": "User is already banned"}
            )

        new_sibyl_system_banned(item.user_id, sibyl_ban, item.reason, date_joined)
        return SuccessResponse(
            status="True",
            randydev={
                "user_id": item.user_id,
                "sibyl_name": sibyl_ban,
                "reason": item.reason,
                "date_joined": date_joined,
                "message": f"Successfully banned {item.user_id} from the Sibyl ban list.",
            },
        )
    except Exception as e:
        return ErrorStatus(status="false", message=f"Internal server error: {str(e)}")


@app.get("/UFoP/bans")
def sibyl_system(
    user_id: int = Query(..., description="User ID in query parameter"),
    api_key: None = Depends(validate_api_key),
):
    result = get_sibyl_system_banned(user_id)
    if result is not None:
        sibyl_name, reason, is_banned, date_joined, sibyl_user_id = result
        return {
            "status": "true",
            "sukuna": {
                "sibyl_name": sibyl_name,
                "reason": reason,
                "is_banned": is_banned,
                "date_joined": date_joined,
                "sibyl_user_id": sibyl_user_id,
            },
        }
    else:
        return {"status": "false", "message": "Not Found User"}


async def get_torrent_info(url):
    try:
        async with aiohttp.ClientSession() as session:
            async with session.get(url) as response:
                html = await response.text()
                soup = BeautifulSoup(html, "html.parser")
                torrents = []
                for movie_div in soup.find_all("div", class_="container", id="movie-content"):
                    poster = movie_div.find("img", itemprop="image")
                    if poster:
                        poster_url = poster["src"]
                    else:
                        poster_url = "N/A"
                    
                    # Extract other torrent information
                    torrent_divs = movie_div.find_all("div", class_="modal-torrent")
                    for div in torrent_divs:
                        quality = div.find("div", class_="modal-quality").find("span").text
                        all_p = div.find_all("p", class_="quality-size")
                        quality_type = all_p[0].text if all_p else "N/A"
                        size = all_p[1].text if len(all_p) > 1 else "N/A"
                        torrent_link = div.find("a", class_="download-torrent")["href"]
                        magnet = div.find("a", class_="magnet-download")["href"]
                        hash = re.search(r"([{a-f\d,A-F\d}]{32,40})\b", magnet).group(0)
                        
                        torrents.append(
                            {
                                "poster": poster_url,
                                "quality": quality,
                                "type": quality_type,
                                "size": size,
                                "torrent": torrent_link,
                                "magnet": magnet,
                                "hash": hash,
                            }
                        )
                return torrents
    except Exception as e:
        print("Error fetching torrent info:", e)
        return []


app.get("/UFoP/yts", response_model=List[MovieInfo])
async def get_movie_info(name: str, api_key: str = Header(...)):
    validate_api_key(api_key)  # Validate API key here
    results = []
    try:
        for page in range(1, 2):
            url = f"https://yts.mx/browse-movies/{name}/all/all/0/seeds/0/all"
            r = await async_searcher(url)
            soup = BeautifulSoup(r, "lxml")
            for movie in soup.findAll("div", class_="browse-movie-wrap col-xs-10 col-sm-4 col-md-5 col-lg-4"):
                mov_name = movie.find("div", class_="browse-movie-bottom")
                movie_name = mov_name.a.text
                movie_year = mov_name.div.text
                movie_name = movie_name + " " + movie_year
                rating = movie.find("h4", class_="rating", text=True)
                if rating is not None:
                    rating = rating.text
                    rating = rating[:3]
                else:
                    rating = "0.0"
                if rating[2] == "/":
                    rating = rating[0:2]
                try:
                    if movie_name[0] == "[" and movie_name[3] == "]":
                        movie_name = movie_name[5:]
                    movie_name = movie_name.replace(" ", "-")
                    index = 0
                    for char in movie_name:
                        if not char.isalnum() and char != "-":
                            movie_name = movie_name.replace(char, "")
                    for char in movie_name:
                        if char == "-" and movie_name[index + 1] == "-":
                            movie_name = movie_name[:index] + movie_name[index + 1:]
                        if index < len(movie_name) - 1:
                            index = index + 1
                    if "--" in movie_name:
                        movie_name = movie_name.replace("--", "-")
                    movie_url = f"https://yts.mx/movie/{movie_name.lower()}"
                    torrents = await sicX.yts(movie_name, api_key)  # Get torrent info asynchronously
                    entry = {
                        "yts_link": movie_url,
                        "name": movie_name,
                        "year": movie_year,
                        "imdb_links": imdb_link,
                        "genre": genre,
                        "imdb_ratings": rating,
                        "likes": likes,
                        "torrents": torrents,
                    }
                    results.append(entry)
                except Exception as e:
                    print("Error:", e)
                    continue
    except Exception as e:
        print("Error:", e)
    return results


@app.post(
    "/UFoP/gemini-the-oracle",
    response_model=SuccessResponse,
    responses={422: {"model": ErrorStatus}},
)
async def gemini_oracle(item: GeminiOracle):
    if item.is_multi_chat:
        selected_api_key = ASSISTANT_GOOGLE_API_KEYS or item.gemini_api_key
        oracle_base = ORACLE_TOKEN or item.oracle_base
        try:
            geni = GeminiLatest(
                api_key=selected_api_key,
                mongo_url=item.mongo_url,
                version=item.version,
                user_id=item.user_id,
                oracle_base=oracle_base,
            )
            cybersecuritydb(item.user_id, item.mongo_url)
            if item.oracle_base == "Delete":
                clearedhistory = await geni._clear_oracle_history_in_db()
                return SuccessResponse(
                    status="True",
                    randydev={"message": f"Oracle Status: {clearedhistory}"},
                )
            else:
                answer, oracle_chat = await geni._GeminiLatest__get_response_oracle(
                    item.query
                )
            return SuccessResponse(
                status="True", randydev={"message": answer, "chat_history": oracle_chat}
            )
        except Exception as excep:
            return SuccessResponse(status="False", randydev={"message": internal_error})
    else:
        if item.is_login:
            token = item.bard_api_key
        else:
            token = COOKIE_BARD_TOKEN
        try:
            session = requests.Session()
            session.headers = {
                "Host": "bard.google.com",
                "X-Same-Domain": "1",
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
                "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
                "Origin": "https://bard.google.com",
                "Referer": "https://bard.google.com/",
            }
            session.cookies.set("__Secure-1PSID", token)
            bard = Bard(token=token, session=session, timeout=30)
            bard.get_answer(owner_base)["content"]
            message = bard.get_answer(item.query)["content"]
            return SuccessResponse(status="True", randydev={"message": message})
        except BaseException:
            return SuccessResponse(
                status="False", randydev={"message": contact_support}
            )


@app.post(
    "/UFoP/G-AI",
    response_model=SuccessResponse,
    responses={422: {"model": ErrorStatus}},
)
def v1beta3_google_ai(item: ChatgptCustom, api_key: None = Depends(validate_api_key)):
    api_url = f"{SOURCE_ASSISTANT_GOOGLE_AI}/models/text-bison-001:generateText?key={ASSISTANT_GOOGLE_API_KEYS}"
    try:
        headers = {"Content-Type": "application/json"}
        data = {"prompt": {"text": item.query}}
        response = requests.post(api_url, headers=headers, json=data)
        response_str = response.json()
        answer = response_str["candidates"]
        for results in answer:
            message = results.get("output")
        return SuccessResponse(status="True", randydev={"message": message})
    except BaseException:
        return SuccessResponse(status="False", randydev={"message": internal_error})


@app.post(
    "/UFoP/gemini-ai-pro",
    response_model=SuccessResponse,
    responses={422: {"model": ErrorStatus}},
)
async def gemini_pro(item: GeminiPro):
    owner_base = TruAI
    if item.is_multi_chat:
        selected_api_key = ASSISTANT_GOOGLE_API_KEYS or item.gemini_api_key
        try:
            geni = GeminiLatest(
                api_key=selected_api_key,
                mongo_url=item.mongo_url,
                version=item.version,
                user_id=item.user_id
            )
            cybersecuritydb(item.user_id, item.mongo_url)
            answer, gemini_chat = await geni._GeminiLatest__get_response_gemini(item.query)
            return SuccessResponse(
                status="True", randydev={"message": answer, "chat_history": gemini_chat}
            )
        except Exception as excep:
            return SuccessResponse(status="False", randydev={"message": internal_error})
    else:
        if item.is_login:
            token = item.bard_api_key
        else:
            token = COOKIE_BARD_TOKEN
        try:
            session = requests.Session()
            session.headers = {
                "Host": "bard.google.com",
                "X-Same-Domain": "1",
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
                "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
                "Origin": "https://bard.google.com",
                "Referer": "https://bard.google.com/",
            }
            session.cookies.set("__Secure-1PSID", token)
            bard = Bard(token=token, session=session, timeout=30)
            bard.get_answer(owner_base)["content"]
            message = bard.get_answer(item.query)["content"]
            return SuccessResponse(status="True", randydev={"message": message})
        except BaseException:
            return SuccessResponse(
                status="False", randydev={"message": contact_support}
            )


BingImages = BingClient()


@app.post("/Bing/Dall-E-3")
def bing_dalle(item: BingDalle):
    try:        
        set_cookies(
            ".bing.com",
            {
                "_U": item.cookie
            },
        )
    except requests.exceptions.RequestException:
        raise HTTPException(status_code=500, detail="Invalid cookie string, check your cookie string and try again")

    try:
        response = BingImages.images.generate(
            prompt=item.prompt,
            model=item.model,
        )
        return {"status": "true", "sukuna": {"url": response.data[0].url}}

    except BaseException as e:
        return {"status": "false", "message": f"Something went wrong: {e}"}


@app.post("/UFoP/dalle3xl")
def dalle_3xl(
    item: Dalle3XL,
    api_key: None = Depends(validate_api_key)
):
    API_URL = SOURCE_DALLE3XL_URL
    try:
        payload = {"inputs": item.query}
        headers = {
            "Authorization": f"Bearer {HUGGING_TOKEN}",
            "Content-Type": "application/json",
        }
        response = requests.post(API_URL, headers=headers, json=payload, timeout=timeout)
        response.raise_for_status()
    except requests.exceptions.RequestException:
        raise HTTPException(
            status_code=500,
            detail=internal_error
        )

    try:
        encoded_string = base64.b64encode(response.content).decode("utf-8")
    except Exception:
        raise HTTPException(
            status_code=500,
            detail=contact_support
        )

    if encoded_string:
        return SuccessResponse(status="True", randydev={"data": encoded_string})
    else:
        return SuccessResponse(status="False", randydev={"data": contact_support})


@app.post("/UFoP/proteusv02")
async def proteusv0_2(
    item: ProteusV02, 
    api_key: None = Depends(validate_api_key)
):
    API_URL = SOURCE_PROTEUSV0_2_URL
    try:
        payload = {"inputs": item.query}
        headers = {
            "Authorization": f"Bearer {HUGGING_TOKEN}",
            "Content-Type": "application/json",
        }
        async with httpx.AsyncClient() as client:
            response = await client.post(
                API_URL, headers=headers, json=payload, timeout=timeout
            )
        response.raise_for_status()
    except httpx.HTTPStatusError:
        raise HTTPException(
            status_code=500, 
            detail=internal_error
        )

    try:
        encoded_string = base64.b64encode(response.content).decode("utf-8")
    except Exception:
        raise HTTPException(
            status_code=500, 
            detail=contact_support
        )

    if encoded_string:
        return SuccessResponse(status="True", randydev={"data": encoded_string})
    else:
        return SuccessResponse(status="False", randydev={"data": contact_support})


@app.get("/ryuzaki/unsplash")
async def get_image_unsplash(query: str, size: str = "500x500"):
    url = SOURCE_UNSPLASH_URL
    image_url = f"{url}/?{query}/{size}"

    try:
        response = requests.get(image_url)
        response.raise_for_status()
    except requests.exceptions.RequestException as e:
        raise HTTPException(status_code=500, detail=f"Error fetching image: {e}")

    return StreamingResponse(BytesIO(response.content), media_type="image/jpeg")


@app.get("/ryuzaki/reverse")
def google_reverse(
    engine: str = "google_reverse_image",
    image_url: str = None,
    language: str = "en",
    google_lang: str = "us",
    api_key: None = Depends(validate_api_key),
):
    params = {
        "api_key": REVERSE_IMAGE_API,
        "engine": engine,
        "image_url": image_url,
        "hl": language,
        "gl": google_lang,
    }
    try:
        search = GoogleSearch(params)
        results = search.get_dict()
        link = results["search_metadata"]["google_reverse_image_url"]
        total_time_taken = results["search_metadata"]["total_time_taken"]
        create_at = results["search_metadata"]["created_at"]
        processed_at = results["search_metadata"]["processed_at"]
        return {
            "status": "true",
            "sukuna": {
                "link": link,
                "total_time_taken": total_time_taken,
                "create_at": create_at,
                "processed_at": processed_at,
            },
        }
    except Exception as e:
        return {"status": "false", "message": f"Error {e}"}


@app.get("/ryuzaki/ocr")
def ocr_space_url(
    url: str = Query(..., description="URL in query parameter"),
    overlay: bool = False,
    language: str = Query("eng", description="Language in query parameter"),
    api_key: None = Depends(validate_api_key),
):
    payload = {
        "url": url,
        "isOverlayRequired": overlay,
        "apikey": OCR_API_KEY,
        "language": language,
    }
    try:
        response = requests.post(SOURCE_OCR_URL, data=payload)
        response.raise_for_status()
        test_url = response.content.decode()
    except requests.exceptions.RequestException as e:
        return f"Error: {str(e)}"
    try:
        parsed_response = json.loads(test_url)
        if (
            "ParsedResults" in parsed_response
            and len(parsed_response["ParsedResults"]) > 0
        ):
            return {
                "status": "true",
                "sukuna": {"text": parsed_response["ParsedResults"][0]["ParsedText"]},
            }
        else:
            return {"status": "false", "message": "Error response."}
    except (json.JSONDecodeError, KeyError):
        return "Error parsing the OCR response."


@app.get("/ryuzaki/chatgpt4")
def chatgpt4_support(query: str = None, api_key: None = Depends(validate_api_key)):
    try:
        response = g4f.ChatCompletion.create(
            model=g4f.models.gpt_4,
            messages=[{"role": "user", "content": query}],
        )
        return {"status": "true", "sukuna": {"message": response}}
    except BaseException:
        return {"status": "false", "message": "Error response."}


@app.post("/ryuzaki/chatgpt-model")
def chatgpt_model(query: str = None, model_id: int = 1, is_models: bool = True):
    try:
        response = RendyDevChat(query).get_response_model(
            model_id=model_id, is_models=is_models
        )
        return {"status": "true", "sukuna": {"message": response}}
    except BaseException:
        return {"status": "false", "message": "Error response."}


async def get_data(username):
    base_msg = ""
    async with AsyncClient() as gpx:
        req = (await gpx.get(f"https://api.github.com/users/{username}")).json()
        try:
            avatar = req["avatar_url"]
            twitter = req["twitter_username"]
            base_msg += "**❆ Gitub Information ❆** \n\n"
            base_msg += f"**Profile Url:** {req['html_url']} \n"
            base_msg += f"**Name:** `{req['name']}` \n"
            base_msg += f"**Username:** `{req['login']}` \n"
            base_msg += f"**User ID:** `{req['id']}` \n"
            base_msg += f"**Location:** `{req['location']}` \n"
            base_msg += f"**Company:** `{req['company']}` \n"
            base_msg += f"**Blog:** `{req['name']}` \n"
            base_msg += f"**Twitter:** `{f'https://twitter.com/{twitter}' if twitter else 'None'}` \n"
            base_msg += f"**Bio:** `{req['bio']}` \n"
            base_msg += f"**Public Repos:** `{req['public_repos']}` \n"
            base_msg += f"**Public Gists:** `{req['public_gists']}` \n"
            base_msg += f"**Followers:** `{req['followers']}` \n"
            base_msg += f"**Following:** `{req['following']}` \n"
            base_msg += f"**Created At:** `{req['created_at']}` \n"
            base_msg += f"**Update At:** `{req['updated_at']}` \n"
            return [base_msg, avatar]
        except Exception as e:
            base_msg += f"**An error occured while parsing the data!** \n\n**Traceback:** \n `{e}` \n\n`Make sure that you've sent the command with the correct username!`"
            return [base_msg, "https://telegra.ph//file/32f69c18190666ea96553.jpg"]


@app.get("/ryuzaki/github")
async def github(username: str = None):
    try:
        details = await get_data(username)
        return {
            "status": "true",
            "sukuna": {"avatar": details[1], "results": details[0]},
        }
    except BaseException:
        return {"status": "false", "message": "Error response."}


@app.get("/ryuzaki/webshot")
def webshot(
    url: str = None,
    quality: str = "1920x1080",
    type_mine: str = "JPEG",
    pixels: str = "1024",
    cast: str = "Z100",
):
    try:
        required_url = (
            f"https://mini.s-shot.ru/{quality}/{type_mine}/{pixels}/{cast}/?{url}"
        )
        return {"status": "true", "sukuna": {"image_url": required_url}}
    except BaseException:
        return {"status": "false", "message": "Error response."}


@app.get("/ryuzaki/chatbot")
def chatbot(
    query: str = None,
    user_id: int = None,
    bot_name: str = None,
    bot_username: str = None,
):
    api_url = b64decode("aHR0cHM6Ly9hcGkuc2Fmb25lLmRldi9jaGF0Ym90").decode("utf-8")
    params = {
        "query": query,
        "user_id": user_id,
        "bot_name": bot_name,
        "bot_master": bot_username,
    }
    x = requests.get(f"{api_url}", params=params)
    if x.status_code != 200:
        return "Error api request"
    try:
        y = x.json()
        response = y["response"]
        return {"status": "true", "sukuna": {"message": response}}
    except BaseException:
        return {"status": "false", "message": "Error response."}


@app.get("/ryuzaki/waifu")
def waifu_pics(types: str = "sfw", category: str = "neko"):
    waifu_api = f"{SOURCE_WAIFU_URL}/{types}"
    waifu_param = f"{waifu_api}/{category}"

    response = requests.get(waifu_param)

    if response.status_code != 200:
        return (
            "Sorry, there was an error processing your request. Please try again later"
        )
    data_waifu = response.json()
    try:
        waifu_image_url = data_waifu["url"]
    except Exception as e:
        return f"Error request {e}"
    if waifu_image_url:
        try:
            return {"status": "true", "sukuna": {"image_url": waifu_image_url}}
        except BaseException:
            return {"status": "false", "message": "Error response"}
    else:
        return {"status": "false", "message": "Error response."}


@app.get("/ryuzaki/rayso")
def make_rayso(
    code=None,
    title: str = "Ryuzaki Dev",
    theme: str = None,
    setlang: str = "en",
    auto_translate: bool = None,
    ryuzaki_dark: bool = None,
):
    trans = SyncTranslator()
    api_url = b64decode("aHR0cHM6Ly9hcGkuc2Fmb25lLm1lL3JheXNv").decode("utf-8")
    if auto_translate:
        source = trans.detect(code)
        translation = trans(code, sourcelang=source, targetlang=setlang)
        code = translation.text
    else:
        code = code
    if ryuzaki_dark:
        x = requests.post(
            f"{api_url}",
            json={"code": code, "title": title, "theme": theme, "darkMode": True},
        )
        if x.status_code != 200:
            return "Error api Gay"
        data = x.json()
        try:
            image_data = base64.b64decode(data["image"])
            return {"status": "true", "data": {"image": image_data}}
        except BaseException:
            return {"status": "false", "message": "Error response"}
    else:
        x = requests.post(
            f"{api_url}",
            json={"code": code, "title": title, "theme": theme, "darkMode": False},
        )
        if x.status_code != 200:
            return "Error api Gay"
        data = x.json()
        try:
            image_data = base64.b64decode(data["image"])
            return {"status": "true", "data": {"image": image_data}}
        except BaseException:
            return {"status": "false", "message": "Error response"}


@app.get("/ryuzaki/ipcheck")
def whois_ip_address(ip_address: str = None):
    apikey = kc("M0QwN0UyRUFBRjU1OTQwQUY0NDczNEMzRjJBQzdDMUE=").decode("utf-8")
    location_link = "https"
    location_api = "api.ip2location.io"
    location_key = f"key={apikey}"
    location_search = f"ip={ip_address}"
    location_param = (
        f"{location_link}://{location_api}/?{location_key}&{location_search}"
    )
    response = requests.get(location_param)
    if response.status_code != 200:
        return (
            "Sorry, there was an error processing your request. Please try again later"
        )
    data_location = response.json()
    try:
        location_ip = data_location["ip"]
        location_code = data_location["country_code"]
        location_name = data_location["country_name"]
        location_region = data_location["region_name"]
        location_city = data_location["city_name"]
        location_zip = data_location["zip_code"]
        location_zone = data_location["time_zone"]
        location_card = data_location["as"]
    except Exception as e:
        return f"error {e}"
    if (
        location_ip
        and location_code
        and location_name
        and location_region
        and location_city
        and location_zip
        and location_zone
        and location_card
    ):
        return {
            "ip_address": location_ip,
            "country_code": location_code,
            "region_name": location_region,
            "city_name": location_city,
            "zip_code": location_zip,
            "time_zone": location_zone,
            "as": location_card,
        }
    else:
        return {"status": "false", "message": "Invalid ip address"}


@app.get("/ryuzaki/tiktok_douyin")
def tiktok_douyin(tiktok_url: str = None):
    response = requests.get(f"{SOURCE_TIKTOK_WTF_URL}={tiktok_url}")
    if response.status_code != 200:
        return "Error request:"
    try:
        download_video = response.json()["aweme_list"][0]["video"]["play_addr"][
            "url_list"
        ][0]
        download_audio = response.json()["aweme_list"][0]["music"]["play_url"][
            "url_list"
        ][0]
        description = response.json()["aweme_list"][0]["desc"]
        author = response.json()["aweme_list"][0]["author"]["nickname"]
        request = response.json()["aweme_list"][0]["author"]["signature"]
        return {
            "status": "true",
            "sukuna": {
                "video_url": download_video,
                "music_url": download_audio,
                "description": description,
                "author": author,
                "request": request,
            },
        }
    except BaseException:
        return {"status": "false", "message": "Error request"}


@app.get("/ryuzaki/tiktok")
def tiktok_downloader(tiktok_url: Union[str, None] = None, only_video: bool = None):
    api_devs = SOURCE_TIKTOK_TECH_URL
    parameter = f"tiktok?url={tiktok_url}"
    api_url = f"{api_devs}/{parameter}"
    response = requests.get(api_url)

    if response.status_code != 200:
        return "Error: Unable to fetch data from the TikTok API"
    try:
        results = response.json()
        caption = results.get("result", {}).get("desc", "")
        if only_video:
            video_url = results.get("result", {}).get("withoutWaterMarkVideo", "")
            if video_url:
                return {"download_url": video_url, "caption": caption}
        else:
            music_mp3 = results.get("result", {}).get("music", "")
            if music_mp3:
                return {"music_url": music_mp3, "caption": caption}
        return "Error: TikTok data not found or unsupported format"
    except BaseException:
        return {"status": "false", "message": "Invalid Link"}


@app.get("/ryuzaki/mediafire")
def mediafire(link: Union[str, None] = None):
    try:
        down_link = str(link)
        mid = down_link.split("/", 5)
        if mid[3] == "view":
            mid[3] = "file"
            down_link = "/".join(mid)
            print(down_link)
        r = requests.get(down_link)
        soup = BeautifulSoup(r.content, "html.parser")
        a_href = soup.find("a", {"class": "input popsok"}).get("href")
        a = str(a_href)
        id = link.split("/", 5)[4]
        a_byte = soup.find("a", {"class": "input popsok"}).get_text()
        a_name = soup.find("div", {"class": "dl-btn-label"}).get_text()
        details = soup.find("ul", {"class": "details"})
        li_items = details.find_all("li")[1]
        some = li_items.find_all("span")[0].get_text().split()
        dat = list(some)
        down = a_byte.replace(" ", "").strip()
        time = dat[1]
        date = dat[0]
        byte = down.split("(", 1)[1].split(")", 1)[0]
        name = a_name.replace(" ", "").strip()
        return {
            "status": "true",
            "data": {
                "file": {
                    "url": {
                        "directDownload": a,
                        "original": link,
                    },
                    "metadata": {
                        "id": id,
                        "name": name,
                        "size": {"readable": byte},
                        "DateAndTime": {"time": time, "date": date},
                    },
                }
            },
        }

    except BaseException:
        return "{'status': 'false', 'message': 'Invalid Link'}"


@app.get("/ryuzaki/gdrive")
def gdrive(link: Union[str, None] = None):
    try:
        down = link.split("/", 6)
        url = f"https://drive.google.com/uc?export=download&id={down[5]}"
        session = requests.Session()

        response = session.get(url, stream=True)
        headers = response.headers
        content_disp = headers.get("content-disposition")
        filename = None
        if content_disp:
            match = re.search(r'filename="(.+)"', content_disp)
            if match:
                filename = match.group(1)

        content_length = headers.get("content-length")
        last_modified = headers.get("last-modified")
        content_type = headers.get("content-type")

        return {
            "status": "true",
            "data": {
                "file": {
                    "url": {
                        "directDownload": url,
                        "original": link,
                    },
                    "metadata": {
                        "id": down[5],
                        "name": (
                            filename
                            if filename
                            else "No filename provided by the server."
                        ),
                        "size": {
                            "readable": (
                                f"{round(int(content_length) / (1024 * 1024), 2)} MB"
                                if content_length
                                else "No content length provided by the server."
                            ),
                            "type": (
                                content_type
                                if content_type
                                else "No content type provided by the server."
                            ),
                        },
                        "DateAndTime": (
                            last_modified
                            if last_modified
                            else "No last modified date provided by the server."
                        ),
                    },
                }
            },
        }

    except BaseException:
        return "{'status': 'false', 'message': 'Invalid Link'}"


@app.get("/ryuzaki/anonfiles")
def anonfiles(link: Union[str, None] = None):
    try:
        r = requests.get(link)
        soup = BeautifulSoup(r.content, "html.parser")
        a_href = soup.find("a", {"id": "download-url"}).get("href")
        a = str(a_href)
        id = link.split("/", 4)[3]
        jsondata = requests.get(f"https://api.anonfiles.com/v2/file/{id}/info").json()
        jsondata["data"]["file"]["url"]["directDownload"] = a
        del jsondata["data"]["file"]["url"]["full"]

        return jsondata
    except BaseException:
        return "{'status': 'false', 'message': 'Invalid Link'}"


@app.get("/ryuzaki/filechan")
def filechan(link: Union[str, None] = None):
    try:
        r = requests.get(link)
        soup = BeautifulSoup(r.content, "html.parser")
        a_href = soup.find("a", {"id": "download-url"}).get("href")
        a = str(a_href)
        id = link.split("/", 4)[3]
        jsondata = requests.get(f"https://api.filechan.org/v2/file/{id}/info").json()
        jsondata["data"]["file"]["url"]["directDownload"] = a
        del jsondata["data"]["file"]["url"]["full"]

        return jsondata
    except BaseException:
        return "{'status': 'false', 'message': 'Invalid Link'}"


@app.get("/ryuzaki/letsupload")
def letsupload(link: Union[str, None] = None):
    try:
        r = requests.get(link)
        soup = BeautifulSoup(r.content, "html.parser")
        a_href = soup.find("a", {"id": "download-url"}).get("href")
        a = str(a_href)
        id = link.split("/", 4)[3]
        jsondata = requests.get(f"https://api.letsupload.cc/v2/file/{id}/info").json()
        jsondata["data"]["file"]["url"]["directDownload"] = a
        del jsondata["data"]["file"]["url"]["full"]

        return jsondata
    except BaseException:
        return "{'status': 'false', 'message': 'Invalid Link'}"


@app.get("/ryuzaki/megaupload")
def megaupload(link: Union[str, None] = None):
    try:
        r = requests.get(link)
        soup = BeautifulSoup(r.content, "html.parser")
        a_href = soup.find("a", {"id": "download-url"}).get("href")
        a = str(a_href)
        id = link.split("/", 4)[3]
        jsondata = requests.get(f"https://api.megaupload.nz/v2/file/{id}/info").json()
        jsondata["data"]["file"]["url"]["directDownload"] = a
        del jsondata["data"]["file"]["url"]["full"]

        return jsondata
    except BaseException:
        return "{'status': 'false', 'message': 'Invalid Link'}"


@app.get("/ryuzaki/myfile")
def myfile(link: Union[str, None] = None):
    try:
        r = requests.get(link)
        soup = BeautifulSoup(r.content, "html.parser")
        a_href = soup.find("a", {"id": "download-url"}).get("href")
        a = str(a_href)
        id = link.split("/", 4)[3]
        jsondata = requests.get(f"https://api.myfile.is/v2/file/{id}/info").json()
        jsondata["data"]["file"]["url"]["directDownload"] = a
        del jsondata["data"]["file"]["url"]["full"]

        return jsondata
    except BaseException:
        return "{'status': 'false', 'message': 'Invalid Link'}"


def custom_exception_handler(request: Request, exc: HTTPException) -> JSONResponse:
    error_detail = [{"error": str(exc.detail)}]
    custom_error_model = CustomErrorResponseModel(detail=error_detail)

    return JSONResponse(
        status_code=exc.status_code,
        content=custom_error_model.dict(),
        headers=exc.headers,
    )


# Add the custom exception handler to your FastAPI app
app.add_exception_handler(HTTPException, custom_exception_handler)