Skip to content

Commit 3333de6

Browse files
committed
fix: hotfix for seadex api changes
1 parent 10a4204 commit 3333de6

File tree

4 files changed

+35
-32
lines changed

4 files changed

+35
-32
lines changed

src/seadex/_enums.py

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
import base64
4+
35
from stringenum import CaseInsensitiveStrEnum
46

57

@@ -12,7 +14,7 @@ class Tracker(CaseInsensitiveStrEnum):
1214
ANIDEX = "AniDex"
1315
RUTRACKER = "RuTracker"
1416
# Private Trackers
15-
ANIMEBYTES = "AnimeBytes"
17+
PRIVATE_TRACKER = "PT"
1618
BEYONDHD = "BeyondHD"
1719
PASSTHEPOPCORN = "PassThePopcorn"
1820
BROADCASTTHENET = "BroadcastTheNet"
@@ -56,19 +58,21 @@ def domain(self) -> str:
5658
Domain name of the tracker, or an empty string for "Other".
5759
5860
"""
59-
return {
61+
_map = {
6062
# Public Trackers
61-
"NYAA": "nyaa.si",
62-
"ANIMETOSHO": "animetosho.org",
63-
"ANIDEX": "anidex.info",
64-
"RUTRACKER": "rutracker.org",
63+
"NYAA": b"bnlhYS5zaQ==",
64+
"ANIMETOSHO": b"YW5pbWV0b3Noby5vcmc=",
65+
"ANIDEX": b"YW5pZGV4LmluZm8=",
66+
"RUTRACKER": b"cnV0cmFja2VyLm9yZw==",
6567
# Private Trackers
66-
"ANIMEBYTES": "animebytes.tv",
67-
"BEYONDHD": "beyond-hd.me",
68-
"PASSTHEPOPCORN": "passthepopcorn.me",
69-
"BROADCASTTHENET": "broadcasthe.net",
70-
"HDBITS": "hdbits.org",
71-
"BLUTOPIA": "blutopia.cc",
72-
"AITHER": "aither.cc",
73-
"OTHER": "",
74-
}[self.name]
68+
"PRIVATE_TRACKER": b"YW5pbWVieXRlcy50dg==",
69+
"BEYONDHD": b"YmV5b25kLWhkLm1l",
70+
"PASSTHEPOPCORN": b"cGFzc3RoZXBvcGNvcm4ubWU=",
71+
"BROADCASTTHENET": b"YnJvYWRjYXN0aGUubmV0",
72+
"HDBITS": b"aGRiaXRzLm9yZw==",
73+
"BLUTOPIA": b"Ymx1dG9waWEuY2M=",
74+
"AITHER": b"YWl0aGVyLmNj",
75+
"OTHER": b"",
76+
}
77+
78+
return base64.b64decode(_map[self.name]).decode()

tests/test_entry.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@
5454
"infoHash": "<redacted>",
5555
"isBest": True,
5656
"releaseGroup": "LYS1TH3A",
57-
"tracker": "AnimeBytes",
57+
"tracker": "PT",
5858
"updated": "2024-01-30 19:28:09.461Z",
59-
"url": "https://animebytes.tv/torrents.php?id=20684&torrentid=1053072",
59+
"url": "/torrents.php?id=20684&torrentid=1053072",
6060
},
6161
]
6262
},
@@ -93,11 +93,11 @@ def test_from_anilist_id(seadex_entry: SeaDexEntry, httpx_mock: HTTPXMock) -> No
9393
)
9494
assert entry.theoretical_best is None
9595
assert entry.torrents[0].url == "https://nyaa.si/view/1693872"
96-
assert entry.torrents[1].url == "https://animebytes.tv/torrents.php?id=20684&torrentid=1053072"
96+
assert entry.torrents[1].url == "/torrents.php?id=20684&torrentid=1053072"
9797
assert entry.torrents[0].infohash is not None
9898
assert entry.torrents[1].infohash is None
9999
assert entry.torrents[0].tracker == Tracker.NYAA
100-
assert entry.torrents[1].tracker == Tracker.ANIMEBYTES
100+
assert entry.torrents[1].tracker == Tracker.PRIVATE_TRACKER
101101
assert entry.torrents[0].infohash is not None
102102
assert entry.torrents[1].infohash is None
103103
assert isinstance(entry.updated_at, datetime)
@@ -121,11 +121,11 @@ def test_from_seadex_id(seadex_entry: SeaDexEntry, httpx_mock: HTTPXMock) -> Non
121121
)
122122
assert entry.theoretical_best is None
123123
assert entry.torrents[0].url == "https://nyaa.si/view/1693872"
124-
assert entry.torrents[1].url == "https://animebytes.tv/torrents.php?id=20684&torrentid=1053072"
124+
assert entry.torrents[1].url == "/torrents.php?id=20684&torrentid=1053072"
125125
assert entry.torrents[0].infohash is not None
126126
assert entry.torrents[1].infohash is None
127127
assert entry.torrents[0].tracker == Tracker.NYAA
128-
assert entry.torrents[1].tracker == Tracker.ANIMEBYTES
128+
assert entry.torrents[1].tracker == Tracker.PRIVATE_TRACKER
129129
assert entry.torrents[0].infohash is not None
130130
assert entry.torrents[1].infohash is None
131131
assert entry.updated_at == datetime(2024, 1, 30, 19, 28, 10, 337000, tzinfo=timezone.utc)
@@ -160,7 +160,7 @@ def test_from_title(seadex_entry: SeaDexEntry, httpx_mock: HTTPXMock) -> None:
160160
assert entry.torrents[0].infohash is not None
161161
assert entry.torrents[1].infohash is None
162162
assert entry.torrents[0].tracker == Tracker.NYAA
163-
assert entry.torrents[1].tracker == Tracker.ANIMEBYTES
163+
assert entry.torrents[1].tracker == Tracker.PRIVATE_TRACKER
164164
assert entry.torrents[0].infohash is not None
165165
assert entry.torrents[1].infohash is None
166166
assert entry.updated_at == datetime(2024, 1, 30, 19, 28, 10, 337000, tzinfo=timezone.utc)
@@ -188,7 +188,7 @@ def test_from_filename(seadex_entry: SeaDexEntry, httpx_mock: HTTPXMock) -> None
188188
assert entry.torrents[0].infohash is not None
189189
assert entry.torrents[1].infohash is None
190190
assert entry.torrents[0].tracker == Tracker.NYAA
191-
assert entry.torrents[1].tracker == Tracker.ANIMEBYTES
191+
assert entry.torrents[1].tracker == Tracker.PRIVATE_TRACKER
192192
assert entry.torrents[0].infohash is not None
193193
assert entry.torrents[1].infohash is None
194194
assert entry.updated_at == datetime(2024, 1, 30, 19, 28, 10, 337000, tzinfo=timezone.utc)
@@ -219,11 +219,11 @@ def test_iterator(seadex_entry: SeaDexEntry, httpx_mock: HTTPXMock) -> None:
219219
)
220220
assert entry.theoretical_best is None
221221
assert entry.torrents[0].url == "https://nyaa.si/view/1693872"
222-
assert entry.torrents[1].url == "https://animebytes.tv/torrents.php?id=20684&torrentid=1053072"
222+
assert entry.torrents[1].url == "/torrents.php?id=20684&torrentid=1053072"
223223
assert entry.torrents[0].infohash is not None
224224
assert entry.torrents[1].infohash is None
225225
assert entry.torrents[0].tracker == Tracker.NYAA
226-
assert entry.torrents[1].tracker == Tracker.ANIMEBYTES
226+
assert entry.torrents[1].tracker == Tracker.PRIVATE_TRACKER
227227
assert entry.torrents[0].infohash is not None
228228
assert entry.torrents[1].infohash is None
229229
assert entry.updated_at == datetime(2024, 1, 30, 19, 28, 10, 337000, tzinfo=timezone.utc)

tests/test_enums.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
(Tracker.ANIMETOSHO, "AnimeTosho"),
1313
(Tracker.ANIDEX, "AniDex"),
1414
(Tracker.RUTRACKER, "RuTracker"),
15-
(Tracker.ANIMEBYTES, "AnimeBytes"),
15+
(Tracker.PRIVATE_TRACKER, "PT"),
1616
(Tracker.BEYONDHD, "BeyondHD"),
1717
(Tracker.PASSTHEPOPCORN, "PassThePopcorn"),
1818
(Tracker.BROADCASTTHENET, "BroadcastTheNet"),
@@ -33,7 +33,7 @@ def test_tracker_values(tracker: Tracker, value: str) -> None:
3333
("AnimeTosho", False, True),
3434
("AniDex", False, True),
3535
("RuTracker", False, True),
36-
("AnimeBytes", True, False),
36+
("PT", True, False),
3737
("BeyondHD", True, False),
3838
("PassThePopcorn", True, False),
3939
("BroadcastTheNet", True, False),
@@ -55,7 +55,6 @@ def test_tracker_is_private(tracker: str, is_private: bool, is_public: bool) ->
5555
("AnimeTosho", "animetosho.org"),
5656
("AniDex", "anidex.info"),
5757
("RuTracker", "rutracker.org"),
58-
("AnimeBytes", "animebytes.tv"),
5958
("BeyondHD", "beyond-hd.me"),
6059
("PassThePopcorn", "passthepopcorn.me"),
6160
("BroadcastTheNet", "broadcasthe.net"),
@@ -80,4 +79,4 @@ def test_bad_value() -> None:
8079
def test_case_insensitive_lookup() -> None:
8180
assert Tracker("nyAA") is Tracker.NYAA
8281
assert Tracker("ANIMETOSHO") is Tracker.ANIMETOSHO
83-
assert Tracker("animebytes") is Tracker.ANIMEBYTES
82+
assert Tracker("pt") is Tracker.PRIVATE_TRACKER

tests/test_records.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ def test_entry_record() -> None:
8181
"infoHash": "<redacted>",
8282
"isBest": True,
8383
"releaseGroup": "LYS1TH3A",
84-
"tracker": "AnimeBytes",
84+
"tracker": "PT",
8585
"updated": "2024-01-30 19:28:09.461Z",
86-
"url": "https://animebytes.tv/torrents.php?id=20684&torrentid=1053072",
86+
"url": "/torrents.php?id=20684&torrentid=1053072",
8787
},
8888
]
8989
},
@@ -109,7 +109,7 @@ def test_entry_record() -> None:
109109
)
110110
assert record.theoretical_best is None
111111
assert record.torrents[0].url == "https://nyaa.si/view/1693872"
112-
assert record.torrents[1].url == "https://animebytes.tv/torrents.php?id=20684&torrentid=1053072"
112+
assert record.torrents[1].url == "/torrents.php?id=20684&torrentid=1053072"
113113
assert record.torrents[0].infohash is not None
114114
assert record.torrents[1].infohash is None
115115
assert isinstance(record.updated_at, datetime)

0 commit comments

Comments
 (0)