mikmc commited on
Commit
7f14e1e
·
verified ·
1 Parent(s): e87ad17

Upload 28 files

Browse files
.env CHANGED
@@ -1,16 +1,29 @@
1
- ADDON_ID=stremio.comet.fast # for Stremio
2
- ADDON_NAME=Comet # for Stremio
3
  FASTAPI_HOST=0.0.0.0
4
- FASTAPI_PORT=8000
5
- FASTAPI_WORKERS=1 # remove to destroy CPU -> max performances
6
- DATABASE_PATH=data/comet.db # only change it if you know what it is - folders in path must exist
 
 
 
7
  CACHE_TTL=86400 # cache duration in seconds
8
- DEBRID_PROXY_URL=http://127.0.0.1:1080 # https://github.com/cmj2002/warp-docker
9
- INDEXER_MANAGER_TYPE=jackett # or prowlarr
10
- INDEXER_MANAGER_URL=http://82.172.152.9:9117
11
- INDEXER_MANAGER_API_KEY=kptut9ad0fqgllyeykn27dhr9p6cd3hq
12
  INDEXER_MANAGER_TIMEOUT=60 # maximum time to obtain search results from indexer manager in seconds
13
- INDEXER_MANAGER_INDEXERS='["audiences","milkie","pterclub","rutracker","rutracker-ru","scenehd","thepiratebay","torrentleech","totheglory2fa","yourbittorrent"]'
14
  GET_TORRENT_TIMEOUT=5 # maximum time to obtain the torrent info hash in seconds
15
- ZILEAN_URL=None # for DMM search - https://github.com/iPromKnight/zilean
16
- CUSTOM_HEADER_HTML=None # only set it if you know what it is
 
 
 
 
 
 
 
 
 
 
 
1
+ ADDON_ID=stremio.comet.hy # for Stremio
2
+ ADDON_NAME=Help Yourself # for Stremio
3
  FASTAPI_HOST=0.0.0.0
4
+ FASTAPI_PORT=3000
5
+ FASTAPI_WORKERS=1 # remove to destroy CPU -> max performances :D
6
+ DASHBOARD_ADMIN_PASSWORD=CHANGE_ME # The password to access the dashboard with active connections and soon more...
7
+ DATABASE_TYPE=sqlite # or postgresql if you know what you're doing
8
+ DATABASE_URL=username:password@hostname:port # to connect to PostgreSQL
9
+ DATABASE_PATH=data/comet.db # only change it if you know what it is - folders in path must exist - ignored if PostgreSQL used
10
  CACHE_TTL=86400 # cache duration in seconds
11
+ DEBRID_PROXY_URL=http://127.0.0.1:1080 # https://github.com/cmj2002/warp-docker to bypass Debrid Services and Torrentio server IP blacklist
12
+ INDEXER_MANAGER_TYPE=jackett # or prowlarr or None if you want to disable it completely and use Zilean or Torrentio
13
+ INDEXER_MANAGER_URL=http://23.121.245.187:9117
14
+ INDEXER_MANAGER_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
15
  INDEXER_MANAGER_TIMEOUT=60 # maximum time to obtain search results from indexer manager in seconds
16
+ INDEXER_MANAGER_INDEXERS='["1337x","animetosho","btsow","eztv","kickasstorrents-to","kickasstorrents-ws","knaben","nyaasi","subsplease","thepiratebay","therarbg","torlock","torrentproject2","torrentscsv","torrentz2nz","yourbittorrent","yts"]'
17
  GET_TORRENT_TIMEOUT=5 # maximum time to obtain the torrent info hash in seconds
18
+ ZILEAN_URL=None # for DMM search - https://github.com/iPromKnight/zilean - ex: http://127.0.0.1:8181
19
+ ZILEAN_TAKE_FIRST=500 # only change it if you know what it is
20
+ SCRAPE_TORRENTIO=True # scrape Torrentio
21
+ SCRAPE_MEDIAFUSION=False # scrape MediaFusion - has better results for Indian content
22
+ MEDIAFUSION_URL=https://mediafusion.elfhosted.com # Allows you to scrape custom instances of MediaFusion
23
+ PROXY_DEBRID_STREAM=False # Proxy Debrid Streams (very useful to use your debrid service on multiple IPs at same time)
24
+ PROXY_DEBRID_STREAM_PASSWORD=CHANGE_ME # Secret password to enter on configuration page to prevent people from abusing your debrid stream proxy
25
+ PROXY_DEBRID_STREAM_MAX_CONNECTIONS=100 # IP-Based connection limit for the Debrid Stream Proxy
26
+ PROXY_DEBRID_STREAM_DEBRID_DEFAULT_SERVICE=realdebrid # if you want your users who use the Debrid Stream Proxy not to have to specify Debrid information, but to use the default one instead
27
+ PROXY_DEBRID_STREAM_DEBRID_DEFAULT_APIKEY=CHANGE_ME # if you want your users who use the Debrid Stream Proxy not to have to specify Debrid information, but to use the default one instead
28
+ TITLE_MATCH_CHECK=True # disable if you only use Torrentio / MediaFusion and are sure you're only scraping good titles, for example (keep it True if Zilean is enabled)
29
+ CUSTOM_HEADER_HTML=None # only set it if you know what it is
.env-sample ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ADDON_ID=stremio.comet.fast # for Stremio
2
+ ADDON_NAME=Comet # for Stremio
3
+ FASTAPI_HOST=0.0.0.0
4
+ FASTAPI_PORT=8000
5
+ FASTAPI_WORKERS=1 # remove to destroy CPU -> max performances :D
6
+ DASHBOARD_ADMIN_PASSWORD=CHANGE_ME # The password to access the dashboard with active connections and soon more...
7
+ DATABASE_TYPE=sqlite # or postgresql if you know what you're doing
8
+ DATABASE_URL=username:password@hostname:port # to connect to PostgreSQL
9
+ DATABASE_PATH=data/comet.db # only change it if you know what it is - folders in path must exist - ignored if PostgreSQL used
10
+ CACHE_TTL=86400 # cache duration in seconds
11
+ DEBRID_PROXY_URL=http://127.0.0.1:1080 # https://github.com/cmj2002/warp-docker to bypass Debrid Services and Torrentio server IP blacklist
12
+ INDEXER_MANAGER_TYPE=jackett # or prowlarr or None if you want to disable it completely and use Zilean or Torrentio
13
+ INDEXER_MANAGER_URL=http://127.0.0.1:9117
14
+ INDEXER_MANAGER_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
15
+ INDEXER_MANAGER_TIMEOUT=60 # maximum time to obtain search results from indexer manager in seconds
16
+ INDEXER_MANAGER_INDEXERS='["EXAMPLE1_CHANGETHIS", "EXAMPLE2_CHANGETHIS"]'
17
+ GET_TORRENT_TIMEOUT=5 # maximum time to obtain the torrent info hash in seconds
18
+ ZILEAN_URL=None # for DMM search - https://github.com/iPromKnight/zilean - ex: http://127.0.0.1:8181
19
+ ZILEAN_TAKE_FIRST=500 # only change it if you know what it is
20
+ SCRAPE_TORRENTIO=False # scrape Torrentio
21
+ SCRAPE_MEDIAFUSION=False # scrape MediaFusion - has better results for Indian content
22
+ MEDIAFUSION_URL=https://mediafusion.elfhosted.com # Allows you to scrape custom instances of MediaFusion
23
+ PROXY_DEBRID_STREAM=False # Proxy Debrid Streams (very useful to use your debrid service on multiple IPs at same time)
24
+ PROXY_DEBRID_STREAM_PASSWORD=CHANGE_ME # Secret password to enter on configuration page to prevent people from abusing your debrid stream proxy
25
+ PROXY_DEBRID_STREAM_MAX_CONNECTIONS=100 # IP-Based connection limit for the Debrid Stream Proxy
26
+ PROXY_DEBRID_STREAM_DEBRID_DEFAULT_SERVICE=realdebrid # if you want your users who use the Debrid Stream Proxy not to have to specify Debrid information, but to use the default one instead
27
+ PROXY_DEBRID_STREAM_DEBRID_DEFAULT_APIKEY=CHANGE_ME # if you want your users who use the Debrid Stream Proxy not to have to specify Debrid information, but to use the default one instead
28
+ TITLE_MATCH_CHECK=True # disable if you only use Torrentio / MediaFusion and are sure you're only scraping good titles, for example (keep it True if Zilean is enabled)
29
+ CUSTOM_HEADER_HTML=None # only set it if you know what it is
CHANGELOG.md CHANGED
@@ -1,5 +1,648 @@
1
  # Changelog
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ## [1.3.1](https://github.com/g0ldyy/comet/compare/v1.3.0...v1.3.1) (2024-07-03)
4
 
5
 
 
1
  # Changelog
2
 
3
+ ## [1.33.0](https://github.com/g0ldyy/comet/compare/v1.32.2...v1.33.0) (2024-11-14)
4
+
5
+
6
+ ### Features
7
+
8
+ * add media fusion hashes ([ece4600](https://github.com/g0ldyy/comet/commit/ece4600ddec3bfc64cd39ce3fdb667b022c2cd35))
9
+ * custom MediaFusion urls for elfhosted <3 ([bc29eb9](https://github.com/g0ldyy/comet/commit/bc29eb9582dca426ad58cc770f7d7d4d0cd6acd0))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * add missing env var ([77ef84a](https://github.com/g0ldyy/comet/commit/77ef84a89306fe1bb63dc0178024a6c28fe6c262))
15
+ * I just want to release ([9bb4a4e](https://github.com/g0ldyy/comet/commit/9bb4a4ecc0c0e9449fc57b37b142025c314c5dda))
16
+ * update hashinfo ([c15206b](https://github.com/g0ldyy/comet/commit/c15206b4b410fc685fbbcd7f31df574553ca6cd5))
17
+
18
+ ## [1.32.2](https://github.com/g0ldyy/comet/compare/v1.32.1...v1.32.2) (2024-10-04)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * ip debrid ([057126b](https://github.com/g0ldyy/comet/commit/057126bbd00f818075969e5e73eff3e834a8ef1f))
24
+ * missing year metadata ([4a4dfb6](https://github.com/g0ldyy/comet/commit/4a4dfb68923d4c496b8e837eb3a238d6ba21ae95))
25
+ * realdebrid ip stuff ([6ee6b92](https://github.com/g0ldyy/comet/commit/6ee6b928a57351a82af284b3c6446bcbf01a8e10))
26
+ * weird shit ([1176b2a](https://github.com/g0ldyy/comet/commit/1176b2a84233f705033b142b1492c2bdc7da5b77))
27
+
28
+ ## [1.32.1](https://github.com/g0ldyy/comet/compare/v1.32.0...v1.32.1) (2024-10-01)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * title parsing ([732021c](https://github.com/g0ldyy/comet/commit/732021c99b8004192b15d29d5b63a39bce893568))
34
+
35
+ ## [1.32.0](https://github.com/g0ldyy/comet/compare/v1.31.4...v1.32.0) (2024-09-18)
36
+
37
+
38
+ ### Features
39
+
40
+ * autplay ([1147845](https://github.com/g0ldyy/comet/commit/1147845640a628bda61e0355f186d425587cb989))
41
+
42
+ ## [1.31.4](https://github.com/g0ldyy/comet/compare/v1.31.3...v1.31.4) (2024-09-17)
43
+
44
+
45
+ ### Bug Fixes
46
+
47
+ * bye samples ([efcf44d](https://github.com/g0ldyy/comet/commit/efcf44dbdff688031771e6834ca4d3244489fc3c))
48
+
49
+ ## [1.31.3](https://github.com/g0ldyy/comet/compare/v1.31.2...v1.31.3) (2024-09-06)
50
+
51
+
52
+ ### Bug Fixes
53
+
54
+ * latin and spanish separated ([2421667](https://github.com/g0ldyy/comet/commit/24216678b8fca0ab8edd48d239fb772f06712b5f))
55
+
56
+ ## [1.31.2](https://github.com/g0ldyy/comet/compare/v1.31.1...v1.31.2) (2024-09-04)
57
+
58
+
59
+ ### Bug Fixes
60
+
61
+ * fail build ([9e7407d](https://github.com/g0ldyy/comet/commit/9e7407d7ced4a1d570e11c350dd5b6ce4a878db6))
62
+
63
+ ## [1.31.1](https://github.com/g0ldyy/comet/compare/v1.31.0...v1.31.1) (2024-09-04)
64
+
65
+
66
+ ### Bug Fixes
67
+
68
+ * metadata ([23966f2](https://github.com/g0ldyy/comet/commit/23966f22887e1d744f2342a97d7b39652155ddb1))
69
+
70
+ ## [1.31.0](https://github.com/g0ldyy/comet/compare/v1.30.1...v1.31.0) (2024-09-01)
71
+
72
+
73
+ ### Features
74
+
75
+ * realdebrid real ip ([479aa8e](https://github.com/g0ldyy/comet/commit/479aa8e527ebfeec01ffcde5c825b0a5af19538e))
76
+
77
+ ## [1.30.1](https://github.com/g0ldyy/comet/compare/v1.30.0...v1.30.1) (2024-08-31)
78
+
79
+
80
+ ### Bug Fixes
81
+
82
+ * torrentio ([165cb25](https://github.com/g0ldyy/comet/commit/165cb256d2c4e27020eb775d52de299cddbdc0f5))
83
+ * zilean ([6a272fc](https://github.com/g0ldyy/comet/commit/6a272fcf7638581a171ea7ea20aaa5854c3552cc))
84
+
85
+ ## [1.30.0](https://github.com/g0ldyy/comet/compare/v1.29.1...v1.30.0) (2024-08-31)
86
+
87
+
88
+ ### Features
89
+
90
+ * add multi to languages ([da4d1d7](https://github.com/g0ldyy/comet/commit/da4d1d7cc2a4fc590c6acb0a7c0f43be9fc54568))
91
+
92
+ ## [1.29.1](https://github.com/g0ldyy/comet/compare/v1.29.0...v1.29.1) (2024-08-31)
93
+
94
+
95
+ ### Bug Fixes
96
+
97
+ * improves prowlarr compatibility ([7c0ee96](https://github.com/g0ldyy/comet/commit/7c0ee96dafb4a14db02c66e8cfaf2dd5ac05273c))
98
+
99
+ ## [1.29.0](https://github.com/g0ldyy/comet/compare/v1.28.5...v1.29.0) (2024-08-31)
100
+
101
+
102
+ ### Features
103
+
104
+ * faster than ever, better results ([19f9cc4](https://github.com/g0ldyy/comet/commit/19f9cc48ae83e27b43fdbb8541ec8d6b6f2878df))
105
+
106
+ ## [1.28.5](https://github.com/g0ldyy/comet/compare/v1.28.4...v1.28.5) (2024-08-29)
107
+
108
+
109
+ ### Bug Fixes
110
+
111
+ * debrid download link caching not working in certain case ([271dbb6](https://github.com/g0ldyy/comet/commit/271dbb6f43481c509e7a74018d0c804c263eadcd))
112
+
113
+ ## [1.28.4](https://github.com/g0ldyy/comet/compare/v1.28.3...v1.28.4) (2024-08-28)
114
+
115
+
116
+ ### Bug Fixes
117
+
118
+ * metadata ([809e32b](https://github.com/g0ldyy/comet/commit/809e32bb9c727076be12ab88b073b86213b50e12))
119
+
120
+ ## [1.28.3](https://github.com/g0ldyy/comet/compare/v1.28.2...v1.28.3) (2024-08-28)
121
+
122
+
123
+ ### Bug Fixes
124
+
125
+ * sqlite download_link caching ([34c93c6](https://github.com/g0ldyy/comet/commit/34c93c6d3b0d77a8573e810e1f6cefff71a83e85))
126
+
127
+ ## [1.28.2](https://github.com/g0ldyy/comet/compare/v1.28.1...v1.28.2) (2024-08-28)
128
+
129
+
130
+ ### Bug Fixes
131
+
132
+ * metadata retriever ([8f4e133](https://github.com/g0ldyy/comet/commit/8f4e13392ac65ce6b6d23f26f4bfafb629201574))
133
+
134
+ ## [1.28.1](https://github.com/g0ldyy/comet/compare/v1.28.0...v1.28.1) (2024-08-27)
135
+
136
+
137
+ ### Bug Fixes
138
+
139
+ * typo causing errors ([7584af6](https://github.com/g0ldyy/comet/commit/7584af66dd19d3a2c089f75b9f6cf1646ddbc25c))
140
+
141
+ ## [1.28.0](https://github.com/g0ldyy/comet/compare/v1.27.1...v1.28.0) (2024-08-27)
142
+
143
+
144
+ ### Features
145
+
146
+ * PostgreSQL support ([8f46d7f](https://github.com/g0ldyy/comet/commit/8f46d7f1829148190d27adf0d35ed64bf233d029))
147
+
148
+ ## [1.27.1](https://github.com/g0ldyy/comet/compare/v1.27.0...v1.27.1) (2024-08-27)
149
+
150
+
151
+ ### Bug Fixes
152
+
153
+ * Jinja2 missing sometimes ([11a96b7](https://github.com/g0ldyy/comet/commit/11a96b705b29b7a8dd72d81c6d2f6957360bfea9))
154
+ * jinja2????? ([55fe625](https://github.com/g0ldyy/comet/commit/55fe625c595ac2b8eea5ac3ee98219bbc6adeddf))
155
+
156
+ ## [1.27.0](https://github.com/g0ldyy/comet/compare/v1.26.0...v1.27.0) (2024-08-27)
157
+
158
+
159
+ ### Features
160
+
161
+ * disable indexer select if indexer manager disabled ([2907a0e](https://github.com/g0ldyy/comet/commit/2907a0e25ca3da405b309e0c90ce7d191e7825f7))
162
+
163
+ ## [1.26.0](https://github.com/g0ldyy/comet/compare/v1.25.2...v1.26.0) (2024-08-27)
164
+
165
+
166
+ ### Features
167
+
168
+ * new admin dashboard for debrid proxy stream + title year check + ip-based max connections for debrid proxy stream ([1d11ac4](https://github.com/g0ldyy/comet/commit/1d11ac46bde0c951ee0c3afa746e83a46bb8474f))
169
+
170
+
171
+ ### Bug Fixes
172
+
173
+ * remove fullstacksample docker compose as it needs to be changed a lot ([7533ecb](https://github.com/g0ldyy/comet/commit/7533ecb4b08a349b25a1bce2e70b1481fc3407bd))
174
+
175
+ ## [1.25.2](https://github.com/g0ldyy/comet/compare/v1.25.1...v1.25.2) (2024-08-16)
176
+
177
+
178
+ ### Bug Fixes
179
+
180
+ * zilean ([40b62b2](https://github.com/g0ldyy/comet/commit/40b62b29dc351775da3c7d914203579abfede646))
181
+
182
+ ## [1.25.1](https://github.com/g0ldyy/comet/compare/v1.25.0...v1.25.1) (2024-08-15)
183
+
184
+
185
+ ### Bug Fixes
186
+
187
+ * zilean 1.5 ([12a9bc5](https://github.com/g0ldyy/comet/commit/12a9bc59ef545ff2ff86637791609fd8e7ffec57))
188
+
189
+ ## [1.25.0](https://github.com/g0ldyy/comet/compare/v1.24.0...v1.25.0) (2024-08-06)
190
+
191
+
192
+ ### Features
193
+
194
+ * Add metadata to result title ([33f3f96](https://github.com/g0ldyy/comet/commit/33f3f96b8c0d2416c8cdb1db8614970f714708ae))
195
+
196
+ ## [1.24.0](https://github.com/g0ldyy/comet/compare/v1.23.2...v1.24.0) (2024-08-05)
197
+
198
+
199
+ ### Features
200
+
201
+ * custom results title ([fa800ef](https://github.com/g0ldyy/comet/commit/fa800ef6b6a0f8ba91ebe2ebfa21147f9cb667a1))
202
+
203
+ ## [1.23.2](https://github.com/g0ldyy/comet/compare/v1.23.1...v1.23.2) (2024-07-29)
204
+
205
+
206
+ ### Bug Fixes
207
+
208
+ * alldebrid support ([1ea4464](https://github.com/g0ldyy/comet/commit/1ea446471ce7e9673724952a24075e64672d3510))
209
+
210
+ ## [1.23.1](https://github.com/g0ldyy/comet/compare/v1.23.0...v1.23.1) (2024-07-24)
211
+
212
+
213
+ ### Bug Fixes
214
+
215
+ * db error ([d1232ce](https://github.com/g0ldyy/comet/commit/d1232cec61b7ecc7d639098d949dc8696822a274))
216
+
217
+ ## [1.23.0](https://github.com/g0ldyy/comet/compare/v1.22.0...v1.23.0) (2024-07-24)
218
+
219
+
220
+ ### Features
221
+
222
+ * ability to enable/disable title match check (TITLE_MATCH_CHECK env var) ([755c4fb](https://github.com/g0ldyy/comet/commit/755c4fb8d21e74576aa615c7d84b399ebedeb45a))
223
+ * show language emoji in results ([d9e15e7](https://github.com/g0ldyy/comet/commit/d9e15e7e88244eca1c264221ca71e38b4dab7dbc))
224
+
225
+ ## [1.22.0](https://github.com/g0ldyy/comet/compare/v1.21.2...v1.22.0) (2024-07-24)
226
+
227
+
228
+ ### Features
229
+
230
+ * debrid download links are now cached for 1h (massive speed improvement) ([aab0b91](https://github.com/g0ldyy/comet/commit/aab0b918bd205b668ce15510c13d672efb5ed923))
231
+
232
+
233
+ ### Bug Fixes
234
+
235
+ * imdb metadata wrong name ([0ecba3e](https://github.com/g0ldyy/comet/commit/0ecba3e64aaf6b3f5dad47f4f5527f0a8732d57a))
236
+ * torrentio proxy ([b098bb1](https://github.com/g0ldyy/comet/commit/b098bb1ed9a60af89e173c527bf4bb579a91a29c))
237
+
238
+ ## [1.21.2](https://github.com/g0ldyy/comet/compare/v1.21.1...v1.21.2) (2024-07-24)
239
+
240
+
241
+ ### Bug Fixes
242
+
243
+ * revert IMDb metadata bug ([595c2c0](https://github.com/g0ldyy/comet/commit/595c2c0da9f6a94a930e82d1e555cafefa343ad2))
244
+
245
+ ## [1.21.1](https://github.com/g0ldyy/comet/compare/v1.21.0...v1.21.1) (2024-07-23)
246
+
247
+
248
+ ### Bug Fixes
249
+
250
+ * coding blind ([2a5002a](https://github.com/g0ldyy/comet/commit/2a5002a3a134429fb9cffc708ac1973dceff0b40))
251
+ * IMDb metadata retriever ([914c5d2](https://github.com/g0ldyy/comet/commit/914c5d2d455cc4f12f738a4e3aa014aa816c619b))
252
+ * not retrieving saved stremio settings if all selected ([42c5863](https://github.com/g0ldyy/comet/commit/42c5863297807f231e04f2eb25510b146c6f789a))
253
+ * proxy stream ([1ceeff5](https://github.com/g0ldyy/comet/commit/1ceeff57223f521b006b4311c314ed62f56096fe))
254
+ * try to fix Nvidia shield debrid stream proxying ([bdb22dc](https://github.com/g0ldyy/comet/commit/bdb22dcc63b4ca6fd014faaf287b7d8034093c12))
255
+ * where is the client ([c532656](https://github.com/g0ldyy/comet/commit/c532656b3bba916a5df8cbdcf306b822ef94a871))
256
+
257
+ ## [1.21.0](https://github.com/g0ldyy/comet/compare/v1.20.0...v1.21.0) (2024-07-22)
258
+
259
+
260
+ ### Features
261
+
262
+ * fetch previous settings from stremio configure ([b42f4fb](https://github.com/g0ldyy/comet/commit/b42f4fbc96622a48f035de10e711bae2c9a9e2d2))
263
+ * save settings on Stremio configure button ([6dd22cc](https://github.com/g0ldyy/comet/commit/6dd22ccce7858967c287ad028ea011caefffd2af))
264
+
265
+ ## [1.20.0](https://github.com/g0ldyy/comet/compare/v1.19.5...v1.20.0) (2024-07-22)
266
+
267
+
268
+ ### Features
269
+
270
+ * use debrid proxy for torrentio (bypass Cloudflare server IP blacklist) ([5d02247](https://github.com/g0ldyy/comet/commit/5d02247021ca897aa79842bde1bbb56817a58967))
271
+
272
+ ## [1.19.5](https://github.com/g0ldyy/comet/compare/v1.19.4...v1.19.5) (2024-07-21)
273
+
274
+
275
+ ### Bug Fixes
276
+
277
+ * prowlarr indexer ([4003fb4](https://github.com/g0ldyy/comet/commit/4003fb4fc06c70364fb7d64a077a334d303de085))
278
+
279
+ ## [1.19.4](https://github.com/g0ldyy/comet/compare/v1.19.3...v1.19.4) (2024-07-21)
280
+
281
+
282
+ ### Bug Fixes
283
+
284
+ * debrid stream proxy on some devices ([240364b](https://github.com/g0ldyy/comet/commit/240364bd883070cf2556fb2b7bdd89fa4a1230f6))
285
+
286
+ ## [1.19.3](https://github.com/g0ldyy/comet/compare/v1.19.2...v1.19.3) (2024-07-21)
287
+
288
+
289
+ ### Bug Fixes
290
+
291
+ * wtf ([b47676c](https://github.com/g0ldyy/comet/commit/b47676cc86758964bb9feb5a4ebcccc97ae7ef02))
292
+
293
+ ## [1.19.2](https://github.com/g0ldyy/comet/compare/v1.19.1...v1.19.2) (2024-07-21)
294
+
295
+
296
+ ### Bug Fixes
297
+
298
+ * Delete poetry.lock ([833bb33](https://github.com/g0ldyy/comet/commit/833bb332c4b4899372b08007c57db4084752339e))
299
+
300
+ ## [1.19.1](https://github.com/g0ldyy/comet/compare/v1.19.0...v1.19.1) (2024-07-21)
301
+
302
+
303
+ ### Bug Fixes
304
+
305
+ * torrentio cloudflare bypass ([d9c98a7](https://github.com/g0ldyy/comet/commit/d9c98a75cb4e101d00395022549499b9a7d3965b))
306
+
307
+ ## [1.19.0](https://github.com/g0ldyy/comet/compare/v1.18.3...v1.19.0) (2024-07-20)
308
+
309
+
310
+ ### Features
311
+
312
+ * torrentio scraper ([94c21d9](https://github.com/g0ldyy/comet/commit/94c21d962d784405d0c09e2986393b90c497dfd9))
313
+
314
+
315
+ ### Bug Fixes
316
+
317
+ * add torrentio scraper to features ([27d23a5](https://github.com/g0ldyy/comet/commit/27d23a5fa6bb15a92be61ec7701207554864e422))
318
+
319
+ ## [1.18.3](https://github.com/g0ldyy/comet/compare/v1.18.2...v1.18.3) (2024-07-19)
320
+
321
+
322
+ ### Bug Fixes
323
+
324
+ * slightly improve anime results ([c9f230c](https://github.com/g0ldyy/comet/commit/c9f230c9cb8649dbe5f0dfab923039785b4c885b))
325
+
326
+ ## [1.18.2](https://github.com/g0ldyy/comet/compare/v1.18.1...v1.18.2) (2024-07-19)
327
+
328
+
329
+ ### Bug Fixes
330
+
331
+ * faster debrid file parsing ([bf846fa](https://github.com/g0ldyy/comet/commit/bf846fa8a8d8444d13f404ec1651e7f0d71b4697))
332
+
333
+ ## [1.18.1](https://github.com/g0ldyy/comet/compare/v1.18.0...v1.18.1) (2024-07-19)
334
+
335
+
336
+ ### Bug Fixes
337
+
338
+ * torrents faster ([ef53efe](https://github.com/g0ldyy/comet/commit/ef53efe7337679cc1cf1843d1efa956c09cad62a))
339
+
340
+ ## [1.18.0](https://github.com/g0ldyy/comet/compare/v1.17.2...v1.18.0) (2024-07-18)
341
+
342
+
343
+ ### Features
344
+
345
+ * Kitsu support ([b641c69](https://github.com/g0ldyy/comet/commit/b641c69c04173b82386a4e150fccba2e078a85be))
346
+
347
+ ## [1.17.2](https://github.com/g0ldyy/comet/compare/v1.17.1...v1.17.2) (2024-07-18)
348
+
349
+
350
+ ### Bug Fixes
351
+
352
+ * update manifest for animes support ([8ee3220](https://github.com/g0ldyy/comet/commit/8ee32205f14ad098dc96c1f9aea3f78314807431))
353
+
354
+ ## [1.17.1](https://github.com/g0ldyy/comet/compare/v1.17.0...v1.17.1) (2024-07-18)
355
+
356
+
357
+ ### Bug Fixes
358
+
359
+ * metadata ([81ff5bc](https://github.com/g0ldyy/comet/commit/81ff5bc71b1b8a683f662fa9af7c364cf6046b85))
360
+
361
+ ## [1.17.0](https://github.com/g0ldyy/comet/compare/v1.16.0...v1.17.0) (2024-07-18)
362
+
363
+
364
+ ### Features
365
+
366
+ * error videos added to playback ([83668ea](https://github.com/g0ldyy/comet/commit/83668ea3c15858504dfbb58fae5764995dc30bf9))
367
+
368
+
369
+ ### Bug Fixes
370
+
371
+ * faster (we title match check before doing the rest) ([19fc235](https://github.com/g0ldyy/comet/commit/19fc235e838bcfb6d3d7e06f95309ff72c491fd5))
372
+
373
+ ## [1.16.0](https://github.com/g0ldyy/comet/compare/v1.15.5...v1.16.0) (2024-07-18)
374
+
375
+
376
+ ### Features
377
+
378
+ * add real torrent_size in results ([33ef5b1](https://github.com/g0ldyy/comet/commit/33ef5b119fa9f01bb914ba969bf19f95b61a761f))
379
+ * config string now sent to console when copy/install button clicked ([9f46fa9](https://github.com/g0ldyy/comet/commit/9f46fa98ddfdd9a0466f200144cd72dc09a8e160))
380
+
381
+ ## [1.15.5](https://github.com/g0ldyy/comet/compare/v1.15.4...v1.15.5) (2024-07-16)
382
+
383
+
384
+ ### Bug Fixes
385
+
386
+ * prowlarr infoHash ([71738ee](https://github.com/g0ldyy/comet/commit/71738ee3a65115694a219b4e55e645df2ccef138))
387
+
388
+ ## [1.15.4](https://github.com/g0ldyy/comet/compare/v1.15.3...v1.15.4) (2024-07-16)
389
+
390
+
391
+ ### Bug Fixes
392
+
393
+ * I fixed it I think guys ([86ea5d5](https://github.com/g0ldyy/comet/commit/86ea5d5a3d2af47e3698c04f160e195cf8def614))
394
+
395
+ ## [1.15.3](https://github.com/g0ldyy/comet/compare/v1.15.2...v1.15.3) (2024-07-16)
396
+
397
+
398
+ ### Bug Fixes
399
+
400
+ * hope ([0086f3f](https://github.com/g0ldyy/comet/commit/0086f3f90ed31dba29d5e5ad0f6b6451f9144e91))
401
+
402
+ ## [1.15.2](https://github.com/g0ldyy/comet/compare/v1.15.1...v1.15.2) (2024-07-15)
403
+
404
+
405
+ ### Bug Fixes
406
+
407
+ * alldebrid .fr to .com ([22c4445](https://github.com/g0ldyy/comet/commit/22c444573766bba40ac5d40fe83a0bc2fbf04ec3))
408
+ * int to float ([a0d72d8](https://github.com/g0ldyy/comet/commit/a0d72d8849b289a6f7c7be4e4219a46ccdd82ee2))
409
+
410
+ ## [1.15.1](https://github.com/g0ldyy/comet/compare/v1.15.0...v1.15.1) (2024-07-15)
411
+
412
+
413
+ ### Bug Fixes
414
+
415
+ * do the maths client side ([b0aa42c](https://github.com/g0ldyy/comet/commit/b0aa42c519767b61ed9d3dfdec7eceed79e127ae))
416
+
417
+ ## [1.15.0](https://github.com/g0ldyy/comet/compare/v1.14.2...v1.15.0) (2024-07-15)
418
+
419
+
420
+ ### Features
421
+
422
+ * faster, prowlarr pack support, max size, tracker name in results and more... ([0fabd79](https://github.com/g0ldyy/comet/commit/0fabd79a6e07b33fde76074ebbb5193cea7b9d10))
423
+ * realTitle in results for prowlarr support ([57440a9](https://github.com/g0ldyy/comet/commit/57440a9d08d2630ed084cfd07b374c9d9a96ef19))
424
+
425
+
426
+ ### Bug Fixes
427
+
428
+ * valid debrid api key not needed anymore if results already cached ([e94e224](https://github.com/g0ldyy/comet/commit/e94e2249a0ac9bd99eaee1f90dd3cdfd41bc43ba))
429
+
430
+ ## [1.14.2](https://github.com/g0ldyy/comet/compare/v1.14.1...v1.14.2) (2024-07-13)
431
+
432
+
433
+ ### Bug Fixes
434
+
435
+ * divising by 0 ([dcef22a](https://github.com/g0ldyy/comet/commit/dcef22a46d6331befae31d51a977ed714868366f))
436
+
437
+ ## [1.14.1](https://github.com/g0ldyy/comet/compare/v1.14.0...v1.14.1) (2024-07-12)
438
+
439
+
440
+ ### Bug Fixes
441
+
442
+ * speed up playback ([683a826](https://github.com/g0ldyy/comet/commit/683a82656aa35a90a891ef902f59acb967c078e4))
443
+
444
+ ## [1.14.0](https://github.com/g0ldyy/comet/compare/v1.13.0...v1.14.0) (2024-07-12)
445
+
446
+
447
+ ### Features
448
+
449
+ * Debrid-Link support ([dadca78](https://github.com/g0ldyy/comet/commit/dadca784b1ddddbbde1d7db59e2d12039a99f60a))
450
+
451
+
452
+ ### Bug Fixes
453
+
454
+ * alldebrid get files ([4bf8e88](https://github.com/g0ldyy/comet/commit/4bf8e88c0be7e82349581c8027f4ecb407ec99de))
455
+
456
+ ## [1.13.0](https://github.com/g0ldyy/comet/compare/v1.12.4...v1.13.0) (2024-07-11)
457
+
458
+
459
+ ### Features
460
+
461
+ * torbox integration ([db1a003](https://github.com/g0ldyy/comet/commit/db1a003a7b6225ea06dfd118cb8247dd2b385a1e))
462
+
463
+
464
+ ### Bug Fixes
465
+
466
+ * torbox faster (removed useless checks) ([dfaf12b](https://github.com/g0ldyy/comet/commit/dfaf12b6afcf7d1aa2d7d998bdf9dedef8ec0502))
467
+ * torbox ignore empty data ([f971255](https://github.com/g0ldyy/comet/commit/f971255c0f6da4207e015d0a7d779b9a89afdb91))
468
+ * useless repeated code ([fa8ce05](https://github.com/g0ldyy/comet/commit/fa8ce0546575eb7e93560dc25649ea9620a2e554))
469
+
470
+ ## [1.12.4](https://github.com/g0ldyy/comet/compare/v1.12.3...v1.12.4) (2024-07-10)
471
+
472
+
473
+ ### Bug Fixes
474
+
475
+ * realdebrid pack caching issue ([0a9eb03](https://github.com/g0ldyy/comet/commit/0a9eb03c5895fffaff8f13c6eb96d546487dcccd))
476
+
477
+ ## [1.12.3](https://github.com/g0ldyy/comet/compare/v1.12.2...v1.12.3) (2024-07-08)
478
+
479
+
480
+ ### Bug Fixes
481
+
482
+ * zilean multithreaded ([73b0a35](https://github.com/g0ldyy/comet/commit/73b0a35d38dd29c6b9ba4dad116f8f86f5086064))
483
+
484
+ ## [1.12.2](https://github.com/g0ldyy/comet/compare/v1.12.1...v1.12.2) (2024-07-08)
485
+
486
+
487
+ ### Bug Fixes
488
+
489
+ * lower not needed ([ff60d91](https://github.com/g0ldyy/comet/commit/ff60d91091f465db1c5b06eeb3ad8efd064f2c24))
490
+
491
+ ## [1.12.1](https://github.com/g0ldyy/comet/compare/v1.12.0...v1.12.1) (2024-07-08)
492
+
493
+
494
+ ### Bug Fixes
495
+
496
+ * wrong debrid stream proxy password warning being showed everytime ([0514484](https://github.com/g0ldyy/comet/commit/05144847976207a9780460a92e7c1b1ff20f10f1))
497
+
498
+ ## [1.12.0](https://github.com/g0ldyy/comet/compare/v1.11.2...v1.12.0) (2024-07-08)
499
+
500
+
501
+ ### Features
502
+
503
+ * wrong password warning for debrid stream proxy ([6b8303b](https://github.com/g0ldyy/comet/commit/6b8303b2745bf3191a60f0a9c25d0d2bd81c4436))
504
+
505
+ ## [1.11.2](https://github.com/g0ldyy/comet/compare/v1.11.1...v1.11.2) (2024-07-07)
506
+
507
+
508
+ ### Bug Fixes
509
+
510
+ * prowlarr ([a6179bf](https://github.com/g0ldyy/comet/commit/a6179bf3b029619286edbc1a7746091d0d254d7b))
511
+
512
+ ## [1.11.1](https://github.com/g0ldyy/comet/compare/v1.11.0...v1.11.1) (2024-07-07)
513
+
514
+
515
+ ### Bug Fixes
516
+
517
+ * webui copy button for non secured environments ([8eda672](https://github.com/g0ldyy/comet/commit/8eda6720ff3b27bc748b9329fc0a5442310aa291))
518
+
519
+ ## [1.11.0](https://github.com/g0ldyy/comet/compare/v1.10.0...v1.11.0) (2024-07-07)
520
+
521
+
522
+ ### Features
523
+
524
+ * pack support for alldebrid ([30fe1ef](https://github.com/g0ldyy/comet/commit/30fe1ef6bd97aec5545aa808bf77db9ae4a8d4fa))
525
+ * zilean only mode ([123378f](https://github.com/g0ldyy/comet/commit/123378ff351ed4b6df15f0a33c6d1227f6f91fc5))
526
+
527
+
528
+ ### Bug Fixes
529
+
530
+ * zilean filtering speed fixed ([dad68c2](https://github.com/g0ldyy/comet/commit/dad68c256e93df99a3aa5ed810dc495dc67d739d))
531
+
532
+ ## [1.10.0](https://github.com/g0ldyy/comet/compare/v1.9.1...v1.10.0) (2024-07-07)
533
+
534
+
535
+ ### Features
536
+
537
+ * premiumize support ([ab846a7](https://github.com/g0ldyy/comet/commit/ab846a76134fa2c0ebf6091a878bf3f0aeb93ff4))
538
+
539
+
540
+ ### Bug Fixes
541
+
542
+ * proxy is not needed with premiumize ([82fb354](https://github.com/g0ldyy/comet/commit/82fb354ed10a471f1ac3d9b807af71c1ae6c80de))
543
+
544
+ ## [1.9.1](https://github.com/g0ldyy/comet/compare/v1.9.0...v1.9.1) (2024-07-06)
545
+
546
+
547
+ ### Bug Fixes
548
+
549
+ * easier for elfhosted to process ([6443fa1](https://github.com/g0ldyy/comet/commit/6443fa1b5fe601cbdf27e208bd80feaf3ac3156d))
550
+ * log error ([9fb92eb](https://github.com/g0ldyy/comet/commit/9fb92eb3780e8b312cdb97dd566f699846eaec4e))
551
+
552
+ ## [1.9.0](https://github.com/g0ldyy/comet/compare/v1.8.1...v1.9.0) (2024-07-06)
553
+
554
+
555
+ ### Features
556
+
557
+ * ui improvements ([9a94f0f](https://github.com/g0ldyy/comet/commit/9a94f0fc272c07185f16ecbb0463335a04b6a77f))
558
+
559
+ ## [1.8.1](https://github.com/g0ldyy/comet/compare/v1.8.0...v1.8.1) (2024-07-06)
560
+
561
+
562
+ ### Bug Fixes
563
+
564
+ * debrid stream proxy dynamic input field ([2e0a219](https://github.com/g0ldyy/comet/commit/2e0a219ca523e4f9f4e1fdd1301e651f2846470e))
565
+
566
+ ## [1.8.0](https://github.com/g0ldyy/comet/compare/v1.7.0...v1.8.0) (2024-07-06)
567
+
568
+
569
+ ### Features
570
+
571
+ * improve debrid stream proxy ([60710fa](https://github.com/g0ldyy/comet/commit/60710faa41d732c441fdd76a03c20b8649c7274d))
572
+
573
+
574
+ ### Bug Fixes
575
+
576
+ * logs ([8743e49](https://github.com/g0ldyy/comet/commit/8743e4973b0db85d252fca321f04f23f0ca54a55))
577
+
578
+ ## [1.7.0](https://github.com/g0ldyy/comet/compare/v1.6.2...v1.7.0) (2024-07-05)
579
+
580
+
581
+ ### Features
582
+
583
+ * cosmetics + important fixes ([a1441c8](https://github.com/g0ldyy/comet/commit/a1441c8d9a0bc788caad359e823034a709c1cc2c))
584
+
585
+ ## [1.6.2](https://github.com/g0ldyy/comet/compare/v1.6.1...v1.6.2) (2024-07-05)
586
+
587
+
588
+ ### Bug Fixes
589
+
590
+ * I forgot something I need to release for elfhosted bruh ([14d6ebf](https://github.com/g0ldyy/comet/commit/14d6ebf0f43c87d6e199e6fdd57a02bfa6acc973))
591
+
592
+ ## [1.6.1](https://github.com/g0ldyy/comet/compare/v1.6.0...v1.6.1) (2024-07-05)
593
+
594
+
595
+ ### Bug Fixes
596
+
597
+ * alldebrid stream proxy ([1502d4c](https://github.com/g0ldyy/comet/commit/1502d4cf17e785b5972d781a185eda1dade119dd))
598
+
599
+ ## [1.6.0](https://github.com/g0ldyy/comet/compare/v1.5.1...v1.6.0) (2024-07-05)
600
+
601
+
602
+ ### Features
603
+
604
+ * alldebrid support ([afd27c0](https://github.com/g0ldyy/comet/commit/afd27c083da37204797246450619a4f9c1a7fc89))
605
+
606
+ ## [1.5.1](https://github.com/g0ldyy/comet/compare/v1.5.0...v1.5.1) (2024-07-05)
607
+
608
+
609
+ ### Bug Fixes
610
+
611
+ * imdb metadata api returning "Summer Watch Guide" ([e9af38b](https://github.com/g0ldyy/comet/commit/e9af38bdc1c1d0aea225ef10f201658ce4b749c6))
612
+
613
+ ## [1.5.0](https://github.com/g0ldyy/comet/compare/v1.4.0...v1.5.0) (2024-07-04)
614
+
615
+
616
+ ### Features
617
+
618
+ * insane new debrid stream proxy (allows to use debrid service on multiple IPs at same time) ([ba1f78e](https://github.com/g0ldyy/comet/commit/ba1f78eb84fda5e4d3b9f488d5fbde46fa57317d))
619
+
620
+
621
+ ### Bug Fixes
622
+
623
+ * try to fix session unclosed issue with debrid stream proxy ([1f63113](https://github.com/g0ldyy/comet/commit/1f63113d8d418a8101cea925625f6d1d0cef5cf7))
624
+
625
+ ## [1.4.0](https://github.com/g0ldyy/comet/compare/v1.3.3...v1.4.0) (2024-07-04)
626
+
627
+
628
+ ### Features
629
+
630
+ * add option to toggle title checking ([bbb257d](https://github.com/g0ldyy/comet/commit/bbb257dda87875bfcb0d236d1cd82e9a3781fdef))
631
+
632
+ ## [1.3.3](https://github.com/g0ldyy/comet/compare/v1.3.2...v1.3.3) (2024-07-03)
633
+
634
+
635
+ ### Bug Fixes
636
+
637
+ * 0.30ms faster :pro: ([6b1daa6](https://github.com/g0ldyy/comet/commit/6b1daa61a0106d6557047059348ab6e7caecb693))
638
+
639
+ ## [1.3.2](https://github.com/g0ldyy/comet/compare/v1.3.1...v1.3.2) (2024-07-03)
640
+
641
+
642
+ ### Bug Fixes
643
+
644
+ * only show stars for non mobile users (performance issue) ([7415984](https://github.com/g0ldyy/comet/commit/741598497eedbb4be3c75e89470077e68ed3528d))
645
+
646
  ## [1.3.1](https://github.com/g0ldyy/comet/compare/v1.3.0...v1.3.1) (2024-07-03)
647
 
648
 
Dockerfile CHANGED
@@ -1,30 +1,28 @@
1
- FROM python:3.11-alpine
2
- LABEL name="Comet" \
3
- description="Stremio's fastest torrent/debrid search add-on." \
4
- url="https://github.com/g0ldyy/comet"
5
-
6
- WORKDIR /app
7
-
8
- ARG DATABASE_PATH
9
-
10
- ENV PYTHONUNBUFFERED=1 \
11
- PYTHONDONTWRITEBYTECODE=1 \
12
- POETRY_NO_INTERACTION=1 \
13
- POETRY_HOME="/usr/local" \
14
- FORCE_COLOR=1 \
15
- TERM=xterm-256color
16
-
17
- # Fix python-alpine gcc
18
- RUN apk add --no-cache \
19
- gcc \
20
- musl-dev \
21
- libffi-dev \
22
- make
23
-
24
- RUN pip install poetry
25
- RUN mkdir -p /root/.cache/pypoetry/virtualenvs
26
- RUN chmod 777 /root/.cache/pypoetry/virtualenvs
27
- COPY . .
28
- RUN poetry install --no-cache --no-root --without dev
29
-
30
- ENTRYPOINT ["poetry", "run", "python", "-m", "comet.main"]
 
1
+ FROM python:3.11-alpine
2
+ LABEL name="Comet" \
3
+ description="Stremio's fastest torrent/debrid search add-on." \
4
+ url="https://github.com/g0ldyy/comet"
5
+
6
+ WORKDIR /app
7
+
8
+ ARG DATABASE_PATH
9
+
10
+ ENV PYTHONUNBUFFERED=1 \
11
+ PYTHONDONTWRITEBYTECODE=1 \
12
+ POETRY_NO_INTERACTION=1 \
13
+ POETRY_HOME="/usr/local" \
14
+ FORCE_COLOR=1 \
15
+ TERM=xterm-256color
16
+
17
+ # Fix python-alpine gcc
18
+ RUN apk add --no-cache \
19
+ gcc \
20
+ musl-dev \
21
+ libffi-dev \
22
+ make
23
+
24
+ RUN pip install poetry
25
+ COPY . .
26
+ RUN poetry install --no-cache --no-root --without dev
27
+
28
+ ENTRYPOINT ["poetry", "run", "python", "-m", "comet.main"]
 
 
comet/api/core.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import RTN
2
 
3
  from fastapi import APIRouter, Request
@@ -5,6 +6,7 @@ from fastapi.responses import RedirectResponse
5
  from fastapi.templating import Jinja2Templates
6
 
7
  from comet.utils.models import settings
 
8
 
9
  templates = Jinja2Templates("comet/templates")
10
  main = APIRouter()
@@ -21,23 +23,13 @@ async def health():
21
 
22
 
23
  indexers = settings.INDEXER_MANAGER_INDEXERS
 
 
24
  web_config = {
25
  "indexers": [indexer.replace(" ", "_").lower() for indexer in indexers],
26
- "languages": [
27
- language.replace(" ", "_")
28
- for language in RTN.patterns.language_code_mapping.keys()
29
- ],
30
- "resolutions": [
31
- "360p",
32
- "480p",
33
- "576p",
34
- "720p",
35
- "1080p",
36
- "1440p",
37
- "2160p",
38
- "4K",
39
- "Unknown",
40
- ],
41
  }
42
 
43
 
@@ -49,26 +41,39 @@ async def configure(request: Request):
49
  {
50
  "request": request,
51
  "CUSTOM_HEADER_HTML": settings.CUSTOM_HEADER_HTML
52
- if settings.CUSTOM_HEADER_HTML and settings.CUSTOM_HEADER_HTML != "None"
53
  else "",
54
  "webConfig": web_config,
 
 
55
  },
56
  )
57
 
58
 
59
  @main.get("/manifest.json")
60
  @main.get("/{b64config}/manifest.json")
61
- async def manifest():
 
 
 
 
 
 
62
  return {
63
  "id": settings.ADDON_ID,
64
- "version": "1.0.0",
65
- "name": settings.ADDON_NAME,
66
  "description": "Stremio's fastest torrent/debrid search add-on.",
 
 
 
 
 
 
 
 
 
 
67
  "logo": "https://i.imgur.com/jmVoVMu.jpeg",
68
  "background": "https://i.imgur.com/WwnXB3k.jpeg",
69
- "resources": ["stream"],
70
- "types": ["movie", "series"],
71
- "idPrefixes": ["tt"],
72
- "catalogs": [],
73
- "behaviorHints": {"configurable": True},
74
  }
 
1
+ import PTT
2
  import RTN
3
 
4
  from fastapi import APIRouter, Request
 
6
  from fastapi.templating import Jinja2Templates
7
 
8
  from comet.utils.models import settings
9
+ from comet.utils.general import config_check, get_debrid_extension
10
 
11
  templates = Jinja2Templates("comet/templates")
12
  main = APIRouter()
 
23
 
24
 
25
  indexers = settings.INDEXER_MANAGER_INDEXERS
26
+ languages = [language for language in PTT.parse.LANGUAGES_TRANSLATION_TABLE.values()]
27
+ languages.insert(0, "Multi")
28
  web_config = {
29
  "indexers": [indexer.replace(" ", "_").lower() for indexer in indexers],
30
+ "languages": languages,
31
+ "resolutions": [resolution.value for resolution in RTN.models.Resolution],
32
+ "resultFormat": ["Title", "Metadata", "Size", "Tracker", "Languages"],
 
 
 
 
 
 
 
 
 
 
 
 
33
  }
34
 
35
 
 
41
  {
42
  "request": request,
43
  "CUSTOM_HEADER_HTML": settings.CUSTOM_HEADER_HTML
44
+ if settings.CUSTOM_HEADER_HTML
45
  else "",
46
  "webConfig": web_config,
47
+ "indexerManager": settings.INDEXER_MANAGER_TYPE,
48
+ "proxyDebridStream": settings.PROXY_DEBRID_STREAM,
49
  },
50
  )
51
 
52
 
53
  @main.get("/manifest.json")
54
  @main.get("/{b64config}/manifest.json")
55
+ async def manifest(b64config: str = None):
56
+ config = config_check(b64config)
57
+ if not config:
58
+ config = {"debridService": None}
59
+
60
+ debrid_extension = get_debrid_extension(config["debridService"])
61
+
62
  return {
63
  "id": settings.ADDON_ID,
64
+ "name": f"{settings.ADDON_NAME}{(' | ' + debrid_extension) if debrid_extension is not None else ''}",
 
65
  "description": "Stremio's fastest torrent/debrid search add-on.",
66
+ "version": "1.0.0",
67
+ "catalogs": [],
68
+ "resources": [
69
+ {
70
+ "name": "stream",
71
+ "types": ["movie", "series"],
72
+ "idPrefixes": ["tt", "kitsu"],
73
+ }
74
+ ],
75
+ "types": ["movie", "series", "anime", "other"],
76
  "logo": "https://i.imgur.com/jmVoVMu.jpeg",
77
  "background": "https://i.imgur.com/WwnXB3k.jpeg",
78
+ "behaviorHints": {"configurable": True, "configurationRequired": False},
 
 
 
 
79
  }
comet/api/stream.py CHANGED
@@ -3,21 +3,34 @@ import hashlib
3
  import json
4
  import time
5
  import aiohttp
 
 
 
6
 
7
  from fastapi import APIRouter, Request
8
- from fastapi.responses import RedirectResponse
9
- from RTN import Torrent, parse, sort_torrents, title_match
 
 
 
 
 
 
10
 
11
  from comet.debrid.manager import getDebrid
12
-
13
  from comet.utils.general import (
14
- bytes_to_size,
15
  config_check,
 
16
  get_indexer_manager,
 
 
 
 
17
  get_torrent_hash,
18
- is_video,
19
  translate,
20
  get_balanced_hashes,
 
 
21
  )
22
  from comet.utils.logger import logger
23
  from comet.utils.models import database, rtn, settings
@@ -42,39 +55,61 @@ async def stream(request: Request, b64config: str, type: str, id: str):
42
 
43
  connector = aiohttp.TCPConnector(limit=0)
44
  async with aiohttp.ClientSession(connector=connector) as session:
45
- debrid = getDebrid(session, config)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
- check_debrid = await debrid.check_premium()
48
- if not check_debrid:
49
  return {
50
  "streams": [
51
  {
52
  "name": "[⚠️] Comet",
53
- "title": f"Invalid {config['debridService']} account.",
54
  "url": "https://comet.fast",
55
  }
56
  ]
57
  }
58
 
59
- season = None
60
- episode = None
61
- if type == "series":
62
- info = id.split(":")
63
-
64
- id = info[0]
65
- season = int(info[1])
66
- episode = int(info[2])
67
-
68
- get_metadata = await session.get(
69
- f"https://v3.sg.media-imdb.com/suggestion/a/{id}.json"
70
- )
71
- metadata = await get_metadata.json()
72
-
73
- name = metadata["d"][0]["l"]
74
  name = translate(name)
75
- logName = name
76
  if type == "series":
77
- logName = f"{name} S{season:02d}E{episode:02d}"
78
 
79
  cache_key = hashlib.md5(
80
  json.dumps(
@@ -91,7 +126,7 @@ async def stream(request: Request, b64config: str, type: str, id: str):
91
  f"SELECT EXISTS (SELECT 1 FROM cache WHERE cacheKey = '{cache_key}')"
92
  )
93
  if cached[0] != 0:
94
- logger.info(f"Cache found for {logName}")
95
 
96
  timestamp = await database.fetch_one(
97
  f"SELECT timestamp FROM cache WHERE cacheKey = '{cache_key}'"
@@ -101,23 +136,58 @@ async def stream(request: Request, b64config: str, type: str, id: str):
101
  f"DELETE FROM cache WHERE cacheKey = '{cache_key}'"
102
  )
103
 
104
- logger.info(f"Cache expired for {logName}")
105
  else:
106
  sorted_ranked_files = await database.fetch_one(
107
  f"SELECT results FROM cache WHERE cacheKey = '{cache_key}'"
108
  )
109
  sorted_ranked_files = json.loads(sorted_ranked_files[0])
110
 
111
- balanced_hashes = await get_balanced_hashes(sorted_ranked_files, config)
 
 
 
112
  results = []
113
- for hash in sorted_ranked_files:
114
- for resolution in balanced_hashes:
115
- if hash in balanced_hashes[resolution]:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  results.append(
117
  {
118
- "name": f"[RD⚡] Comet {sorted_ranked_files[hash]['data']['resolution'][0] if len(sorted_ranked_files[hash]['data']['resolution']) > 0 else 'Unknown'}",
119
- "title": f"{sorted_ranked_files[hash]['data']['title']}\n💾 {bytes_to_size(sorted_ranked_files[hash]['data']['size'])}",
120
- "url": f"{request.url.scheme}://{request.url.netloc}/{b64config}/playback/{hash}/{sorted_ranked_files[hash]['data']['index']}",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  }
122
  )
123
 
@@ -125,199 +195,256 @@ async def stream(request: Request, b64config: str, type: str, id: str):
125
 
126
  return {"streams": results}
127
  else:
128
- logger.info(f"No cache found for {logName} with user configuration")
 
 
 
 
 
 
 
 
 
 
 
129
 
130
- indexer_manager_type = settings.INDEXER_MANAGER_TYPE
131
 
132
- logger.info(
133
- f"Start of {indexer_manager_type} search for {logName} with indexers {config['indexers']}"
134
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
 
 
 
136
  tasks = []
137
- tasks.append(
138
- get_indexer_manager(session, indexer_manager_type, config["indexers"], name)
139
- )
140
- if type == "series":
141
- tasks.append(
 
 
 
 
 
 
 
142
  get_indexer_manager(
143
- session,
144
- indexer_manager_type,
145
- config["indexers"],
146
- f"{name} S0{season}E0{episode}",
147
  )
 
 
 
 
 
148
  )
149
- search_response = await asyncio.gather(*tasks)
150
 
151
- torrents = []
152
- for results in search_response:
153
- if results == None:
154
- continue
 
155
 
 
 
 
 
 
156
  for result in results:
157
  torrents.append(result)
158
 
159
  logger.info(
160
- f"{len(torrents)} torrents found for {logName} with {indexer_manager_type}"
161
- )
162
-
163
- zilean_hashes_count = 0
164
- try:
165
- if settings.ZILEAN_URL:
166
- get_dmm = await session.post(
167
- f"{settings.ZILEAN_URL}/dmm/search", json={"queryText": name}
 
 
 
 
168
  )
169
- get_dmm = await get_dmm.json()
170
-
171
- if "status" not in get_dmm:
172
- for result in get_dmm:
173
- zilean_hashes_count += 1
 
 
 
 
 
 
174
 
175
- if indexer_manager_type == "jackett":
176
- object = {
177
- "Title": result["filename"],
178
- "InfoHash": result["infoHash"],
179
- "zilean": True,
180
- }
181
 
182
- if indexer_manager_type == "prowlarr":
183
- object = {
184
- "title": result["filename"],
185
- "infoHash": result["infoHash"],
186
- "zilean": True,
187
- }
 
188
 
189
- torrents.append(object)
 
 
 
 
 
 
 
 
 
 
 
190
 
191
  logger.info(
192
- f"{zilean_hashes_count} torrents found for {logName} with Zilean API"
193
- )
194
- except:
195
- logger.warning(
196
- f"Exception while getting torrents for {logName} with Zilean API"
197
  )
198
 
199
- if len(torrents) == 0:
200
- return {"streams": []}
201
 
202
  tasks = []
203
- filtered = 0
204
- for torrent in torrents:
205
- # Only title match check if from Zilean
206
- if "zilean" in torrent:
207
- parsed_torrent = parse(
208
- torrent["Title"]
209
- if indexer_manager_type == "jackett"
210
- else torrent["title"]
211
- )
212
- if not title_match(name.lower(), parsed_torrent.parsed_title.lower()):
213
- filtered += 1
214
- continue
215
-
216
- tasks.append(get_torrent_hash(session, indexer_manager_type, torrent))
217
-
218
- logger.info(f"{filtered} filtered torrents from Zilean API for {logName}")
219
 
220
  torrent_hashes = await asyncio.gather(*tasks)
221
- torrent_hashes = list(set([hash for hash in torrent_hashes if hash]))
222
-
223
- logger.info(f"{len(torrent_hashes)} info hashes found for {logName}")
224
-
225
- torrent_hashes = list(set([hash for hash in torrent_hashes if hash]))
226
-
227
- if len(torrent_hashes) == 0:
228
- return {"streams": []}
229
-
230
- tasks = []
231
  for hash in torrent_hashes:
232
- tasks.append(debrid.check_hash_cache(hash))
233
-
234
- responses = await asyncio.gather(*tasks)
235
-
236
- availability = {}
237
- for response in responses:
238
- if not response:
239
  continue
240
 
241
- availability.update(await response.json())
242
-
243
- files = {}
244
- for hash, details in availability.items():
245
- if "rd" not in details:
246
- continue
247
-
248
- if type == "series":
249
- for variants in details["rd"]:
250
- for index, file in variants.items():
251
- filename = file["filename"]
252
-
253
- if not is_video(filename):
254
- continue
255
-
256
- filename_parsed = parse(filename)
257
- if (
258
- season in filename_parsed.season
259
- and episode in filename_parsed.episode
260
- ):
261
- files[hash] = {
262
- "index": index,
263
- "title": filename,
264
- "size": file["filesize"],
265
- }
266
-
267
- continue
268
 
269
- for variants in details["rd"]:
270
- for index, file in variants.items():
271
- filename = file["filename"]
272
 
273
- if not is_video(filename):
274
- continue
275
 
276
- files[hash] = {
277
- "index": index,
278
- "title": filename,
279
- "size": file["filesize"],
280
- }
 
 
281
 
282
  ranked_files = set()
283
  for hash in files:
284
- ranked_file = rtn.rank(files[hash]["title"], hash)
285
- ranked_files.add(ranked_file)
 
 
 
 
 
 
 
286
 
287
  sorted_ranked_files = sort_torrents(ranked_files)
288
 
 
289
  logger.info(
290
- f"{len(sorted_ranked_files)} cached files found on Real-Debrid for {logName}"
291
  )
292
 
293
- if len(sorted_ranked_files) == 0:
 
 
 
 
 
 
 
 
 
 
 
294
  return {"streams": []}
295
 
296
  sorted_ranked_files = {
297
  key: (value.model_dump() if isinstance(value, Torrent) else value)
298
  for key, value in sorted_ranked_files.items()
299
  }
 
300
  for hash in sorted_ranked_files: # needed for caching
301
  sorted_ranked_files[hash]["data"]["title"] = files[hash]["title"]
 
 
 
 
 
 
302
  sorted_ranked_files[hash]["data"]["size"] = files[hash]["size"]
 
 
 
 
303
  sorted_ranked_files[hash]["data"]["index"] = files[hash]["index"]
304
 
305
  json_data = json.dumps(sorted_ranked_files).replace("'", "''")
306
  await database.execute(
307
- f"INSERT OR IGNORE INTO cache (cacheKey, results, timestamp) VALUES ('{cache_key}', '{json_data}', {time.time()})"
 
308
  )
309
- logger.info(f"Results have been cached for {logName}")
 
 
 
 
310
 
311
- balanced_hashes = await get_balanced_hashes(sorted_ranked_files, config)
312
  results = []
313
- for hash in sorted_ranked_files:
314
- for resolution in balanced_hashes:
315
- if hash in balanced_hashes[resolution]:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  results.append(
317
  {
318
- "name": f"[RD⚡] Comet {sorted_ranked_files[hash]['data']['resolution'][0] if len(sorted_ranked_files[hash]['data']['resolution']) > 0 else 'Unknown'}",
319
- "title": f"{sorted_ranked_files[hash]['data']['title']}\n💾 {bytes_to_size(sorted_ranked_files[hash]['data']['size'])}",
320
- "url": f"{request.url.scheme}://{request.url.netloc}/{b64config}/playback/{hash}/{sorted_ranked_files[hash]['data']['index']}",
 
 
 
 
 
 
321
  }
322
  )
323
 
@@ -328,25 +455,175 @@ async def stream(request: Request, b64config: str, type: str, id: str):
328
 
329
  @streams.head("/{b64config}/playback/{hash}/{index}")
330
  async def playback(b64config: str, hash: str, index: str):
331
- config = config_check(b64config)
332
- if not config:
333
- return
334
 
335
- async with aiohttp.ClientSession() as session:
336
- debrid = getDebrid(session, config)
337
- download_link = await debrid.generate_download_link(hash, index)
338
 
339
- return RedirectResponse(download_link, status_code=302)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
340
 
341
 
342
  @streams.get("/{b64config}/playback/{hash}/{index}")
343
- async def playback(b64config: str, hash: str, index: str):
344
  config = config_check(b64config)
345
  if not config:
346
- return
 
 
 
 
 
 
 
 
347
 
348
  async with aiohttp.ClientSession() as session:
349
- debrid = getDebrid(session, config)
350
- download_link = await debrid.generate_download_link(hash, index)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
351
 
352
- return RedirectResponse(download_link, status_code=302)
 
3
  import json
4
  import time
5
  import aiohttp
6
+ import httpx
7
+ import uuid
8
+ import orjson
9
 
10
  from fastapi import APIRouter, Request
11
+ from fastapi.responses import (
12
+ RedirectResponse,
13
+ StreamingResponse,
14
+ FileResponse,
15
+ Response,
16
+ )
17
+ from starlette.background import BackgroundTask
18
+ from RTN import Torrent, sort_torrents
19
 
20
  from comet.debrid.manager import getDebrid
 
21
  from comet.utils.general import (
 
22
  config_check,
23
+ get_debrid_extension,
24
  get_indexer_manager,
25
+ get_zilean,
26
+ get_torrentio,
27
+ get_mediafusion,
28
+ filter,
29
  get_torrent_hash,
 
30
  translate,
31
  get_balanced_hashes,
32
+ format_title,
33
+ get_client_ip,
34
  )
35
  from comet.utils.logger import logger
36
  from comet.utils.models import database, rtn, settings
 
55
 
56
  connector = aiohttp.TCPConnector(limit=0)
57
  async with aiohttp.ClientSession(connector=connector) as session:
58
+ full_id = id
59
+ season = None
60
+ episode = None
61
+ if type == "series":
62
+ info = id.split(":")
63
+ id = info[0]
64
+ season = int(info[1])
65
+ episode = int(info[2])
66
+
67
+ try:
68
+ kitsu = False
69
+ if id == "kitsu":
70
+ kitsu = True
71
+ get_metadata = await session.get(
72
+ f"https://kitsu.io/api/edge/anime/{season}"
73
+ )
74
+ metadata = await get_metadata.json()
75
+ name = metadata["data"]["attributes"]["canonicalTitle"]
76
+ season = 1
77
+ year = None
78
+ else:
79
+ get_metadata = await session.get(
80
+ f"https://v3.sg.media-imdb.com/suggestion/a/{id}.json"
81
+ )
82
+ metadata = await get_metadata.json()
83
+ element = metadata["d"][
84
+ 0
85
+ if metadata["d"][0]["id"]
86
+ not in ["/imdbpicks/summer-watch-guide", "/emmys"]
87
+ else 1
88
+ ]
89
+
90
+ for element in metadata["d"]:
91
+ if "/" not in element["id"]:
92
+ break
93
+
94
+ name = element["l"]
95
+ year = element.get("y")
96
+ except Exception as e:
97
+ logger.warning(f"Exception while getting metadata for {id}: {e}")
98
 
 
 
99
  return {
100
  "streams": [
101
  {
102
  "name": "[⚠️] Comet",
103
+ "title": f"Can't get metadata for {id}",
104
  "url": "https://comet.fast",
105
  }
106
  ]
107
  }
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  name = translate(name)
110
+ log_name = name
111
  if type == "series":
112
+ log_name = f"{name} S0{season}E0{episode}"
113
 
114
  cache_key = hashlib.md5(
115
  json.dumps(
 
126
  f"SELECT EXISTS (SELECT 1 FROM cache WHERE cacheKey = '{cache_key}')"
127
  )
128
  if cached[0] != 0:
129
+ logger.info(f"Cache found for {log_name}")
130
 
131
  timestamp = await database.fetch_one(
132
  f"SELECT timestamp FROM cache WHERE cacheKey = '{cache_key}'"
 
136
  f"DELETE FROM cache WHERE cacheKey = '{cache_key}'"
137
  )
138
 
139
+ logger.info(f"Cache expired for {log_name}")
140
  else:
141
  sorted_ranked_files = await database.fetch_one(
142
  f"SELECT results FROM cache WHERE cacheKey = '{cache_key}'"
143
  )
144
  sorted_ranked_files = json.loads(sorted_ranked_files[0])
145
 
146
+ debrid_extension = get_debrid_extension(config["debridService"])
147
+
148
+ balanced_hashes = get_balanced_hashes(sorted_ranked_files, config)
149
+
150
  results = []
151
+ if (
152
+ config["debridStreamProxyPassword"] != ""
153
+ and settings.PROXY_DEBRID_STREAM
154
+ and settings.PROXY_DEBRID_STREAM_PASSWORD
155
+ != config["debridStreamProxyPassword"]
156
+ ):
157
+ results.append(
158
+ {
159
+ "name": "[⚠️] Comet",
160
+ "title": "Debrid Stream Proxy Password incorrect.\nStreams will not be proxied.",
161
+ "url": "https://comet.fast",
162
+ }
163
+ )
164
+
165
+ for (
166
+ hash,
167
+ hash_data,
168
+ ) in sorted_ranked_files.items():
169
+ for resolution, hash_list in balanced_hashes.items():
170
+ if hash in hash_list:
171
+ data = hash_data["data"]
172
  results.append(
173
  {
174
+ "name": f"[{debrid_extension}⚡] Comet {data['resolution']}",
175
+ "title": format_title(data, config),
176
+ "torrentTitle": (
177
+ data["torrent_title"]
178
+ if "torrent_title" in data
179
+ else None
180
+ ),
181
+ "torrentSize": (
182
+ data["torrent_size"]
183
+ if "torrent_size" in data
184
+ else None
185
+ ),
186
+ "url": f"{request.url.scheme}://{request.url.netloc}/{b64config}/playback/{hash}/{data['index']}",
187
+ "behaviorHints": {
188
+ "filename": data["raw_title"],
189
+ "bingeGroup": "comet|" + hash,
190
+ },
191
  }
192
  )
193
 
 
195
 
196
  return {"streams": results}
197
  else:
198
+ logger.info(f"No cache found for {log_name} with user configuration")
199
+
200
+ if (
201
+ settings.PROXY_DEBRID_STREAM
202
+ and settings.PROXY_DEBRID_STREAM_PASSWORD
203
+ == config["debridStreamProxyPassword"]
204
+ and config["debridApiKey"] == ""
205
+ ):
206
+ config["debridService"] = (
207
+ settings.PROXY_DEBRID_STREAM_DEBRID_DEFAULT_SERVICE
208
+ )
209
+ config["debridApiKey"] = settings.PROXY_DEBRID_STREAM_DEBRID_DEFAULT_APIKEY
210
 
211
+ debrid = getDebrid(session, config, get_client_ip(request))
212
 
213
+ check_premium = await debrid.check_premium()
214
+ if not check_premium:
215
+ additional_info = ""
216
+ if config["debridService"] == "alldebrid":
217
+ additional_info = "\nCheck your email!"
218
+
219
+ return {
220
+ "streams": [
221
+ {
222
+ "name": "[⚠️] Comet",
223
+ "title": f"Invalid {config['debridService']} account.{additional_info}",
224
+ "url": "https://comet.fast",
225
+ }
226
+ ]
227
+ }
228
+
229
+ indexer_manager_type = settings.INDEXER_MANAGER_TYPE
230
 
231
+ search_indexer = len(config["indexers"]) != 0
232
+ torrents = []
233
  tasks = []
234
+ if indexer_manager_type and search_indexer:
235
+ logger.info(
236
+ f"Start of {indexer_manager_type} search for {log_name} with indexers {config['indexers']}"
237
+ )
238
+
239
+ search_terms = [name]
240
+ if type == "series":
241
+ if not kitsu:
242
+ search_terms.append(f"{name} S0{season}E0{episode}")
243
+ else:
244
+ search_terms.append(f"{name} {episode}")
245
+ tasks.extend(
246
  get_indexer_manager(
247
+ session, indexer_manager_type, config["indexers"], term
 
 
 
248
  )
249
+ for term in search_terms
250
+ )
251
+ else:
252
+ logger.info(
253
+ f"No indexer {'manager ' if not indexer_manager_type else ''}{'selected by user' if indexer_manager_type else 'defined'} for {log_name}"
254
  )
 
255
 
256
+ if settings.ZILEAN_URL:
257
+ tasks.append(get_zilean(session, name, log_name, season, episode))
258
+
259
+ if settings.SCRAPE_TORRENTIO:
260
+ tasks.append(get_torrentio(log_name, type, full_id))
261
 
262
+ if settings.SCRAPE_MEDIAFUSION:
263
+ tasks.append(get_mediafusion(log_name, type, full_id))
264
+
265
+ search_response = await asyncio.gather(*tasks)
266
+ for results in search_response:
267
  for result in results:
268
  torrents.append(result)
269
 
270
  logger.info(
271
+ f"{len(torrents)} torrents found for {log_name}"
272
+ + (
273
+ " with "
274
+ + ", ".join(
275
+ part
276
+ for part in [
277
+ indexer_manager_type,
278
+ "Zilean" if settings.ZILEAN_URL else None,
279
+ "Torrentio" if settings.SCRAPE_TORRENTIO else None,
280
+ "MediaFusion" if settings.SCRAPE_MEDIAFUSION else None,
281
+ ]
282
+ if part
283
  )
284
+ if any(
285
+ [
286
+ indexer_manager_type,
287
+ settings.ZILEAN_URL,
288
+ settings.SCRAPE_TORRENTIO,
289
+ settings.SCRAPE_MEDIAFUSION,
290
+ ]
291
+ )
292
+ else ""
293
+ )
294
+ )
295
 
296
+ if len(torrents) == 0:
297
+ return {"streams": []}
 
 
 
 
298
 
299
+ if settings.TITLE_MATCH_CHECK:
300
+ indexed_torrents = [(i, torrents[i]["Title"]) for i in range(len(torrents))]
301
+ chunk_size = 50
302
+ chunks = [
303
+ indexed_torrents[i : i + chunk_size]
304
+ for i in range(0, len(indexed_torrents), chunk_size)
305
+ ]
306
 
307
+ tasks = []
308
+ for chunk in chunks:
309
+ tasks.append(filter(chunk, name, year))
310
+
311
+ filtered_torrents = await asyncio.gather(*tasks)
312
+ index_less = 0
313
+ for result in filtered_torrents:
314
+ for filtered in result:
315
+ if not filtered[1]:
316
+ del torrents[filtered[0] - index_less]
317
+ index_less += 1
318
+ continue
319
 
320
  logger.info(
321
+ f"{len(torrents)} torrents passed title match check for {log_name}"
 
 
 
 
322
  )
323
 
324
+ if len(torrents) == 0:
325
+ return {"streams": []}
326
 
327
  tasks = []
328
+ for i in range(len(torrents)):
329
+ tasks.append(get_torrent_hash(session, (i, torrents[i])))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
 
331
  torrent_hashes = await asyncio.gather(*tasks)
332
+ index_less = 0
 
 
 
 
 
 
 
 
 
333
  for hash in torrent_hashes:
334
+ if not hash[1]:
335
+ del torrents[hash[0] - index_less]
336
+ index_less += 1
 
 
 
 
337
  continue
338
 
339
+ torrents[hash[0] - index_less]["InfoHash"] = hash[1]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
340
 
341
+ logger.info(f"{len(torrents)} info hashes found for {log_name}")
 
 
342
 
343
+ if len(torrents) == 0:
344
+ return {"streams": []}
345
 
346
+ files = await debrid.get_files(
347
+ [hash[1] for hash in torrent_hashes if hash[1] is not None],
348
+ type,
349
+ season,
350
+ episode,
351
+ kitsu,
352
+ )
353
 
354
  ranked_files = set()
355
  for hash in files:
356
+ try:
357
+ ranked_file = rtn.rank(
358
+ files[hash]["title"],
359
+ hash, # , correct_title=name, remove_trash=True
360
+ )
361
+
362
+ ranked_files.add(ranked_file)
363
+ except:
364
+ pass
365
 
366
  sorted_ranked_files = sort_torrents(ranked_files)
367
 
368
+ len_sorted_ranked_files = len(sorted_ranked_files)
369
  logger.info(
370
+ f"{len_sorted_ranked_files} cached files found on {config['debridService']} for {log_name}"
371
  )
372
 
373
+ if len_sorted_ranked_files == 0:
374
+ if config["debridApiKey"] == "realdebrid":
375
+ return {
376
+ "streams": [
377
+ {
378
+ "name": "[⚠️] Comet",
379
+ "title": f"RealDebrid API is unstable!",
380
+ "url": "https://comet.fast",
381
+ }
382
+ ]
383
+ }
384
+
385
  return {"streams": []}
386
 
387
  sorted_ranked_files = {
388
  key: (value.model_dump() if isinstance(value, Torrent) else value)
389
  for key, value in sorted_ranked_files.items()
390
  }
391
+ torrents_by_hash = {torrent["InfoHash"]: torrent for torrent in torrents}
392
  for hash in sorted_ranked_files: # needed for caching
393
  sorted_ranked_files[hash]["data"]["title"] = files[hash]["title"]
394
+ sorted_ranked_files[hash]["data"]["torrent_title"] = torrents_by_hash[hash][
395
+ "Title"
396
+ ]
397
+ sorted_ranked_files[hash]["data"]["tracker"] = torrents_by_hash[hash][
398
+ "Tracker"
399
+ ]
400
  sorted_ranked_files[hash]["data"]["size"] = files[hash]["size"]
401
+ torrent_size = torrents_by_hash[hash]["Size"]
402
+ sorted_ranked_files[hash]["data"]["torrent_size"] = (
403
+ torrent_size if torrent_size else files[hash]["size"]
404
+ )
405
  sorted_ranked_files[hash]["data"]["index"] = files[hash]["index"]
406
 
407
  json_data = json.dumps(sorted_ranked_files).replace("'", "''")
408
  await database.execute(
409
+ f"INSERT {'OR IGNORE ' if settings.DATABASE_TYPE == 'sqlite' else ''}INTO cache (cacheKey, results, timestamp) VALUES (:cache_key, :json_data, :timestamp){' ON CONFLICT DO NOTHING' if settings.DATABASE_TYPE == 'postgresql' else ''}",
410
+ {"cache_key": cache_key, "json_data": json_data, "timestamp": time.time()},
411
  )
412
+ logger.info(f"Results have been cached for {log_name}")
413
+
414
+ debrid_extension = get_debrid_extension(config["debridService"])
415
+
416
+ balanced_hashes = get_balanced_hashes(sorted_ranked_files, config)
417
 
 
418
  results = []
419
+ if (
420
+ config["debridStreamProxyPassword"] != ""
421
+ and settings.PROXY_DEBRID_STREAM
422
+ and settings.PROXY_DEBRID_STREAM_PASSWORD
423
+ != config["debridStreamProxyPassword"]
424
+ ):
425
+ results.append(
426
+ {
427
+ "name": "[⚠️] Comet",
428
+ "title": "Debrid Stream Proxy Password incorrect.\nStreams will not be proxied.",
429
+ "url": "https://comet.fast",
430
+ }
431
+ )
432
+
433
+ for hash, hash_data in sorted_ranked_files.items():
434
+ for resolution, hash_list in balanced_hashes.items():
435
+ if hash in hash_list:
436
+ data = hash_data["data"]
437
  results.append(
438
  {
439
+ "name": f"[{debrid_extension}⚡] Comet {data['resolution']}",
440
+ "title": format_title(data, config),
441
+ "torrentTitle": data["torrent_title"],
442
+ "torrentSize": data["torrent_size"],
443
+ "url": f"{request.url.scheme}://{request.url.netloc}/{b64config}/playback/{hash}/{data['index']}",
444
+ "behaviorHints": {
445
+ "filename": data["raw_title"],
446
+ "bingeGroup": "comet|" + hash,
447
+ },
448
  }
449
  )
450
 
 
455
 
456
  @streams.head("/{b64config}/playback/{hash}/{index}")
457
  async def playback(b64config: str, hash: str, index: str):
458
+ return RedirectResponse("https://stremio.fast", status_code=302)
 
 
459
 
 
 
 
460
 
461
+ class CustomORJSONResponse(Response):
462
+ media_type = "application/json"
463
+
464
+ def render(self, content) -> bytes:
465
+ assert orjson is not None, "orjson must be installed"
466
+ return orjson.dumps(content, option=orjson.OPT_INDENT_2)
467
+
468
+
469
+ @streams.get("/active-connections", response_class=CustomORJSONResponse)
470
+ async def active_connections(request: Request, password: str):
471
+ if password != settings.DASHBOARD_ADMIN_PASSWORD:
472
+ return "Invalid Password"
473
+
474
+ active_connections = await database.fetch_all("SELECT * FROM active_connections")
475
+
476
+ return {
477
+ "total_connections": len(active_connections),
478
+ "active_connections": active_connections,
479
+ }
480
 
481
 
482
  @streams.get("/{b64config}/playback/{hash}/{index}")
483
+ async def playback(request: Request, b64config: str, hash: str, index: str):
484
  config = config_check(b64config)
485
  if not config:
486
+ return FileResponse("comet/assets/invalidconfig.mp4")
487
+
488
+ if (
489
+ settings.PROXY_DEBRID_STREAM
490
+ and settings.PROXY_DEBRID_STREAM_PASSWORD == config["debridStreamProxyPassword"]
491
+ and config["debridApiKey"] == ""
492
+ ):
493
+ config["debridService"] = settings.PROXY_DEBRID_STREAM_DEBRID_DEFAULT_SERVICE
494
+ config["debridApiKey"] = settings.PROXY_DEBRID_STREAM_DEBRID_DEFAULT_APIKEY
495
 
496
  async with aiohttp.ClientSession() as session:
497
+ # Check for cached download link
498
+ cached_link = await database.fetch_one(
499
+ f"SELECT link, timestamp FROM download_links WHERE debrid_key = '{config['debridApiKey']}' AND hash = '{hash}' AND file_index = '{index}'"
500
+ )
501
+
502
+ current_time = time.time()
503
+ download_link = None
504
+ if cached_link:
505
+ link = cached_link["link"]
506
+ timestamp = cached_link["timestamp"]
507
+
508
+ if current_time - timestamp < 3600:
509
+ download_link = link
510
+ else:
511
+ # Cache expired, remove old entry
512
+ await database.execute(
513
+ f"DELETE FROM download_links WHERE debrid_key = '{config['debridApiKey']}' AND hash = '{hash}' AND file_index = '{index}'"
514
+ )
515
+
516
+ ip = get_client_ip(request)
517
+
518
+ if not download_link:
519
+ debrid = getDebrid(
520
+ session,
521
+ config,
522
+ ip
523
+ if (
524
+ not settings.PROXY_DEBRID_STREAM
525
+ or settings.PROXY_DEBRID_STREAM_PASSWORD
526
+ != config["debridStreamProxyPassword"]
527
+ )
528
+ else "",
529
+ )
530
+ download_link = await debrid.generate_download_link(hash, index)
531
+ if not download_link:
532
+ return FileResponse("comet/assets/uncached.mp4")
533
+
534
+ # Cache the new download link
535
+ await database.execute(
536
+ f"INSERT {'OR IGNORE ' if settings.DATABASE_TYPE == 'sqlite' else ''}INTO download_links (debrid_key, hash, file_index, link, timestamp) VALUES (:debrid_key, :hash, :file_index, :link, :timestamp){' ON CONFLICT DO NOTHING' if settings.DATABASE_TYPE == 'postgresql' else ''}",
537
+ {
538
+ "debrid_key": config["debridApiKey"],
539
+ "hash": hash,
540
+ "file_index": index,
541
+ "link": download_link,
542
+ "timestamp": current_time,
543
+ },
544
+ )
545
+
546
+ if (
547
+ settings.PROXY_DEBRID_STREAM
548
+ and settings.PROXY_DEBRID_STREAM_PASSWORD
549
+ == config["debridStreamProxyPassword"]
550
+ ):
551
+ active_ip_connections = await database.fetch_all(
552
+ "SELECT ip, COUNT(*) as connections FROM active_connections GROUP BY ip"
553
+ )
554
+ if any(
555
+ connection["ip"] == ip
556
+ and connection["connections"]
557
+ >= settings.PROXY_DEBRID_STREAM_MAX_CONNECTIONS
558
+ for connection in active_ip_connections
559
+ ):
560
+ return FileResponse("comet/assets/proxylimit.mp4")
561
+
562
+ proxy = None
563
+
564
+ class Streamer:
565
+ def __init__(self, id: str):
566
+ self.id = id
567
+
568
+ self.client = httpx.AsyncClient(proxy=proxy)
569
+ self.response = None
570
+
571
+ async def stream_content(self, headers: dict):
572
+ async with self.client.stream(
573
+ "GET", download_link, headers=headers
574
+ ) as self.response:
575
+ async for chunk in self.response.aiter_raw():
576
+ yield chunk
577
+
578
+ async def close(self):
579
+ await database.execute(
580
+ f"DELETE FROM active_connections WHERE id = '{self.id}'"
581
+ )
582
+
583
+ if self.response is not None:
584
+ await self.response.aclose()
585
+ if self.client is not None:
586
+ await self.client.aclose()
587
+
588
+ range_header = request.headers.get("range", "bytes=0-")
589
+
590
+ response = await session.head(
591
+ download_link, headers={"Range": range_header}
592
+ )
593
+ if response.status == 503 and config["debridService"] == "alldebrid":
594
+ proxy = (
595
+ settings.DEBRID_PROXY_URL
596
+ ) # proxy is not needed to proxy realdebrid stream
597
+
598
+ response = await session.head(
599
+ download_link, headers={"Range": range_header}, proxy=proxy
600
+ )
601
+
602
+ if response.status == 206:
603
+ id = str(uuid.uuid4())
604
+ await database.execute(
605
+ f"INSERT {'OR IGNORE ' if settings.DATABASE_TYPE == 'sqlite' else ''}INTO active_connections (id, ip, content, timestamp) VALUES (:id, :ip, :content, :timestamp){' ON CONFLICT DO NOTHING' if settings.DATABASE_TYPE == 'postgresql' else ''}",
606
+ {
607
+ "id": id,
608
+ "ip": ip,
609
+ "content": str(response.url),
610
+ "timestamp": current_time,
611
+ },
612
+ )
613
+
614
+ streamer = Streamer(id)
615
+
616
+ return StreamingResponse(
617
+ streamer.stream_content({"Range": range_header}),
618
+ status_code=206,
619
+ headers={
620
+ "Content-Range": response.headers["Content-Range"],
621
+ "Content-Length": response.headers["Content-Length"],
622
+ "Accept-Ranges": "bytes",
623
+ },
624
+ background=BackgroundTask(streamer.close),
625
+ )
626
+
627
+ return FileResponse("comet/assets/uncached.mp4")
628
 
629
+ return RedirectResponse(download_link, status_code=302)
comet/assets/invalidconfig.mp4 ADDED
Binary file (137 kB). View file
 
comet/assets/proxylimit.mp4 ADDED
Binary file (55.8 kB). View file
 
comet/assets/uncached.mp4 ADDED
Binary file (303 kB). View file
 
comet/debrid/alldebrid.py ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import aiohttp
2
+ import asyncio
3
+
4
+ from RTN import parse
5
+
6
+ from comet.utils.general import is_video
7
+ from comet.utils.logger import logger
8
+ from comet.utils.models import settings
9
+
10
+
11
+ class AllDebrid:
12
+ def __init__(self, session: aiohttp.ClientSession, debrid_api_key: str):
13
+ session.headers["Authorization"] = f"Bearer {debrid_api_key}"
14
+ self.session = session
15
+ self.proxy = None
16
+
17
+ self.api_url = "http://api.alldebrid.com/v4"
18
+ self.agent = "comet"
19
+
20
+ async def check_premium(self):
21
+ try:
22
+ check_premium = await self.session.get(
23
+ f"{self.api_url}/user?agent={self.agent}"
24
+ )
25
+ check_premium = await check_premium.text()
26
+ if '"isPremium":true' in check_premium:
27
+ return True
28
+ except Exception as e:
29
+ logger.warning(
30
+ f"Exception while checking premium status on All-Debrid: {e}"
31
+ )
32
+
33
+ return False
34
+
35
+ async def get_instant(self, chunk: list):
36
+ try:
37
+ get_instant = await self.session.get(
38
+ f"{self.api_url}/magnet/instant?agent={self.agent}&magnets[]={'&magnets[]='.join(chunk)}"
39
+ )
40
+ return await get_instant.json()
41
+ except Exception as e:
42
+ logger.warning(
43
+ f"Exception while checking hashes instant availability on All-Debrid: {e}"
44
+ )
45
+
46
+ async def get_files(
47
+ self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool
48
+ ):
49
+ chunk_size = 500
50
+ chunks = [
51
+ torrent_hashes[i : i + chunk_size]
52
+ for i in range(0, len(torrent_hashes), chunk_size)
53
+ ]
54
+
55
+ tasks = []
56
+ for chunk in chunks:
57
+ tasks.append(self.get_instant(chunk))
58
+
59
+ responses = await asyncio.gather(*tasks)
60
+
61
+ availability = [response for response in responses if response]
62
+
63
+ files = {}
64
+
65
+ if type == "series":
66
+ for result in availability:
67
+ if "status" not in result or result["status"] != "success":
68
+ continue
69
+
70
+ for magnet in result["data"]["magnets"]:
71
+ if not magnet["instant"]:
72
+ continue
73
+
74
+ for file in magnet["files"]:
75
+ filename = file["n"]
76
+ pack = False
77
+ if "e" in file: # PACK
78
+ filename = file["e"][0]["n"]
79
+ pack = True
80
+
81
+ if not is_video(filename):
82
+ continue
83
+
84
+ if "sample" in filename:
85
+ continue
86
+
87
+ filename_parsed = parse(filename)
88
+ if episode not in filename_parsed.episodes:
89
+ continue
90
+
91
+ if kitsu:
92
+ if filename_parsed.seasons:
93
+ continue
94
+ else:
95
+ if season not in filename_parsed.seasons:
96
+ continue
97
+
98
+ files[magnet["hash"]] = {
99
+ "index": magnet["files"].index(file),
100
+ "title": filename,
101
+ "size": file["e"][0]["s"] if pack else file["s"],
102
+ }
103
+
104
+ break
105
+ else:
106
+ for result in availability:
107
+ if "status" not in result or result["status"] != "success":
108
+ continue
109
+
110
+ for magnet in result["data"]["magnets"]:
111
+ if not magnet["instant"]:
112
+ continue
113
+
114
+ for file in magnet["files"]:
115
+ filename = file["n"]
116
+
117
+ if not is_video(filename):
118
+ continue
119
+
120
+ if "sample" in filename:
121
+ continue
122
+
123
+ files[magnet["hash"]] = {
124
+ "index": magnet["files"].index(file),
125
+ "title": filename,
126
+ "size": file["s"],
127
+ }
128
+
129
+ break
130
+
131
+ return files
132
+
133
+ async def generate_download_link(self, hash: str, index: str):
134
+ try:
135
+ check_blacklisted = await self.session.get(
136
+ f"{self.api_url}/magnet/upload?agent=comet&magnets[]={hash}"
137
+ )
138
+ check_blacklisted = await check_blacklisted.text()
139
+ if "NO_SERVER" in check_blacklisted:
140
+ self.proxy = settings.DEBRID_PROXY_URL
141
+ if not self.proxy:
142
+ logger.warning(
143
+ "All-Debrid blacklisted server's IP. No proxy found."
144
+ )
145
+ else:
146
+ logger.warning(
147
+ f"All-Debrid blacklisted server's IP. Switching to proxy {self.proxy} for {hash}|{index}"
148
+ )
149
+
150
+ upload_magnet = await self.session.get(
151
+ f"{self.api_url}/magnet/upload?agent=comet&magnets[]={hash}",
152
+ proxy=self.proxy,
153
+ )
154
+ upload_magnet = await upload_magnet.json()
155
+
156
+ get_magnet_status = await self.session.get(
157
+ f"{self.api_url}/magnet/status?agent=comet&id={upload_magnet['data']['magnets'][0]['id']}",
158
+ proxy=self.proxy,
159
+ )
160
+ get_magnet_status = await get_magnet_status.json()
161
+
162
+ unlock_link = await self.session.get(
163
+ f"{self.api_url}/link/unlock?agent=comet&link={get_magnet_status['data']['magnets']['links'][int(index)]['link']}",
164
+ proxy=self.proxy,
165
+ )
166
+ unlock_link = await unlock_link.json()
167
+
168
+ return unlock_link["data"]["link"]
169
+ except Exception as e:
170
+ logger.warning(
171
+ f"Exception while getting download link from All-Debrid for {hash}|{index}: {e}"
172
+ )
comet/debrid/debridlink.py ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import aiohttp
2
+ import asyncio
3
+
4
+ from RTN import parse
5
+
6
+ from comet.utils.general import is_video
7
+ from comet.utils.logger import logger
8
+
9
+
10
+ class DebridLink:
11
+ def __init__(self, session: aiohttp.ClientSession, debrid_api_key: str):
12
+ session.headers["Authorization"] = f"Bearer {debrid_api_key}"
13
+ self.session = session
14
+ self.proxy = None
15
+
16
+ self.api_url = "https://debrid-link.com/api/v2"
17
+
18
+ async def check_premium(self):
19
+ try:
20
+ check_premium = await self.session.get(f"{self.api_url}/account/infos")
21
+ check_premium = await check_premium.text()
22
+ if '"accountType":1' in check_premium:
23
+ return True
24
+ except Exception as e:
25
+ logger.warning(
26
+ f"Exception while checking premium status on Debrid-Link: {e}"
27
+ )
28
+
29
+ return False
30
+
31
+ async def get_instant(self, chunk: list):
32
+ try:
33
+ get_instant = await self.session.get(
34
+ f"{self.api_url}/seedbox/cached?url={','.join(chunk)}"
35
+ )
36
+ return await get_instant.json()
37
+ except Exception as e:
38
+ logger.warning(
39
+ f"Exception while checking hashes instant availability on Debrid-Link: {e}"
40
+ )
41
+
42
+ async def get_files(
43
+ self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool
44
+ ):
45
+ chunk_size = 250
46
+ chunks = [
47
+ torrent_hashes[i : i + chunk_size]
48
+ for i in range(0, len(torrent_hashes), chunk_size)
49
+ ]
50
+
51
+ tasks = []
52
+ for chunk in chunks:
53
+ tasks.append(self.get_instant(chunk))
54
+
55
+ responses = await asyncio.gather(*tasks)
56
+
57
+ availability = [
58
+ response for response in responses if response and response.get("success")
59
+ ]
60
+
61
+ files = {}
62
+
63
+ if type == "series":
64
+ for result in availability:
65
+ for hash, torrent_data in result["value"].items():
66
+ for file in torrent_data["files"]:
67
+ filename = file["name"]
68
+
69
+ if not is_video(filename):
70
+ continue
71
+
72
+ if "sample" in filename:
73
+ continue
74
+
75
+ filename_parsed = parse(filename)
76
+ if episode not in filename_parsed.episodes:
77
+ continue
78
+
79
+ if kitsu:
80
+ if filename_parsed.seasons:
81
+ continue
82
+ else:
83
+ if season not in filename_parsed.seasons:
84
+ continue
85
+
86
+ files[hash] = {
87
+ "index": torrent_data["files"].index(file),
88
+ "title": filename,
89
+ "size": file["size"],
90
+ }
91
+
92
+ break
93
+ else:
94
+ for result in availability:
95
+ for hash, torrent_data in result["value"].items():
96
+ for file in torrent_data["files"]:
97
+ filename = file["name"]
98
+
99
+ if not is_video(filename):
100
+ continue
101
+
102
+ if "sample" in filename:
103
+ continue
104
+
105
+ files[hash] = {
106
+ "index": torrent_data["files"].index(file),
107
+ "title": filename,
108
+ "size": file["size"],
109
+ }
110
+
111
+ break
112
+
113
+ return files
114
+
115
+ async def generate_download_link(self, hash: str, index: str):
116
+ try:
117
+ add_torrent = await self.session.post(
118
+ f"{self.api_url}/seedbox/add", data={"url": hash, "async": True}
119
+ )
120
+ add_torrent = await add_torrent.json()
121
+
122
+ return add_torrent["value"]["files"][int(index)]["downloadUrl"]
123
+ except Exception as e:
124
+ logger.warning(
125
+ f"Exception while getting download link from Debrid-Link for {hash}|{index}: {e}"
126
+ )
comet/debrid/manager.py CHANGED
@@ -1,8 +1,22 @@
1
  import aiohttp
2
 
3
  from .realdebrid import RealDebrid
 
 
 
 
4
 
5
 
6
- def getDebrid(session: aiohttp.ClientSession, config: dict):
7
- if config["debridService"] == "realdebrid":
8
- return RealDebrid(session, config["debridApiKey"])
 
 
 
 
 
 
 
 
 
 
 
1
  import aiohttp
2
 
3
  from .realdebrid import RealDebrid
4
+ from .alldebrid import AllDebrid
5
+ from .premiumize import Premiumize
6
+ from .torbox import TorBox
7
+ from .debridlink import DebridLink
8
 
9
 
10
+ def getDebrid(session: aiohttp.ClientSession, config: dict, ip: str):
11
+ debrid_service = config["debridService"]
12
+ debrid_api_key = config["debridApiKey"]
13
+ if debrid_service == "realdebrid":
14
+ return RealDebrid(session, debrid_api_key, ip)
15
+ elif debrid_service == "alldebrid":
16
+ return AllDebrid(session, debrid_api_key)
17
+ elif debrid_service == "premiumize":
18
+ return Premiumize(session, debrid_api_key)
19
+ elif debrid_service == "torbox":
20
+ return TorBox(session, debrid_api_key)
21
+ elif debrid_service == "debridlink":
22
+ return DebridLink(session, debrid_api_key)
comet/debrid/premiumize.py ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import aiohttp
2
+ import asyncio
3
+
4
+ from RTN import parse
5
+
6
+ from comet.utils.general import is_video
7
+ from comet.utils.logger import logger
8
+
9
+
10
+ class Premiumize:
11
+ def __init__(self, session: aiohttp.ClientSession, debrid_api_key: str):
12
+ self.session = session
13
+ self.proxy = None
14
+
15
+ self.api_url = "https://premiumize.me/api"
16
+ self.debrid_api_key = debrid_api_key
17
+
18
+ async def check_premium(self):
19
+ try:
20
+ check_premium = await self.session.get(
21
+ f"{self.api_url}/account/info?apikey={self.debrid_api_key}"
22
+ )
23
+ check_premium = await check_premium.text()
24
+ if (
25
+ '"status":"success"' in check_premium
26
+ and '"premium_until":null' not in check_premium
27
+ ):
28
+ return True
29
+ except Exception as e:
30
+ logger.warning(
31
+ f"Exception while checking premium status on Premiumize: {e}"
32
+ )
33
+
34
+ return False
35
+
36
+ async def get_instant(self, chunk: list):
37
+ try:
38
+ response = await self.session.get(
39
+ f"{self.api_url}/cache/check?apikey={self.debrid_api_key}&items[]={'&items[]='.join(chunk)}"
40
+ )
41
+
42
+ response = await response.json()
43
+ response["hashes"] = chunk
44
+
45
+ return response
46
+ except Exception as e:
47
+ logger.warning(
48
+ f"Exception while checking hash instant availability on Premiumize: {e}"
49
+ )
50
+
51
+ async def get_files(
52
+ self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool
53
+ ):
54
+ chunk_size = 100
55
+ chunks = [
56
+ torrent_hashes[i : i + chunk_size]
57
+ for i in range(0, len(torrent_hashes), chunk_size)
58
+ ]
59
+
60
+ tasks = []
61
+ for chunk in chunks:
62
+ tasks.append(self.get_instant(chunk))
63
+
64
+ responses = await asyncio.gather(*tasks)
65
+
66
+ availability = []
67
+ for response in responses:
68
+ if not response:
69
+ continue
70
+
71
+ availability.append(response)
72
+
73
+ files = {}
74
+
75
+ if type == "series":
76
+ for result in availability:
77
+ if result["status"] != "success":
78
+ continue
79
+
80
+ responses = result["response"]
81
+ filenames = result["filename"]
82
+ filesizes = result["filesize"]
83
+ hashes = result["hashes"]
84
+ for index, response in enumerate(responses):
85
+ if not response:
86
+ continue
87
+
88
+ if not filesizes[index]:
89
+ continue
90
+
91
+ filename = filenames[index]
92
+
93
+ if "sample" in filename:
94
+ continue
95
+
96
+ filename_parsed = parse(filename)
97
+ if episode not in filename_parsed.episodes:
98
+ continue
99
+
100
+ if kitsu:
101
+ if filename_parsed.seasons:
102
+ continue
103
+ else:
104
+ if season not in filename_parsed.seasons:
105
+ continue
106
+
107
+ files[hashes[index]] = {
108
+ "index": f"{season}|{episode}",
109
+ "title": filename,
110
+ "size": int(filesizes[index]),
111
+ }
112
+ else:
113
+ for result in availability:
114
+ if result["status"] != "success":
115
+ continue
116
+
117
+ responses = result["response"]
118
+ filenames = result["filename"]
119
+ filesizes = result["filesize"]
120
+ hashes = result["hashes"]
121
+ for index, response in enumerate(responses):
122
+ if response is False:
123
+ continue
124
+
125
+ if not filesizes[index]:
126
+ continue
127
+
128
+ filename = filenames[index]
129
+
130
+ if "sample" in filename:
131
+ continue
132
+
133
+ files[hashes[index]] = {
134
+ "index": 0,
135
+ "title": filename,
136
+ "size": int(filesizes[index]),
137
+ }
138
+
139
+ return files
140
+
141
+ async def generate_download_link(self, hash: str, index: str):
142
+ try:
143
+ add_magnet = await self.session.post(
144
+ f"{self.api_url}/transfer/directdl?apikey={self.debrid_api_key}&src=magnet:?xt=urn:btih:{hash}",
145
+ )
146
+ add_magnet = await add_magnet.json()
147
+
148
+ season = None
149
+ if "|" in index:
150
+ index = index.split("|")
151
+ season = int(index[0])
152
+ episode = int(index[1])
153
+
154
+ content = add_magnet["content"]
155
+ for file in content:
156
+ filename = file["path"]
157
+ if "/" in filename:
158
+ filename = filename.split("/")[1]
159
+
160
+ if not is_video(filename):
161
+ content.remove(file)
162
+ continue
163
+
164
+ if season is not None:
165
+ filename_parsed = parse(filename)
166
+ if (
167
+ season in filename_parsed.seasons
168
+ and episode in filename_parsed.episodes
169
+ ):
170
+ return file["link"]
171
+
172
+ max_size_item = max(content, key=lambda x: x["size"])
173
+ return max_size_item["link"]
174
+ except Exception as e:
175
+ logger.warning(
176
+ f"Exception while getting download link from Premiumize for {hash}|{index}: {e}"
177
+ )
comet/debrid/realdebrid.py CHANGED
@@ -1,90 +1,192 @@
1
  import aiohttp
 
2
 
 
 
 
3
  from comet.utils.logger import logger
4
  from comet.utils.models import settings
5
 
6
 
7
  class RealDebrid:
8
- def __init__(self, session: aiohttp.ClientSession, debrid_api_key: str):
9
  session.headers["Authorization"] = f"Bearer {debrid_api_key}"
10
  self.session = session
 
 
 
 
11
 
12
  async def check_premium(self):
13
  try:
14
- check_premium = await self.session.get(
15
- "https://api.real-debrid.com/rest/1.0/user"
16
- )
17
  check_premium = await check_premium.text()
18
- if '"type": "premium"' not in check_premium:
19
- return False
20
-
21
- return True
22
  except Exception as e:
23
  logger.warning(
24
- f"Exception while checking premium status on Real Debrid: {e}"
25
  )
26
- return False
27
 
28
- async def check_hash_cache(self, hash: str):
 
 
29
  try:
30
  response = await self.session.get(
31
- f"https://api.real-debrid.com/rest/1.0/torrents/instantAvailability/{hash}"
32
  )
33
- return response
34
  except Exception as e:
35
  logger.warning(
36
- f"Exception while checking hash cache on Real Debrid for {hash}: {e}"
37
  )
38
- return
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  async def generate_download_link(self, hash: str, index: str):
41
  try:
42
  check_blacklisted = await self.session.get("https://real-debrid.com/vpn")
43
  check_blacklisted = await check_blacklisted.text()
44
- proxy = None
45
  if (
46
  "Your ISP or VPN provider IP address is currently blocked on our website"
47
  in check_blacklisted
48
  ):
49
- proxy = settings.DEBRID_PROXY_URL
50
- if not proxy:
51
  logger.warning(
52
  "Real-Debrid blacklisted server's IP. No proxy found."
53
  )
54
  else:
55
  logger.warning(
56
- f"Real-Debrid blacklisted server's IP. Switching to proxy {proxy} for {hash}|{index}"
57
  )
58
 
59
  add_magnet = await self.session.post(
60
- "https://api.real-debrid.com/rest/1.0/torrents/addMagnet",
61
- data={"magnet": f"magnet:?xt=urn:btih:{hash}"},
62
- proxy=proxy,
63
  )
64
  add_magnet = await add_magnet.json()
65
 
66
- get_magnet_info = await self.session.get(add_magnet["uri"], proxy=proxy)
 
 
67
  get_magnet_info = await get_magnet_info.json()
68
 
69
  await self.session.post(
70
- f"https://api.real-debrid.com/rest/1.0/torrents/selectFiles/{add_magnet['id']}",
71
- data={"files": index},
72
- proxy=proxy,
 
 
 
 
 
 
 
73
  )
74
 
75
- get_magnet_info = await self.session.get(add_magnet["uri"], proxy=proxy)
 
 
76
  get_magnet_info = await get_magnet_info.json()
77
 
 
 
 
 
 
 
 
 
 
78
  unrestrict_link = await self.session.post(
79
- "https://api.real-debrid.com/rest/1.0/unrestrict/link",
80
- data={"link": get_magnet_info["links"][0]},
81
- proxy=proxy,
82
  )
83
  unrestrict_link = await unrestrict_link.json()
84
 
85
  return unrestrict_link["download"]
86
  except Exception as e:
87
  logger.warning(
88
- f"Exception while getting download link from Real Debrid for {hash}|{index}: {e}"
89
  )
90
- return "https://comet.fast"
 
1
  import aiohttp
2
+ import asyncio
3
 
4
+ from RTN import parse
5
+
6
+ from comet.utils.general import is_video
7
  from comet.utils.logger import logger
8
  from comet.utils.models import settings
9
 
10
 
11
  class RealDebrid:
12
+ def __init__(self, session: aiohttp.ClientSession, debrid_api_key: str, ip: str):
13
  session.headers["Authorization"] = f"Bearer {debrid_api_key}"
14
  self.session = session
15
+ self.ip = ip
16
+ self.proxy = None
17
+
18
+ self.api_url = "https://api.real-debrid.com/rest/1.0"
19
 
20
  async def check_premium(self):
21
  try:
22
+ check_premium = await self.session.get(f"{self.api_url}/user")
 
 
23
  check_premium = await check_premium.text()
24
+ if '"type": "premium"' in check_premium:
25
+ return True
 
 
26
  except Exception as e:
27
  logger.warning(
28
+ f"Exception while checking premium status on Real-Debrid: {e}"
29
  )
 
30
 
31
+ return False
32
+
33
+ async def get_instant(self, chunk: list):
34
  try:
35
  response = await self.session.get(
36
+ f"{self.api_url}/torrents/instantAvailability/{'/'.join(chunk)}"
37
  )
38
+ return await response.json()
39
  except Exception as e:
40
  logger.warning(
41
+ f"Exception while checking hash instant availability on Real-Debrid: {e}"
42
  )
43
+
44
+ async def get_files(
45
+ self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool
46
+ ):
47
+ chunk_size = 50
48
+ chunks = [
49
+ torrent_hashes[i : i + chunk_size]
50
+ for i in range(0, len(torrent_hashes), chunk_size)
51
+ ]
52
+
53
+ tasks = []
54
+ for chunk in chunks:
55
+ tasks.append(self.get_instant(chunk))
56
+
57
+ responses = await asyncio.gather(*tasks)
58
+
59
+ availability = {}
60
+ for response in responses:
61
+ if response is not None:
62
+ availability.update(response)
63
+
64
+ files = {}
65
+
66
+ if type == "series":
67
+ for hash, details in availability.items():
68
+ if "rd" not in details:
69
+ continue
70
+
71
+ for variants in details["rd"]:
72
+ for index, file in variants.items():
73
+ filename = file["filename"]
74
+
75
+ if not is_video(filename):
76
+ continue
77
+
78
+ if "sample" in filename:
79
+ continue
80
+
81
+ filename_parsed = parse(filename)
82
+ if episode not in filename_parsed.episodes:
83
+ continue
84
+
85
+ if kitsu:
86
+ if filename_parsed.seasons:
87
+ continue
88
+ else:
89
+ if season not in filename_parsed.seasons:
90
+ continue
91
+
92
+ files[hash] = {
93
+ "index": index,
94
+ "title": filename,
95
+ "size": file["filesize"],
96
+ }
97
+
98
+ break
99
+ else:
100
+ for hash, details in availability.items():
101
+ if "rd" not in details:
102
+ continue
103
+
104
+ for variants in details["rd"]:
105
+ for index, file in variants.items():
106
+ filename = file["filename"]
107
+
108
+ if not is_video(filename):
109
+ continue
110
+
111
+ if "sample" in filename:
112
+ continue
113
+
114
+ files[hash] = {
115
+ "index": index,
116
+ "title": filename,
117
+ "size": file["filesize"],
118
+ }
119
+
120
+ break
121
+
122
+ return files
123
 
124
  async def generate_download_link(self, hash: str, index: str):
125
  try:
126
  check_blacklisted = await self.session.get("https://real-debrid.com/vpn")
127
  check_blacklisted = await check_blacklisted.text()
 
128
  if (
129
  "Your ISP or VPN provider IP address is currently blocked on our website"
130
  in check_blacklisted
131
  ):
132
+ self.proxy = settings.DEBRID_PROXY_URL
133
+ if not self.proxy:
134
  logger.warning(
135
  "Real-Debrid blacklisted server's IP. No proxy found."
136
  )
137
  else:
138
  logger.warning(
139
+ f"Real-Debrid blacklisted server's IP. Switching to proxy {self.proxy} for {hash}|{index}"
140
  )
141
 
142
  add_magnet = await self.session.post(
143
+ f"{self.api_url}/torrents/addMagnet",
144
+ data={"magnet": f"magnet:?xt=urn:btih:{hash}", "ip": self.ip},
145
+ proxy=self.proxy,
146
  )
147
  add_magnet = await add_magnet.json()
148
 
149
+ get_magnet_info = await self.session.get(
150
+ add_magnet["uri"], proxy=self.proxy
151
+ )
152
  get_magnet_info = await get_magnet_info.json()
153
 
154
  await self.session.post(
155
+ f"{self.api_url}/torrents/selectFiles/{add_magnet['id']}",
156
+ data={
157
+ "files": ",".join(
158
+ str(file["id"])
159
+ for file in get_magnet_info["files"]
160
+ if is_video(file["path"])
161
+ ),
162
+ "ip": self.ip,
163
+ },
164
+ proxy=self.proxy,
165
  )
166
 
167
+ get_magnet_info = await self.session.get(
168
+ add_magnet["uri"], proxy=self.proxy
169
+ )
170
  get_magnet_info = await get_magnet_info.json()
171
 
172
+ index = int(index)
173
+ realIndex = index
174
+ for file in get_magnet_info["files"]:
175
+ if file["id"] == realIndex:
176
+ break
177
+
178
+ if file["selected"] != 1:
179
+ index -= 1
180
+
181
  unrestrict_link = await self.session.post(
182
+ f"{self.api_url}/unrestrict/link",
183
+ data={"link": get_magnet_info["links"][index - 1], "ip": self.ip},
184
+ proxy=self.proxy,
185
  )
186
  unrestrict_link = await unrestrict_link.json()
187
 
188
  return unrestrict_link["download"]
189
  except Exception as e:
190
  logger.warning(
191
+ f"Exception while getting download link from Real-Debrid for {hash}|{index}: {e}"
192
  )
 
comet/debrid/torbox.py ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import aiohttp
2
+ import asyncio
3
+
4
+ from RTN import parse
5
+
6
+ from comet.utils.general import is_video
7
+ from comet.utils.logger import logger
8
+
9
+
10
+ class TorBox:
11
+ def __init__(self, session: aiohttp.ClientSession, debrid_api_key: str):
12
+ session.headers["Authorization"] = f"Bearer {debrid_api_key}"
13
+ self.session = session
14
+ self.proxy = None
15
+
16
+ self.api_url = "https://api.torbox.app/v1/api"
17
+ self.debrid_api_key = debrid_api_key
18
+
19
+ async def check_premium(self):
20
+ try:
21
+ check_premium = await self.session.get(
22
+ f"{self.api_url}/user/me?settings=false"
23
+ )
24
+ check_premium = await check_premium.text()
25
+ if '"success":true' in check_premium and '"plan":0' not in check_premium:
26
+ return True
27
+ except Exception as e:
28
+ logger.warning(f"Exception while checking premium status on TorBox: {e}")
29
+
30
+ return False
31
+
32
+ async def get_instant(self, chunk: list):
33
+ try:
34
+ response = await self.session.get(
35
+ f"{self.api_url}/torrents/checkcached?hash={','.join(chunk)}&format=list&list_files=true"
36
+ )
37
+ return await response.json()
38
+ except Exception as e:
39
+ logger.warning(
40
+ f"Exception while checking hash instant availability on TorBox: {e}"
41
+ )
42
+
43
+ async def get_files(
44
+ self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool
45
+ ):
46
+ chunk_size = 100
47
+ chunks = [
48
+ torrent_hashes[i : i + chunk_size]
49
+ for i in range(0, len(torrent_hashes), chunk_size)
50
+ ]
51
+
52
+ tasks = []
53
+ for chunk in chunks:
54
+ tasks.append(self.get_instant(chunk))
55
+
56
+ responses = await asyncio.gather(*tasks)
57
+
58
+ availability = [response for response in responses if response is not None]
59
+
60
+ files = {}
61
+
62
+ if type == "series":
63
+ for result in availability:
64
+ if not result["success"] or not result["data"]:
65
+ continue
66
+
67
+ for torrent in result["data"]:
68
+ torrent_files = torrent["files"]
69
+ for file in torrent_files:
70
+ filename = file["name"].split("/")[1]
71
+
72
+ if not is_video(filename):
73
+ continue
74
+
75
+ if "sample" in filename:
76
+ continue
77
+
78
+ filename_parsed = parse(filename)
79
+ if episode not in filename_parsed.episodes:
80
+ continue
81
+
82
+ if kitsu:
83
+ if filename_parsed.seasons:
84
+ continue
85
+ else:
86
+ if season not in filename_parsed.seasons:
87
+ continue
88
+
89
+ files[torrent["hash"]] = {
90
+ "index": torrent_files.index(file),
91
+ "title": filename,
92
+ "size": file["size"],
93
+ }
94
+
95
+ break
96
+ else:
97
+ for result in availability:
98
+ if not result["success"] or not result["data"]:
99
+ continue
100
+
101
+ for torrent in result["data"]:
102
+ torrent_files = torrent["files"]
103
+ for file in torrent_files:
104
+ filename = file["name"].split("/")[1]
105
+
106
+ if not is_video(filename):
107
+ continue
108
+
109
+ if "sample" in filename:
110
+ continue
111
+
112
+ files[torrent["hash"]] = {
113
+ "index": torrent_files.index(file),
114
+ "title": filename,
115
+ "size": file["size"],
116
+ }
117
+
118
+ break
119
+
120
+ return files
121
+
122
+ async def generate_download_link(self, hash: str, index: str):
123
+ try:
124
+ get_torrents = await self.session.get(
125
+ f"{self.api_url}/torrents/mylist?bypass_cache=true"
126
+ )
127
+ get_torrents = await get_torrents.json()
128
+ exists = False
129
+ for torrent in get_torrents["data"]:
130
+ if torrent["hash"] == hash:
131
+ torrent_id = torrent["id"]
132
+ exists = True
133
+ break
134
+ if not exists:
135
+ create_torrent = await self.session.post(
136
+ f"{self.api_url}/torrents/createtorrent",
137
+ data={"magnet": f"magnet:?xt=urn:btih:{hash}"},
138
+ )
139
+ create_torrent = await create_torrent.json()
140
+ torrent_id = create_torrent["data"]["torrent_id"]
141
+
142
+ # get_torrents = await self.session.get(
143
+ # f"{self.api_url}/torrents/mylist?bypass_cache=true"
144
+ # )
145
+ # get_torrents = await get_torrents.json()
146
+
147
+ # for torrent in get_torrents["data"]:
148
+ # if torrent["id"] == torrent_id:
149
+ # file_id = torrent["files"][int(index)]["id"]
150
+ # Useless, we already have file index
151
+
152
+ get_download_link = await self.session.get(
153
+ f"{self.api_url}/torrents/requestdl?token={self.debrid_api_key}&torrent_id={torrent_id}&file_id={index}&zip=false",
154
+ )
155
+ get_download_link = await get_download_link.json()
156
+
157
+ return get_download_link["data"]
158
+ except Exception as e:
159
+ logger.warning(
160
+ f"Exception while getting download link from TorBox for {hash}|{index}: {e}"
161
+ )
comet/main.py CHANGED
@@ -102,6 +102,8 @@ config = uvicorn.Config(
102
  app,
103
  host=settings.FASTAPI_HOST,
104
  port=settings.FASTAPI_PORT,
 
 
105
  workers=settings.FASTAPI_WORKERS,
106
  log_config=None,
107
  )
@@ -114,19 +116,44 @@ def start_log():
114
  f"Server started on http://{settings.FASTAPI_HOST}:{settings.FASTAPI_PORT} - {settings.FASTAPI_WORKERS} workers",
115
  )
116
  logger.log(
117
- "COMET", f"Database: {settings.DATABASE_PATH} - TTL: {settings.CACHE_TTL}s"
 
118
  )
119
- logger.log("COMET", f"Debrid Proxy: {settings.DEBRID_PROXY_URL}")
120
  logger.log(
121
  "COMET",
122
- f"Indexer Manager: {settings.INDEXER_MANAGER_TYPE}|{settings.INDEXER_MANAGER_URL} - Timeout: {settings.INDEXER_MANAGER_TIMEOUT}s",
123
  )
124
- logger.log("COMET", f"Indexers: {settings.INDEXER_MANAGER_INDEXERS}")
125
- logger.log("COMET", f"Get Torrent Timeout: {settings.GET_TORRENT_TIMEOUT}s")
126
- logger.log("COMET", f"Zilean API: {settings.ZILEAN_URL}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  logger.log(
128
- "COMET", f"Custom Header HTML Enabled: {bool(settings.CUSTOM_HEADER_HTML)}"
 
129
  )
 
 
130
 
131
 
132
  with server.run_in_thread():
 
102
  app,
103
  host=settings.FASTAPI_HOST,
104
  port=settings.FASTAPI_PORT,
105
+ proxy_headers=True,
106
+ forwarded_allow_ips="*",
107
  workers=settings.FASTAPI_WORKERS,
108
  log_config=None,
109
  )
 
116
  f"Server started on http://{settings.FASTAPI_HOST}:{settings.FASTAPI_PORT} - {settings.FASTAPI_WORKERS} workers",
117
  )
118
  logger.log(
119
+ "COMET",
120
+ f"Dashboard Admin Password: {settings.DASHBOARD_ADMIN_PASSWORD} - http://{settings.FASTAPI_HOST}:{settings.FASTAPI_PORT}/active-connections?password={settings.DASHBOARD_ADMIN_PASSWORD}",
121
  )
 
122
  logger.log(
123
  "COMET",
124
+ f"Database ({settings.DATABASE_TYPE}): {settings.DATABASE_PATH if settings.DATABASE_TYPE == 'sqlite' else settings.DATABASE_URL} - TTL: {settings.CACHE_TTL}s",
125
  )
126
+ logger.log("COMET", f"Debrid Proxy: {settings.DEBRID_PROXY_URL}")
127
+
128
+ if settings.INDEXER_MANAGER_TYPE:
129
+ logger.log(
130
+ "COMET",
131
+ f"Indexer Manager: {settings.INDEXER_MANAGER_TYPE}|{settings.INDEXER_MANAGER_URL} - Timeout: {settings.INDEXER_MANAGER_TIMEOUT}s",
132
+ )
133
+ logger.log("COMET", f"Indexers: {', '.join(settings.INDEXER_MANAGER_INDEXERS)}")
134
+ logger.log("COMET", f"Get Torrent Timeout: {settings.GET_TORRENT_TIMEOUT}s")
135
+ else:
136
+ logger.log("COMET", "Indexer Manager: False")
137
+
138
+ if settings.ZILEAN_URL:
139
+ logger.log(
140
+ "COMET",
141
+ f"Zilean: {settings.ZILEAN_URL} - Take first: {settings.ZILEAN_TAKE_FIRST}",
142
+ )
143
+ else:
144
+ logger.log("COMET", "Zilean: False")
145
+
146
+ logger.log("COMET", f"Torrentio Scraper: {bool(settings.SCRAPE_TORRENTIO)}")
147
+
148
+ mediafusion_url = f" - {settings.MEDIAFUSION_URL}"
149
+ logger.log("COMET", f"MediaFusion Scraper: {bool(settings.SCRAPE_MEDIAFUSION)}{mediafusion_url if settings.SCRAPE_MEDIAFUSION else ''}")
150
+
151
  logger.log(
152
+ "COMET",
153
+ f"Debrid Stream Proxy: {bool(settings.PROXY_DEBRID_STREAM)} - Password: {settings.PROXY_DEBRID_STREAM_PASSWORD} - Max Connections: {settings.PROXY_DEBRID_STREAM_MAX_CONNECTIONS} - Default Debrid Service: {settings.PROXY_DEBRID_STREAM_DEBRID_DEFAULT_SERVICE} - Default Debrid API Key: {settings.PROXY_DEBRID_STREAM_DEBRID_DEFAULT_APIKEY}",
154
  )
155
+ logger.log("COMET", f"Title Match Check: {bool(settings.TITLE_MATCH_CHECK)}")
156
+ logger.log("COMET", f"Custom Header HTML: {bool(settings.CUSTOM_HEADER_HTML)}")
157
 
158
 
159
  with server.run_in_thread():
comet/templates/index.html CHANGED
@@ -1,577 +1,794 @@
1
- <!DOCTYPE html>
2
- <html class="sl-theme-dark">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6
- <meta content="Comet" property="og:title" />
7
- <meta content="Stremio's fastest torrent/debrid search add-on." property="og:description" />
8
- <meta content="https://comet.fast" property="og:url" />
9
- <meta content="https://i.imgur.com/jmVoVMu.jpeg" property="og:image" />
10
- <meta content="#6b6ef8" data-react-helmet="true" name="theme-color" />
11
-
12
- <title>Comet - Stremio's fastest torrent/debrid search add-on.</title>
13
- <link id="favicon" rel="icon" type="image/x-icon" href="https://i.imgur.com/jmVoVMu.jpeg">
14
-
15
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.15.1/cdn/themes/dark.css" />
16
- <script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.15.1/cdn/shoelace-autoloader.js"></script>
17
-
18
- <style>
19
- :not(:defined) {
20
- visibility: hidden;
21
- }
22
-
23
- body {
24
- opacity: 0;
25
- display: flex;
26
- flex-direction: column;
27
- justify-content: center;
28
- align-items: center;
29
- min-height: 100vh;
30
- margin: 0;
31
- background: radial-gradient(ellipse at bottom, #25292c 0%, #0c0d13 100%);
32
- font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
33
- font-size: 1rem;
34
- font-weight: 400;
35
- }
36
-
37
- body.ready {
38
- opacity: 1;
39
- transition: 0.25s opacity;
40
- }
41
-
42
- ::-webkit-scrollbar {
43
- overflow: hidden;
44
- }
45
-
46
- .header {
47
- text-align: center;
48
- width: 40%;
49
- margin-bottom: 20px;
50
- }
51
-
52
- .comet-text {
53
- font-size: calc(1.375rem + 1.5vw);
54
- font-weight: 500;
55
- margin-bottom: 0;
56
- }
57
-
58
- .form-container {
59
- background-color: #1a1d20;
60
- padding: 2rem;
61
- border-radius: 0.375rem;
62
- box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
63
- width: 50%;
64
- margin-bottom: 50px;
65
- }
66
-
67
- .form-item {
68
- margin-bottom: 0.75rem;
69
- }
70
-
71
- .centered-item {
72
- display: flex;
73
- justify-content: center;
74
- }
75
-
76
- .stars {
77
- position: fixed;
78
- top: 0;
79
- left: 0;
80
- width: 100%;
81
- height: 120%;
82
- transform: rotate(-45deg);
83
- z-index: -1;
84
- }
85
- .star {
86
- --star-color: var(--primary-color);
87
- --star-tail-length: 6em;
88
- --star-tail-height: 2px;
89
- --star-width: calc(var(--star-tail-length) / 6);
90
- --fall-duration: 9s;
91
- --tail-fade-duration: var(--fall-duration);
92
- position: absolute;
93
- top: var(--top-offset);
94
- left: 0;
95
- width: var(--star-tail-length);
96
- height: var(--star-tail-height);
97
- color: var(--star-color);
98
- background: linear-gradient(45deg, currentColor, transparent);
99
- border-radius: 50%;
100
- filter: drop-shadow(0 0 6px currentColor);
101
- transform: translate3d(104em, 0, 0);
102
- animation: fall var(--fall-duration) var(--fall-delay) linear infinite, tail-fade var(--tail-fade-duration) var(--fall-delay) ease-out infinite;
103
- }
104
- @media screen and (max-width: 750px) {
105
- .star {
106
- animation: fall var(--fall-duration) var(--fall-delay) linear infinite;
107
- }
108
- }
109
- .star:nth-child(1) {
110
- --star-tail-length: 6.14em;
111
- --top-offset: 3.64vh;
112
- --fall-duration: 10.878s;
113
- --fall-delay: 0.034s;
114
- }
115
- .star:nth-child(2) {
116
- --star-tail-length: 5.08em;
117
- --top-offset: 69.69vh;
118
- --fall-duration: 11.372s;
119
- --fall-delay: 1.679s;
120
- }
121
- .star:nth-child(3) {
122
- --star-tail-length: 6.1em;
123
- --top-offset: 64.3vh;
124
- --fall-duration: 7.088s;
125
- --fall-delay: 3.382s;
126
- }
127
- .star:nth-child(4) {
128
- --star-tail-length: 6.66em;
129
- --top-offset: 34.91vh;
130
- --fall-duration: 6.184s;
131
- --fall-delay: 9.61s;
132
- }
133
- .star:nth-child(5) {
134
- --star-tail-length: 6.89em;
135
- --top-offset: 24.92vh;
136
- --fall-duration: 9.465s;
137
- --fall-delay: 9.12s;
138
- }
139
- .star:nth-child(6) {
140
- --star-tail-length: 6.5em;
141
- --top-offset: 51.9vh;
142
- --fall-duration: 10.52s;
143
- --fall-delay: 0.214s;
144
- }
145
- .star:nth-child(7) {
146
- --star-tail-length: 5.58em;
147
- --top-offset: 24.15vh;
148
- --fall-duration: 8.9s;
149
- --fall-delay: 0.499s;
150
- }
151
- .star:nth-child(8) {
152
- --star-tail-length: 6.26em;
153
- --top-offset: 59.4vh;
154
- --fall-duration: 7.671s;
155
- --fall-delay: 1.694s;
156
- }
157
- .star:nth-child(9) {
158
- --star-tail-length: 6.46em;
159
- --top-offset: 54.52vh;
160
- --fall-duration: 6.484s;
161
- --fall-delay: 4.616s;
162
- }
163
- .star:nth-child(10) {
164
- --star-tail-length: 5.34em;
165
- --top-offset: 74.03vh;
166
- --fall-duration: 8.565s;
167
- --fall-delay: 1.159s;
168
- }
169
- .star:nth-child(11) {
170
- --star-tail-length: 6.84em;
171
- --top-offset: 90.94vh;
172
- --fall-duration: 10.133s;
173
- --fall-delay: 6.108s;
174
- }
175
- .star:nth-child(12) {
176
- --star-tail-length: 5.48em;
177
- --top-offset: 97.27vh;
178
- --fall-duration: 10.248s;
179
- --fall-delay: 4.186s;
180
- }
181
- .star:nth-child(13) {
182
- --star-tail-length: 7.21em;
183
- --top-offset: 17.75vh;
184
- --fall-duration: 10.549s;
185
- --fall-delay: 1.868s;
186
- }
187
- .star:nth-child(14) {
188
- --star-tail-length: 6.35em;
189
- --top-offset: 94.98vh;
190
- --fall-duration: 9.682s;
191
- --fall-delay: 9.327s;
192
- }
193
- .star:nth-child(15) {
194
- --star-tail-length: 5.18em;
195
- --top-offset: 52.87vh;
196
- --fall-duration: 9.934s;
197
- --fall-delay: 8.919s;
198
- }
199
- .star:nth-child(16) {
200
- --star-tail-length: 5.07em;
201
- --top-offset: 50.26vh;
202
- --fall-duration: 11.826s;
203
- --fall-delay: 8.478s;
204
- }
205
- .star:nth-child(17) {
206
- --star-tail-length: 7.01em;
207
- --top-offset: 85.73vh;
208
- --fall-duration: 9.87s;
209
- --fall-delay: 1.206s;
210
- }
211
- .star:nth-child(18) {
212
- --star-tail-length: 6.39em;
213
- --top-offset: 2.81vh;
214
- --fall-duration: 10.292s;
215
- --fall-delay: 4.394s;
216
- }
217
- .star:nth-child(19) {
218
- --star-tail-length: 5.27em;
219
- --top-offset: 56.83vh;
220
- --fall-duration: 8.944s;
221
- --fall-delay: 8.779s;
222
- }
223
- .star:nth-child(20) {
224
- --star-tail-length: 6.07em;
225
- --top-offset: 54.55vh;
226
- --fall-duration: 9.324s;
227
- --fall-delay: 7.375s;
228
- }
229
- .star:nth-child(21) {
230
- --star-tail-length: 6.1em;
231
- --top-offset: 87.67vh;
232
- --fall-duration: 11.943s;
233
- --fall-delay: 6.919s;
234
- }
235
- .star:nth-child(22) {
236
- --star-tail-length: 5.98em;
237
- --top-offset: 70.04vh;
238
- --fall-duration: 9.995s;
239
- --fall-delay: 4.472s;
240
- }
241
- .star:nth-child(23) {
242
- --star-tail-length: 6.34em;
243
- --top-offset: 77.19vh;
244
- --fall-duration: 10.073s;
245
- --fall-delay: 8.354s;
246
- }
247
- .star:nth-child(24) {
248
- --star-tail-length: 6.95em;
249
- --top-offset: 14.48vh;
250
- --fall-duration: 9.028s;
251
- --fall-delay: 7.638s;
252
- }
253
- .star:nth-child(25) {
254
- --star-tail-length: 6.23em;
255
- --top-offset: 8.48vh;
256
- --fall-duration: 7.427s;
257
- --fall-delay: 0.915s;
258
- }
259
- .star:nth-child(26) {
260
- --star-tail-length: 5.09em;
261
- --top-offset: 6.56vh;
262
- --fall-duration: 7.706s;
263
- --fall-delay: 2.841s;
264
- }
265
- .star:nth-child(27) {
266
- --star-tail-length: 7.01em;
267
- --top-offset: 92.85vh;
268
- --fall-duration: 7.359s;
269
- --fall-delay: 7.229s;
270
- }
271
- .star:nth-child(28) {
272
- --star-tail-length: 5.49em;
273
- --top-offset: 27.89vh;
274
- --fall-duration: 10.344s;
275
- --fall-delay: 2.346s;
276
- }
277
- .star:nth-child(29) {
278
- --star-tail-length: 5.82em;
279
- --top-offset: 56.08vh;
280
- --fall-duration: 10.911s;
281
- --fall-delay: 4.231s;
282
- }
283
- .star:nth-child(30) {
284
- --star-tail-length: 7.24em;
285
- --top-offset: 22.54vh;
286
- --fall-duration: 9.344s;
287
- --fall-delay: 2.112s;
288
- }
289
- .star:nth-child(31) {
290
- --star-tail-length: 6.8em;
291
- --top-offset: 59.49vh;
292
- --fall-duration: 7.059s;
293
- --fall-delay: 0.924s;
294
- }
295
- .star:nth-child(32) {
296
- --star-tail-length: 5.22em;
297
- --top-offset: 44.01vh;
298
- --fall-duration: 10.121s;
299
- --fall-delay: 0.591s;
300
- }
301
- .star:nth-child(33) {
302
- --star-tail-length: 6.1em;
303
- --top-offset: 78.61vh;
304
- --fall-duration: 8.306s;
305
- --fall-delay: 4.403s;
306
- }
307
- .star:nth-child(34) {
308
- --star-tail-length: 7.26em;
309
- --top-offset: 85.76vh;
310
- --fall-duration: 7.058s;
311
- --fall-delay: 6.772s;
312
- }
313
- .star:nth-child(35) {
314
- --star-tail-length: 7.01em;
315
- --top-offset: 77.17vh;
316
- --fall-duration: 6.29s;
317
- --fall-delay: 1.468s;
318
- }
319
- .star:nth-child(36) {
320
- --star-tail-length: 5.17em;
321
- --top-offset: 13.63vh;
322
- --fall-duration: 6.739s;
323
- --fall-delay: 0.019s;
324
- }
325
- .star:nth-child(37) {
326
- --star-tail-length: 6.41em;
327
- --top-offset: 70.18vh;
328
- --fall-duration: 6.177s;
329
- --fall-delay: 8.148s;
330
- }
331
- .star:nth-child(38) {
332
- --star-tail-length: 5.32em;
333
- --top-offset: 62.65vh;
334
- --fall-duration: 10.476s;
335
- --fall-delay: 0.98s;
336
- }
337
- .star:nth-child(39) {
338
- --star-tail-length: 7.24em;
339
- --top-offset: 66.12vh;
340
- --fall-duration: 8.449s;
341
- --fall-delay: 4.255s;
342
- }
343
- .star:nth-child(40) {
344
- --star-tail-length: 6.73em;
345
- --top-offset: 14.73vh;
346
- --fall-duration: 9.857s;
347
- --fall-delay: 6.867s;
348
- }
349
- .star:nth-child(41) {
350
- --star-tail-length: 5.25em;
351
- --top-offset: 45.23vh;
352
- --fall-duration: 7.898s;
353
- --fall-delay: 4.966s;
354
- }
355
- .star:nth-child(42) {
356
- --star-tail-length: 6.73em;
357
- --top-offset: 36.17vh;
358
- --fall-duration: 7.32s;
359
- --fall-delay: 3.93s;
360
- }
361
- .star:nth-child(43) {
362
- --star-tail-length: 7.38em;
363
- --top-offset: 83.09vh;
364
- --fall-duration: 7.394s;
365
- --fall-delay: 5.388s;
366
- }
367
- .star:nth-child(44) {
368
- --star-tail-length: 5.18em;
369
- --top-offset: 98.36vh;
370
- --fall-duration: 6.905s;
371
- --fall-delay: 2.771s;
372
- }
373
- .star:nth-child(45) {
374
- --star-tail-length: 6.66em;
375
- --top-offset: 27.99vh;
376
- --fall-duration: 7.62s;
377
- --fall-delay: 3.624s;
378
- }
379
- .star:nth-child(46) {
380
- --star-tail-length: 5.19em;
381
- --top-offset: 92vh;
382
- --fall-duration: 9.158s;
383
- --fall-delay: 1.984s;
384
- }
385
- .star:nth-child(47) {
386
- --star-tail-length: 6.16em;
387
- --top-offset: 2.87vh;
388
- --fall-duration: 9.266s;
389
- --fall-delay: 4.04s;
390
- }
391
- .star:nth-child(48) {
392
- --star-tail-length: 6.34em;
393
- --top-offset: 19.39vh;
394
- --fall-duration: 7.503s;
395
- --fall-delay: 0.045s;
396
- }
397
- .star:nth-child(49) {
398
- --star-tail-length: 6.85em;
399
- --top-offset: 79.92vh;
400
- --fall-duration: 7.472s;
401
- --fall-delay: 1.514s;
402
- }
403
- .star:nth-child(50) {
404
- --star-tail-length: 7.35em;
405
- --top-offset: 63.71vh;
406
- --fall-duration: 8.117s;
407
- --fall-delay: 4.46s;
408
- }
409
- .star::before, .star::after {
410
- position: absolute;
411
- content: "";
412
- top: 0;
413
- left: calc(var(--star-width) / -2);
414
- width: var(--star-width);
415
- height: 100%;
416
- background: linear-gradient(45deg, transparent, currentColor, transparent);
417
- border-radius: inherit;
418
- animation: blink 2s linear infinite;
419
- }
420
- .star::before {
421
- transform: rotate(45deg);
422
- }
423
- .star::after {
424
- transform: rotate(-45deg);
425
- }
426
-
427
- @keyframes fall {
428
- to {
429
- transform: translate3d(-30em, 0, 0);
430
- }
431
- }
432
- @keyframes tail-fade {
433
- 0%, 50% {
434
- width: var(--star-tail-length);
435
- opacity: 1;
436
- }
437
- 70%, 80% {
438
- width: 0;
439
- opacity: 0.4;
440
- }
441
- 100% {
442
- width: 0;
443
- opacity: 0;
444
- }
445
- }
446
- @keyframes blink {
447
- 50% {
448
- opacity: 0.6;
449
- }
450
- }
451
- </style>
452
- </head>
453
-
454
- <body>
455
- <div class="stars"></div>
456
-
457
- <script>
458
- document.addEventListener("DOMContentLoaded", function() {
459
- const starsContainer = document.querySelector('.stars');
460
- const isMobile = window.innerWidth <= 750;
461
- const starCount = isMobile ? 30 : 30; // Reduce the number of stars on mobile because of performance issues (currently disabled because we need to find a better workarround)
462
-
463
- for (let i = 0; i < starCount; i++) {
464
- const star = document.createElement("div");
465
- star.classList.add("star");
466
- starsContainer.appendChild(star);
467
- }
468
- });
469
- </script>
470
-
471
- <div class="header">
472
- <p class="comet-text">🚀 Comet - <a href="https://github.com/g0ldyy/comet">GitHub</a></p>
473
- {{CUSTOM_HEADER_HTML|safe}}
474
- </div>
475
-
476
- <div class="form-container">
477
- <div class="form-item">
478
- <sl-select id="indexers" multiple clearable label="Indexers" placeholder="Select indexers"></sl-select>
479
- </div>
480
-
481
- <div class="form-item">
482
- <sl-select id="languages" multiple clearable label="Languages" placeholder="Select languages"></sl-select>
483
- </div>
484
-
485
- <div class="form-item">
486
- <sl-select id="resolutions" multiple clearable label="Resolutions" placeholder="Select resolutions"></sl-select>
487
- </div>
488
-
489
- <div class="form-item">
490
- <sl-input id="maxResults" type="number" min=0 value=0 label="Max Results" placeholder="Enter max results"></sl-input>
491
- </div>
492
-
493
- <div class="form-item">
494
- <sl-select id="debridService" value="realdebrid" label="Debrid Service" placeholder="Select debrid service">
495
- <sl-option value="realdebrid">Real-Debrid</sl-option>
496
- </sl-select>
497
- </div>
498
-
499
- <div class="form-item">
500
- <sl-input id="debridApiKey" label="Debrid API Key" placeholder="Enter API key"></sl-input>
501
- </div>
502
-
503
- <div class="centered-item">
504
- <sl-button id="install" variant="neutral">Install</sl-button>
505
-
506
- <sl-alert variant="neutral" duration="3000" closable>
507
- <sl-icon slot="icon" name="clipboard2-check"></sl-icon>
508
- <strong>The Stremio addon link has been automatically copied.</strong>
509
- </sl-alert>
510
-
511
- <script type="module">
512
- let defaultLanguages = [];
513
- let defaultResolutions = [];
514
-
515
- document.addEventListener("DOMContentLoaded", async () => {
516
- await Promise.allSettled([
517
- customElements.whenDefined("sl-button"),
518
- customElements.whenDefined("sl-alert"),
519
- customElements.whenDefined("sl-select"),
520
- customElements.whenDefined("sl-input"),
521
- customElements.whenDefined("sl-option"),
522
- customElements.whenDefined("sl-icon")
523
- ]);
524
-
525
- const webConfig = {{webConfig|tojson}};
526
- populateSelect("indexers", webConfig.indexers);
527
- populateSelect("languages", webConfig.languages);
528
- populateSelect("resolutions", webConfig.resolutions);
529
-
530
- document.body.classList.add("ready");
531
-
532
- defaultLanguages = webConfig.languages;
533
- defaultResolutions = webConfig.resolutions;
534
- });
535
-
536
- function populateSelect(selectId, options) {
537
- const selectElement = document.getElementById(selectId);
538
- options.forEach(option => {
539
- const optionElement = document.createElement("sl-option");
540
- optionElement.value = option;
541
- optionElement.textContent = option;
542
- selectElement.appendChild(optionElement);
543
- });
544
- selectElement.value = options;
545
- }
546
-
547
- const button = document.querySelector("sl-button");
548
- const alert = document.querySelector('sl-alert[variant="neutral"]');
549
- button.addEventListener("click", () => {
550
- const debridService = document.getElementById("debridService").value;
551
- const debridApiKey = document.getElementById("debridApiKey").value;
552
- const indexers = Array.from(document.getElementById("indexers").selectedOptions).map(option => option.value);
553
- const languages = Array.from(document.getElementById("languages").selectedOptions).map(option => option.value);
554
- const resolutions = Array.from(document.getElementById("resolutions").selectedOptions).map(option => option.value);
555
- const maxResults = document.getElementById("maxResults").value;
556
-
557
- const selectedLanguages = languages.length === defaultLanguages.length && languages.every((val, index) => val === defaultLanguages[index]) ? ["All"] : languages;
558
- const selectedResolutions = resolutions.length === defaultResolutions.length && resolutions.every((val, index) => val === defaultResolutions[index]) ? ["All"] : resolutions;
559
-
560
- const settings = {
561
- debridService: debridService,
562
- debridApiKey: debridApiKey,
563
- indexers: indexers,
564
- maxResults: parseInt(maxResults),
565
- resolutions: selectedResolutions,
566
- languages: selectedLanguages
567
- };
568
-
569
- navigator.clipboard.writeText(`${window.location.origin}/${btoa(JSON.stringify(settings))}/manifest.json`).then(() => {
570
- alert.toast();
571
- });
572
- });
573
- </script>
574
- </div>
575
- </div>
576
- </body>
577
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html class="sl-theme-dark">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6
+ <meta content="Comet" property="og:title" />
7
+ <meta content="Stremio's fastest torrent/debrid search add-on." property="og:description" />
8
+ <meta content="https://comet.fast" property="og:url" />
9
+ <meta content="https://i.imgur.com/jmVoVMu.jpeg" property="og:image" />
10
+ <meta content="#6b6ef8" data-react-helmet="true" name="theme-color" />
11
+
12
+ <title>Comet - Stremio's fastest torrent/debrid search add-on.</title>
13
+ <link id="favicon" rel="icon" type="image/x-icon" href="https://i.imgur.com/jmVoVMu.jpeg">
14
+
15
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.15.1/cdn/themes/dark.css" />
16
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.15.1/cdn/shoelace-autoloader.js"></script>
17
+
18
+ <style>
19
+ :not(:defined) {
20
+ visibility: hidden;
21
+ }
22
+
23
+ body {
24
+ opacity: 0;
25
+ display: flex;
26
+ flex-direction: column;
27
+ justify-content: center;
28
+ align-items: center;
29
+ min-height: 100vh;
30
+ margin: 0;
31
+ background: radial-gradient(ellipse at bottom, #25292c 0%, #0c0d13 100%);
32
+ font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
33
+ font-size: 1rem;
34
+ font-weight: 400;
35
+ }
36
+
37
+ body.ready {
38
+ opacity: 1;
39
+ transition: 0.25s opacity;
40
+ }
41
+
42
+ ::-webkit-scrollbar {
43
+ overflow: hidden;
44
+ }
45
+
46
+ .header {
47
+ text-align: center;
48
+ width: 40%;
49
+ margin-bottom: 20px;
50
+ }
51
+
52
+ .comet-text {
53
+ font-size: calc(1.375rem + 1.5vw);
54
+ font-weight: 500;
55
+ margin-bottom: 0;
56
+ }
57
+
58
+ .emoji {
59
+ width: 1em;
60
+ height: 1em;
61
+ vertical-align: middle;
62
+ }
63
+
64
+ .form-container {
65
+ background-color: #1a1d20;
66
+ padding: 2rem;
67
+ border-radius: 0.375rem;
68
+ box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
69
+ width: 80vw;
70
+ max-width: 950px;
71
+ margin-bottom: 50px;
72
+ }
73
+
74
+ .form-item {
75
+ margin-bottom: 0.75rem;
76
+ }
77
+
78
+ sl-details {
79
+ margin-bottom: 0.75rem;
80
+ }
81
+
82
+ .centered-item {
83
+ display: flex;
84
+ justify-content: center;
85
+ }
86
+
87
+ .margin-left-install {
88
+ margin-right: 10px;
89
+ }
90
+
91
+ .stars {
92
+ position: fixed;
93
+ top: 0;
94
+ left: 0;
95
+ width: 100%;
96
+ height: 120%;
97
+ transform: rotate(-45deg);
98
+ z-index: -1;
99
+ }
100
+ .star {
101
+ --star-color: var(--primary-color);
102
+ --star-tail-length: 6em;
103
+ --star-tail-height: 2px;
104
+ --star-width: calc(var(--star-tail-length) / 6);
105
+ --fall-duration: 9s;
106
+ --tail-fade-duration: var(--fall-duration);
107
+ position: absolute;
108
+ top: var(--top-offset);
109
+ left: 0;
110
+ width: var(--star-tail-length);
111
+ height: var(--star-tail-height);
112
+ color: var(--star-color);
113
+ background: linear-gradient(45deg, currentColor, transparent);
114
+ border-radius: 50%;
115
+ filter: drop-shadow(0 0 6px currentColor);
116
+ transform: translate3d(104em, 0, 0);
117
+ animation: fall var(--fall-duration) var(--fall-delay) linear infinite, tail-fade var(--tail-fade-duration) var(--fall-delay) ease-out infinite;
118
+ }
119
+ @media screen and (max-width: 750px) {
120
+ .star {
121
+ animation: fall var(--fall-duration) var(--fall-delay) linear infinite;
122
+ }
123
+ }
124
+ .star:nth-child(1) {
125
+ --star-tail-length: 6.14em;
126
+ --top-offset: 3.64vh;
127
+ --fall-duration: 10.878s;
128
+ --fall-delay: 0.034s;
129
+ }
130
+ .star:nth-child(2) {
131
+ --star-tail-length: 5.08em;
132
+ --top-offset: 69.69vh;
133
+ --fall-duration: 11.372s;
134
+ --fall-delay: 1.679s;
135
+ }
136
+ .star:nth-child(3) {
137
+ --star-tail-length: 6.1em;
138
+ --top-offset: 64.3vh;
139
+ --fall-duration: 7.088s;
140
+ --fall-delay: 3.382s;
141
+ }
142
+ .star:nth-child(4) {
143
+ --star-tail-length: 6.66em;
144
+ --top-offset: 34.91vh;
145
+ --fall-duration: 6.184s;
146
+ --fall-delay: 9.61s;
147
+ }
148
+ .star:nth-child(5) {
149
+ --star-tail-length: 6.89em;
150
+ --top-offset: 24.92vh;
151
+ --fall-duration: 9.465s;
152
+ --fall-delay: 9.12s;
153
+ }
154
+ .star:nth-child(6) {
155
+ --star-tail-length: 6.5em;
156
+ --top-offset: 51.9vh;
157
+ --fall-duration: 10.52s;
158
+ --fall-delay: 0.214s;
159
+ }
160
+ .star:nth-child(7) {
161
+ --star-tail-length: 5.58em;
162
+ --top-offset: 24.15vh;
163
+ --fall-duration: 8.9s;
164
+ --fall-delay: 0.499s;
165
+ }
166
+ .star:nth-child(8) {
167
+ --star-tail-length: 6.26em;
168
+ --top-offset: 59.4vh;
169
+ --fall-duration: 7.671s;
170
+ --fall-delay: 1.694s;
171
+ }
172
+ .star:nth-child(9) {
173
+ --star-tail-length: 6.46em;
174
+ --top-offset: 54.52vh;
175
+ --fall-duration: 6.484s;
176
+ --fall-delay: 4.616s;
177
+ }
178
+ .star:nth-child(10) {
179
+ --star-tail-length: 5.34em;
180
+ --top-offset: 74.03vh;
181
+ --fall-duration: 8.565s;
182
+ --fall-delay: 1.159s;
183
+ }
184
+ .star:nth-child(11) {
185
+ --star-tail-length: 6.84em;
186
+ --top-offset: 90.94vh;
187
+ --fall-duration: 10.133s;
188
+ --fall-delay: 6.108s;
189
+ }
190
+ .star:nth-child(12) {
191
+ --star-tail-length: 5.48em;
192
+ --top-offset: 97.27vh;
193
+ --fall-duration: 10.248s;
194
+ --fall-delay: 4.186s;
195
+ }
196
+ .star:nth-child(13) {
197
+ --star-tail-length: 7.21em;
198
+ --top-offset: 17.75vh;
199
+ --fall-duration: 10.549s;
200
+ --fall-delay: 1.868s;
201
+ }
202
+ .star:nth-child(14) {
203
+ --star-tail-length: 6.35em;
204
+ --top-offset: 94.98vh;
205
+ --fall-duration: 9.682s;
206
+ --fall-delay: 9.327s;
207
+ }
208
+ .star:nth-child(15) {
209
+ --star-tail-length: 5.18em;
210
+ --top-offset: 52.87vh;
211
+ --fall-duration: 9.934s;
212
+ --fall-delay: 8.919s;
213
+ }
214
+ .star:nth-child(16) {
215
+ --star-tail-length: 5.07em;
216
+ --top-offset: 50.26vh;
217
+ --fall-duration: 11.826s;
218
+ --fall-delay: 8.478s;
219
+ }
220
+ .star:nth-child(17) {
221
+ --star-tail-length: 7.01em;
222
+ --top-offset: 85.73vh;
223
+ --fall-duration: 9.87s;
224
+ --fall-delay: 1.206s;
225
+ }
226
+ .star:nth-child(18) {
227
+ --star-tail-length: 6.39em;
228
+ --top-offset: 2.81vh;
229
+ --fall-duration: 10.292s;
230
+ --fall-delay: 4.394s;
231
+ }
232
+ .star:nth-child(19) {
233
+ --star-tail-length: 5.27em;
234
+ --top-offset: 56.83vh;
235
+ --fall-duration: 8.944s;
236
+ --fall-delay: 8.779s;
237
+ }
238
+ .star:nth-child(20) {
239
+ --star-tail-length: 6.07em;
240
+ --top-offset: 54.55vh;
241
+ --fall-duration: 9.324s;
242
+ --fall-delay: 7.375s;
243
+ }
244
+ .star:nth-child(21) {
245
+ --star-tail-length: 6.1em;
246
+ --top-offset: 87.67vh;
247
+ --fall-duration: 11.943s;
248
+ --fall-delay: 6.919s;
249
+ }
250
+ .star:nth-child(22) {
251
+ --star-tail-length: 5.98em;
252
+ --top-offset: 70.04vh;
253
+ --fall-duration: 9.995s;
254
+ --fall-delay: 4.472s;
255
+ }
256
+ .star:nth-child(23) {
257
+ --star-tail-length: 6.34em;
258
+ --top-offset: 77.19vh;
259
+ --fall-duration: 10.073s;
260
+ --fall-delay: 8.354s;
261
+ }
262
+ .star:nth-child(24) {
263
+ --star-tail-length: 6.95em;
264
+ --top-offset: 14.48vh;
265
+ --fall-duration: 9.028s;
266
+ --fall-delay: 7.638s;
267
+ }
268
+ .star:nth-child(25) {
269
+ --star-tail-length: 6.23em;
270
+ --top-offset: 8.48vh;
271
+ --fall-duration: 7.427s;
272
+ --fall-delay: 0.915s;
273
+ }
274
+ .star:nth-child(26) {
275
+ --star-tail-length: 5.09em;
276
+ --top-offset: 6.56vh;
277
+ --fall-duration: 7.706s;
278
+ --fall-delay: 2.841s;
279
+ }
280
+ .star:nth-child(27) {
281
+ --star-tail-length: 7.01em;
282
+ --top-offset: 92.85vh;
283
+ --fall-duration: 7.359s;
284
+ --fall-delay: 7.229s;
285
+ }
286
+ .star:nth-child(28) {
287
+ --star-tail-length: 5.49em;
288
+ --top-offset: 27.89vh;
289
+ --fall-duration: 10.344s;
290
+ --fall-delay: 2.346s;
291
+ }
292
+ .star:nth-child(29) {
293
+ --star-tail-length: 5.82em;
294
+ --top-offset: 56.08vh;
295
+ --fall-duration: 10.911s;
296
+ --fall-delay: 4.231s;
297
+ }
298
+ .star:nth-child(30) {
299
+ --star-tail-length: 7.24em;
300
+ --top-offset: 22.54vh;
301
+ --fall-duration: 9.344s;
302
+ --fall-delay: 2.112s;
303
+ }
304
+ .star:nth-child(31) {
305
+ --star-tail-length: 6.8em;
306
+ --top-offset: 59.49vh;
307
+ --fall-duration: 7.059s;
308
+ --fall-delay: 0.924s;
309
+ }
310
+ .star:nth-child(32) {
311
+ --star-tail-length: 5.22em;
312
+ --top-offset: 44.01vh;
313
+ --fall-duration: 10.121s;
314
+ --fall-delay: 0.591s;
315
+ }
316
+ .star:nth-child(33) {
317
+ --star-tail-length: 6.1em;
318
+ --top-offset: 78.61vh;
319
+ --fall-duration: 8.306s;
320
+ --fall-delay: 4.403s;
321
+ }
322
+ .star:nth-child(34) {
323
+ --star-tail-length: 7.26em;
324
+ --top-offset: 85.76vh;
325
+ --fall-duration: 7.058s;
326
+ --fall-delay: 6.772s;
327
+ }
328
+ .star:nth-child(35) {
329
+ --star-tail-length: 7.01em;
330
+ --top-offset: 77.17vh;
331
+ --fall-duration: 6.29s;
332
+ --fall-delay: 1.468s;
333
+ }
334
+ .star:nth-child(36) {
335
+ --star-tail-length: 5.17em;
336
+ --top-offset: 13.63vh;
337
+ --fall-duration: 6.739s;
338
+ --fall-delay: 0.019s;
339
+ }
340
+ .star:nth-child(37) {
341
+ --star-tail-length: 6.41em;
342
+ --top-offset: 70.18vh;
343
+ --fall-duration: 6.177s;
344
+ --fall-delay: 8.148s;
345
+ }
346
+ .star:nth-child(38) {
347
+ --star-tail-length: 5.32em;
348
+ --top-offset: 62.65vh;
349
+ --fall-duration: 10.476s;
350
+ --fall-delay: 0.98s;
351
+ }
352
+ .star:nth-child(39) {
353
+ --star-tail-length: 7.24em;
354
+ --top-offset: 66.12vh;
355
+ --fall-duration: 8.449s;
356
+ --fall-delay: 4.255s;
357
+ }
358
+ .star:nth-child(40) {
359
+ --star-tail-length: 6.73em;
360
+ --top-offset: 14.73vh;
361
+ --fall-duration: 9.857s;
362
+ --fall-delay: 6.867s;
363
+ }
364
+ .star:nth-child(41) {
365
+ --star-tail-length: 5.25em;
366
+ --top-offset: 45.23vh;
367
+ --fall-duration: 7.898s;
368
+ --fall-delay: 4.966s;
369
+ }
370
+ .star:nth-child(42) {
371
+ --star-tail-length: 6.73em;
372
+ --top-offset: 36.17vh;
373
+ --fall-duration: 7.32s;
374
+ --fall-delay: 3.93s;
375
+ }
376
+ .star:nth-child(43) {
377
+ --star-tail-length: 7.38em;
378
+ --top-offset: 83.09vh;
379
+ --fall-duration: 7.394s;
380
+ --fall-delay: 5.388s;
381
+ }
382
+ .star:nth-child(44) {
383
+ --star-tail-length: 5.18em;
384
+ --top-offset: 98.36vh;
385
+ --fall-duration: 6.905s;
386
+ --fall-delay: 2.771s;
387
+ }
388
+ .star:nth-child(45) {
389
+ --star-tail-length: 6.66em;
390
+ --top-offset: 27.99vh;
391
+ --fall-duration: 7.62s;
392
+ --fall-delay: 3.624s;
393
+ }
394
+ .star:nth-child(46) {
395
+ --star-tail-length: 5.19em;
396
+ --top-offset: 92vh;
397
+ --fall-duration: 9.158s;
398
+ --fall-delay: 1.984s;
399
+ }
400
+ .star:nth-child(47) {
401
+ --star-tail-length: 6.16em;
402
+ --top-offset: 2.87vh;
403
+ --fall-duration: 9.266s;
404
+ --fall-delay: 4.04s;
405
+ }
406
+ .star:nth-child(48) {
407
+ --star-tail-length: 6.34em;
408
+ --top-offset: 19.39vh;
409
+ --fall-duration: 7.503s;
410
+ --fall-delay: 0.045s;
411
+ }
412
+ .star:nth-child(49) {
413
+ --star-tail-length: 6.85em;
414
+ --top-offset: 79.92vh;
415
+ --fall-duration: 7.472s;
416
+ --fall-delay: 1.514s;
417
+ }
418
+ .star:nth-child(50) {
419
+ --star-tail-length: 7.35em;
420
+ --top-offset: 63.71vh;
421
+ --fall-duration: 8.117s;
422
+ --fall-delay: 4.46s;
423
+ }
424
+ .star::before, .star::after {
425
+ position: absolute;
426
+ content: "";
427
+ top: 0;
428
+ left: calc(var(--star-width) / -2);
429
+ width: var(--star-width);
430
+ height: 100%;
431
+ background: linear-gradient(45deg, transparent, currentColor, transparent);
432
+ border-radius: inherit;
433
+ animation: blink 2s linear infinite;
434
+ }
435
+ .star::before {
436
+ transform: rotate(45deg);
437
+ }
438
+ .star::after {
439
+ transform: rotate(-45deg);
440
+ }
441
+
442
+ @keyframes fall {
443
+ to {
444
+ transform: translate3d(-30em, 0, 0);
445
+ }
446
+ }
447
+ @keyframes tail-fade {
448
+ 0%, 50% {
449
+ width: var(--star-tail-length);
450
+ opacity: 1;
451
+ }
452
+ 70%, 80% {
453
+ width: 0;
454
+ opacity: 0.4;
455
+ }
456
+ 100% {
457
+ width: 0;
458
+ opacity: 0;
459
+ }
460
+ }
461
+ @keyframes blink {
462
+ 50% {
463
+ opacity: 0.6;
464
+ }
465
+ }
466
+ </style>
467
+ </head>
468
+
469
+ <body>
470
+ <div class="stars"></div>
471
+
472
+ <script>
473
+ let hasTouchScreen = false;
474
+ if ("maxTouchPoints" in navigator) {
475
+ hasTouchScreen = navigator.maxTouchPoints > 0;
476
+ } else if ("msMaxTouchPoints" in navigator) {
477
+ hasTouchScreen = navigator.msMaxTouchPoints > 0;
478
+ } else {
479
+ const mQ = matchMedia?.("(pointer:coarse)");
480
+ if (mQ?.media === "(pointer:coarse)") {
481
+ hasTouchScreen = !!mQ.matches;
482
+ } else if ("orientation" in window) {
483
+ hasTouchScreen = true;
484
+ } else {
485
+ const UA = navigator.userAgent;
486
+ hasTouchScreen =
487
+ /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) ||
488
+ /\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA);
489
+ }
490
+ }
491
+
492
+ if (!hasTouchScreen) {
493
+ document.addEventListener("DOMContentLoaded", function() {
494
+ const starsContainer = document.querySelector('.stars');
495
+ const starCount = 30
496
+
497
+ for (let i = 0; i < starCount; i++) {
498
+ const star = document.createElement("div");
499
+ star.classList.add("star");
500
+ starsContainer.appendChild(star);
501
+ }
502
+ });
503
+ }
504
+ </script>
505
+ <div class="header">
506
+ <p class="comet-text">
507
+ <img class="emoji" src="https://fonts.gstatic.com/s/e/notoemoji/latest/1f4ab/512.gif">
508
+ Comet - <a href="https://github.com/g0ldyy/comet">GitHub</a>
509
+ </p>
510
+ {{CUSTOM_HEADER_HTML|safe}}
511
+ </div>
512
+
513
+ <div class="form-container">
514
+ <div class="form-item">
515
+ <sl-select id="indexers" multiple clearable label="Indexers" placeholder="Select indexers" {% if not indexerManager %} disabled {% endif %}></sl-select>
516
+ </div>
517
+
518
+ <div class="form-item">
519
+ <sl-select id="languages" multiple clearable label="Languages" placeholder="Select languages"></sl-select>
520
+ </div>
521
+
522
+ <div class="form-item">
523
+ <sl-select id="resolutions" multiple clearable label="Resolutions" placeholder="Select resolutions"></sl-select>
524
+ </div>
525
+
526
+ <div class="form-item">
527
+ <sl-input id="maxResults" type="number" min=0 value=0 label="Max Results" placeholder="Enter max results"></sl-input>
528
+ </div>
529
+
530
+ <div class="form-item">
531
+ <sl-input id="maxSize" type="number" min=0 value=0 label="Max Size (GB)" placeholder="Enter max size in gigabytes"></sl-input>
532
+ </div>
533
+
534
+ <div class="form-item">
535
+ <sl-input id="debridStreamProxyPassword" label="Debrid Stream Proxy Password" placeholder="{% if not proxyDebridStream %}Configuration required, see docs{% else %}Enter password{% endif %}" help-text="Debrid Stream Proxying allows you to use your Debrid Service from multiple IPs at same time!" {% if not proxyDebridStream %} disabled {% endif %}></sl-input>
536
+ </div>
537
+
538
+ <div class="form-item">
539
+ <sl-select id="debridService" value="realdebrid" label="Debrid Service" placeholder="Select debrid service">
540
+ <sl-option value="realdebrid">Real-Debrid</sl-option>
541
+ <sl-option value="alldebrid">All-Debrid</sl-option>
542
+ <sl-option value="premiumize">Premiumize</sl-option>
543
+ <sl-option value="torbox">TorBox</sl-option>
544
+ <sl-option value="debridlink">Debrid-Link</sl-option>
545
+ </sl-select>
546
+ </div>
547
+
548
+ <div class="form-item">
549
+ <label for="debridService">
550
+ Debrid API Key -
551
+ <a id="apiKeyLink" href="https://real-debrid.com/apitoken" target="_blank">Get It Here</a>
552
+ </label>
553
+ <sl-input id="debridApiKey" placeholder="Enter API key"></sl-input>
554
+ </div>
555
+
556
+ <sl-details summary="Advanced Settings">
557
+ <div class="form-item">
558
+ <sl-select id="resultFormat" multiple label="Result Format" placeholder="Select what to show in result title" hoist max-options-visible=10>
559
+ </sl-select>
560
+ </div>
561
+ </sl-details>
562
+
563
+ <script>
564
+ document.getElementById("debridService").addEventListener("sl-change", function(event) {
565
+ const selectedService = event.target.value;
566
+ const apiKeyLink = document.getElementById("apiKeyLink");
567
+
568
+ if (selectedService === "realdebrid") {
569
+ apiKeyLink.href = "https://real-debrid.com/apitoken";
570
+ } else if (selectedService === "alldebrid") {
571
+ apiKeyLink.href = "https://alldebrid.com/apikeys";
572
+ } else if (selectedService === "premiumize") {
573
+ apiKeyLink.href = "https://premiumize.me/account";
574
+ } else if (selectedService === "torbox") {
575
+ apiKeyLink.href = "https://torbox.app/settings";
576
+ } else if (selectedService === "debridlink") {
577
+ apiKeyLink.href = "https://debrid-link.com/webapp/apikey";
578
+ }
579
+ });
580
+ </script>
581
+
582
+ <div class="centered-item">
583
+ <sl-button id="install" variant="neutral" class="margin-left-install">Install</sl-button>
584
+ <sl-alert id="installAlert" variant="neutral" duration="3000" closable>
585
+ <sl-icon slot="icon" name="clipboard2-check"></sl-icon>
586
+ <strong>Attempting to add the addon to Stremio...</strong>
587
+ </sl-alert>
588
+
589
+ <sl-button id="copy-link" variant="neutral">Copy Link</sl-button>
590
+ <sl-alert id="copyAlert" variant="neutral" duration="3000" closable>
591
+ <sl-icon slot="icon" name="clipboard2-check"></sl-icon>
592
+ <strong>The Stremio addon link has been automatically copied.</strong>
593
+ </sl-alert>
594
+
595
+ <script type="module">
596
+ const languagesEmojis = {
597
+ "Multi": "🌎",
598
+ "English": "🇬🇧",
599
+ "Japanese": "🇯🇵",
600
+ "Chinese": "🇨🇳",
601
+ "Russian": "🇷🇺",
602
+ "Arabic": "🇸🇦",
603
+ "Portuguese": "🇵🇹",
604
+ "Spanish": "🇪🇸",
605
+ "French": "🇫🇷",
606
+ "German": "🇩🇪",
607
+ "Italian": "🇮🇹",
608
+ "Korean": "🇰🇷",
609
+ "Hindi": "🇮🇳",
610
+ "Bengali": "🇧🇩",
611
+ "Punjabi": "🇵🇰",
612
+ "Marathi": "🇮🇳",
613
+ "Gujarati": "🇮🇳",
614
+ "Tamil": "🇮🇳",
615
+ "Telugu": "🇮🇳",
616
+ "Kannada": "🇮🇳",
617
+ "Malayalam": "🇮🇳",
618
+ "Thai": "🇹🇭",
619
+ "Vietnamese": "🇻🇳",
620
+ "Indonesian": "🇮🇩",
621
+ "Turkish": "🇹🇷",
622
+ "Hebrew": "🇮🇱",
623
+ "Persian": "🇮🇷",
624
+ "Ukrainian": "🇺🇦",
625
+ "Greek": "🇬🇷",
626
+ "Lithuanian": "🇱🇹",
627
+ "Latvian": "🇱🇻",
628
+ "Estonian": "🇪🇪",
629
+ "Polish": "🇵🇱",
630
+ "Czech": "🇨🇿",
631
+ "Slovak": "🇸🇰",
632
+ "Hungarian": "🇭🇺",
633
+ "Romanian": "🇷🇴",
634
+ "Bulgarian": "🇧🇬",
635
+ "Serbian": "🇷🇸",
636
+ "Croatian": "🇭🇷",
637
+ "Slovenian": "🇸🇮",
638
+ "Dutch": "🇳🇱",
639
+ "Danish": "🇩🇰",
640
+ "Finnish": "🇫🇮",
641
+ "Swedish": "🇸🇪",
642
+ "Norwegian": "🇳🇴",
643
+ "Malay": "🇲🇾",
644
+ "Latino": "💃🏻",
645
+ };
646
+
647
+ let defaultLanguages = [];
648
+ let defaultResolutions = [];
649
+ let defaultResultFormat = [];
650
+
651
+ document.addEventListener("DOMContentLoaded", async () => {
652
+ await Promise.allSettled([
653
+ customElements.whenDefined("sl-button"),
654
+ customElements.whenDefined("sl-alert"),
655
+ customElements.whenDefined("sl-select"),
656
+ customElements.whenDefined("sl-input"),
657
+ customElements.whenDefined("sl-option"),
658
+ customElements.whenDefined("sl-icon")
659
+ ]);
660
+
661
+ const webConfig = {{webConfig|tojson}};
662
+ populateSelect("indexers", webConfig.indexers);
663
+ populateSelect("languages", webConfig.languages);
664
+ populateSelect("resolutions", webConfig.resolutions);
665
+ populateSelect("resultFormat", webConfig.resultFormat);
666
+ document.body.classList.add("ready");
667
+ defaultLanguages = webConfig.languages;
668
+ defaultResolutions = webConfig.resolutions;
669
+ defaultResultFormat = webConfig.resultFormat;
670
+
671
+ // try populate the form from previous settings
672
+ try {
673
+ const settings = getSettingsFromUrl();
674
+ if (settings != null) { populateFormFromSettings(settings); }
675
+ } catch (error) {
676
+ console.log("Failed to retrieve or parse settings from URL:", error);
677
+ }
678
+
679
+ });
680
+
681
+ function populateSelect(selectId, options) {
682
+ const selectElement = document.getElementById(selectId);
683
+ options.forEach(option => {
684
+ const optionElement = document.createElement("sl-option");
685
+ optionElement.value = option;
686
+
687
+ if (selectId === "languages") {
688
+ // For languages, prepend the flag emoji if it exists
689
+ const flag = languagesEmojis[option] || '';
690
+ optionElement.textContent = `${flag} ${option}`;
691
+ } else {
692
+ // For other selects, just use the option text as is
693
+ optionElement.textContent = option;
694
+ }
695
+
696
+ selectElement.appendChild(optionElement);
697
+ });
698
+
699
+ // Set the default value
700
+ selectElement.value = options; // Assuming first option as default
701
+ }
702
+
703
+ const installButton = document.querySelector("#install");
704
+ const installAlert = document.querySelector('#installAlert');
705
+ const copyLinkButton = document.querySelector("#copy-link");
706
+ const copyAlert = document.querySelector('#copyAlert');
707
+
708
+ function getSettings() {
709
+ const indexers = Array.from(document.getElementById("indexers").selectedOptions).map(option => option.value);
710
+ const languages = Array.from(document.getElementById("languages").selectedOptions).map(option => option.value);
711
+ const resolutions = Array.from(document.getElementById("resolutions").selectedOptions).map(option => option.value);
712
+ const maxResults = document.getElementById("maxResults").value;
713
+ const maxSize = document.getElementById("maxSize").value;
714
+ const resultFormat = Array.from(document.getElementById("resultFormat").selectedOptions).map(option => option.value);
715
+ const debridService = document.getElementById("debridService").value;
716
+ const debridApiKey = document.getElementById("debridApiKey").value;
717
+ const debridStreamProxyPassword = document.getElementById("debridStreamProxyPassword").value;
718
+ const selectedLanguages = languages.length === defaultLanguages.length && languages.every((val, index) => val === defaultLanguages[index]) ? ["All"] : languages;
719
+ const selectedResolutions = resolutions.length === defaultResolutions.length && resolutions.every((val, index) => val === defaultResolutions[index]) ? ["All"] : resolutions;
720
+ const selectedResultFormat = resultFormat.length === defaultResultFormat.length && resultFormat.every((val, index) => val === defaultResultFormat[index]) ? ["All"] : resultFormat;
721
+
722
+ return {
723
+ indexers: indexers,
724
+ maxResults: parseInt(maxResults),
725
+ maxSize: parseFloat(maxSize * 1073741824),
726
+ resultFormat: selectedResultFormat,
727
+ resolutions: selectedResolutions,
728
+ languages: selectedLanguages,
729
+ debridService: debridService,
730
+ debridApiKey: debridApiKey,
731
+ debridStreamProxyPassword: debridStreamProxyPassword,
732
+ };
733
+ }
734
+
735
+ copyLinkButton.addEventListener("click", () => {
736
+ const settings = getSettings();
737
+ const settingsString = btoa(JSON.stringify(settings))
738
+
739
+ const textArea = document.createElement("textarea");
740
+ textArea.value = `${window.location.origin}/${settingsString}/manifest.json`;
741
+ document.body.appendChild(textArea);
742
+ textArea.focus();
743
+ textArea.select();
744
+ document.execCommand("copy");
745
+ document.body.removeChild(textArea);
746
+
747
+ console.log(settingsString);
748
+
749
+ copyAlert.toast();
750
+ });
751
+
752
+ installButton.addEventListener("click", () => {
753
+ const settings = getSettings();
754
+ const settingsString = btoa(JSON.stringify(settings))
755
+ window.location.href = `stremio://${window.location.host}/${settingsString}/manifest.json`;
756
+ console.log(settingsString);
757
+ installAlert.toast();
758
+ });
759
+
760
+ function getSettingsFromUrl() {
761
+ const url = window.location.href;
762
+ // Try parse settings from the URL
763
+ if (url.split("/").length < 5) {
764
+ console.log("no previous settings"); return null;
765
+ }
766
+ const settingsString = url.split("/")[3];
767
+ if (typeof settingsString === "undefined") {
768
+ console.log("can't fetch previous settings", settingsString)
769
+ return null;
770
+ }
771
+ const settingsJson = atob(settingsString);
772
+ return JSON.parse(settingsJson);
773
+ }
774
+
775
+ function populateFormFromSettings(settings) {
776
+ document.getElementById("maxResults").value = settings.maxResults;
777
+ document.getElementById("maxSize").value = settings.maxSize / 1073741824; // Convert back from bytes to GB
778
+ document.getElementById("debridService").value = settings.debridService;
779
+ document.getElementById("debridApiKey").value = settings.debridApiKey;
780
+ document.getElementById("debridStreamProxyPassword").value = settings.debridStreamProxyPassword;
781
+ document.getElementById("indexers").value = settings.indexers;
782
+ if (settings.languages != "All")
783
+ document.getElementById("languages").value = settings.languages;
784
+ if (settings.resolutions != "All")
785
+ document.getElementById("resolutions").value = settings.resolutions;
786
+ if (settings.resultFormat != "All")
787
+ document.getElementById("resultFormat").value = settings.resultFormat;
788
+ }
789
+
790
+ </script>
791
+ </div>
792
+ </div>
793
+ </body>
794
+ </html>
comet/utils/db.py CHANGED
@@ -6,16 +6,22 @@ from comet.utils.models import database, settings
6
 
7
  async def setup_database():
8
  try:
9
- # Ensure the database directory exists
10
- os.makedirs(os.path.dirname(settings.DATABASE_PATH), exist_ok=True)
11
 
12
- # Ensure the database file exists
13
- if not os.path.exists(settings.DATABASE_PATH):
14
- open(settings.DATABASE_PATH, "a").close()
15
 
16
  await database.connect()
17
  await database.execute(
18
- "CREATE TABLE IF NOT EXISTS cache (cacheKey BLOB PRIMARY KEY, timestamp INTEGER, results TEXT)"
 
 
 
 
 
 
 
19
  )
20
  except Exception as e:
21
  logger.error(f"Error setting up the database: {e}")
 
6
 
7
  async def setup_database():
8
  try:
9
+ if settings.DATABASE_TYPE == "sqlite":
10
+ os.makedirs(os.path.dirname(settings.DATABASE_PATH), exist_ok=True)
11
 
12
+ if not os.path.exists(settings.DATABASE_PATH):
13
+ open(settings.DATABASE_PATH, "a").close()
 
14
 
15
  await database.connect()
16
  await database.execute(
17
+ "CREATE TABLE IF NOT EXISTS cache (cacheKey TEXT PRIMARY KEY, timestamp INTEGER, results TEXT)"
18
+ )
19
+ await database.execute(
20
+ "CREATE TABLE IF NOT EXISTS download_links (debrid_key TEXT, hash TEXT, file_index TEXT, link TEXT, timestamp INTEGER, PRIMARY KEY (debrid_key, hash, file_index))"
21
+ )
22
+ await database.execute("DROP TABLE IF EXISTS active_connections")
23
+ await database.execute(
24
+ "CREATE TABLE IF NOT EXISTS active_connections (id TEXT PRIMARY KEY, ip TEXT, content TEXT, timestamp INTEGER)"
25
  )
26
  except Exception as e:
27
  logger.error(f"Error setting up the database: {e}")
comet/utils/general.py CHANGED
@@ -1,371 +1,658 @@
1
- import base64
2
- import hashlib
3
- import json
4
- import math
5
- import re
6
- import aiohttp
7
- import bencodepy
8
-
9
- from comet.utils.logger import logger
10
- from comet.utils.models import settings
11
-
12
- translation_table = {
13
- "ā": "a",
14
- "ă": "a",
15
- "ą": "a",
16
- "ć": "c",
17
- "č": "c",
18
- "ç": "c",
19
- "ĉ": "c",
20
- "ċ": "c",
21
- "ď": "d",
22
- "đ": "d",
23
- "è": "e",
24
- "é": "e",
25
- "ê": "e",
26
- "ë": "e",
27
- "ē": "e",
28
- "ĕ": "e",
29
- "ę": "e",
30
- "ě": "e",
31
- "ĝ": "g",
32
- "ğ": "g",
33
- "ġ": "g",
34
- "ģ": "g",
35
- "ĥ": "h",
36
- "î": "i",
37
- "ï": "i",
38
- "ì": "i",
39
- "í": "i",
40
- "ī": "i",
41
- "ĩ": "i",
42
- "ĭ": "i",
43
- "ı": "i",
44
- "ĵ": "j",
45
- "ķ": "k",
46
- "ĺ": "l",
47
- "ļ": "l",
48
- "ł": "l",
49
- "ń": "n",
50
- "ň": "n",
51
- "ñ": "n",
52
- "ņ": "n",
53
- "ʼn": "n",
54
- "ó": "o",
55
- "ô": "o",
56
- "õ": "o",
57
- "ö": "o",
58
- "ø": "o",
59
- "ō": "o",
60
- "ő": "o",
61
- "œ": "oe",
62
- "ŕ": "r",
63
- "ř": "r",
64
- "ŗ": "r",
65
- "š": "s",
66
- "ş": "s",
67
- "ś": "s",
68
- "ș": "s",
69
- "ß": "ss",
70
- "ť": "t",
71
- "ţ": "t",
72
- "ū": "u",
73
- "ŭ": "u",
74
- "ũ": "u",
75
- "û": "u",
76
- "ü": "u",
77
- "ù": "u",
78
- "ú": "u",
79
- "ų": "u",
80
- "ű": "u",
81
- "ŵ": "w",
82
- "ý": "y",
83
- "ÿ": "y",
84
- "ŷ": "y",
85
- "ž": "z",
86
- "ż": "z",
87
- "ź": "z",
88
- "æ": "ae",
89
- "ǎ": "a",
90
- "ǧ": "g",
91
- "ə": "e",
92
- "ƒ": "f",
93
- "ǐ": "i",
94
- "ǒ": "o",
95
- "ǔ": "u",
96
- "ǚ": "u",
97
- "ǜ": "u",
98
- "ǹ": "n",
99
- "ǻ": "a",
100
- "ǽ": "ae",
101
- "ǿ": "o",
102
- }
103
-
104
- translation_table = str.maketrans(translation_table)
105
- info_hash_pattern = re.compile(r"\b([a-fA-F0-9]{40})\b")
106
-
107
-
108
- def translate(title: str):
109
- return title.translate(translation_table)
110
-
111
-
112
- def is_video(title: str):
113
- return title.endswith(
114
- tuple(
115
- [
116
- ".mkv",
117
- ".mp4",
118
- ".avi",
119
- ".mov",
120
- ".flv",
121
- ".wmv",
122
- ".webm",
123
- ".mpg",
124
- ".mpeg",
125
- ".m4v",
126
- ".3gp",
127
- ".3g2",
128
- ".ogv",
129
- ".ogg",
130
- ".drc",
131
- ".gif",
132
- ".gifv",
133
- ".mng",
134
- ".avi",
135
- ".mov",
136
- ".qt",
137
- ".wmv",
138
- ".yuv",
139
- ".rm",
140
- ".rmvb",
141
- ".asf",
142
- ".amv",
143
- ".m4p",
144
- ".m4v",
145
- ".mpg",
146
- ".mp2",
147
- ".mpeg",
148
- ".mpe",
149
- ".mpv",
150
- ".mpg",
151
- ".mpeg",
152
- ".m2v",
153
- ".m4v",
154
- ".svi",
155
- ".3gp",
156
- ".3g2",
157
- ".mxf",
158
- ".roq",
159
- ".nsv",
160
- ".flv",
161
- ".f4v",
162
- ".f4p",
163
- ".f4a",
164
- ".f4b",
165
- ]
166
- )
167
- )
168
-
169
-
170
- def bytes_to_size(bytes: int):
171
- sizes = ["Bytes", "KB", "MB", "GB", "TB"]
172
-
173
- if bytes == 0:
174
- return "0 Byte"
175
-
176
- i = int(math.floor(math.log(bytes, 1024)))
177
-
178
- return f"{round(bytes / math.pow(1024, i), 2)} {sizes[i]}"
179
-
180
-
181
- def config_check(b64config: str):
182
- try:
183
- config = json.loads(base64.b64decode(b64config).decode())
184
-
185
- if not isinstance(config["debridService"], str) or config[
186
- "debridService"
187
- ] not in ["realdebrid"]:
188
- return False
189
- if not isinstance(config["debridApiKey"], str):
190
- return False
191
- if not isinstance(config["indexers"], list):
192
- return False
193
- if not isinstance(config["maxResults"], int) or config["maxResults"] < 0:
194
- return False
195
- if (
196
- not isinstance(config["resolutions"], list)
197
- or len(config["resolutions"]) == 0
198
- ):
199
- return False
200
- if not isinstance(config["languages"], list) or len(config["languages"]) == 0:
201
- return False
202
-
203
- return config
204
- except:
205
- return False
206
-
207
-
208
- async def get_indexer_manager(
209
- session: aiohttp.ClientSession,
210
- indexer_manager_type: str,
211
- indexers: list,
212
- query: str,
213
- ):
214
- try:
215
- indexers = [indexer.replace("_", " ") for indexer in indexers]
216
-
217
- timeout = aiohttp.ClientTimeout(total=settings.INDEXER_MANAGER_TIMEOUT)
218
- results = []
219
-
220
- if indexer_manager_type == "jackett":
221
- response = await session.get(
222
- f"{settings.INDEXER_MANAGER_URL}/api/v2.0/indexers/all/results?apikey={settings.INDEXER_MANAGER_API_KEY}&Query={query}&Tracker[]={'&Tracker[]='.join(indexer for indexer in indexers)}",
223
- timeout=timeout,
224
- ) # &Category[]=2000&Category[]=5000
225
- response = await response.json()
226
-
227
- for result in response["Results"]:
228
- results.append(result)
229
-
230
- if indexer_manager_type == "prowlarr":
231
- get_indexers = await session.get(
232
- f"{settings.INDEXER_MANAGER_URL}/api/v1/indexer",
233
- headers={"X-Api-Key": settings.INDEXER_MANAGER_API_KEY},
234
- )
235
- get_indexers = await get_indexers.json()
236
-
237
- indexers_id = []
238
- for indexer in get_indexers:
239
- if (
240
- indexer["name"].lower() in indexers
241
- or indexer["definitionName"].lower() in indexers
242
- ):
243
- indexers_id.append(indexer["id"])
244
-
245
- response = await session.get(
246
- f"{settings.INDEXER_MANAGER_URL}/api/v1/search?query={query}&indexerIds={'&indexerIds='.join(str(indexer_id) for indexer_id in indexers_id)}&type=search",
247
- headers={ # &categories=2000&categories=5000
248
- "X-Api-Key": settings.INDEXER_MANAGER_API_KEY
249
- },
250
- )
251
- response = await response.json()
252
-
253
- for result in response:
254
- results.append(result)
255
-
256
- return results
257
- except Exception as e:
258
- logger.warning(
259
- f"Exception while getting {indexer_manager_type} results for {query} with {indexers}: {e}"
260
- )
261
-
262
-
263
- async def get_torrent_hash(
264
- session: aiohttp.ClientSession, indexer_manager_type: str, torrent: dict
265
- ):
266
- if "InfoHash" in torrent and torrent["InfoHash"] != None:
267
- return torrent["InfoHash"]
268
-
269
- if "infoHash" in torrent:
270
- return torrent["infoHash"]
271
-
272
- url = (
273
- torrent["Link"] if indexer_manager_type == "jackett" else torrent["downloadUrl"]
274
- )
275
-
276
- try:
277
- timeout = aiohttp.ClientTimeout(total=settings.GET_TORRENT_TIMEOUT)
278
- response = await session.get(url, allow_redirects=False, timeout=timeout)
279
- if response.status == 200:
280
- torrent_data = await response.read()
281
- torrent_dict = bencodepy.decode(torrent_data)
282
- info = bencodepy.encode(torrent_dict[b"info"])
283
- hash = hashlib.sha1(info).hexdigest()
284
- else:
285
- location = response.headers.get("Location", "")
286
- if not location:
287
- return
288
-
289
- match = info_hash_pattern.search(location)
290
- if not match:
291
- return
292
-
293
- hash = match.group(1).upper()
294
-
295
- return hash
296
- except Exception as e:
297
- logger.warning(
298
- f"Exception while getting torrent info hash for {torrent['indexer'] if 'indexer' in torrent else (torrent['Tracker'] if 'Tracker' in torrent else '')}|{url}: {e}"
299
- )
300
-
301
-
302
- async def get_balanced_hashes(hashes: dict, config: dict):
303
- max_results = config["maxResults"]
304
- config_resolutions = config["resolutions"]
305
- config_languages = config["languages"]
306
-
307
- hashes_by_resolution = {}
308
- for hash in hashes:
309
- if (
310
- "All" not in config_languages
311
- and not hashes[hash]["data"]["is_multi_audio"]
312
- and not any(
313
- language.replace("_", " ").capitalize()
314
- in hashes[hash]["data"]["language"]
315
- for language in config_languages
316
- )
317
- ):
318
- continue
319
-
320
- resolution = hashes[hash]["data"]["resolution"]
321
- if len(resolution) == 0:
322
- if "All" not in config_resolutions and "Unknown" not in config_resolutions:
323
- continue
324
-
325
- if "Unknown" not in hashes_by_resolution:
326
- hashes_by_resolution["Unknown"] = [hash]
327
- continue
328
-
329
- hashes_by_resolution["Unknown"].append(hash)
330
- continue
331
-
332
- if "All" not in config_resolutions and resolution[0] not in config_resolutions:
333
- continue
334
-
335
- if resolution[0] not in hashes_by_resolution:
336
- hashes_by_resolution[resolution[0]] = [hash]
337
- continue
338
-
339
- hashes_by_resolution[resolution[0]].append(hash)
340
-
341
- if max_results == 0:
342
- return hashes_by_resolution
343
-
344
- total_resolutions = len(hashes_by_resolution)
345
- hashes_per_resolution = max_results // total_resolutions
346
- extra_hashes = max_results % total_resolutions
347
-
348
- balanced_hashes = {}
349
- for resolution, hashes in hashes_by_resolution.items():
350
- selected_count = hashes_per_resolution
351
-
352
- if extra_hashes > 0:
353
- selected_count += 1
354
- extra_hashes -= 1
355
-
356
- balanced_hashes[resolution] = hashes[:selected_count]
357
-
358
- selected_total = sum(len(hashes) for hashes in balanced_hashes.values())
359
- if selected_total < max_results:
360
- missing_hashes = max_results - selected_total
361
-
362
- for resolution, hashes in hashes_by_resolution.items():
363
- if missing_hashes <= 0:
364
- break
365
-
366
- current_count = len(balanced_hashes[resolution])
367
- available_hashes = hashes[current_count : current_count + missing_hashes]
368
- balanced_hashes[resolution].extend(available_hashes)
369
- missing_hashes -= len(available_hashes)
370
-
371
- return balanced_hashes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import base64
2
+ import hashlib
3
+ import json
4
+ import re
5
+ import aiohttp
6
+ import bencodepy
7
+ import PTT
8
+ import asyncio
9
+
10
+ from RTN import parse, title_match
11
+ from curl_cffi import requests
12
+ from fastapi import Request
13
+
14
+ from comet.utils.logger import logger
15
+ from comet.utils.models import settings, ConfigModel
16
+
17
+ languages_emojis = {
18
+ "multi": "🌎", # Dubbed
19
+ "en": "🇬🇧", # English
20
+ "ja": "🇯🇵", # Japanese
21
+ "zh": "🇨🇳", # Chinese
22
+ "ru": "🇷🇺", # Russian
23
+ "ar": "🇸🇦", # Arabic
24
+ "pt": "🇵🇹", # Portuguese
25
+ "es": "🇪🇸", # Spanish
26
+ "fr": "🇫🇷", # French
27
+ "de": "🇩🇪", # German
28
+ "it": "🇮🇹", # Italian
29
+ "ko": "🇰🇷", # Korean
30
+ "hi": "🇮🇳", # Hindi
31
+ "bn": "🇧🇩", # Bengali
32
+ "pa": "🇵🇰", # Punjabi
33
+ "mr": "🇮🇳", # Marathi
34
+ "gu": "🇮🇳", # Gujarati
35
+ "ta": "🇮🇳", # Tamil
36
+ "te": "🇮🇳", # Telugu
37
+ "kn": "🇮🇳", # Kannada
38
+ "ml": "🇮🇳", # Malayalam
39
+ "th": "🇹🇭", # Thai
40
+ "vi": "🇻🇳", # Vietnamese
41
+ "id": "🇮🇩", # Indonesian
42
+ "tr": "🇹🇷", # Turkish
43
+ "he": "🇮🇱", # Hebrew
44
+ "fa": "🇮🇷", # Persian
45
+ "uk": "🇺🇦", # Ukrainian
46
+ "el": "🇬🇷", # Greek
47
+ "lt": "🇱🇹", # Lithuanian
48
+ "lv": "🇱🇻", # Latvian
49
+ "et": "🇪🇪", # Estonian
50
+ "pl": "🇵🇱", # Polish
51
+ "cs": "🇨🇿", # Czech
52
+ "sk": "🇸🇰", # Slovak
53
+ "hu": "🇭🇺", # Hungarian
54
+ "ro": "🇷🇴", # Romanian
55
+ "bg": "🇧🇬", # Bulgarian
56
+ "sr": "🇷🇸", # Serbian
57
+ "hr": "🇭🇷", # Croatian
58
+ "sl": "🇸🇮", # Slovenian
59
+ "nl": "🇳🇱", # Dutch
60
+ "da": "🇩🇰", # Danish
61
+ "fi": "🇫🇮", # Finnish
62
+ "sv": "🇸🇪", # Swedish
63
+ "no": "🇳🇴", # Norwegian
64
+ "ms": "🇲🇾", # Malay
65
+ "la": "💃🏻", # Latino
66
+ }
67
+
68
+
69
+ def get_language_emoji(language: str):
70
+ language_formatted = language.lower()
71
+ return (
72
+ languages_emojis[language_formatted]
73
+ if language_formatted in languages_emojis
74
+ else language
75
+ )
76
+
77
+
78
+ translation_table = {
79
+ "ā": "a",
80
+ "ă": "a",
81
+ "ą": "a",
82
+ "ć": "c",
83
+ "č": "c",
84
+ "ç": "c",
85
+ "ĉ": "c",
86
+ "ċ": "c",
87
+ "ď": "d",
88
+ "đ": "d",
89
+ "è": "e",
90
+ "é": "e",
91
+ "ê": "e",
92
+ "ë": "e",
93
+ "ē": "e",
94
+ "ĕ": "e",
95
+ "ę": "e",
96
+ "ě": "e",
97
+ "ĝ": "g",
98
+ "ğ": "g",
99
+ "ġ": "g",
100
+ "ģ": "g",
101
+ "ĥ": "h",
102
+ "î": "i",
103
+ "ï": "i",
104
+ "ì": "i",
105
+ "í": "i",
106
+ "ī": "i",
107
+ "ĩ": "i",
108
+ "ĭ": "i",
109
+ "ı": "i",
110
+ "ĵ": "j",
111
+ "ķ": "k",
112
+ "ĺ": "l",
113
+ "ļ": "l",
114
+ "ł": "l",
115
+ "ń": "n",
116
+ "ň": "n",
117
+ "ñ": "n",
118
+ "ņ": "n",
119
+ "ʼn": "n",
120
+ "ó": "o",
121
+ "ô": "o",
122
+ "õ": "o",
123
+ "ö": "o",
124
+ "ø": "o",
125
+ "ō": "o",
126
+ "ő": "o",
127
+ "œ": "oe",
128
+ "ŕ": "r",
129
+ "ř": "r",
130
+ "ŗ": "r",
131
+ "š": "s",
132
+ "ş": "s",
133
+ "ś": "s",
134
+ "ș": "s",
135
+ "ß": "ss",
136
+ "ť": "t",
137
+ "ţ": "t",
138
+ "ū": "u",
139
+ "ŭ": "u",
140
+ "ũ": "u",
141
+ "û": "u",
142
+ "ü": "u",
143
+ "ù": "u",
144
+ "ú": "u",
145
+ "ų": "u",
146
+ "ű": "u",
147
+ "ŵ": "w",
148
+ "ý": "y",
149
+ "ÿ": "y",
150
+ "ŷ": "y",
151
+ "ž": "z",
152
+ "ż": "z",
153
+ "ź": "z",
154
+ "æ": "ae",
155
+ "ǎ": "a",
156
+ "ǧ": "g",
157
+ "ə": "e",
158
+ "ƒ": "f",
159
+ "ǐ": "i",
160
+ "ǒ": "o",
161
+ "ǔ": "u",
162
+ "ǚ": "u",
163
+ "ǜ": "u",
164
+ "ǹ": "n",
165
+ "ǻ": "a",
166
+ "ǽ": "ae",
167
+ "ǿ": "o",
168
+ }
169
+
170
+ translation_table = str.maketrans(translation_table)
171
+ info_hash_pattern = re.compile(r"\b([a-fA-F0-9]{40})\b")
172
+
173
+
174
+ def translate(title: str):
175
+ return title.translate(translation_table)
176
+
177
+
178
+ def is_video(title: str):
179
+ return title.endswith(
180
+ tuple(
181
+ [
182
+ ".mkv",
183
+ ".mp4",
184
+ ".avi",
185
+ ".mov",
186
+ ".flv",
187
+ ".wmv",
188
+ ".webm",
189
+ ".mpg",
190
+ ".mpeg",
191
+ ".m4v",
192
+ ".3gp",
193
+ ".3g2",
194
+ ".ogv",
195
+ ".ogg",
196
+ ".drc",
197
+ ".gif",
198
+ ".gifv",
199
+ ".mng",
200
+ ".avi",
201
+ ".mov",
202
+ ".qt",
203
+ ".wmv",
204
+ ".yuv",
205
+ ".rm",
206
+ ".rmvb",
207
+ ".asf",
208
+ ".amv",
209
+ ".m4p",
210
+ ".m4v",
211
+ ".mpg",
212
+ ".mp2",
213
+ ".mpeg",
214
+ ".mpe",
215
+ ".mpv",
216
+ ".mpg",
217
+ ".mpeg",
218
+ ".m2v",
219
+ ".m4v",
220
+ ".svi",
221
+ ".3gp",
222
+ ".3g2",
223
+ ".mxf",
224
+ ".roq",
225
+ ".nsv",
226
+ ".flv",
227
+ ".f4v",
228
+ ".f4p",
229
+ ".f4a",
230
+ ".f4b",
231
+ ]
232
+ )
233
+ )
234
+
235
+
236
+ def bytes_to_size(bytes: int):
237
+ sizes = ["Bytes", "KB", "MB", "GB", "TB"]
238
+ if bytes == 0:
239
+ return "0 Byte"
240
+
241
+ i = 0
242
+ while bytes >= 1024 and i < len(sizes) - 1:
243
+ bytes /= 1024
244
+ i += 1
245
+
246
+ return f"{round(bytes, 2)} {sizes[i]}"
247
+
248
+
249
+ def config_check(b64config: str):
250
+ try:
251
+ config = json.loads(base64.b64decode(b64config).decode())
252
+ validated_config = ConfigModel(**config)
253
+ return validated_config.model_dump()
254
+ except:
255
+ return False
256
+
257
+
258
+ def get_debrid_extension(debridService: str):
259
+ debrid_extension = None
260
+ if debridService == "realdebrid":
261
+ debrid_extension = "RD"
262
+ elif debridService == "alldebrid":
263
+ debrid_extension = "AD"
264
+ elif debridService == "premiumize":
265
+ debrid_extension = "PM"
266
+ elif debridService == "torbox":
267
+ debrid_extension = "TB"
268
+ elif debridService == "debridlink":
269
+ debrid_extension = "DL"
270
+
271
+ return debrid_extension
272
+
273
+
274
+ async def get_indexer_manager(
275
+ session: aiohttp.ClientSession,
276
+ indexer_manager_type: str,
277
+ indexers: list,
278
+ query: str,
279
+ ):
280
+ results = []
281
+ try:
282
+ indexers = [indexer.replace("_", " ") for indexer in indexers]
283
+
284
+ if indexer_manager_type == "jackett":
285
+
286
+ async def fetch_jackett_results(
287
+ session: aiohttp.ClientSession, indexer: str, query: str
288
+ ):
289
+ try:
290
+ async with session.get(
291
+ f"{settings.INDEXER_MANAGER_URL}/api/v2.0/indexers/all/results?apikey={settings.INDEXER_MANAGER_API_KEY}&Query={query}&Tracker[]={indexer}",
292
+ timeout=aiohttp.ClientTimeout(
293
+ total=settings.INDEXER_MANAGER_TIMEOUT
294
+ ),
295
+ ) as response:
296
+ response_json = await response.json()
297
+ return response_json.get("Results", [])
298
+ except Exception as e:
299
+ logger.warning(
300
+ f"Exception while fetching Jackett results for indexer {indexer}: {e}"
301
+ )
302
+ return []
303
+
304
+ tasks = [
305
+ fetch_jackett_results(session, indexer, query) for indexer in indexers
306
+ ]
307
+ all_results = await asyncio.gather(*tasks)
308
+
309
+ for result_set in all_results:
310
+ results.extend(result_set)
311
+
312
+ elif indexer_manager_type == "prowlarr":
313
+ get_indexers = await session.get(
314
+ f"{settings.INDEXER_MANAGER_URL}/api/v1/indexer",
315
+ headers={"X-Api-Key": settings.INDEXER_MANAGER_API_KEY},
316
+ )
317
+ get_indexers = await get_indexers.json()
318
+
319
+ indexers_id = []
320
+ for indexer in get_indexers:
321
+ if (
322
+ indexer["name"].lower() in indexers
323
+ or indexer["definitionName"].lower() in indexers
324
+ ):
325
+ indexers_id.append(indexer["id"])
326
+
327
+ response = await session.get(
328
+ f"{settings.INDEXER_MANAGER_URL}/api/v1/search?query={query}&indexerIds={'&indexerIds='.join(str(indexer_id) for indexer_id in indexers_id)}&type=search",
329
+ headers={"X-Api-Key": settings.INDEXER_MANAGER_API_KEY},
330
+ )
331
+ response = await response.json()
332
+
333
+ for result in response:
334
+ result["InfoHash"] = (
335
+ result["infoHash"] if "infoHash" in result else None
336
+ )
337
+ result["Title"] = result["title"]
338
+ result["Size"] = result["size"]
339
+ result["Link"] = (
340
+ result["downloadUrl"] if "downloadUrl" in result else None
341
+ )
342
+ result["Tracker"] = result["indexer"]
343
+
344
+ results.append(result)
345
+ except Exception as e:
346
+ logger.warning(
347
+ f"Exception while getting {indexer_manager_type} results for {query} with {indexers}: {e}"
348
+ )
349
+ pass
350
+
351
+ return results
352
+
353
+
354
+ async def get_zilean(
355
+ session: aiohttp.ClientSession, name: str, log_name: str, season: int, episode: int
356
+ ):
357
+ results = []
358
+ try:
359
+ show = f"&season={season}&episode={episode}"
360
+ get_dmm = await session.get(
361
+ f"{settings.ZILEAN_URL}/dmm/filtered?query={name}{show if season else ''}"
362
+ )
363
+ get_dmm = await get_dmm.json()
364
+
365
+ if isinstance(get_dmm, list):
366
+ take_first = get_dmm[: settings.ZILEAN_TAKE_FIRST]
367
+ for result in take_first:
368
+ object = {
369
+ "Title": result["raw_title"],
370
+ "InfoHash": result["info_hash"],
371
+ "Size": result["size"],
372
+ "Tracker": "DMM",
373
+ }
374
+
375
+ results.append(object)
376
+
377
+ logger.info(f"{len(results)} torrents found for {log_name} with Zilean")
378
+ except Exception as e:
379
+ logger.warning(
380
+ f"Exception while getting torrents for {log_name} with Zilean: {e}"
381
+ )
382
+ pass
383
+
384
+ return results
385
+
386
+
387
+ async def get_torrentio(log_name: str, type: str, full_id: str):
388
+ results = []
389
+ try:
390
+ try:
391
+ get_torrentio = requests.get(
392
+ f"https://torrentio.strem.fun/stream/{type}/{full_id}.json"
393
+ ).json()
394
+ except:
395
+ get_torrentio = requests.get(
396
+ f"https://torrentio.strem.fun/stream/{type}/{full_id}.json",
397
+ proxies={
398
+ "http": settings.DEBRID_PROXY_URL,
399
+ "https": settings.DEBRID_PROXY_URL,
400
+ },
401
+ ).json()
402
+
403
+ for torrent in get_torrentio["streams"]:
404
+ title = torrent["title"]
405
+ title_full = title.split("\n👤")[0]
406
+ tracker = title.split("⚙️ ")[1].split("\n")[0]
407
+
408
+ results.append(
409
+ {
410
+ "Title": title_full,
411
+ "InfoHash": torrent["infoHash"],
412
+ "Size": None,
413
+ "Tracker": f"Torrentio|{tracker}",
414
+ }
415
+ )
416
+
417
+ logger.info(f"{len(results)} torrents found for {log_name} with Torrentio")
418
+ except Exception as e:
419
+ logger.warning(
420
+ f"Exception while getting torrents for {log_name} with Torrentio, your IP is most likely blacklisted (you should try proxying Comet): {e}"
421
+ )
422
+ pass
423
+
424
+ return results
425
+
426
+
427
+ async def get_mediafusion(log_name: str, type: str, full_id: str):
428
+ results = []
429
+ try:
430
+ try:
431
+ get_mediafusion = requests.get(
432
+ f"{settings.MEDIAFUSION_URL}/stream/{type}/{full_id}.json"
433
+ ).json()
434
+ except:
435
+ get_mediafusion = requests.get(
436
+ f"{settings.MEDIAFUSION_URL}/stream/{type}/{full_id}.json",
437
+ proxies={
438
+ "http": settings.DEBRID_PROXY_URL,
439
+ "https": settings.DEBRID_PROXY_URL,
440
+ },
441
+ ).json()
442
+
443
+ for torrent in get_mediafusion["streams"]:
444
+ title_full = torrent["description"]
445
+ title = title_full.split("\n")[0] if "\n" in title_full else title_full
446
+ tracker = title_full.split("🔗 ")[1] if "🔗" in title_full else "Unknown"
447
+
448
+ results.append(
449
+ {
450
+ "Title": title,
451
+ "InfoHash": torrent["infoHash"],
452
+ "Size": torrent["behaviorHints"][
453
+ "videoSize"
454
+ ], # not the pack size but still useful for prowlarr userss
455
+ "Tracker": f"MediaFusion|{tracker}",
456
+ }
457
+ )
458
+
459
+ logger.info(f"{len(results)} torrents found for {log_name} with MediaFusion")
460
+
461
+ except Exception as e:
462
+ logger.warning(
463
+ f"Exception while getting torrents for {log_name} with MediaFusion, your IP is most likely blacklisted (you should try proxying Comet): {e}"
464
+ )
465
+ pass
466
+
467
+ return results
468
+
469
+
470
+ async def filter(torrents: list, name: str, year: int):
471
+ results = []
472
+ for torrent in torrents:
473
+ index = torrent[0]
474
+ title = torrent[1]
475
+
476
+ if "\n" in title: # Torrentio title parsing
477
+ title = title.split("\n")[1]
478
+
479
+ parsed = parse(title)
480
+
481
+ if parsed.parsed_title and not title_match(name, parsed.parsed_title):
482
+ results.append((index, False))
483
+ continue
484
+
485
+ if year and parsed.year and year != parsed.year:
486
+ results.append((index, False))
487
+ continue
488
+
489
+ results.append((index, True))
490
+
491
+ return results
492
+
493
+
494
+ async def get_torrent_hash(session: aiohttp.ClientSession, torrent: tuple):
495
+ index = torrent[0]
496
+ torrent = torrent[1]
497
+ if "InfoHash" in torrent and torrent["InfoHash"] is not None:
498
+ return (index, torrent["InfoHash"].lower())
499
+
500
+ url = torrent["Link"]
501
+
502
+ try:
503
+ timeout = aiohttp.ClientTimeout(total=settings.GET_TORRENT_TIMEOUT)
504
+ response = await session.get(url, allow_redirects=False, timeout=timeout)
505
+ if response.status == 200:
506
+ torrent_data = await response.read()
507
+ torrent_dict = bencodepy.decode(torrent_data)
508
+ info = bencodepy.encode(torrent_dict[b"info"])
509
+ hash = hashlib.sha1(info).hexdigest()
510
+ else:
511
+ location = response.headers.get("Location", "")
512
+ if not location:
513
+ return (index, None)
514
+
515
+ match = info_hash_pattern.search(location)
516
+ if not match:
517
+ return (index, None)
518
+
519
+ hash = match.group(1).upper()
520
+
521
+ return (index, hash.lower())
522
+ except Exception as e:
523
+ logger.warning(
524
+ f"Exception while getting torrent info hash for {torrent['indexer'] if 'indexer' in torrent else (torrent['Tracker'] if 'Tracker' in torrent else '')}|{url}: {e}"
525
+ )
526
+
527
+ return (index, None)
528
+
529
+
530
+ def get_balanced_hashes(hashes: dict, config: dict):
531
+ max_results = config["maxResults"]
532
+
533
+ max_size = config["maxSize"]
534
+ config_resolutions = [resolution.lower() for resolution in config["resolutions"]]
535
+ include_all_resolutions = "all" in config_resolutions
536
+
537
+ languages = [language.lower() for language in config["languages"]]
538
+ include_all_languages = "all" in languages
539
+ if not include_all_languages:
540
+ config_languages = [
541
+ code
542
+ for code, name in PTT.parse.LANGUAGES_TRANSLATION_TABLE.items()
543
+ if name.lower() in languages
544
+ ]
545
+
546
+ hashes_by_resolution = {}
547
+ for hash, hash_data in hashes.items():
548
+ hash_info = hash_data["data"]
549
+
550
+ if max_size != 0 and hash_info["size"] > max_size:
551
+ continue
552
+
553
+ if (
554
+ not include_all_languages
555
+ and not any(lang in hash_info["languages"] for lang in config_languages)
556
+ and ("multi" not in languages if hash_info["dubbed"] else True)
557
+ ):
558
+ continue
559
+
560
+ resolution = hash_info["resolution"]
561
+ if not include_all_resolutions and resolution not in config_resolutions:
562
+ continue
563
+
564
+ if resolution not in hashes_by_resolution:
565
+ hashes_by_resolution[resolution] = []
566
+ hashes_by_resolution[resolution].append(hash)
567
+
568
+ total_resolutions = len(hashes_by_resolution)
569
+ if max_results == 0 or total_resolutions == 0:
570
+ return hashes_by_resolution
571
+
572
+ hashes_per_resolution = max_results // total_resolutions
573
+ extra_hashes = max_results % total_resolutions
574
+
575
+ balanced_hashes = {}
576
+ for resolution, hash_list in hashes_by_resolution.items():
577
+ selected_count = hashes_per_resolution + (1 if extra_hashes > 0 else 0)
578
+ balanced_hashes[resolution] = hash_list[:selected_count]
579
+ if extra_hashes > 0:
580
+ extra_hashes -= 1
581
+
582
+ selected_total = sum(len(hashes) for hashes in balanced_hashes.values())
583
+ if selected_total < max_results:
584
+ missing_hashes = max_results - selected_total
585
+ for resolution, hash_list in hashes_by_resolution.items():
586
+ if missing_hashes <= 0:
587
+ break
588
+ current_count = len(balanced_hashes[resolution])
589
+ available_hashes = hash_list[current_count : current_count + missing_hashes]
590
+ balanced_hashes[resolution].extend(available_hashes)
591
+ missing_hashes -= len(available_hashes)
592
+
593
+ return balanced_hashes
594
+
595
+
596
+ def format_metadata(data: dict):
597
+ extras = []
598
+ if data["quality"]:
599
+ extras.append(data["quality"])
600
+ if data["hdr"]:
601
+ extras.extend(data["hdr"])
602
+ if data["codec"]:
603
+ extras.append(data["codec"])
604
+ if data["audio"]:
605
+ extras.extend(data["audio"])
606
+ if data["channels"]:
607
+ extras.extend(data["channels"])
608
+ if data["bit_depth"]:
609
+ extras.append(data["bit_depth"])
610
+ if data["network"]:
611
+ extras.append(data["network"])
612
+ if data["group"]:
613
+ extras.append(data["group"])
614
+
615
+ return "|".join(extras)
616
+
617
+
618
+ def format_title(data: dict, config: dict):
619
+ title = ""
620
+ if "All" in config["resultFormat"] or "Title" in config["resultFormat"]:
621
+ title += f"{data['title']}\n"
622
+
623
+ if "All" in config["resultFormat"] or "Metadata" in config["resultFormat"]:
624
+ metadata = format_metadata(data)
625
+ if metadata != "":
626
+ title += f"💿 {metadata}\n"
627
+
628
+ if "All" in config["resultFormat"] or "Size" in config["resultFormat"]:
629
+ title += f"💾 {bytes_to_size(data['size'])} "
630
+
631
+ if "All" in config["resultFormat"] or "Tracker" in config["resultFormat"]:
632
+ title += f"🔎 {data['tracker'] if 'tracker' in data else '?'}"
633
+
634
+ if "All" in config["resultFormat"] or "Languages" in config["resultFormat"]:
635
+ languages = data["languages"]
636
+ if data["dubbed"]:
637
+ languages.insert(0, "multi")
638
+ formatted_languages = (
639
+ "/".join(get_language_emoji(language) for language in languages)
640
+ if languages
641
+ else None
642
+ )
643
+ languages_str = "\n" + formatted_languages if formatted_languages else ""
644
+ title += f"{languages_str}"
645
+
646
+ if title == "":
647
+ # Without this, Streamio shows SD as the result, which is confusing
648
+ title = "Empty result format configuration"
649
+
650
+ return title
651
+
652
+
653
+ def get_client_ip(request: Request):
654
+ return (
655
+ request.headers["cf-connecting-ip"]
656
+ if "cf-connecting-ip" in request.headers
657
+ else request.client.host
658
+ )
comet/utils/models.py CHANGED
@@ -1,57 +1,125 @@
1
  import os
 
 
2
 
3
  from typing import List, Optional
4
  from databases import Database
 
5
  from pydantic_settings import BaseSettings, SettingsConfigDict
6
- from RTN import RTN, BaseRankingModel, SettingsModel
7
 
8
 
9
  class AppSettings(BaseSettings):
10
  model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")
11
 
12
- ADDON_ID: str = "stremio.comet.fast"
13
- ADDON_NAME: str = "Comet"
14
- FASTAPI_HOST: str = "0.0.0.0"
15
- FASTAPI_PORT: int = 8000
16
- FASTAPI_WORKERS: int = 2 * (os.cpu_count() or 1)
17
- DATABASE_PATH: str = "data/comet.db"
18
- CACHE_TTL: int = 86400
 
 
 
19
  DEBRID_PROXY_URL: Optional[str] = None
20
- INDEXER_MANAGER_TYPE: str = "jackett"
21
- INDEXER_MANAGER_URL: str = "http://127.0.0.1:9117"
22
- INDEXER_MANAGER_API_KEY: str = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
23
- INDEXER_MANAGER_TIMEOUT: int = 30
24
  INDEXER_MANAGER_INDEXERS: List[str] = ["EXAMPLE1_CHANGETHIS", "EXAMPLE2_CHANGETHIS"]
25
- GET_TORRENT_TIMEOUT: int = 5
26
  ZILEAN_URL: Optional[str] = None
 
 
 
 
27
  CUSTOM_HEADER_HTML: Optional[str] = None
 
 
 
 
 
 
28
 
 
 
 
 
 
29
 
30
- class BestOverallRanking(BaseRankingModel):
31
- uhd: int = 100
32
- fhd: int = 90
33
- hd: int = 80
34
- sd: int = 70
35
- dolby_video: int = 100
36
- hdr: int = 80
37
- hdr10: int = 90
38
- dts_x: int = 100
39
- dts_hd: int = 80
40
- dts_hd_ma: int = 90
41
- atmos: int = 90
42
- truehd: int = 60
43
- ddplus: int = 40
44
- aac: int = 30
45
- ac3: int = 20
46
- remux: int = 150
47
- bluray: int = 120
48
- webdl: int = 90
49
-
50
-
51
- rtn_settings: SettingsModel = SettingsModel()
52
- rtn_ranking: BestOverallRanking = BestOverallRanking()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
  # For use anywhere
55
- rtn: RTN = RTN(settings=rtn_settings, ranking_model=rtn_ranking)
56
- settings: AppSettings = AppSettings()
57
- database = Database(f"sqlite:///{settings.DATABASE_PATH}")
 
 
 
 
 
 
 
 
1
  import os
2
+ import random
3
+ import string
4
 
5
  from typing import List, Optional
6
  from databases import Database
7
+ from pydantic import BaseModel, field_validator
8
  from pydantic_settings import BaseSettings, SettingsConfigDict
9
+ from RTN import RTN, BestRanking, SettingsModel
10
 
11
 
12
  class AppSettings(BaseSettings):
13
  model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")
14
 
15
+ ADDON_ID: Optional[str] = "stremio.comet.fast"
16
+ ADDON_NAME: Optional[str] = "Comet"
17
+ FASTAPI_HOST: Optional[str] = "0.0.0.0"
18
+ FASTAPI_PORT: Optional[int] = 8000
19
+ FASTAPI_WORKERS: Optional[int] = 2 * (os.cpu_count() or 1)
20
+ DASHBOARD_ADMIN_PASSWORD: Optional[str] = None
21
+ DATABASE_TYPE: Optional[str] = "sqlite"
22
+ DATABASE_URL: Optional[str] = "username:password@hostname:port"
23
+ DATABASE_PATH: Optional[str] = "data/comet.db"
24
+ CACHE_TTL: Optional[int] = 86400
25
  DEBRID_PROXY_URL: Optional[str] = None
26
+ INDEXER_MANAGER_TYPE: Optional[str] = None
27
+ INDEXER_MANAGER_URL: Optional[str] = "http://127.0.0.1:9117"
28
+ INDEXER_MANAGER_API_KEY: Optional[str] = None
29
+ INDEXER_MANAGER_TIMEOUT: Optional[int] = 30
30
  INDEXER_MANAGER_INDEXERS: List[str] = ["EXAMPLE1_CHANGETHIS", "EXAMPLE2_CHANGETHIS"]
31
+ GET_TORRENT_TIMEOUT: Optional[int] = 5
32
  ZILEAN_URL: Optional[str] = None
33
+ ZILEAN_TAKE_FIRST: Optional[int] = 500
34
+ SCRAPE_TORRENTIO: Optional[bool] = False
35
+ SCRAPE_MEDIAFUSION: Optional[bool] = False
36
+ MEDIAFUSION_URL: Optional[str] = "https://mediafusion.elfhosted.com"
37
  CUSTOM_HEADER_HTML: Optional[str] = None
38
+ PROXY_DEBRID_STREAM: Optional[bool] = False
39
+ PROXY_DEBRID_STREAM_PASSWORD: Optional[str] = None
40
+ PROXY_DEBRID_STREAM_MAX_CONNECTIONS: Optional[int] = 100
41
+ PROXY_DEBRID_STREAM_DEBRID_DEFAULT_SERVICE: Optional[str] = "realdebrid"
42
+ PROXY_DEBRID_STREAM_DEBRID_DEFAULT_APIKEY: Optional[str] = None
43
+ TITLE_MATCH_CHECK: Optional[bool] = True
44
 
45
+ @field_validator("DASHBOARD_ADMIN_PASSWORD")
46
+ def set_dashboard_admin_password(cls, v, values):
47
+ if v is None:
48
+ return "".join(random.choices(string.ascii_letters + string.digits, k=16))
49
+ return v
50
 
51
+ @field_validator("INDEXER_MANAGER_TYPE")
52
+ def set_indexer_manager_type(cls, v, values):
53
+ if v == "None":
54
+ return None
55
+ return v
56
+
57
+ @field_validator("PROXY_DEBRID_STREAM_PASSWORD")
58
+ def set_debrid_stream_proxy_password(cls, v, values):
59
+ if v is None:
60
+ return "".join(random.choices(string.ascii_letters + string.digits, k=16))
61
+ return v
62
+
63
+
64
+ settings = AppSettings()
65
+
66
+
67
+ class ConfigModel(BaseModel):
68
+ indexers: List[str]
69
+ languages: Optional[List[str]] = ["All"]
70
+ resolutions: Optional[List[str]] = ["All"]
71
+ resultFormat: Optional[List[str]] = ["All"]
72
+ maxResults: Optional[int] = 0
73
+ maxSize: Optional[float] = 0
74
+ debridService: str
75
+ debridApiKey: str
76
+ debridStreamProxyPassword: Optional[str] = ""
77
+
78
+ @field_validator("indexers")
79
+ def check_indexers(cls, v, values):
80
+ settings.INDEXER_MANAGER_INDEXERS = [
81
+ indexer.replace(" ", "_").lower()
82
+ for indexer in settings.INDEXER_MANAGER_INDEXERS
83
+ ] # to equal webui
84
+ valid_indexers = [
85
+ indexer for indexer in v if indexer in settings.INDEXER_MANAGER_INDEXERS
86
+ ]
87
+ # if not valid_indexers: # For only Zilean mode
88
+ # raise ValueError(
89
+ # f"At least one indexer must be from {settings.INDEXER_MANAGER_INDEXERS}"
90
+ # )
91
+ return valid_indexers
92
+
93
+ @field_validator("maxResults")
94
+ def check_max_results(cls, v):
95
+ if v < 0:
96
+ v = 0
97
+ return v
98
+
99
+ @field_validator("maxSize")
100
+ def check_max_size(cls, v):
101
+ if v < 0:
102
+ v = 0
103
+ return v
104
+
105
+ @field_validator("debridService")
106
+ def check_debrid_service(cls, v):
107
+ if v not in ["realdebrid", "alldebrid", "premiumize", "torbox", "debridlink"]:
108
+ raise ValueError("Invalid debridService")
109
+ return v
110
+
111
+
112
+ rtn_settings = SettingsModel()
113
+ rtn_ranking = BestRanking()
114
 
115
  # For use anywhere
116
+ rtn = RTN(settings=rtn_settings, ranking_model=rtn_ranking)
117
+
118
+ database_url = (
119
+ settings.DATABASE_PATH
120
+ if settings.DATABASE_TYPE == "sqlite"
121
+ else settings.DATABASE_URL
122
+ )
123
+ database = Database(
124
+ f"{'sqlite' if settings.DATABASE_TYPE == 'sqlite' else 'postgresql+asyncpg'}://{'/' if settings.DATABASE_TYPE == 'sqlite' else ''}{database_url}"
125
+ )
docker-compose.yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ volumes:
2
+ comet_data:
3
+
4
+ services:
5
+ comet:
6
+ container_name: comet
7
+ image: g0ldyy/comet
8
+ restart: unless-stopped
9
+ ports:
10
+ - "8000:8000"
11
+ env_file:
12
+ - .env
13
+ volumes:
14
+ - comet_data:/data
pyproject.toml CHANGED
@@ -9,16 +9,23 @@ repository = "https://github.com/g0ldyy/comet"
9
 
10
  [tool.poetry.dependencies]
11
  python = "^3.11"
12
- rank-torrent-name = "*"
13
  uvicorn = "*"
14
  fastapi = "*"
15
  aiohttp = "*"
16
- bencodepy = "*"
17
  asyncio = "*"
18
  loguru = "*"
19
  databases = "*"
20
- aiosqlite = "*"
21
  pydantic-settings = "*"
 
 
 
 
 
 
 
 
 
 
22
 
23
  [tool.poetry.group.dev.dependencies]
24
  isort = "*"
 
9
 
10
  [tool.poetry.dependencies]
11
  python = "^3.11"
 
12
  uvicorn = "*"
13
  fastapi = "*"
14
  aiohttp = "*"
 
15
  asyncio = "*"
16
  loguru = "*"
17
  databases = "*"
 
18
  pydantic-settings = "*"
19
+ bencode-py = "*"
20
+ httpx = "*"
21
+ curl-cffi = "*"
22
+ orjson = "*"
23
+ asyncpg = "*"
24
+ aiosqlite = "*"
25
+ jinja2 = "*"
26
+ rank-torrent-name = "*"
27
+ parsett = "*"
28
+
29
 
30
  [tool.poetry.group.dev.dependencies]
31
  isort = "*"