mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-06 12:51:08 -08:00
Compare commits
1159 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95586eb36f | ||
|
|
c01c08c03b | ||
|
|
14e1f44696 | ||
|
|
36b71c0751 | ||
|
|
6a5d7a0116 | ||
|
|
91efee9065 | ||
|
|
69d3d2e032 | ||
|
|
29ba77f795 | ||
|
|
a4950efa02 | ||
|
|
bbd7931790 | ||
|
|
c3ae5f9053 | ||
|
|
bf06d7ee2c | ||
|
|
41aaf92bae | ||
|
|
d38dc3194f | ||
|
|
54233aca79 | ||
|
|
6b8dfba57e | ||
|
|
3b008696d5 | ||
|
|
ece1f77e99 | ||
|
|
7b9de8620b | ||
|
|
725754ea1a | ||
|
|
80771f65ea | ||
|
|
c8c4e1b2c0 | ||
|
|
f4958cc0cc | ||
|
|
1f72e0a579 | ||
|
|
803c8316a7 | ||
|
|
26bc84e2eb | ||
|
|
901d1e87c5 | ||
|
|
523766868c | ||
|
|
bd9bf24e1c | ||
|
|
f27c0b8548 | ||
|
|
76c1dcd5ac | ||
|
|
25a46bd242 | ||
|
|
a70db611f7 | ||
|
|
091edb3a9b | ||
|
|
9050dd7787 | ||
|
|
393b9e6ed6 | ||
|
|
5193df2197 | ||
|
|
6ccd96d252 | ||
|
|
e8387f3db9 | ||
|
|
23ebff3f42 | ||
|
|
8e803e8ecb | ||
|
|
61fcd39188 | ||
|
|
313f8369d7 | ||
|
|
bee73b3f9a | ||
|
|
f647b7419a | ||
|
|
901c4422b5 | ||
|
|
08ae8786c3 | ||
|
|
64093204ad | ||
|
|
8440ffb5e5 | ||
|
|
6e287d320d | ||
|
|
a7b0f21deb | ||
|
|
71b668894b | ||
|
|
8b3a57ed07 | ||
|
|
b2f9c8349a | ||
|
|
25fe1e5e01 | ||
|
|
45ff463f7a | ||
|
|
29ce664e4c | ||
|
|
2217f011af | ||
|
|
5960a7c502 | ||
|
|
bd0309ee85 | ||
|
|
3724f06e33 | ||
|
|
d20af89fc8 | ||
|
|
3872b4c8a8 | ||
|
|
9545b893e1 | ||
|
|
1519c8be17 | ||
|
|
9a619b41f4 | ||
|
|
0c3a963cc4 | ||
|
|
192818362b | ||
|
|
2d8c1d3569 | ||
|
|
e37f9213f6 | ||
|
|
097db713bc | ||
|
|
106278e386 | ||
|
|
44b3663644 | ||
|
|
925c30c06e | ||
|
|
7401a1ad8f | ||
|
|
9a0bb65e52 | ||
|
|
1d129a5771 | ||
|
|
515660b0f6 | ||
|
|
9f5c895bf5 | ||
|
|
5634214fb8 | ||
|
|
66c0ada29d | ||
|
|
02465b4ddb | ||
|
|
5ffd94ac24 | ||
|
|
d2864df6d0 | ||
|
|
2a28e3b9a3 | ||
|
|
7b8027a8b3 | ||
|
|
2a36152c38 | ||
|
|
2048c7b743 | ||
|
|
133fd4c1c8 | ||
|
|
e22120fe99 | ||
|
|
44e6220662 | ||
|
|
1fea1335c6 | ||
|
|
8b664fae36 | ||
|
|
19a85511b4 | ||
|
|
205299108b | ||
|
|
7670bdd2f3 | ||
|
|
cd3f7f7fb8 | ||
|
|
5be03ed5b8 | ||
|
|
6581179336 | ||
|
|
2bb674f4a0 | ||
|
|
642e77f601 | ||
|
|
a5e99122f5 | ||
|
|
39bd7bed61 | ||
|
|
869072633b | ||
|
|
cbd788a573 | ||
|
|
11fe54b146 | ||
|
|
a13bdb1aa0 | ||
|
|
627b09a723 | ||
|
|
aecec5c75b | ||
|
|
49b298ed52 | ||
|
|
9a90fa196b | ||
|
|
4ac059e873 | ||
|
|
8b39a28e32 | ||
|
|
066cc89b74 | ||
|
|
db16758d9f | ||
|
|
78e17b2ba0 | ||
|
|
c5326eb8d9 | ||
|
|
4a2d95e75e | ||
|
|
3a92ba69df | ||
|
|
cf59f4822e | ||
|
|
1cea6d0179 | ||
|
|
4bc1edcc4e | ||
|
|
0c546af99c | ||
|
|
1b49e186c8 | ||
|
|
fe831f9658 | ||
|
|
72f0e2e5b9 | ||
|
|
8530da23ef | ||
|
|
1e01b6e54a | ||
|
|
aa6ba9018d | ||
|
|
354ba6256a | ||
|
|
eae31420f9 | ||
|
|
01432a0fec | ||
|
|
c158d3fb99 | ||
|
|
877bc043a0 | ||
|
|
4968f8030a | ||
|
|
c5c7644d0d | ||
|
|
ff2a5d635a | ||
|
|
8626d1991c | ||
|
|
75d15a100d | ||
|
|
25d9895c52 | ||
|
|
f1b796d72b | ||
|
|
3f63198563 | ||
|
|
8d61463156 | ||
|
|
2daa51d384 | ||
|
|
43a0d77e1b | ||
|
|
eaedf3268d | ||
|
|
ade0465ea4 | ||
|
|
5e82db4ea8 | ||
|
|
a10e56cb6f | ||
|
|
fbd95e1966 | ||
|
|
d37a441ccf | ||
|
|
cbc1ceccbb | ||
|
|
249a207cad | ||
|
|
c8a42c4920 | ||
|
|
de8b6b7f2f | ||
|
|
54e0942233 | ||
|
|
8ea0c121c2 | ||
|
|
eddaad64e7 | ||
|
|
43be7a52cf | ||
|
|
b689760a25 | ||
|
|
e53246b79b | ||
|
|
b0fc94cdc5 | ||
|
|
449f6c1e59 | ||
|
|
ab4734b79d | ||
|
|
93d0f6a1a5 | ||
|
|
19c75c48b2 | ||
|
|
5341b0a844 | ||
|
|
24e7e6a16b | ||
|
|
4b310e60b8 | ||
|
|
4d50cffd86 | ||
|
|
f6fedf0500 | ||
|
|
7b431450fe | ||
|
|
66b247330b | ||
|
|
c6b8cfc294 | ||
|
|
6895426d67 | ||
|
|
cc69dc35f6 | ||
|
|
ed81f37ae4 | ||
|
|
c6858b00c4 | ||
|
|
a44034a5d4 | ||
|
|
f768518721 | ||
|
|
97f5bb9cb3 | ||
|
|
b09fdbf69b | ||
|
|
071c46cad9 | ||
|
|
5d32503ff9 | ||
|
|
e67532c496 | ||
|
|
819012897d | ||
|
|
c4f78b12a4 | ||
|
|
8aacbcc35b | ||
|
|
5976ab43b2 | ||
|
|
99c67a4bc0 | ||
|
|
34851fd3e4 | ||
|
|
e74b5977bb | ||
|
|
0650f45fba | ||
|
|
0c8f2a70ba | ||
|
|
ce7cd98783 | ||
|
|
ec14c40c77 | ||
|
|
6a6e03c744 | ||
|
|
26de1a0fb4 | ||
|
|
e49fb4898c | ||
|
|
e2407d4948 | ||
|
|
cd16ab50e3 | ||
|
|
b53a7d9b03 | ||
|
|
2b9fdb99b1 | ||
|
|
9c6e1877ed | ||
|
|
73bb77fe46 | ||
|
|
4cdc5bfd34 | ||
|
|
ca491d95a0 | ||
|
|
1003f75db3 | ||
|
|
5821c4ca97 | ||
|
|
de774a58d2 | ||
|
|
ee25cbba10 | ||
|
|
278a771f64 | ||
|
|
0d8c287e2f | ||
|
|
74308dfdc5 | ||
|
|
7ca1b8572e | ||
|
|
54aed9e5a0 | ||
|
|
4511d14e8b | ||
|
|
bff684e8cb | ||
|
|
cfc83450c8 | ||
|
|
04a6a425b7 | ||
|
|
088d232bfd | ||
|
|
03fd8c0bf8 | ||
|
|
17f1744025 | ||
|
|
9a5f3d46be | ||
|
|
66eb854da5 | ||
|
|
ae62adf233 | ||
|
|
55a7c7facf | ||
|
|
2340c34d02 | ||
|
|
40b29ba6e5 | ||
|
|
5dc768f7e8 | ||
|
|
b343bfb645 | ||
|
|
37773265ce | ||
|
|
70ef1bf633 | ||
|
|
bee97acd35 | ||
|
|
fb61fd17f1 | ||
|
|
98fff7d00f | ||
|
|
3cc9ae50b6 | ||
|
|
26f7de172a | ||
|
|
673b6280e4 | ||
|
|
7943dcc3db | ||
|
|
49ee1f9bbd | ||
|
|
fd80149e74 | ||
|
|
7c11616bea | ||
|
|
b9130018ca | ||
|
|
70ade13017 | ||
|
|
071c0daf4f | ||
|
|
ed136fc8a0 | ||
|
|
3a29127366 | ||
|
|
b7c938fec4 | ||
|
|
c6aada6139 | ||
|
|
e4c4203364 | ||
|
|
52cd4a8d85 | ||
|
|
b9b0d49530 | ||
|
|
ba4df96dc8 | ||
|
|
335ba86367 | ||
|
|
92c18f850f | ||
|
|
70763807de | ||
|
|
51438c8864 | ||
|
|
03426bd0da | ||
|
|
ccdb0346eb | ||
|
|
6fba74b3ca | ||
|
|
b436f23f65 | ||
|
|
cd7b70dd6b | ||
|
|
ac9b000ce8 | ||
|
|
84a3b6185b | ||
|
|
7f52d8cb39 | ||
|
|
87372e41be | ||
|
|
9cfbc0bdcf | ||
|
|
af6e64ee0c | ||
|
|
4a2f272e14 | ||
|
|
a2e2ae8dd3 | ||
|
|
5ce9bbaa0d | ||
|
|
25812b6562 | ||
|
|
ee52b945ea | ||
|
|
be14e6a135 | ||
|
|
9402e7a2b6 | ||
|
|
590d6a1851 | ||
|
|
8186fe9991 | ||
|
|
4d2831eee1 | ||
|
|
ea918909b9 | ||
|
|
93c0f2ab83 | ||
|
|
985e7fee18 | ||
|
|
7bd7ddecae | ||
|
|
9afb9a9a32 | ||
|
|
40065478cc | ||
|
|
65aa8fcb4e | ||
|
|
2717d0b012 | ||
|
|
9f0cf5f8dc | ||
|
|
ef4a850d75 | ||
|
|
d8804c711e | ||
|
|
adf75f65b2 | ||
|
|
6e7e75b514 | ||
|
|
9515559afb | ||
|
|
e8849940e1 | ||
|
|
007954802f | ||
|
|
b874bef2d5 | ||
|
|
6c1bcebd99 | ||
|
|
fe5e8c641d | ||
|
|
45a4913ead | ||
|
|
03f0f40c9a | ||
|
|
af616e0047 | ||
|
|
6000ed2a84 | ||
|
|
5a869060d8 | ||
|
|
58618bd82d | ||
|
|
84570c5595 | ||
|
|
18b4071ad9 | ||
|
|
fd052c87de | ||
|
|
ee959b3428 | ||
|
|
ad6bdad594 | ||
|
|
316832e771 | ||
|
|
9edeeb5ca4 | ||
|
|
7eb6054d5c | ||
|
|
5b06039cef | ||
|
|
abe36296c1 | ||
|
|
dcbf0df1a0 | ||
|
|
c2acbcdb68 | ||
|
|
96233b14ff | ||
|
|
a8f2579f82 | ||
|
|
5ed9700c5c | ||
|
|
fd74fbe2ef | ||
|
|
19426019a2 | ||
|
|
276c8d48d9 | ||
|
|
99809f3fd3 | ||
|
|
f79c8540c3 | ||
|
|
e602a6fbc4 | ||
|
|
8abfaed7bf | ||
|
|
15b920698a | ||
|
|
44cf9c3da7 | ||
|
|
460d3c7d94 | ||
|
|
5f030a5d9e | ||
|
|
8091e23196 | ||
|
|
e641a48156 | ||
|
|
c59babc30d | ||
|
|
494104ee19 | ||
|
|
159136cfb1 | ||
|
|
7e211f109e | ||
|
|
48e906e464 | ||
|
|
98c2fef8cd | ||
|
|
7088b8ce18 | ||
|
|
6cfc766db3 | ||
|
|
89ff453778 | ||
|
|
1c95d45be4 | ||
|
|
75e67c22d2 | ||
|
|
1a1d8cc8f4 | ||
|
|
3ea37c4079 | ||
|
|
b18e419831 | ||
|
|
fe06c8e0f1 | ||
|
|
759276237f | ||
|
|
d475dda41c | ||
|
|
ad499657e0 | ||
|
|
dbf96afea7 | ||
|
|
001a63d3df | ||
|
|
1207426a96 | ||
|
|
82ca5f32b1 | ||
|
|
2924fcd077 | ||
|
|
9fc66db248 | ||
|
|
f4e73c3335 | ||
|
|
5246a2fc4b | ||
|
|
4bbfe221f2 | ||
|
|
6017833605 | ||
|
|
f2538f5341 | ||
|
|
fec09e9b74 | ||
|
|
67a174158d | ||
|
|
ae3a59d116 | ||
|
|
fd59d64b76 | ||
|
|
b1ac4a6558 | ||
|
|
8e9aeb660f | ||
|
|
4f401aa91c | ||
|
|
b8733eccbd | ||
|
|
3617465f64 | ||
|
|
4c9ecafb9b | ||
|
|
e87e4e5639 | ||
|
|
16fa39397d | ||
|
|
24ffc4ee53 | ||
|
|
3e0be026eb | ||
|
|
a04643d36a | ||
|
|
5392d4f25a | ||
|
|
63e107ba53 | ||
|
|
9ba3f88813 | ||
|
|
5da5dc5dcc | ||
|
|
3c42f660ce | ||
|
|
4349b9fc22 | ||
|
|
048d008ca1 | ||
|
|
17636d766a | ||
|
|
367520450d | ||
|
|
d6f773f41f | ||
|
|
f76350bc5b | ||
|
|
d299355d90 | ||
|
|
4aa9fa9253 | ||
|
|
fcb16a574e | ||
|
|
8b52a1ef27 | ||
|
|
574a739cb6 | ||
|
|
f27a98aaa6 | ||
|
|
a266a7100f | ||
|
|
d1e07930f9 | ||
|
|
bc7936d9cc | ||
|
|
19c6656cdf | ||
|
|
06506fb47f | ||
|
|
29480c64cd | ||
|
|
474da2f1fd | ||
|
|
abac604ccd | ||
|
|
48f46cdf3d | ||
|
|
9cafcde9e1 | ||
|
|
e908c793c6 | ||
|
|
0fd69d03dd | ||
|
|
3a9be3f699 | ||
|
|
d3f08ea9c4 | ||
|
|
9efe9f9949 | ||
|
|
83933f7a63 | ||
|
|
afe1cb68f6 | ||
|
|
a6ddb10734 | ||
|
|
f678fa13f0 | ||
|
|
2067467134 | ||
|
|
d78b62fcee | ||
|
|
6c30cf808b | ||
|
|
6e9babf270 | ||
|
|
aa50ab62b5 | ||
|
|
88975e59c0 | ||
|
|
64c427fe41 | ||
|
|
987ae57e33 | ||
|
|
ac36e24a32 | ||
|
|
04d877a72e | ||
|
|
43174db8e4 | ||
|
|
3092ef0887 | ||
|
|
5e45fba66d | ||
|
|
65e4726f82 | ||
|
|
384d326fa8 | ||
|
|
60c583d115 | ||
|
|
f716f9687a | ||
|
|
db1006a6b2 | ||
|
|
9163b1394d | ||
|
|
0ce27f8e50 | ||
|
|
0e6aeeea18 | ||
|
|
452c2cf764 | ||
|
|
a1de0548f4 | ||
|
|
f60cdea2e1 | ||
|
|
b67284cfeb | ||
|
|
17161f5f78 | ||
|
|
c0d87c4351 | ||
|
|
725fe4875d | ||
|
|
ac3c6801d7 | ||
|
|
27b1f3f792 | ||
|
|
49cdd440df | ||
|
|
490f8b0e8b | ||
|
|
5dde02570a | ||
|
|
e3deb28d26 | ||
|
|
1a85b2f216 | ||
|
|
0639a3c949 | ||
|
|
bdbf0821c5 | ||
|
|
5e81c44312 | ||
|
|
41ed56f395 | ||
|
|
26f9c3b8de | ||
|
|
ecdd1b5f20 | ||
|
|
b6dd965e49 | ||
|
|
273dd56680 | ||
|
|
be4cc58e47 | ||
|
|
c882691412 | ||
|
|
f4c4c874df | ||
|
|
f8992d46dd | ||
|
|
222c50b4b2 | ||
|
|
064401f8e8 | ||
|
|
a079f9919c | ||
|
|
a88df7f3ef | ||
|
|
d1dfddf290 | ||
|
|
e8491e3723 | ||
|
|
2f21e7139b | ||
|
|
f5c831077d | ||
|
|
badd10bf97 | ||
|
|
42bd4963b8 | ||
|
|
f08ff7155c | ||
|
|
e487435d7e | ||
|
|
54f7327ed7 | ||
|
|
ba620bae96 | ||
|
|
48eac48738 | ||
|
|
194b8ca2df | ||
|
|
96c2d4976c | ||
|
|
c5034a5829 | ||
|
|
7c91288e6e | ||
|
|
de2ba342ad | ||
|
|
b847e02fe0 | ||
|
|
f02f92b80b | ||
|
|
a2da6974fa | ||
|
|
be1babbedc | ||
|
|
5c804f7aa6 | ||
|
|
723a7ab24f | ||
|
|
18a9b07144 | ||
|
|
d279cc70b9 | ||
|
|
27d71cbb23 | ||
|
|
615b420c74 | ||
|
|
f9c2b6e939 | ||
|
|
85368393fc | ||
|
|
b9636c94d3 | ||
|
|
4920ee508a | ||
|
|
fd448ad701 | ||
|
|
b223a34879 | ||
|
|
d5e1e60266 | ||
|
|
783b63219f | ||
|
|
317fee916b | ||
|
|
870bb24e1b | ||
|
|
f51ceaacd7 | ||
|
|
cdad70e40d | ||
|
|
0737c5c14b | ||
|
|
32f4d9271f | ||
|
|
355f10dd9e | ||
|
|
2f2ffc0a84 | ||
|
|
e35683e90a | ||
|
|
2bd02c7e99 | ||
|
|
5a50e79216 | ||
|
|
ec78c81381 | ||
|
|
f042e5042b | ||
|
|
428bbb20bd | ||
|
|
3af31a2dfd | ||
|
|
759889acd4 | ||
|
|
d106bf7c5d | ||
|
|
00ff89d14f | ||
|
|
76460b6c54 | ||
|
|
e58fd33fe0 | ||
|
|
931f9f10f8 | ||
|
|
0e9dbd2c6b | ||
|
|
3bdfa27e1c | ||
|
|
f46f09ffdf | ||
|
|
d309c04214 | ||
|
|
b19a323d15 | ||
|
|
ff94edfd05 | ||
|
|
59e1a82646 | ||
|
|
2e902fa4e7 | ||
|
|
d2e17af7a9 | ||
|
|
f1fa40c419 | ||
|
|
8bbde97403 | ||
|
|
a2b7d71eb2 | ||
|
|
67b4f0ea38 | ||
|
|
a6d5d5f37c | ||
|
|
67a066f16e | ||
|
|
e6297619d4 | ||
|
|
8f514858f2 | ||
|
|
eb9cffbd7a | ||
|
|
c5f9c37d3a | ||
|
|
44fd65ebab | ||
|
|
e919980ff7 | ||
|
|
6887c6ff10 | ||
|
|
b394de0b23 | ||
|
|
71003049d6 | ||
|
|
6f69b785d8 | ||
|
|
6756540fd1 | ||
|
|
e6b9df25dd | ||
|
|
f40dd2363a | ||
|
|
61a525ff94 | ||
|
|
27d671f89d | ||
|
|
58edb0427f | ||
|
|
7abcdc8f7c | ||
|
|
ca4ca0d476 | ||
|
|
5a337b1c97 | ||
|
|
6c94dd22fc | ||
|
|
8c7e1e201f | ||
|
|
98e41e1eb5 | ||
|
|
bd0e7db73c | ||
|
|
fb705b4ac2 | ||
|
|
93654be74f | ||
|
|
9b14a4c723 | ||
|
|
bce5acf7b5 | ||
|
|
228be7e1f7 | ||
|
|
2eb434e42a | ||
|
|
fbb3a00ab0 | ||
|
|
8341ffe8fd | ||
|
|
0822e2e92c | ||
|
|
3b9fbd0665 | ||
|
|
60b74bee18 | ||
|
|
d7dc63e003 | ||
|
|
d40edb6ff6 | ||
|
|
803712649f | ||
|
|
7bc0d33f69 | ||
|
|
5885d134df | ||
|
|
5500ec49c8 | ||
|
|
8c94380050 | ||
|
|
87a97dd0c6 | ||
|
|
80d9f732b1 | ||
|
|
051273dac9 | ||
|
|
036f448906 | ||
|
|
b5aeed9268 | ||
|
|
4257502b85 | ||
|
|
28a857520f | ||
|
|
4f9fff375c | ||
|
|
ce31f63788 | ||
|
|
9412c2491e | ||
|
|
8209adec62 | ||
|
|
39703d9eca | ||
|
|
57d16b3e18 | ||
|
|
73a99f8b96 | ||
|
|
309d7d5858 | ||
|
|
8d20e490ca | ||
|
|
3a6e005f3a | ||
|
|
bdf49bd7ce | ||
|
|
c4df2587d0 | ||
|
|
b38f66767f | ||
|
|
6c0e0ccf72 | ||
|
|
e39c992883 | ||
|
|
a1744fc9b3 | ||
|
|
3c5106c32c | ||
|
|
fd0d899f72 | ||
|
|
c753873f61 | ||
|
|
4c8ff2ae9b | ||
|
|
23274de367 | ||
|
|
2aec40ead0 | ||
|
|
172f2bb1de | ||
|
|
2f5684a93a | ||
|
|
1d40160abf | ||
|
|
af84d80137 | ||
|
|
e6412631ae | ||
|
|
978d8d45ba | ||
|
|
06575120d6 | ||
|
|
72cec28613 | ||
|
|
8023edcf3a | ||
|
|
0cb50cd506 | ||
|
|
9981b3dec8 | ||
|
|
50c048e158 | ||
|
|
c0a57c7814 | ||
|
|
bcdd88c725 | ||
|
|
d45d438663 | ||
|
|
3d12059e27 | ||
|
|
677f4690fa | ||
|
|
a79b59f727 | ||
|
|
5641c245e7 | ||
|
|
058fc285cd | ||
|
|
71cfe667c9 | ||
|
|
d9692201aa | ||
|
|
1fd4087b41 | ||
|
|
787eb0c9ca | ||
|
|
acd937f8ab | ||
|
|
52af68d13f | ||
|
|
1ff3074fad | ||
|
|
debaa2ffa6 | ||
|
|
5b6ccbe748 | ||
|
|
d6ca923951 | ||
|
|
0e9bf7f2de | ||
|
|
ccad2435b0 | ||
|
|
30fa9851dd | ||
|
|
000bae9bb7 | ||
|
|
8c2bb71e08 | ||
|
|
57393b085a | ||
|
|
5f721847d7 | ||
|
|
383cb62ede | ||
|
|
434ac947dd | ||
|
|
d0fb39cede | ||
|
|
f98ae77587 | ||
|
|
33e1b0fb6f | ||
|
|
7134702eb9 | ||
|
|
cac7586a86 | ||
|
|
0b9da27def | ||
|
|
ddbb4ca451 | ||
|
|
757393aa36 | ||
|
|
eb54d5e995 | ||
|
|
0d95a38321 | ||
|
|
8d2734db74 | ||
|
|
b3abcb958b | ||
|
|
0667749e4c | ||
|
|
57e73e6799 | ||
|
|
7d890b9719 | ||
|
|
8cbbcf458d | ||
|
|
67bc25a527 | ||
|
|
e668f9326a | ||
|
|
a02db6471f | ||
|
|
08b1f0c90c | ||
|
|
3ec8dbee8c | ||
|
|
473c11faca | ||
|
|
320e3799d3 | ||
|
|
a0f28ddf6d | ||
|
|
9512c3530a | ||
|
|
72602a0ec1 | ||
|
|
4daf6a2b07 | ||
|
|
8b37927f6a | ||
|
|
9d6f785a7f | ||
|
|
897c34d98c | ||
|
|
28c75215bd | ||
|
|
8697b27fe0 | ||
|
|
b6e05c877b | ||
|
|
d8c3ba6181 | ||
|
|
8b5c917038 | ||
|
|
856f62c245 | ||
|
|
02dfc9d71c | ||
|
|
cef0bae528 | ||
|
|
4867720ad2 | ||
|
|
8d85e30150 | ||
|
|
eb99b7e6ba | ||
|
|
089c049f26 | ||
|
|
a33e47d205 | ||
|
|
25dc35eaaf | ||
|
|
525586e955 | ||
|
|
5129219e23 | ||
|
|
7cd97c78b1 | ||
|
|
27b4422ef3 | ||
|
|
1c367c8aa1 | ||
|
|
7b6cc48b90 | ||
|
|
812d0110a7 | ||
|
|
60b05bf0ac | ||
|
|
d830cca3bc | ||
|
|
209e93b6d9 | ||
|
|
b10d9dc39a | ||
|
|
fe8cda094c | ||
|
|
33c06eab0a | ||
|
|
f3f4be7410 | ||
|
|
3915ef0fb6 | ||
|
|
20d26166dd | ||
|
|
ddca724bd8 | ||
|
|
b86c1a0479 | ||
|
|
1fa7830ddf | ||
|
|
59abafbe16 | ||
|
|
b6eebb9736 | ||
|
|
7797053102 | ||
|
|
d763445f72 | ||
|
|
7bc6b14b5f | ||
|
|
f70d2ac8af | ||
|
|
defdfc5a47 | ||
|
|
e67eeda492 | ||
|
|
a17588d02c | ||
|
|
67b59305c4 | ||
|
|
61db9aeea6 | ||
|
|
4f0768a060 | ||
|
|
21704cbbea | ||
|
|
886bc4d011 | ||
|
|
e3437e066a | ||
|
|
8f2795843a | ||
|
|
c6290592e8 | ||
|
|
050ba740b8 | ||
|
|
0b1a27b223 | ||
|
|
bafd04b788 | ||
|
|
fb5f51eea5 | ||
|
|
799e1f0681 | ||
|
|
53a2d953f8 | ||
|
|
9ce5bc3c76 | ||
|
|
dc58fc8536 | ||
|
|
1d5c3016fc | ||
|
|
8737aea746 | ||
|
|
bd03866f5e | ||
|
|
81690a8015 | ||
|
|
933112a52b | ||
|
|
eb513dfe0e | ||
|
|
3928b77506 | ||
|
|
95cb2bd78c | ||
|
|
4fa1c45eb2 | ||
|
|
b9051bc792 | ||
|
|
a590024f1c | ||
|
|
2f51936679 | ||
|
|
327c50d290 | ||
|
|
031dfbb9b5 | ||
|
|
050365302a | ||
|
|
0f248b1119 | ||
|
|
871d5cf758 | ||
|
|
320376d2e8 | ||
|
|
02e7fdff6f | ||
|
|
2c5c28f295 | ||
|
|
2d3509ccc1 | ||
|
|
30babf2d69 | ||
|
|
cfbbabf898 | ||
|
|
5ac6c45fdf | ||
|
|
a14645b563 | ||
|
|
90dbc26c46 | ||
|
|
54cc830c35 | ||
|
|
4928ff5b74 | ||
|
|
bb481fe21a | ||
|
|
0d27b8f652 | ||
|
|
bdd3aae399 | ||
|
|
af94cd7eb5 | ||
|
|
54044f9527 | ||
|
|
1e5c039ece | ||
|
|
15555759dc | ||
|
|
0ed51e05cc | ||
|
|
634ef6febf | ||
|
|
bda4b2dbe1 | ||
|
|
f015305e7c | ||
|
|
d32b7e917f | ||
|
|
3b35e80199 | ||
|
|
c65a1a2815 | ||
|
|
0b3615c9f5 | ||
|
|
3ac4e1ac71 | ||
|
|
d62f580d7a | ||
|
|
02e35b66cb | ||
|
|
7b11e0a301 | ||
|
|
aa8b91aed3 | ||
|
|
fe0fa97576 | ||
|
|
92059cd5ed | ||
|
|
ed3064e3b1 | ||
|
|
441d1e5e6c | ||
|
|
653b2cf4eb | ||
|
|
8d4b71e0c8 | ||
|
|
29cc6cad09 | ||
|
|
8119eef263 | ||
|
|
912c8674cf | ||
|
|
6b3ca236dd | ||
|
|
f1c352d4ff | ||
|
|
714533d845 | ||
|
|
56dd25df8d | ||
|
|
8248dc53df | ||
|
|
1a8a187de6 | ||
|
|
bc86be8c93 | ||
|
|
75026d4fc5 | ||
|
|
f8a5ccb8d2 | ||
|
|
719d1bd187 | ||
|
|
0dd83463c6 | ||
|
|
966301bce8 | ||
|
|
d776880306 | ||
|
|
1ee50e8a55 | ||
|
|
ae95c5ea3d | ||
|
|
d64ad5e11d | ||
|
|
d1a47c6d44 | ||
|
|
51a834a62f | ||
|
|
3a030bf6f7 | ||
|
|
eb6a6fc82c | ||
|
|
437ccd94e4 | ||
|
|
d65868cc30 | ||
|
|
8678aa6544 | ||
|
|
00e5141152 | ||
|
|
90e757dfe1 | ||
|
|
8b471b08e8 | ||
|
|
158bc5710f | ||
|
|
a0b946a13d | ||
|
|
b547b75f03 | ||
|
|
58c7427a47 | ||
|
|
6220b9c55d | ||
|
|
6b9b5c131c | ||
|
|
212f2af39c | ||
|
|
f7b2b4e0c9 | ||
|
|
a747529279 | ||
|
|
1dfdcc27ce | ||
|
|
3c03289453 | ||
|
|
06fd446a72 | ||
|
|
172d912d8b | ||
|
|
2396018607 | ||
|
|
a9be9779c5 | ||
|
|
2f76b26a99 | ||
|
|
2fe5edf810 | ||
|
|
d67ee6a779 | ||
|
|
e06ec5dbd4 | ||
|
|
c1b24ba2aa | ||
|
|
59e9cf9fd0 | ||
|
|
58761f5b96 | ||
|
|
ac959da229 | ||
|
|
bacc8c48ec | ||
|
|
905a159428 | ||
|
|
20f734cab2 | ||
|
|
7c2c644aef | ||
|
|
0efc92081a | ||
|
|
fafeee2367 | ||
|
|
e03063cd76 | ||
|
|
93b38b055f | ||
|
|
045635fb55 | ||
|
|
de7f773e9e | ||
|
|
ef6a465bd2 | ||
|
|
0c623af8a4 | ||
|
|
0589f83998 | ||
|
|
e17608afd5 | ||
|
|
b915654685 | ||
|
|
2ce9bf6c47 | ||
|
|
3c22232432 | ||
|
|
3474e9520c | ||
|
|
e9bacf4f9c | ||
|
|
ef422ed6fd | ||
|
|
d0f5366908 | ||
|
|
3557205feb | ||
|
|
ba4c41d888 | ||
|
|
1427a3193c | ||
|
|
b5cee20e56 | ||
|
|
be7f464073 | ||
|
|
c7f8f168f5 | ||
|
|
ba59fbdcb0 | ||
|
|
9f54fa4998 | ||
|
|
3c9688b32c | ||
|
|
1f046447bb | ||
|
|
87e3a275bb | ||
|
|
037b5c36a4 | ||
|
|
7d8b60fb14 | ||
|
|
0ad16fee53 | ||
|
|
249243aeb4 | ||
|
|
c208dc3579 | ||
|
|
ea93f2ba23 | ||
|
|
d910a0bb6a | ||
|
|
550fcfeddc | ||
|
|
c6910e5a1c | ||
|
|
8555edb521 | ||
|
|
139193ce29 | ||
|
|
1a87375ccd | ||
|
|
83cbef40f6 | ||
|
|
85b4fc75a1 | ||
|
|
f2e2da378f | ||
|
|
7c34bc9120 | ||
|
|
6f153f2acb | ||
|
|
8171083978 | ||
|
|
db5b9a59b4 | ||
|
|
6fa656ba11 | ||
|
|
de0682c1bb | ||
|
|
a6a32d8de4 | ||
|
|
bb14b269de | ||
|
|
14331d8bc2 | ||
|
|
1729464844 | ||
|
|
5fb9747285 | ||
|
|
394228d391 | ||
|
|
5d3c0cc6ec | ||
|
|
3ef7c5248c | ||
|
|
8bebc401fd | ||
|
|
215b28457b | ||
|
|
dfd2bfc857 | ||
|
|
f991292e94 | ||
|
|
d837457f80 | ||
|
|
343bdba31b | ||
|
|
1c1c2457e8 | ||
|
|
b083bfb074 | ||
|
|
ea1abcb2ae | ||
|
|
001030ba2b | ||
|
|
eda8984781 | ||
|
|
d8dc6f0a34 | ||
|
|
2d711a7a7f | ||
|
|
30ca25626a | ||
|
|
b1f5a558c8 | ||
|
|
8062c8dc83 | ||
|
|
cb7eed46bc | ||
|
|
4626eca89e | ||
|
|
0d549c5915 | ||
|
|
33c518ed4c | ||
|
|
8e155dcc74 | ||
|
|
7743b0423e | ||
|
|
6346ea7343 | ||
|
|
32de01047f | ||
|
|
35c7f81afb | ||
|
|
2dbbb1c4df | ||
|
|
6a6efa9d56 | ||
|
|
e510dc3a11 | ||
|
|
9639fd8c05 | ||
|
|
add35ce682 | ||
|
|
6bcc77ea44 | ||
|
|
1a72f88be3 | ||
|
|
1a9f1120b8 | ||
|
|
c2fc807688 | ||
|
|
2b0ade093c | ||
|
|
a26193706e | ||
|
|
ff3c57ef9b | ||
|
|
3b987bd07a | ||
|
|
e8474c0428 | ||
|
|
c78a759aa1 | ||
|
|
d1aad70c48 | ||
|
|
62b36f3e58 | ||
|
|
c5b905fb0d | ||
|
|
7d3dc671ed | ||
|
|
0ec3c7a5bb | ||
|
|
8e0619863a | ||
|
|
e8a05ec4b8 | ||
|
|
34e8b2abd1 | ||
|
|
161b6eb961 | ||
|
|
dd2090f85d | ||
|
|
8b1595a5da | ||
|
|
77ffa27ed8 | ||
|
|
15f79b65c9 | ||
|
|
33c3af0241 | ||
|
|
9badde62fb | ||
|
|
4e401dca40 | ||
|
|
25422b1b7d | ||
|
|
e8463f13b4 | ||
|
|
556f42e41f | ||
|
|
b99a4f7efc | ||
|
|
f6f45cf322 | ||
|
|
ae6db1847a | ||
|
|
20d04ea07b | ||
|
|
8f3834453c | ||
|
|
7ad8b8a0e3 | ||
|
|
80b41f06da | ||
|
|
e79321ed50 | ||
|
|
f7b5898dfa | ||
|
|
144bf53081 | ||
|
|
16dded9724 | ||
|
|
c47b158bff | ||
|
|
9a36e15d9d | ||
|
|
d6b2bd7761 | ||
|
|
2346552dc4 | ||
|
|
ba275055db | ||
|
|
de4ddf2f3a | ||
|
|
9c94d824d1 | ||
|
|
495f3cfbf6 | ||
|
|
b56c9ae3dd | ||
|
|
5e9ef87526 | ||
|
|
b68d6d6fe9 | ||
|
|
5870cc6640 | ||
|
|
7a43d58d82 | ||
|
|
fc7efebc8d | ||
|
|
528be74194 | ||
|
|
ab782acf2f | ||
|
|
45836d1ebc | ||
|
|
dff059d8eb | ||
|
|
4010cfc9c8 | ||
|
|
6329730820 | ||
|
|
006592ae7d | ||
|
|
831dcf4e88 | ||
|
|
0d2cf7ed66 | ||
|
|
aa6dc2b98e | ||
|
|
2e5cde3365 | ||
|
|
d75a03e594 | ||
|
|
9268c02683 | ||
|
|
89913036c9 | ||
|
|
2244026c67 | ||
|
|
c70564474b | ||
|
|
74514c9fbc | ||
|
|
077e9ab8c4 | ||
|
|
b05f7f1640 | ||
|
|
3382b720e3 | ||
|
|
f72c2d4b17 | ||
|
|
ff027991e0 | ||
|
|
21cdc6b015 | ||
|
|
29a2e3e6d1 | ||
|
|
5b3b9f740b | ||
|
|
5bc0e52179 | ||
|
|
40f1c4fba5 | ||
|
|
454341eaf5 | ||
|
|
abab2540a3 | ||
|
|
b2bc8cbace | ||
|
|
90bbf3c033 | ||
|
|
ac91b1770a | ||
|
|
19d42b7924 | ||
|
|
9ec3136734 | ||
|
|
943fca43cf | ||
|
|
b2e00feb94 | ||
|
|
f726c8d55c | ||
|
|
57db2e0626 | ||
|
|
40f66b5fde | ||
|
|
c87417e5e7 | ||
|
|
a841dd6f66 | ||
|
|
d6e85bad5c | ||
|
|
b590ac1e91 | ||
|
|
9cfa3aeea5 | ||
|
|
18c60691ca | ||
|
|
2e9fadf3b2 | ||
|
|
510b47b187 | ||
|
|
49c4d0eec0 | ||
|
|
8367f7bbed | ||
|
|
0182f674e0 | ||
|
|
2b50fb4c97 | ||
|
|
2602a20aa7 | ||
|
|
13200e2d1f | ||
|
|
22f6e89400 | ||
|
|
8409fa7d43 | ||
|
|
c81da78190 | ||
|
|
e17ea4bb89 | ||
|
|
0087728aa8 | ||
|
|
9e48e02f7a | ||
|
|
1291d55ab0 | ||
|
|
b5c6a1e39e | ||
|
|
d6adb30802 | ||
|
|
1d08a69a85 | ||
|
|
1087ab3408 | ||
|
|
51afd504df | ||
|
|
75efc9d73a | ||
|
|
6b68086cff | ||
|
|
3686cdfdb3 | ||
|
|
83c98936d1 | ||
|
|
0891cb279a | ||
|
|
95ba96f537 | ||
|
|
586790173b | ||
|
|
1d19449ab7 | ||
|
|
e1f73334ef | ||
|
|
4faac017b5 | ||
|
|
bfbd2a57a0 | ||
|
|
9519472f83 | ||
|
|
5c0c119cbc | ||
|
|
87eb257a10 | ||
|
|
4a08076c3b | ||
|
|
0d239e6793 | ||
|
|
0a0d47ae88 | ||
|
|
2ba07d47b3 | ||
|
|
f1b520fe3c | ||
|
|
8cfcc26468 | ||
|
|
cd51edf0b8 | ||
|
|
6eb28cfa3d | ||
|
|
542d39fa6a | ||
|
|
e5e328148f | ||
|
|
cea1a67d64 | ||
|
|
97c6dc7968 | ||
|
|
d97072e298 | ||
|
|
7cd246478e | ||
|
|
8afe1df3a9 | ||
|
|
452c2a3569 | ||
|
|
f738069794 | ||
|
|
d178eb976e | ||
|
|
d58dae6d6b | ||
|
|
136cf841e1 | ||
|
|
748d321f36 | ||
|
|
3e71239981 | ||
|
|
571ab488f8 | ||
|
|
62878311c6 | ||
|
|
432e9374cb | ||
|
|
a4974fbba7 | ||
|
|
b935e80928 | ||
|
|
8999d88d23 | ||
|
|
9608bace07 | ||
|
|
09b88df49a | ||
|
|
ccaacc9948 | ||
|
|
96d88b0f47 | ||
|
|
6939471e48 | ||
|
|
b1a2307c4d | ||
|
|
1ead2fb176 | ||
|
|
51e3ca004e | ||
|
|
3814db460f | ||
|
|
4102685cbc | ||
|
|
c80a8235e1 | ||
|
|
622427b748 | ||
|
|
e36413cdef | ||
|
|
7e9a510706 | ||
|
|
9185a08102 | ||
|
|
4f754a5129 | ||
|
|
cec7aaebdb | ||
|
|
bfd580ec79 | ||
|
|
aabd356c0b | ||
|
|
f929e83a62 | ||
|
|
74cacded6e | ||
|
|
82b6b849cf | ||
|
|
5dbc3a16f7 | ||
|
|
912535d166 | ||
|
|
09ce90f8b0 | ||
|
|
ec40406437 | ||
|
|
a1d1fca538 | ||
|
|
88776ce134 | ||
|
|
35caa93a56 | ||
|
|
4e19c2c108 | ||
|
|
b7ba85fb96 | ||
|
|
eb8b7ea534 | ||
|
|
d2aae33654 | ||
|
|
a2872db216 | ||
|
|
030f77bbf3 | ||
|
|
8f5e01295f | ||
|
|
7b2096e0eb | ||
|
|
45ccaec458 | ||
|
|
b4cbb57f29 | ||
|
|
c4255fc748 | ||
|
|
fa42d0e403 | ||
|
|
0e5cb56970 | ||
|
|
33d69cb95a | ||
|
|
1fbca22be8 | ||
|
|
1a88b6e998 | ||
|
|
3c09268da9 | ||
|
|
c0e5f5dd49 | ||
|
|
1bbc9506c2 | ||
|
|
c66cc52d53 | ||
|
|
e5f4a61a4e | ||
|
|
739d041c58 | ||
|
|
f12d5ab06c | ||
|
|
c3a3041cfb | ||
|
|
594c687c8b | ||
|
|
91b5d3ea40 | ||
|
|
8c30a7667c | ||
|
|
179fbe59ac | ||
|
|
5bfc210f59 | ||
|
|
eb9c200fca | ||
|
|
603efd56e8 | ||
|
|
4d74dfa339 | ||
|
|
4681e38153 | ||
|
|
242003500d | ||
|
|
66ab365657 | ||
|
|
bc8d7b2e28 | ||
|
|
db3a1f7175 | ||
|
|
3a51e0225e | ||
|
|
7b3388939c | ||
|
|
fcf875bdb2 | ||
|
|
0e4624297c | ||
|
|
91b54dfcb9 |
6
.envrc
Normal file
6
.envrc
Normal file
@@ -0,0 +1,6 @@
|
||||
VIU_APP_NAME="viu-dev"
|
||||
PATH="$PWD/.venv/bin:$PATH"
|
||||
export PATH VIU_APP_NAME
|
||||
if command -v nix >/dev/null; then
|
||||
use flake
|
||||
fi
|
||||
30
.github/chatmodes/new-command.chatmode.md
vendored
Normal file
30
.github/chatmodes/new-command.chatmode.md
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
description: "Generate a new 'click' command following the project's lazy-loading pattern and service architecture."
|
||||
tools: ['codebase']
|
||||
---
|
||||
# viu: CLI Command Generation Mode
|
||||
|
||||
You are an expert on the `viu` CLI structure, which uses `click` and a custom `LazyGroup` for performance. Your task is to generate the boilerplate for a new command.
|
||||
|
||||
**First, ask the user if this is a top-level command (like `viu new-cmd`) or a subcommand (like `viu anilist new-sub-cmd`).**
|
||||
|
||||
---
|
||||
|
||||
### If Top-Level Command:
|
||||
|
||||
1. **File Location:** State that the new command file should be created at: `viu/cli/commands/{command_name}.py`.
|
||||
2. **Boilerplate:** Generate the `click.command()` function.
|
||||
* It **must** accept `config: AppConfig` as the first argument using `@click.pass_obj`.
|
||||
* It **must not** contain business logic. Instead, show how to instantiate a service from `viu.cli.service` and call its methods.
|
||||
3. **Registration:** Instruct the user to register the command by adding it to the `commands` dictionary in `viu/cli/cli.py`. Provide the exact line to add, like: `"new-cmd": "new_cmd.new_cmd_function"`.
|
||||
|
||||
---
|
||||
|
||||
### If Subcommand:
|
||||
|
||||
1. **Ask for Parent:** Ask for the parent command group (e.g., `anilist`, `registry`).
|
||||
2. **File Location:** State that the new command file should be created at: `viu/cli/commands/{parent_name}/commands/{command_name}.py`.
|
||||
3. **Boilerplate:** Generate the `click.command()` function, similar to the top-level command.
|
||||
4. **Registration:** Instruct the user to register the subcommand in the parent's `cmd.py` file (e.g., `viu/cli/commands/anilist/cmd.py`) by adding it to the `lazy_subcommands` dictionary within the `@click.group` decorator.
|
||||
|
||||
**Final Instruction:** Remind the user that if the command introduces new logic, it should be encapsulated in a new or existing **Service** class in the `viu/cli/service/` directory. The CLI command function should only handle argument parsing and calling the service.
|
||||
34
.github/chatmodes/new-component.chatmode.md
vendored
Normal file
34
.github/chatmodes/new-component.chatmode.md
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
description: "Scaffold the necessary files and code for a new Player or Selector component, including configuration."
|
||||
tools: ['codebase', 'search']
|
||||
---
|
||||
# viu: New Component Generation Mode
|
||||
|
||||
You are an expert on `viu`'s modular architecture. Your task is to help the developer add a new **Player** or **Selector** component.
|
||||
|
||||
**First, ask the user whether they want to create a 'Player' or a 'Selector'.** Then, follow the appropriate path below.
|
||||
|
||||
---
|
||||
|
||||
### If the user chooses 'Player':
|
||||
|
||||
1. **Scaffold Directory:** Create a directory at `viu/libs/player/{player_name}/`.
|
||||
2. **Implement `BasePlayer`:** Create a `player.py` file with a class `NewPlayer` that inherits from `viu.libs.player.base.BasePlayer`. Implement the `play` and `play_with_ipc` methods. The `play` method should use `subprocess` to call the player's executable.
|
||||
3. **Add Configuration:**
|
||||
* Instruct to create a new Pydantic model `NewPlayerConfig(OtherConfig)` in `viu/core/config/model.py`.
|
||||
* Add the new config model to the main `AppConfig`.
|
||||
* Add defaults in `viu/core/config/defaults.py` and descriptions in `viu/core/config/descriptions.py`.
|
||||
4. **Register Player:** Instruct to modify `viu/libs/player/player.py` by:
|
||||
* Adding the player name to the `PLAYERS` list.
|
||||
* Adding the instantiation logic to the `PlayerFactory.create` method.
|
||||
|
||||
---
|
||||
|
||||
### If the user chooses 'Selector':
|
||||
|
||||
1. **Scaffold Directory:** Create a directory at `viu/libs/selectors/{selector_name}/`.
|
||||
2. **Implement `BaseSelector`:** Create a `selector.py` file with a class `NewSelector` that inherits from `viu.libs.selectors.base.BaseSelector`. Implement the `choose`, `confirm`, and `ask` methods.
|
||||
3. **Add Configuration:** (Follow the same steps as for a Player).
|
||||
4. **Register Selector:**
|
||||
* Instruct to modify `viu/libs/selectors/selector.py` by adding the selector name to the `SELECTORS` list and the factory logic to `SelectorFactory.create`.
|
||||
* Instruct to update the `Literal` type hint for the `selector` field in `GeneralConfig` (`viu/core/config/model.py`).
|
||||
27
.github/chatmodes/new-provider.chatmode.md
vendored
Normal file
27
.github/chatmodes/new-provider.chatmode.md
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
description: "Scaffold and implement a new anime provider, following all architectural patterns of the viu project."
|
||||
tools: ['codebase', 'search', 'fetch']
|
||||
---
|
||||
# viu: New Provider Generation Mode
|
||||
|
||||
You are an expert on the `viu` codebase, specializing in its provider architecture. Your task is to guide the developer in creating a new anime provider. You must strictly adhere to the project's structure and coding conventions.
|
||||
|
||||
**Your process is as follows:**
|
||||
|
||||
1. **Ask for the Provider's Name:** First, ask the user for the name of the new provider (e.g., `gogoanime`, `crunchyroll`). Use this name (in lowercase) for all subsequent file and directory naming.
|
||||
|
||||
2. **Scaffold the Directory Structure:** Based on the name, state the required directory structure that needs to be created:
|
||||
`viu/libs/provider/anime/{provider_name}/`
|
||||
|
||||
3. **Scaffold the Core Files:** Generate the initial code for the following files inside the new directory. Ensure all code is fully type-hinted.
|
||||
|
||||
* **`__init__.py`**: Can be an empty file.
|
||||
* **`types.py`**: Create placeholder `TypedDict` models for the provider's specific API responses (e.g., `GogoAnimeSearchResult`, `GogoAnimeEpisode`).
|
||||
* **`mappers.py`**: Create empty mapping functions that will convert the provider-specific types into the generic types from `viu.libs.provider.anime.types`. For example: `map_to_search_results(data: GogoAnimeSearchPage) -> SearchResults:`.
|
||||
* **`provider.py`**: Generate the main provider class. It **MUST** inherit from `viu.libs.provider.anime.base.BaseAnimeProvider`. Include stubs for the required abstract methods: `search`, `get`, and `episode_streams`. Remind the user to use `httpx.Client` for requests and to call the mapper functions.
|
||||
|
||||
4. **Instruct on Registration:** Clearly state the two files that **must** be modified to register the new provider:
|
||||
* **`viu/libs/provider/anime/types.py`**: Add the new provider's name to the `ProviderName` enum.
|
||||
* **`viu/libs/provider/anime/provider.py`**: Add an entry to the `PROVIDERS_AVAILABLE` dictionary.
|
||||
|
||||
5. **Final Guidance:** Remind the developer to add any title normalization rules to `viu/assets/normalizer.json` if the provider uses different anime titles than AniList.
|
||||
73
.github/chatmodes/plan.chatmode.md
vendored
Normal file
73
.github/chatmodes/plan.chatmode.md
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
---
|
||||
description: "Plan new features or bug fixes with architectural guidance for the viu project. Does not write implementation code."
|
||||
tools: ['codebase', 'search', 'githubRepo', 'fetch']
|
||||
model: "gpt-4o"
|
||||
---
|
||||
# viu: Feature & Fix Planner Mode
|
||||
|
||||
You are a senior software architect and project planner for the `viu` project. You are an expert in its layered architecture (`Core`, `Libs`, `Service`, `CLI`) and its commitment to modular, testable code.
|
||||
|
||||
Your primary goal is to help the user break down a feature request or bug report into a clear, actionable implementation plan.
|
||||
|
||||
**Crucially, you MUST NOT write the full implementation code.** Your output is the plan itself, which will then guide the developer (or another AI agent in "Edit" mode) to write the code.
|
||||
|
||||
### Your Process:
|
||||
|
||||
1. **Understand the Goal:** Start by asking the user to describe the feature they want to build or the bug they want to fix. If they reference a GitHub issue, use the `githubRepo` tool to get the context.
|
||||
|
||||
2. **Analyze the Codebase:** Use the `codebase` and `search` tools to understand how the request fits into the existing architecture. Identify all potentially affected modules, classes, and layers.
|
||||
|
||||
3. **Ask Clarifying Questions:** Ask questions to refine the requirements. For example:
|
||||
* "Will this feature need a new configuration option? If so, what should the default be?"
|
||||
* "How should this behave in the interactive TUI versus the direct CLI command?"
|
||||
* "Which architectural layer does the core logic for this fix belong in?"
|
||||
|
||||
4. **Generate the Implementation Plan:** Once you have enough information, produce a comprehensive plan in the following Markdown format:
|
||||
|
||||
---
|
||||
|
||||
### Implementation Plan: [Feature/Fix Name]
|
||||
|
||||
**1. Overview**
|
||||
> A brief, one-sentence summary of the goal.
|
||||
|
||||
**2. Architectural Impact Analysis**
|
||||
> This is the most important section. Detail which parts of the codebase will be touched and why.
|
||||
> - **Core Layer (`viu/core`):**
|
||||
> - *Config (`config/model.py`):* Will a new Pydantic model or field be needed?
|
||||
> - *Utils (`utils/`):* Are any new low-level, reusable functions required?
|
||||
> - *Exceptions (`exceptions.py`):* Does this introduce a new failure case that needs a custom exception?
|
||||
> - **Libs Layer (`viu/libs`):**
|
||||
> - *Media API (`media_api/`):* Does this involve a new call to the AniList API?
|
||||
> - *Provider (`provider/`):* Does this affect how data is scraped?
|
||||
> - *Player/Selector (`player/`, `selectors/`):* Does this change how we interact with external tools?
|
||||
> - **Service Layer (`viu/cli/service`):**
|
||||
> - Which service will orchestrate this logic? (e.g., `DownloadService`, `PlayerService`). Will a new service be needed?
|
||||
> - **CLI Layer (`viu/cli`):**
|
||||
> - *Commands (`commands/`):* Which `click` command(s) will expose this feature?
|
||||
> - *Interactive UI (`interactive/`):* Which TUI menu(s) need to be added or modified?
|
||||
|
||||
**3. Implementation Steps**
|
||||
> A step-by-step checklist for the developer.
|
||||
> 1. [ ] **Config:** Add `new_setting` to `GeneralConfig` in `core/config/model.py`.
|
||||
> 2. [ ] **Core:** Implement `new_util()` in `core/utils/helpers.py`.
|
||||
> 3. [ ] **Service:** Add method `handle_new_feature()` to `MyService`.
|
||||
> 4. [ ] **CLI:** Add `--new-feature` option to the `viu anilist search` command.
|
||||
> 5. [ ] **Tests:** Write a unit test for `new_util()` and an integration test for the service method.
|
||||
|
||||
**4. Configuration Changes**
|
||||
> If new settings are needed, list them here and specify which files to update.
|
||||
> - **`core/config/model.py`:** Add field `new_setting: bool`.
|
||||
> - **`core/config/defaults.py`:** Add `GENERAL_NEW_SETTING = False`.
|
||||
> - **`core/config/descriptions.py`:** Add `GENERAL_NEW_SETTING = "Description of the new setting."`
|
||||
|
||||
**5. Testing Strategy**
|
||||
> Briefly describe how to test this change.
|
||||
> - A unit test for the pure logic in the `Core` or `Libs` layer.
|
||||
> - An integration test for the `Service` layer.
|
||||
> - Manual verification steps for the CLI and interactive UI.
|
||||
|
||||
**6. Potential Risks & Open Questions**
|
||||
> - Will this change impact the performance of the provider scraping?
|
||||
> - Do we need to handle a case where the external API does not support this feature?
|
||||
---
|
||||
101
.github/copilot-instructions.md
vendored
Normal file
101
.github/copilot-instructions.md
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
# GitHub Copilot Instructions for the viu Repository
|
||||
|
||||
Hello, Copilot! This document provides instructions and context to help you understand the `viu` codebase. Following these guidelines will help you generate code that is consistent, maintainable, and aligned with the project's architecture.
|
||||
|
||||
## 1. High-Level Project Goal
|
||||
|
||||
`viu` is a command-line tool that brings the anime browsing, streaming, and management experience to the terminal. It integrates with metadata providers like AniList and scrapes streaming links from various anime provider websites. The core goals are efficiency, extensibility, and providing a powerful, scriptable user experience.
|
||||
|
||||
## 2. Core Architectural Concepts
|
||||
|
||||
The project follows a clean, layered architecture. When generating code, please adhere to this structure.
|
||||
|
||||
#### Layer 1: CLI (`viu/cli`)
|
||||
* **Purpose:** Handles user interaction, command parsing, and displaying output.
|
||||
* **Key Libraries:** `click` for command structure, `rich` for styled output.
|
||||
* **Interactive Mode:** The interactive TUI is managed by the `Session` object in `viu/cli/interactive/session.py`. It's a state machine where each menu is a function that returns the next `State` or an `InternalDirective` (like `BACK` or `EXIT`).
|
||||
* **Guideline:** **CLI files should not contain complex business logic.** They should parse arguments and delegate tasks to the Service Layer.
|
||||
|
||||
#### Layer 2: Service (`viu/cli/service`)
|
||||
* **Purpose:** Contains the core application logic. Services act as orchestrators, connecting the CLI layer with the various library components.
|
||||
* **Examples:** `DownloadService`, `PlayerService`, `MediaRegistryService`, `WatchHistoryService`.
|
||||
* **Guideline:** When adding new functionality (e.g., a new way to manage downloads), it should likely be implemented in a service or an existing service should be extended. Services are the "brains" of the application.
|
||||
|
||||
#### Layer 3: Libraries (`viu/libs`)
|
||||
* **Purpose:** A collection of independent, reusable modules with well-defined contracts (Abstract Base Classes).
|
||||
* **`media_api`:** Interfaces with metadata services like AniList. All new metadata clients **must** inherit from `BaseApiClient`.
|
||||
* **`provider`:** Interfaces with anime streaming websites. All new providers **must** inherit from `BaseAnimeProvider`.
|
||||
* **`player`:** Wrappers around external media players like MPV. All new players **must** inherit from `BasePlayer`.
|
||||
* **`selectors`:** Wrappers for interactive UI tools like FZF or Rofi. All new selectors **must** inherit from `BaseSelector`.
|
||||
* **Guideline:** Libraries should be self-contained and not depend on the CLI or Service layers. They receive configuration and perform their specific task.
|
||||
|
||||
#### Layer 4: Core (`viu/core`)
|
||||
* **Purpose:** Foundational code shared across the entire application.
|
||||
* **`config`:** Pydantic models defining the application's configuration structure. **This is the single source of truth for all settings.**
|
||||
* **`downloader`:** The underlying logic for downloading files (using `yt-dlp` or `httpx`).
|
||||
* **`exceptions`:** Custom exception classes used throughout the project.
|
||||
* **`utils`:** Common, low-level utility functions.
|
||||
* **Guideline:** Code in `core` should be generic and have no dependencies on other layers except for other `core` modules.
|
||||
|
||||
## 3. Key Technologies
|
||||
* **Dependency Management:** `uv` is used for all package management and task running. Refer to `pyproject.toml` for dependencies.
|
||||
* **Configuration:** **Pydantic** is used exclusively. The entire configuration is defined in `viu/core/config/model.py`.
|
||||
* **CLI Framework:** `click`. We use a custom `LazyGroup` to load commands on demand for faster startup.
|
||||
* **HTTP Client:** `httpx` is the standard for all network requests.
|
||||
|
||||
## 4. How to Add New Features
|
||||
|
||||
Follow these patterns to ensure your contributions fit the existing architecture.
|
||||
|
||||
### How to Add a New Provider
|
||||
1. **Create Directory:** Add a new folder in `viu/libs/provider/anime/newprovider/`.
|
||||
2. **Implement `BaseAnimeProvider`:** In `provider.py`, create a class `NewProvider` that inherits from `BaseAnimeProvider` and implement the `search`, `get`, and `episode_streams` methods.
|
||||
3. **Create Mappers:** In `mappers.py`, write functions to convert the provider's API/HTML data into the generic Pydantic models from `viu/libs/provider/anime/types.py` (e.g., `SearchResult`, `Anime`, `Server`).
|
||||
4. **Register Provider:**
|
||||
* Add the provider's name to the `ProviderName` enum in `viu/libs/provider/anime/types.py`.
|
||||
* Add it to the `PROVIDERS_AVAILABLE` dictionary in `viu/libs/provider/anime/provider.py`.
|
||||
|
||||
### How to Add a New Player
|
||||
1. **Create Directory:** Add a new folder in `viu/libs/player/newplayer/`.
|
||||
2. **Implement `BasePlayer`:** In `player.py`, create a class `NewPlayer` that inherits from `BasePlayer` and implement the `play` method. It should call the player's executable via `subprocess`.
|
||||
3. **Add Configuration:** If the player has settings, add a `NewPlayerConfig` Pydantic model in `viu/core/config/model.py`, and add it to the main `AppConfig`. Also add defaults and descriptions.
|
||||
4. **Register Player:** Add the player's name to the `PLAYERS` list and the factory logic in `viu/libs/player/player.py`.
|
||||
|
||||
### How to Add a New Selector
|
||||
1. **Create Directory:** Add a new folder in `viu/libs/selectors/newselector/`.
|
||||
2. **Implement `BaseSelector`:** In `selector.py`, create a class `NewSelector` that inherits from `BaseSelector` and implement `choose`, `confirm`, and `ask`.
|
||||
3. **Add Configuration:** If needed, add a `NewSelectorConfig` to `viu/core/config/model.py`.
|
||||
4. **Register Selector:** Add the selector's name to the `SELECTORS` list and the factory logic in `viu/libs/selectors/selector.py`. Update the `Literal` type hint for `selector` in `GeneralConfig`.
|
||||
|
||||
### How to Add a New CLI Command
|
||||
* **Top-Level Command (`viu my-command`):**
|
||||
1. Create `viu/cli/commands/my_command.py` with your `click.command()`.
|
||||
2. Register it in the `commands` dictionary in `viu/cli/cli.py`.
|
||||
* **Subcommand (`viu anilist my-subcommand`):**
|
||||
1. Create `viu/cli/commands/anilist/commands/my_subcommand.py`.
|
||||
2. Register it in the `lazy_subcommands` dictionary of the parent `click.group()` (e.g., in `viu/cli/commands/anilist/cmd.py`).
|
||||
|
||||
### How to Add a New Configuration Option
|
||||
1. **Add to Model:** Add the field to the appropriate Pydantic model in `viu/core/config/model.py`.
|
||||
2. **Add Default:** Add a default value in `viu/core/config/defaults.py`.
|
||||
3. **Add Description:** Add a user-friendly description in `viu/core/config/descriptions.py`.
|
||||
4. The config loader and CLI option generation will handle the rest automatically.
|
||||
|
||||
## 5. Code Style and Conventions
|
||||
* **Style:** `ruff` for formatting, `ruff` for linting. The `pre-commit` hooks handle this.
|
||||
* **Types:** Full type hinting is mandatory. All code must pass `pyright`.
|
||||
* **Commits:** Adhere to the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard.
|
||||
* **Logging:** Use Python's `logging` module. Do not use `print()` for debugging or informational messages in library or service code.
|
||||
|
||||
## 6. Do's and Don'ts
|
||||
|
||||
* ✅ **DO** use the abstract base classes (`BaseProvider`, `BasePlayer`, etc.) as contracts.
|
||||
* ✅ **DO** place business logic in the `service` layer.
|
||||
* ✅ **DO** use the Pydantic models in `viu/core/config/model.py` as the single source of truth for configuration.
|
||||
* ✅ **DO** use the `Context` object in interactive menus to access services and configuration.
|
||||
|
||||
* ❌ **DON'T** hardcode configuration values. Access them via the `config` object.
|
||||
* ❌ **DON'T** put complex logic directly into `click` command functions. Delegate to a service.
|
||||
* ❌ **DON'T** make direct `httpx` calls outside of a `provider` or `media_api` library.
|
||||
* ❌ **DON'T** introduce new dependencies without updating `pyproject.toml` and discussing it first.
|
||||
|
||||
47
.github/workflows/build.yml
vendored
47
.github/workflows/build.yml
vendored
@@ -1,38 +1,43 @@
|
||||
name: debug_build
|
||||
name: build
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Test Workflow"]
|
||||
types:
|
||||
- completed
|
||||
jobs:
|
||||
debug_build:
|
||||
build:
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Python
|
||||
|
||||
- name: "Set up Python"
|
||||
uses: actions/setup-python@v5
|
||||
- name: Install poetry
|
||||
uses: abatilo/actions-poetry@v2
|
||||
- name: Setup a local virtual environment (if no poetry.toml file)
|
||||
run: |
|
||||
poetry config virtualenvs.create true --local
|
||||
poetry config virtualenvs.in-project true --local
|
||||
- uses: actions/cache@v3
|
||||
name: Define a cache for the virtual environment based on the dependencies lock file
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
path: ./.venv
|
||||
key: venv-${{ hashFiles('poetry.lock') }}
|
||||
- name: Install the project dependencies
|
||||
run: poetry install
|
||||
- name: build app
|
||||
run: poetry build
|
||||
enable-cache: true
|
||||
|
||||
- name: Build viu
|
||||
run: uv build
|
||||
|
||||
- name: Archive production artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: fastanime_debug_build
|
||||
name: viu_debug_build
|
||||
path: |
|
||||
dist
|
||||
!dist/*.whl
|
||||
# - name: Run the automated tests (for example)
|
||||
# run: poetry run pytest -v
|
||||
|
||||
- name: Install nix
|
||||
uses: DeterminateSystems/nix-installer-action@main
|
||||
|
||||
- name: Use GitHub Action built-in cache
|
||||
uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
|
||||
- name: Nix Flake check (evaluation + tests)
|
||||
run: nix flake check
|
||||
|
||||
- name: Build the nix derivation
|
||||
run: nix build
|
||||
|
||||
21
.github/workflows/publish.yml
vendored
21
.github/workflows/publish.yml
vendored
@@ -1,12 +1,3 @@
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
|
||||
# GitHub recommends pinning actions to a commit SHA.
|
||||
# To get a newer version, you will need to update the SHA.
|
||||
# You can also reference a tag or branch, but the action may change without warning.
|
||||
|
||||
name: Upload Python Package
|
||||
|
||||
on:
|
||||
@@ -27,11 +18,13 @@ jobs:
|
||||
with:
|
||||
python-version: "3.10"
|
||||
|
||||
- name: Build release distributions
|
||||
run: |
|
||||
# NOTE: put your own distribution build steps here.
|
||||
python -m pip install build
|
||||
python -m build
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
enable-cache: true
|
||||
|
||||
- name: Build viu
|
||||
run: uv build
|
||||
|
||||
- name: Upload distributions
|
||||
uses: actions/upload-artifact@v4
|
||||
|
||||
57
.github/workflows/stale.yml
vendored
Normal file
57
.github/workflows/stale.yml
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
name: Mark Stale Issues and Pull Requests
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# Runs every day at 6:30 UTC
|
||||
- cron: "30 6 * * *"
|
||||
# Allows you to run this workflow manually from the Actions tab for testing
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- uses: actions/stale@v5
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
stale-issue-message: |
|
||||
Greetings @{{author}},
|
||||
|
||||
This bug report is like an ancient scroll detailing a legendary beast. Our small guild of developers is often on many quests at once, so our response times can be slower than a tortoise in a time-stop spell. We deeply appreciate your patience!
|
||||
|
||||
**Seeking Immediate Help or Discussion?**
|
||||
Our **[Discord Tavern](https://discord.gg/HBEmAwvbHV)** is the best place to get a quick response from the community for general questions or setup help!
|
||||
|
||||
**Want to Be the Hero?**
|
||||
You could try to tame this beast yourself! With modern grimoires (like AI coding assistants) and our **[Contribution Guide](https://github.com/viu-media/Viu/blob/master/CONTRIBUTIONS.md)**, you might just be the hero we're waiting for. We would be thrilled to review your solution!
|
||||
|
||||
---
|
||||
To keep our quest board tidy, we need to know if this creature is still roaming the lands in the latest version of `viu`. If we don't get an update within **7 days**, we'll assume it has vanished and archive the scroll.
|
||||
|
||||
Thanks for being our trusted scout!
|
||||
|
||||
stale-pr-message: |
|
||||
Hello @{{author}}, it looks like this powerful contribution has been left in the middle of its training arc! 💪
|
||||
|
||||
Our review dojo is managed by just a few senseis who are sometimes away on long missions, so thank you for your patience as we work through the queue.
|
||||
|
||||
We were excited to see this new technique being developed. Are you still planning to complete its training, or have you embarked on a different quest? If you need a sparring partner (reviewer) or some guidance from a senpai, just let us know!
|
||||
|
||||
To keep our dojo tidy, we'll be archiving unfinished techniques. If we don't hear back within **7 days**, we'll assume it's time to close this PR for now. You can always resume your training and reopen it when you're ready.
|
||||
|
||||
Thank you for your incredible effort!
|
||||
|
||||
# --- Labels and Timing ---
|
||||
stale-issue-label: "stale"
|
||||
stale-pr-label: "stale"
|
||||
|
||||
# How many days of inactivity before an issue/PR is marked as stale.
|
||||
days-before-stale: 14
|
||||
|
||||
# How many days of inactivity to wait before closing a stale issue/PR.
|
||||
days-before-close: 7
|
||||
47
.github/workflows/test.yml
vendored
47
.github/workflows/test.yml
vendored
@@ -6,37 +6,42 @@ on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.10", "3.11"] # List the Python versions you want to test
|
||||
python-version: ["3.11", "3.12"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install poetry
|
||||
uses: abatilo/actions-poetry@v2
|
||||
- name: Setup a local virtual environment (if no poetry.toml file)
|
||||
|
||||
- name: Install dbus-python build dependencies
|
||||
run: |
|
||||
poetry config virtualenvs.create true --local
|
||||
poetry config virtualenvs.in-project true --local
|
||||
- uses: actions/cache@v3
|
||||
name: Define a cache for the virtual environment based on the dependencies lock file
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install libdbus-1-dev libglib2.0-dev
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
path: ./.venv
|
||||
key: venv-${{ hashFiles('poetry.lock') }}
|
||||
- name: Install the project dependencies
|
||||
run: poetry install
|
||||
- name: run linter, formatters and sort imports
|
||||
run: |
|
||||
poetry run black .
|
||||
poetry run ruff check --output-format=github . --fix
|
||||
poetry run isort . --profile black
|
||||
- name: run type checking
|
||||
run: poetry run pyright
|
||||
- name: run tests
|
||||
run: poetry run pytest
|
||||
enable-cache: true
|
||||
|
||||
- name: Install the project
|
||||
run: uv sync --all-extras --dev
|
||||
|
||||
- name: Run linter and formater
|
||||
run: uv run ruff check --output-format=github
|
||||
|
||||
- name: Run type checking
|
||||
run: uv run pyright
|
||||
|
||||
# TODO: write tests
|
||||
|
||||
# - name: Run tests
|
||||
# run: uv run pytest tests
|
||||
|
||||
86
.gitignore
vendored
86
.gitignore
vendored
@@ -1,25 +1,16 @@
|
||||
# mine
|
||||
*.mp4
|
||||
*.mp3
|
||||
*.ass
|
||||
vids
|
||||
data/
|
||||
.project/
|
||||
fastanime.ini
|
||||
crashdump.txt
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*.py[codz]
|
||||
*$py.class
|
||||
anixstream.ini
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
bin/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
@@ -39,7 +30,7 @@ MANIFEST
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
# *.spec
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
@@ -55,7 +46,7 @@ htmlcov/
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
*.py.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
@@ -103,23 +94,36 @@ ipython_config.py
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# UV
|
||||
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
#uv.lock
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
#poetry.lock
|
||||
#poetry.toml
|
||||
|
||||
# pdm
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
||||
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
||||
#pdm.lock
|
||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||
# in version control.
|
||||
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
||||
.pdm.toml
|
||||
#pdm.toml
|
||||
.pdm-python
|
||||
.pdm-build/
|
||||
|
||||
# pixi
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
||||
#pixi.lock
|
||||
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
||||
# in the .venv directory. It is recommended not to include this directory in version control.
|
||||
.pixi
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
|
||||
@@ -168,11 +172,41 @@ cython_debug/
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
.idea/
|
||||
app/anixstream.ini
|
||||
app/settings.json
|
||||
app/user_data.json
|
||||
app/View/SearchScreen/.search_screen.py.un~
|
||||
app/View/SearchScreen/search_screen.py~
|
||||
app/user_data.json
|
||||
.buildozer
|
||||
#.idea/
|
||||
|
||||
# Abstra
|
||||
# Abstra is an AI-powered process automation framework.
|
||||
# Ignore directories containing user credentials, local state, and settings.
|
||||
# Learn more at https://abstra.io/docs
|
||||
.abstra/
|
||||
|
||||
# Visual Studio Code
|
||||
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
||||
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
||||
# you could uncomment the following to ignore the entire vscode folder
|
||||
# .vscode/
|
||||
|
||||
# Ruff stuff:
|
||||
.ruff_cache/
|
||||
|
||||
# PyPI configuration file
|
||||
.pypirc
|
||||
|
||||
# Cursor
|
||||
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
||||
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
||||
# refer to https://docs.cursor.com/context/ignore-files
|
||||
.cursorignore
|
||||
.cursorindexingignore
|
||||
|
||||
# Marimo
|
||||
marimo/_static/
|
||||
marimo/_lsp/
|
||||
__marimo__/
|
||||
|
||||
# custom
|
||||
repomix-output.xml
|
||||
.project/
|
||||
result
|
||||
.direnv
|
||||
|
||||
@@ -1,35 +1,10 @@
|
||||
default_language_version:
|
||||
python: python3.10
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pycqa/isort
|
||||
rev: 5.12.0
|
||||
hooks:
|
||||
- id: isort
|
||||
name: isort (python)
|
||||
args: ["--profile", "black"] # Ensure compatibility with Black
|
||||
|
||||
- repo: https://github.com/PyCQA/autoflake
|
||||
rev: v2.2.1
|
||||
hooks:
|
||||
- id: autoflake
|
||||
args:
|
||||
[
|
||||
"--in-place",
|
||||
"--remove-unused-variables",
|
||||
"--remove-all-unused-imports",
|
||||
]
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
# Ruff version.
|
||||
rev: v0.4.10
|
||||
rev: v0.14.2
|
||||
hooks:
|
||||
# Run the linter.
|
||||
- id: ruff
|
||||
- id: ruff-check
|
||||
args: [--fix]
|
||||
|
||||
- repo: https://github.com/psf/black-pre-commit-mirror
|
||||
rev: 24.4.2
|
||||
hooks:
|
||||
- id: black
|
||||
name: black
|
||||
language_version: python3.10 # to ensure compatibilty
|
||||
# Run the formatter.
|
||||
- id: ruff-format
|
||||
|
||||
1
.python-version
Normal file
1
.python-version
Normal file
@@ -0,0 +1 @@
|
||||
3.11
|
||||
1
.repomixignore
Normal file
1
.repomixignore
Normal file
@@ -0,0 +1 @@
|
||||
**/generated/**/*
|
||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"python.analysis.autoImportCompletions": true
|
||||
}
|
||||
208
CONTRIBUTIONS.md
Normal file
208
CONTRIBUTIONS.md
Normal file
@@ -0,0 +1,208 @@
|
||||
# Contributing to Viu
|
||||
|
||||
First off, thank you for considering contributing to Viu! We welcome any help, whether it's reporting a bug, proposing a feature, or writing code. This document will guide you through the process.
|
||||
|
||||
## How Can I Contribute?
|
||||
|
||||
There are many ways to contribute to the Viu project:
|
||||
|
||||
* **Reporting Bugs:** If you find a bug, please create an issue in our [issue tracker](https://github.com/viu-media/Viu/issues).
|
||||
* **Suggesting Enhancements:** Have an idea for a new feature or an improvement to an existing one? We'd love to hear it.
|
||||
* **Writing Code:** Help us fix bugs or implement new features.
|
||||
* **Improving Documentation:** Enhance our README, add examples, or clarify our contribution guidelines.
|
||||
* **Adding a Provider, Player, or Selector:** Extend Viu's capabilities by integrating new tools and services.
|
||||
|
||||
## Contribution Workflow
|
||||
|
||||
We follow the standard GitHub Fork & Pull Request workflow.
|
||||
|
||||
1. **Create an Issue:** Before starting work on a new feature or a significant bug fix, please [create an issue](https://github.com/viu-media/Viu/issues/new/choose) to discuss your idea. This allows us to give feedback and prevent duplicate work. For small bugs or documentation typos, you can skip this step.
|
||||
|
||||
2. **Fork the Repository:** Create your own fork of the Viu repository.
|
||||
|
||||
3. **Clone Your Fork:**
|
||||
```bash
|
||||
git clone https://github.com/YOUR_USERNAME/Viu.git
|
||||
cd Viu
|
||||
```
|
||||
|
||||
4. **Create a Branch:** Create a new branch for your changes. Use a descriptive name.
|
||||
```bash
|
||||
# For a new feature
|
||||
git checkout -b feat/my-new-feature
|
||||
|
||||
# For a bug fix
|
||||
git checkout -b fix/bug-description
|
||||
```
|
||||
|
||||
5. **Make Your Changes:** Write your code, following the guidelines below.
|
||||
|
||||
6. **Run Quality Checks:** Before committing, ensure your code passes all quality checks.
|
||||
```bash
|
||||
# Format, lint, and sort imports
|
||||
uv run ruff check --fix .
|
||||
uv run ruff format .
|
||||
|
||||
# Run type checking
|
||||
uv run pyright
|
||||
|
||||
# Run tests
|
||||
uv run pytest
|
||||
```
|
||||
|
||||
7. **Commit Your Changes:** We follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. This helps us automate releases and makes the commit history more readable.
|
||||
```bash
|
||||
# Example commit messages
|
||||
git commit -m "feat: add support for XYZ provider"
|
||||
git commit -m "fix(anilist): correctly parse episode numbers with decimals"
|
||||
git commit -m "docs: update installation instructions in README"
|
||||
git commit -m "chore: upgrade httpx to version 0.28.1"
|
||||
```
|
||||
|
||||
8. **Push to Your Fork:**
|
||||
```bash
|
||||
git push origin feat/my-new-feature
|
||||
```
|
||||
|
||||
9. **Submit a Pull Request:** Open a pull request from your branch to the `master` branch of the main Viu repository. Provide a clear title and description of your changes.
|
||||
|
||||
## Setting Up Your Development Environment
|
||||
|
||||
### Prerequisites
|
||||
* Git
|
||||
* Python 3.10+
|
||||
* [uv](https://github.com/astral-sh/uv) (recommended)
|
||||
* **External Tools (for full functionality):** `mpv`, `fzf`, `rofi`, `webtorrent-cli`, `ffmpeg`.
|
||||
|
||||
### Nix / NixOS Users
|
||||
The easiest way to get a development environment with all dependencies is to use our Nix flake.
|
||||
```bash
|
||||
nix develop
|
||||
```
|
||||
This command will drop you into a shell with all the necessary tools and a Python environment ready to go.
|
||||
|
||||
### Standard Setup (uv + venv)
|
||||
|
||||
1. **Clone your fork** (as described above).
|
||||
|
||||
2. **Create and activate a virtual environment:**
|
||||
```bash
|
||||
uv venv
|
||||
source .venv/bin/activate
|
||||
```
|
||||
|
||||
3. **Install all dependencies:** This command installs both runtime and development dependencies, including all optional extras.
|
||||
```bash
|
||||
uv sync --all-extras --dev
|
||||
```
|
||||
|
||||
4. **Set up pre-commit hooks:** This will automatically run linters and formatters before each commit, ensuring your code meets our quality standards.
|
||||
```bash
|
||||
pre-commit install
|
||||
```
|
||||
|
||||
## Coding Guidelines
|
||||
|
||||
To maintain code quality and consistency, please adhere to the following guidelines.
|
||||
|
||||
* **Formatting:** We use **Black** for code formatting and **isort** (via Ruff) for import sorting. The pre-commit hooks will handle this for you.
|
||||
* **Linting:** We use **Ruff** for linting. Please ensure your code has no linting errors before submitting a PR.
|
||||
* **Type Hinting:** All new code should be fully type-hinted and pass `pyright` checks. We rely on Pydantic for data validation and configuration, so leverage it where possible.
|
||||
* **Modularity and Architecture:**
|
||||
* **Services:** Business logic is organized into services (e.g., `PlayerService`, `DownloadService`).
|
||||
* **Factories:** Use factory patterns (`create_provider`, `create_selector`) for creating instances of different implementations.
|
||||
* **Configuration:** All configuration is managed through Pydantic models in `viu/core/config/model.py`. When adding new config options, update the model, defaults, and descriptions.
|
||||
* **Commit Messages:** Follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard.
|
||||
* **Testing:** New features should be accompanied by tests. Bug fixes should ideally include a regression test.
|
||||
|
||||
## How to Add a New Provider
|
||||
|
||||
Adding a new anime provider is a great way to contribute. Here are the steps:
|
||||
|
||||
1. **Create a New Provider Directory:** Inside `viu/libs/provider/anime/`, create a new directory with the provider's name (e.g., `viu/libs/provider/anime/newprovider/`).
|
||||
|
||||
2. **Implement the Provider:**
|
||||
* Create a `provider.py` file.
|
||||
* Define a class (e.g., `NewProviderApi`) that inherits from `BaseAnimeProvider`.
|
||||
* Implement the abstract methods: `search`, `get`, and `episode_streams`.
|
||||
* Create `mappers.py` to convert the provider's data structures into the generic types defined in `viu/libs/provider/anime/types.py`.
|
||||
* Create `types.py` for any provider-specific data structures you need.
|
||||
* If the provider requires complex scraping, place extractor logic in an `extractors/` subdirectory.
|
||||
|
||||
3. **Register the Provider:**
|
||||
* Add your new provider to the `ProviderName` enum in `viu/libs/provider/anime/types.py`.
|
||||
* Register it in the `PROVIDERS_AVAILABLE` dictionary in `viu/libs/provider/anime/provider.py`.
|
||||
|
||||
4. **Add Normalization Rules (Optional):** If the provider uses different anime titles than AniList, add mappings to `viu/assets/normalizer.json`.
|
||||
|
||||
## How to Add a New Player
|
||||
|
||||
1. **Create a New Player Directory:** Inside `viu/libs/player/`, create a directory for your player (e.g., `viu/libs/player/myplayer/`).
|
||||
|
||||
2. **Implement the Player Class:**
|
||||
* In `myplayer/player.py`, create a class (e.g., `MyPlayer`) that inherits from `BasePlayer`.
|
||||
* Implement the required abstract methods: `play(self, params: PlayerParams)` and `play_with_ipc(self, params: PlayerParams, socket_path: str)`. The IPC method is optional but recommended for advanced features.
|
||||
* The `play` method should handle launching the player as a subprocess and return a `PlayerResult`.
|
||||
|
||||
3. **Add Configuration (if needed):**
|
||||
* If your player has configurable options, add a new Pydantic model (e.g., `MyPlayerConfig`) in `viu/core/config/model.py`. It should inherit from `OtherConfig`.
|
||||
* Add this new config model as a field in the main `AppConfig` model.
|
||||
* Add default values in `defaults.py` and descriptions in `descriptions.py`.
|
||||
|
||||
4. **Register the Player:**
|
||||
* Add your player's name to the `PLAYERS` list in `viu/libs/player/player.py`.
|
||||
* Add the logic to instantiate your player class within the `PlayerFactory.create` method.
|
||||
|
||||
## How to Add a New Selector
|
||||
|
||||
1. **Create a New Selector Directory:** Inside `viu/libs/selectors/`, create a new directory (e.g., `viu/libs/selectors/myselector/`).
|
||||
|
||||
2. **Implement the Selector Class:**
|
||||
* In `myselector/selector.py`, create a class (e.g., `MySelector`) that inherits from `BaseSelector`.
|
||||
* Implement the abstract methods: `choose`, `confirm`, and `ask`.
|
||||
* Optionally, you can override `choose_multiple` and `search` for more advanced functionality.
|
||||
|
||||
3. **Add Configuration (if needed):** Follow the same configuration steps as for adding a new player.
|
||||
|
||||
4. **Register the Selector:**
|
||||
* Add your selector's name to the `SELECTORS` list in `viu/libs/selectors/selector.py`.
|
||||
* Add the instantiation logic to the `SelectorFactory.create` method.
|
||||
* Update the `Literal` type hint for the `selector` field in `GeneralConfig` (`viu/core/config/model.py`).
|
||||
|
||||
## How to Add a New CLI Command or Service
|
||||
|
||||
Our CLI uses `click` and a `LazyGroup` class to load commands on demand.
|
||||
|
||||
### Adding a Top-Level Command (e.g., `viu my-command`)
|
||||
|
||||
1. **Create the Command File:** Create a new Python file in `viu/cli/commands/` (e.g., `my_command.py`). This file should contain your `click.command()` function.
|
||||
|
||||
2. **Register the Command:** In `viu/cli/cli.py`, add your command to the `commands` dictionary.
|
||||
```python
|
||||
commands = {
|
||||
# ... existing commands
|
||||
"my-command": "my_command.my_command_function",
|
||||
}
|
||||
```
|
||||
|
||||
### Adding a Subcommand (e.g., `viu anilist my-subcommand`)
|
||||
|
||||
1. **Create the Command File:** Place your new command file inside the appropriate subdirectory, for example, `viu/cli/commands/anilist/commands/my_subcommand.py`.
|
||||
|
||||
2. **Register the Subcommand:** In the parent command's entry point file (e.g., `viu/cli/commands/anilist/cmd.py`), add your subcommand to the `commands` dictionary within the `LazyGroup`.
|
||||
```python
|
||||
@click.group(
|
||||
cls=LazyGroup,
|
||||
# ... other options
|
||||
lazy_subcommands={
|
||||
# ... existing subcommands
|
||||
"my-subcommand": "my_subcommand.my_subcommand_function",
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Creating a Service
|
||||
If your command involves complex logic, consider creating a service in `viu/cli/service/` to keep the business logic separate from the command-line interface. This service can then be instantiated and used within your `click` command function. This follows the existing pattern for services like `DownloadService` and `PlayerService`.
|
||||
|
||||
---
|
||||
Thank you for contributing to Viu
|
||||
38
DISCLAIMER.md
Normal file
38
DISCLAIMER.md
Normal file
@@ -0,0 +1,38 @@
|
||||
<h1 align="center">Disclaimer</h1>
|
||||
|
||||
<div align="center">
|
||||
|
||||
<h2>This project: viu</h2>
|
||||
|
||||
<br>
|
||||
|
||||
The core aim of this project is to co-relate automation and efficiency to extract what is provided to a user on the internet. All content available through the project is hosted by external non-affiliated sources.
|
||||
|
||||
<br>
|
||||
|
||||
<b>All content served through this project is publicly accessible. If your site is listed in this project, the code is pretty much public. Take necessary measures to counter the exploits used to extract content in your site.</b>
|
||||
|
||||
Think of this project as your normal browser, but a bit more straight-forward and specific. While an average browser makes hundreds of requests to get everything from a site, this project goes on to only make requests associated with getting the content served by the sites.
|
||||
|
||||
<b>
|
||||
|
||||
This project is to be used at the user's own risk, based on their government and laws.
|
||||
|
||||
This project has no control on the content it is serving, using copyrighted content from the providers is not going to be accounted for by the developer. It is the user's own risk.
|
||||
|
||||
</b>
|
||||
|
||||
<br>
|
||||
|
||||
<h2>DMCA and Copyright Infrigements</h3>
|
||||
|
||||
<br>
|
||||
|
||||
<b>
|
||||
|
||||
A browser is a tool, and the maliciousness of the tool is directly based on the user.
|
||||
</b>
|
||||
|
||||
This project uses client-side content access mechanisms. Hence, the copyright infrigements or DMCA in this project's regards are to be forwarded to the associated site by the associated notifier of any such claims. This is one of the main reasons the sites are listed in this project.
|
||||
|
||||
<b>Do not harass the developer. Any personal information about the developer is intentionally not made public. Exploiting such information without consent in regards to this topic will lead to legal actions by the developer themselves.</b>
|
||||
10
Dockerfile
10
Dockerfile
@@ -1,10 +0,0 @@
|
||||
FROM ubuntu
|
||||
RUN apt-get update
|
||||
RUN apt-get -y install python3
|
||||
RUN apt-get update
|
||||
RUN apt-get -y install pipx
|
||||
RUN pipx ensurepath
|
||||
COPY . /fastanime
|
||||
WORKDIR /fastanime
|
||||
RUN pipx install .
|
||||
CMD ["bash"]
|
||||
639
README.md
639
README.md
@@ -1,411 +1,334 @@
|
||||
# FastAnime
|
||||
<p align="center">
|
||||
<h1 align="center">Viu</h1>
|
||||
</p>
|
||||
<p align="center">
|
||||
<sup>
|
||||
Your browser anime experience, from the terminal.
|
||||
</sup>
|
||||
</p>
|
||||
<div align="center">
|
||||
|
||||
Welcome to **FastAnime**, anime site experience from the terminal.
|
||||
[](https://pypi.org/project/viu-media/)
|
||||
[](https://pypi.org/project/viu-media/)
|
||||
[](https://github.com/viu-media/Viu/actions)
|
||||
[](https://discord.gg/HBEmAwvbHV)
|
||||
[](https://github.com/viu-media/Viu/issues)
|
||||
[](https://github.com/viu-media/Viu/blob/master/LICENSE)
|
||||
|
||||
</div>
|
||||
|
||||
**fzf mode**
|
||||
<p align="center">
|
||||
<a href="https://discord.gg/HBEmAwvbHV">
|
||||
<img src="https://invidget.switchblade.xyz/C4rhMA4mmK" alt="Discord Server Invite">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
[fa_fzf_demo.webm](https://github.com/user-attachments/assets/b1fecf25-e358-4e8b-a144-bcb7947210cf)
|
||||
|
||||
|
||||
**other modes:**
|
||||
[viu-showcase.webm](https://github.com/user-attachments/assets/5da0ec87-7780-4310-9ca2-33fae7cadd5f)
|
||||
|
||||
<details>
|
||||
<summary><b>rofi mode</b></summary>
|
||||
|
||||
[fa_rofi_mode.webm](https://github.com/user-attachments/assets/2ce669bf-b62f-4c44-bd79-cf0dcaddf37a)
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Default mode</b></summary>
|
||||
<summary>Rofi</summary>
|
||||
|
||||
[fa_default_mode.webm](https://github.com/user-attachments/assets/1ce3a23d-f4a0-4bc1-8518-426ec7b3b69e)
|
||||
[viu-showcase-rofi.webm](https://github.com/user-attachments/assets/01f197d9-5ac9-45e6-a00b-8e8cd5ab459c)
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
Heavily inspired by [animdl](https://github.com/justfoolingaround/animdl), [magic-tape](https://gitlab.com/christosangel/magic-tape/-/tree/main?ref_type=heads) and [ani-cli](https://github.com/pystardust/ani-cli).
|
||||
|
||||
|
||||
|
||||
<!--toc:start-->
|
||||
|
||||
- [FastAnime](#fastanime)
|
||||
- [Installation](#installation)
|
||||
- [Installation using your favourite package manager](#installation-using-your-favourite-package-manager)
|
||||
- [Using pipx](#using-pipx)
|
||||
- [Using pip](#using-pip)
|
||||
- [Installing the bleeding edge version](#installing-the-bleeding-edge-version)
|
||||
- [Building from the source](#building-from-the-source)
|
||||
- [External Dependencies](#external-dependencies)
|
||||
- [Usage](#usage)
|
||||
- [The Commandline interface :fire:](#the-commandline-interface-fire)
|
||||
- [The anilist command](#the-anilist-command)
|
||||
- [Running without any subcommand](#running-without-any-subcommand)
|
||||
- [Subcommands](#subcommands)
|
||||
- [download subcommand](#download-subcommand)
|
||||
- [search subcommand](#search-subcommand)
|
||||
- [downloads subcommand](#downloads-subcommand)
|
||||
- [config subcommand](#config-subcommand)
|
||||
- [Configuration](#configuration)
|
||||
- [Contributing](#contributing)
|
||||
- [Receiving Support](#receiving-support)
|
||||
- [Supporting the Project](#supporting-the-project)
|
||||
<!--toc:end-->
|
||||
|
||||
> [!IMPORTANT]
|
||||
>
|
||||
> This project currently scrapes allanime and is in no way related to them. The site is in the public domain and can be access by any one with a browser.
|
||||
> This project scrapes public-facing websites for its streaming / downloading capabilities and primarily acts as an anilist, jikan and many other media apis tui client. The developer(s) of this application have no affiliation with these content providers. This application hosts zero content and is intended for educational and personal use only. Use at your own risk.
|
||||
>
|
||||
> [**Read the Full Disclaimer**](DISCLAIMER.md)
|
||||
|
||||
## Core Features
|
||||
|
||||
* 📺 **Interactive TUI:** Browse, search, and manage your AniList library in a rich terminal interface powered by `fzf`, `rofi`, or a built-in selector.
|
||||
* ⚡ **Powerful Search:** Filter the entire AniList database with over 20 different criteria, including genres, tags, year, status, and score.
|
||||
* 💾 **Local Registry:** Maintain a fast, local database of your anime for offline access, detailed stats, and robust data management.
|
||||
* ⚙️ **Background Downloader:** Queue episodes for download and let a persistent background worker handle the rest.
|
||||
* 📜 **Scriptable CLI:** Automate streaming and downloading with powerful, non-interactive commands perfect for scripting.
|
||||
* 🔧 **Highly Customizable:** Tailor every aspect—from UI colors and providers to playback behavior—via a simple, well-documented configuration file.
|
||||
* 🔌 **Extensible Architecture:** Easily add new providers, media players, and UI selectors to fit your workflow.
|
||||
|
||||
## Installation
|
||||
|
||||
The app can run wherever python can run. So all you need to have is python installed on your device.
|
||||
On android you can use [termux](https://github.com/termux/termux-app).
|
||||
If you have any difficulty consult for help on the [discord channel](https://discord.gg/HRjySFjQ)
|
||||
Viu runs on any platform with Python 3.10+, including Windows, macOS, Linux, and Android (via Termux).
|
||||
|
||||
### Installation using your favourite package manager
|
||||
### Prerequisites
|
||||
|
||||
Currently the app is only published on [pypi](https://pypi.org/project/fastanime/).
|
||||
For the best experience, please install these external tools:
|
||||
|
||||
#### Using pipx
|
||||
* **Required for Streaming:**
|
||||
* [**mpv**](https://mpv.io/installation/) - The primary and recommended media player.
|
||||
* **Recommended for UI & Previews:**
|
||||
* [**fzf**](https://github.com/junegunn/fzf) - For the best fuzzy-finder interface.
|
||||
* [**chafa**](https://github.com/hpjansson/chafa) or [**kitty's icat**](https://sw.kovidgoyal.net/kitty/kittens/icat/) - For image previews in the terminal.
|
||||
* **Recommended for Downloads & Advanced Features:**
|
||||
* [**ffmpeg**](https://www.ffmpeg.org/) - Required for downloading HLS streams and merging subtitles.
|
||||
* [**webtorrent-cli**](https://github.com/webtorrent/webtorrent-cli) - For streaming torrents directly.
|
||||
|
||||
Preferred method of installation since [Pipx](https://github.com/pypa/pipx) creates an isolated environment for each app it installs.
|
||||
### Recommended Installation (uv)
|
||||
|
||||
The best way to install Viu is with [**uv**](https://github.com/astral-sh/uv), a lightning-fast Python package manager.
|
||||
|
||||
```bash
|
||||
# Install with all optional features for the full experience
|
||||
uv tool install "viu-media[standard]"
|
||||
|
||||
pipx install fastanime
|
||||
# Or, pick and choose the extras you need:
|
||||
uv tool install viu-media # Core functionality only
|
||||
uv tool install "viu-media[download]" # For advanced downloading with yt-dlp
|
||||
uv tool install "viu-media[discord]" # For Discord Rich Presence
|
||||
uv tool install "viu-media[notifications]" # For desktop notifications
|
||||
```
|
||||
|
||||
#### Using pip
|
||||
### Other Installation Methods
|
||||
|
||||
<details>
|
||||
<summary><b>Platform-Specific and Alternative Installers</b></summary>
|
||||
|
||||
#### Nix / NixOS
|
||||
##### Ephemeral / One-Off Run (No Installation)
|
||||
```bash
|
||||
nix run github:viu-media/viu
|
||||
```
|
||||
##### Imperative Installation
|
||||
```bash
|
||||
nix profile install github:viu-media/viu
|
||||
```
|
||||
##### Declarative Installation
|
||||
###### in your flake.nix
|
||||
```nix
|
||||
viu.url = "github:viu-media/viu";
|
||||
```
|
||||
###### in your system or home-manager packages
|
||||
```nix
|
||||
inputs.viu.packages.${pkgs.system}.default
|
||||
```
|
||||
|
||||
#### Arch Linux (AUR)
|
||||
Use an AUR helper like `yay` or `paru`.
|
||||
```bash
|
||||
# Stable version (recommended)
|
||||
yay -S viu-media
|
||||
|
||||
# Git version (latest commit)
|
||||
yay -S viu-media-git
|
||||
```
|
||||
|
||||
#### Using pipx (for isolated environments)
|
||||
```bash
|
||||
pipx install "viu-media[standard]"
|
||||
```
|
||||
|
||||
#### Using pip
|
||||
```bash
|
||||
pip install "viu-media[standard]"
|
||||
```
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Building from Source</b></summary>
|
||||
|
||||
Requires [Git](https://git-scm.com/), [Python 3.10+](https://www.python.org/), and [uv](https://astral.sh/blog/uv).
|
||||
```bash
|
||||
git clone https://github.com/viu-media/Viu.git --depth 1
|
||||
cd Viu
|
||||
uv tool install .
|
||||
viu --version
|
||||
```
|
||||
</details>
|
||||
|
||||
> [!TIP]
|
||||
> Enable shell completions for a much better experience by running `viu completions` and following the on-screen instructions for your shell.
|
||||
|
||||
## Getting Started: Quick Start
|
||||
|
||||
Get up and running in three simple steps:
|
||||
|
||||
1. **Authenticate with AniList:**
|
||||
```bash
|
||||
viu anilist auth
|
||||
```
|
||||
This will open your browser. Authorize the app and paste the obtained token back into the terminal.
|
||||
|
||||
2. **Launch the Interactive TUI:**
|
||||
```bash
|
||||
viu anilist
|
||||
```
|
||||
|
||||
3. **Browse & Play:** Use your arrow keys to navigate the menus, select an anime, and choose an episode to stream instantly.
|
||||
|
||||
## Usage Guide
|
||||
|
||||
### The Interactive TUI (`viu anilist`)
|
||||
|
||||
This is the main, user-friendly way to use Viu. It provides a rich terminal experience where you can:
|
||||
* Browse trending, popular, and seasonal anime.
|
||||
* Manage your personal lists (Watching, Completed, Paused, etc.).
|
||||
* Search for any anime in the AniList database.
|
||||
* View detailed information, characters, recommendations, reviews, and airing schedules.
|
||||
* Stream or download episodes directly from the menus.
|
||||
|
||||
### Powerful Searching (`viu anilist search`)
|
||||
|
||||
Filter the entire AniList database with powerful command-line flags.
|
||||
|
||||
```bash
|
||||
pip install fastanime
|
||||
# Search for anime from 2024, sorted by popularity, that is releasing and not on your list
|
||||
viu anilist search -y 2024 -s POPULARITY_DESC --status RELEASING --not-on-list
|
||||
|
||||
# Find the most popular movies with the "Fantasy" genre
|
||||
viu anilist search -g Fantasy -f MOVIE -s POPULARITY_DESC
|
||||
|
||||
# Dump search results as JSON instead of launching the TUI
|
||||
viu anilist search -t "Demon Slayer" --dump-json
|
||||
```
|
||||
|
||||
### Installing the bleeding edge version
|
||||
### Background Downloads (`viu queue` & `worker`)
|
||||
|
||||
To install the latest build which are created on every push by GitHub actions, download the [fastanime_debug_build](https://github.com/Benex254/FastAnime/actions) of your choosing from the GitHub actions page.
|
||||
Then:
|
||||
Viu includes a robust background downloading system.
|
||||
|
||||
1. **Add episodes to the queue:**
|
||||
```bash
|
||||
# Add episodes 1-12 of Jujutsu Kaisen to the download queue
|
||||
viu queue add -t "Jujutsu Kaisen" -r "0:12"
|
||||
```
|
||||
2. **Start the worker process:**
|
||||
```bash
|
||||
# Run the worker in the foreground (press Ctrl+C to stop)
|
||||
viu worker
|
||||
|
||||
# Or run it as a background process
|
||||
viu worker &
|
||||
```The worker will now process the queue, download your episodes, and check for notifications.
|
||||
|
||||
### Scriptable Commands (`download` & `search`)
|
||||
|
||||
These commands are designed for automation and quick, non-interactive tasks.
|
||||
|
||||
#### `download` Examples
|
||||
```bash
|
||||
unzip fastanime_debug_build
|
||||
# Download the latest 5 episodes of One Piece
|
||||
viu download -t "One Piece" -r "-5"
|
||||
|
||||
# outputs fastanime<version>.tar.gz
|
||||
|
||||
pipx install fastanime<version>.tar.gz
|
||||
|
||||
# --- or ---
|
||||
|
||||
pip install fastanime<version>.tar.gz
|
||||
# Download episodes 1 to 24, merge subtitles, and clean up original files
|
||||
viu download -t "Jujutsu Kaisen" -r "0:24" --merge --clean
|
||||
```
|
||||
|
||||
### Building from the source
|
||||
|
||||
Requirements:
|
||||
|
||||
- [git](https://git-scm.com/)
|
||||
- [python 3.10 and above](https://www.python.org/)
|
||||
- [poetry](https://python-poetry.org/docs/#installation)
|
||||
|
||||
To build from the source, follow these steps:
|
||||
|
||||
1. Clone the repository: `git clone https://github.com/Benex254/FastAnime.git`
|
||||
2. Navigate into the folder: `cd FastAnime`
|
||||
3. Then build and Install the app:
|
||||
|
||||
#### `search` (Binging) Examples
|
||||
```bash
|
||||
# Normal Installation
|
||||
poetry build
|
||||
cd dist
|
||||
pip install fastanime<version>.whl
|
||||
# Start binging an anime from the first episode
|
||||
viu search -t "Attack on Titan" -r ":"
|
||||
|
||||
# Editable installation (easiest for updates)
|
||||
# just do a git pull in the Project dir
|
||||
# the latter will require rebuilding the app
|
||||
pip install -e .
|
||||
# Watch the latest episode directly
|
||||
viu search -t "My Hero Academia" -r "-1"
|
||||
```
|
||||
|
||||
4. Enjoy! Verify installation with:
|
||||
### Local Data Management (`viu registry`)
|
||||
|
||||
```bash
|
||||
fastanime --version
|
||||
```
|
||||
Viu maintains a local database of your anime for offline access and enhanced performance.
|
||||
|
||||
> [!Tip]
|
||||
>
|
||||
> Download the completions from [here](https://github.com/Benex254/FastAnime/tree/master/completions) for your shell.
|
||||
> To add completions:
|
||||
>
|
||||
> - Fish Users: `cp $FASTANIME_PATH/completions/fastanime.fish ~/.config/fish/completions/`
|
||||
> - Bash Users: Add `source $FASTANIME_PATH/completions/fastanime.bash` to your `.bashrc`
|
||||
> - Zsh Users: Add `source $FASTANIME_PATH/completions/fastanime.zsh` to your `.zshrc`
|
||||
|
||||
### External Dependencies
|
||||
|
||||
The only required external dependency, unless you won't be streaming, is [MPV](https://mpv.io/installation/), which i recommend installing with [uosc](https://github.com/tomasklaen/uosc) and [thumbfast](https://github.com/po5/thumbfast) for the best experience since they add a better interface to it.
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> The project currently sees no reason to support any other video
|
||||
> player because we believe nothing beats **MPV** and it provides
|
||||
> everything you could ever need with a small footprint.
|
||||
> But if you have a reason feel free to encourage as to do so.
|
||||
|
||||
**Other dependencies that will just make your experience better:**
|
||||
|
||||
- [fzf](https://github.com/junegunn/fzf) :fire: which is used as a better alternative to the ui.
|
||||
- [chafa](https://github.com/hpjansson/chafa) currently the best cross platform and cross terminal image viewer for the terminal.
|
||||
- [icat](https://sw.kovidgoyal.net/kitty/kittens/icat/) an image viewer that only works in [kitty terminal](https://sw.kovidgoyal.net/kitty/), which is currently the best terminal in my opinion, and by far the best image renderer for the terminal thanks to kitty's terminal graphics protocol. Its terminal graphics is so op that you can [run a browser on it](https://github.com/chase/awrit?tab=readme-ov-file)!!
|
||||
- [bash](https://www.gnu.org/software/bash/) is used as the preview script language.
|
||||
- [ani-skip](https://github.com/synacktraa/ani-skip) :fire: used for skipping the opening and ending theme songs
|
||||
|
||||
## Usage
|
||||
|
||||
The app offers both a graphical interface (under development) and a robust command-line interface.
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> The GUI is mostly in hiatus; use the CLI for now.
|
||||
> However, you can try it out before i decided to change my objective by checking out this [release](https://github.com/Benex254/FastAnime/tree/v0.20.0).
|
||||
> But be reassured for those who aren't terminal chads, i will still complete the GUI for the fun of it
|
||||
|
||||
### The Commandline interface :fire:
|
||||
|
||||
Designed for power users who prefer efficiency over browser-based streaming and still want the experience in their terminal.
|
||||
|
||||
Overview of main commands:
|
||||
|
||||
- `fastanime anilist`: Powerful command for browsing and exploring anime due to AniList integration.
|
||||
- `fastanime download`: Download anime.
|
||||
- `fastanime search`: Powerful command meant for binging since it doesn't require the interfaces
|
||||
- `fastanime downloads`: View downloaded anime and watch with MPV.
|
||||
- `fastanime config`: Quickly edit configuration settings.
|
||||
|
||||
Configuration is directly passed into this command at run time to override your config.
|
||||
|
||||
Available options include:
|
||||
|
||||
- `--server;-s <server>` set the default server to auto select
|
||||
- `--continue;-c/--no-continue;-no-c` whether to continue from the last episode you were watching
|
||||
- `--quality;-q <0|1|2|3>` the link to choose from server
|
||||
- `--translation-type;- <dub|sub` what language for anime
|
||||
- `--auto-select;-a/--no-auto-select;-no-a` auto select title from provider results
|
||||
- `--auto-next;-A;/--no-auto-next;-no-A` auto select next episode
|
||||
- `-downloads-dir;-d <path>` set the folder to download anime into
|
||||
- `--fzf` use fzf for the ui
|
||||
- `--default` use the default ui
|
||||
- `--preview` show a preview when using fzf
|
||||
- `--no-preview` dont show a preview when using fzf
|
||||
- `--format <yt-dlp format string>` set the format of anime downloaded and streamed based on yt-dlp format. Works when `--server gogoanime`
|
||||
- `--icons/--no-icons` toggle the visibility of the icons
|
||||
- `--skip/--no-skip` whether to skip the opening and ending theme songs.
|
||||
- `--rofi` use rofi for the ui
|
||||
- `--rofi-theme <path>` theme to use with rofi
|
||||
- `--rofi-theme-input <path>` theme to use with rofi input
|
||||
- `--rofi-theme-confirm <path>` theme to use with rofi confirm
|
||||
|
||||
#### The anilist command :fire: :fire: :fire:
|
||||
|
||||
Stream, browse, and discover anime efficiently from the terminal using the [AniList API](https://github.com/AniList/ApiV2-GraphQL-Docs).
|
||||
|
||||
##### Running without any subcommand
|
||||
|
||||
Run `fastanime anilist` to access the main interface.
|
||||
|
||||
##### Subcommands
|
||||
|
||||
The subcommands are mainly their as convenience. Since all the features already exist in the main interface.
|
||||
|
||||
- `fastanime anilist trending`: Top 15 trending anime.
|
||||
- `fastanime anilist recent`: Top 15 recently updated anime.
|
||||
- `fastanime anilist search`: Search for anime (top 50 results).
|
||||
- `fastanime anilist upcoming`: Top 15 upcoming anime.
|
||||
- `fastanime anilist popular`: Top 15 popular anime.
|
||||
- `fastanime anilist favourites`: Top 15 favorite anime.
|
||||
- `fastanime anilist random`: get random anime
|
||||
|
||||
The following are commands you can only run if you are signed in to your AniList account:
|
||||
|
||||
- `fastanime anilist watching`
|
||||
- `fastanime anilist planning`
|
||||
- `fastanime anilist rewatching`
|
||||
- `fastanime anilist dropped`
|
||||
- `fastanime anilist paused`
|
||||
- `fastanime anilist completed`
|
||||
|
||||
Plus: `fastanime anilist notifier` :fire:
|
||||
|
||||
```bash
|
||||
# basic form
|
||||
fastanime anilist notifier
|
||||
|
||||
# with logging to stdout
|
||||
fastanime --log anilist notifier
|
||||
|
||||
# with logging to a file. stored in the same place as your config
|
||||
fastanime --log-file anilist notifier
|
||||
```
|
||||
|
||||
The above commands will start a loop that checks every 2 minutes if any of the anime in your watch list that are aireing has just released a new episode.
|
||||
|
||||
The notification will consist of a cover image of the anime in none windows systems.
|
||||
|
||||
You can place the command among your machines startup scripts.
|
||||
|
||||
For fish users for example you can decide to put this in your `~/.config/fish/config.fish`:
|
||||
|
||||
```fish
|
||||
if ! ps aux | grep -q '[f]astanime .* notifier'
|
||||
echo initializing fastanime anilist notifier
|
||||
nohup fastanime --log-file anilist notifier>/dev/null &
|
||||
end
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> To sign in just run `fastanime anilist login` and follow the instructions.
|
||||
> To view your login status `fastanime anilist login --status`
|
||||
|
||||
#### download subcommand
|
||||
|
||||
Download anime to watch later dub or sub with this one command.
|
||||
Its optimized for scripting due to fuzzy matching.
|
||||
So every step of the way has been and can be automated.
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> The download feature is powered by [yt-dlp](https://github.com/yt-dlp/yt-dlp) so all the bells and whistles that it provides are readily available in the project.
|
||||
> Like continuing from where you left of while downloading, after lets say you lost your internet connection.
|
||||
|
||||
**Syntax:**
|
||||
|
||||
```bash
|
||||
# Download all available episodes
|
||||
fastanime download <anime-title>
|
||||
|
||||
# Download specific episode range
|
||||
# be sure to observe the range Syntax
|
||||
fastanime download <anime-title> -r <episodes-start>-<episodes-end>
|
||||
```
|
||||
|
||||
#### search subcommand
|
||||
|
||||
Powerful command mainly aimed at binging anime. Since it doesn't require interaction with the interfaces.
|
||||
|
||||
**Syntax:**
|
||||
|
||||
```bash
|
||||
# basic form where you will still be promted for the episode number
|
||||
fastanime search <anime-title>
|
||||
|
||||
# binge all episodes with this command
|
||||
fastanime search <anime-title> -
|
||||
|
||||
# binge a specific episode range with this command
|
||||
# be sure to observe the range Syntax
|
||||
fastanime search <anime-title> <episodes-start>-<episodes-end>
|
||||
```
|
||||
|
||||
#### downloads subcommand
|
||||
|
||||
View and stream the anime you downloaded using MPV.
|
||||
|
||||
**Syntax:**
|
||||
|
||||
```bash
|
||||
fastanime downloads
|
||||
|
||||
# to get the path to the downloads folder set
|
||||
fastanime downloads --path
|
||||
# useful when you want to use the value for other programs
|
||||
```
|
||||
|
||||
#### config subcommand
|
||||
|
||||
Edit FastAnime configuration settings using your preferred editor (based on `$EDITOR` environment variable so be sure to set it).
|
||||
|
||||
**Syntax:**
|
||||
|
||||
```bash
|
||||
fastanime config
|
||||
|
||||
# to get config path which is useful if you want to use it for another program.
|
||||
fastanime config --path
|
||||
```
|
||||
|
||||
> [!Note]
|
||||
>
|
||||
> If it opens [vim](https://www.vim.org/download.php) you can exit by typing `:q` in case you don't know.
|
||||
* `registry sync`: Synchronize your local data with your remote AniList account.
|
||||
* `registry stats`: Show detailed statistics about your viewing habits.
|
||||
* `registry backup`: Create a compressed backup of your entire registry.
|
||||
* `registry restore`: Restore your data from a backup file.
|
||||
* `registry export/import`: Export/import your data to JSON/CSV for use in other applications.
|
||||
* `registry clean`: Clean up orphaned or invalid entries from your local database.
|
||||
|
||||
## Configuration
|
||||
|
||||
The app includes sensible defaults but can be customized extensively. Configuration is stored in `.ini` format at `~/.config/FastAnime/config.ini` on Linux and mac or somewhere on windows; you can check by running `fastanime config --path`.
|
||||
Viu is highly customizable. A default configuration file with detailed comments is created on the first run.
|
||||
|
||||
* **Find your config file:** `viu config --path`
|
||||
* **Edit in your default editor:** `viu config`
|
||||
* **Use the interactive wizard:** `viu config --interactive`
|
||||
|
||||
Most settings in the config file can be temporarily overridden with command-line flags (e.g., `viu --provider animepahe anilist`).
|
||||
|
||||
<details>
|
||||
<summary><b>Default Configuration (`config.ini`) Explained</b></summary>
|
||||
|
||||
```ini
|
||||
[stream]
|
||||
continue_from_history = True # Auto continue from watch history
|
||||
translation_type = sub # Preferred language for anime (options: dub, sub)
|
||||
server = top # Default server (options: dropbox, sharepoint, wetransfer.gogoanime, top, wixmp)
|
||||
auto_next = False # Auto-select next episode
|
||||
# Auto select the anime provider results with fuzzy find.
|
||||
# Note this wont always be correct.But 99% of the time will be.
|
||||
auto_select=True
|
||||
# whether to skip the opening and ending theme songs
|
||||
# note requires ani-skip to be in path
|
||||
skip=false
|
||||
# the maximum delta time in minutes after which the episode should be considered as completed
|
||||
# used in the continue from time stamp
|
||||
error=3
|
||||
|
||||
# the format of downloaded anime and trailer
|
||||
# based on yt-dlp format and passed directly to it
|
||||
# learn more by looking it up on their site
|
||||
# only works for downloaded anime if server=gogoanime
|
||||
# since its the only one that offers different formats
|
||||
# the others tend not to
|
||||
format=best[height<=1080]/bestvideo[height<=1080]+bestaudio/best # default
|
||||
|
||||
# [general] Section: Controls overall application behavior.
|
||||
[general]
|
||||
preferred_language = romaji # Display language (options: english, romaji)
|
||||
downloads_dir = <Default-videos-dir>/FastAnime # Download directory
|
||||
preview=false # whether to show a preview window when using fzf or rofi
|
||||
provider = allanime ; The default anime provider (allanime, animepahe).
|
||||
selector = fzf ; The interactive UI tool (fzf, rofi, default).
|
||||
preview = full ; Preview type in selectors (full, text, image, none).
|
||||
image_renderer = icat ; Tool for terminal image previews (icat, chafa).
|
||||
icons = True ; Display emoji icons in the UI.
|
||||
auto_select_anime_result = True ; Automatically select the best search match.
|
||||
...
|
||||
|
||||
use_fzf=False # whether to use fzf as the interface for the anilist command and others.
|
||||
# [stream] Section: Controls playback and streaming.
|
||||
[stream]
|
||||
player = mpv ; The media player to use (mpv, vlc).
|
||||
quality = 1080 ; Preferred stream quality (1080, 720, 480, 360).
|
||||
translation_type = sub ; Preferred audio/subtitle type (sub, dub).
|
||||
auto_next = False ; Automatically play the next episode.
|
||||
continue_from_watch_history = True ; Resume playback from where you left off.
|
||||
use_ipc = True ; Enable in-player controls via MPV's IPC.
|
||||
...
|
||||
|
||||
use_rofi=false # whether to use rofi for the ui
|
||||
rofi_theme=<path-to-rofi-theme-file>
|
||||
rofi_theme_input=<path-to-rofi-theme-file>
|
||||
rofi_theme_confirm=<path-to-rofi-theme-file>
|
||||
# [downloads] Section: Controls the downloader.
|
||||
[downloads]
|
||||
downloader = auto ; Downloader to use (auto, default, yt-dlp).
|
||||
downloads_dir = ... ; Directory to save downloaded anime.
|
||||
max_concurrent_downloads = 3 ; Number of parallel downloads in the worker.
|
||||
merge_subtitles = True ; Automatically merge subtitles into the video file.
|
||||
cleanup_after_merge = True ; Delete original files after merging.
|
||||
...
|
||||
|
||||
|
||||
# whether to show the icons
|
||||
icons=false
|
||||
|
||||
# the duration in minutes a notification will stay in the screen
|
||||
# used by notifier command
|
||||
notification_duration=2
|
||||
|
||||
[anilist]
|
||||
# Not implemented yet
|
||||
# [worker] Section: Controls the background worker process.
|
||||
[worker]
|
||||
enabled = True
|
||||
notification_check_interval = 15 ; How often to check for new episodes (minutes).
|
||||
download_check_interval = 5 ; How often to process the download queue (minutes).
|
||||
...
|
||||
```
|
||||
</details>
|
||||
|
||||
## Advanced Features
|
||||
|
||||
### MPV IPC Integration
|
||||
|
||||
When `use_ipc = True` is set in your config, Viu provides powerful in-player controls without needing to close MPV.
|
||||
|
||||
**Key Bindings:**
|
||||
* `Shift+N`: Play the next episode.
|
||||
* `Shift+P`: Play the previous episode.
|
||||
* `Shift+R`: Reload the current episode.
|
||||
* `Shift+A`: Toggle auto-play for the next episode.
|
||||
* `Shift+T`: Toggle between `dub` and `sub`.
|
||||
|
||||
**Script Messages (For MPV Console):**
|
||||
* `script-message select-episode <number>`: Jump to a specific episode.
|
||||
* `script-message select-server <name>`: Switch to a different streaming server.
|
||||
|
||||
### Running as a Service (Linux/systemd)
|
||||
|
||||
You can run the background worker as a systemd service for persistence.
|
||||
|
||||
1. Create a service file at `~/.config/systemd/user/viu-worker.service`:
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Viu Background Worker
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/path/to/your/viu worker --log
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
```
|
||||
*Replace `/path/to/your/viu` with the output of `which viu`.*
|
||||
|
||||
2. Enable and start the service:
|
||||
```bash
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable --now viu-worker.service
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
We welcome your issues and feature requests. However, due to time constraints, we currently do not plan to add another provider.
|
||||
|
||||
If you wish to contribute directly, please first open an issue describing your proposed changes so it can be discussed.
|
||||
|
||||
## Receiving Support
|
||||
|
||||
For inquiries, join our [Discord Server](https://discord.gg/4NUTj5Pt).
|
||||
|
||||
<p align="center">
|
||||
<a href="https://discord.gg/C4rhMA4mmK">
|
||||
<img src="https://invidget.switchblade.xyz/C4rhMA4mmK">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
|
||||
## Supporting the Project
|
||||
|
||||
Show your support by starring our GitHub repository or [buying us a coffee](https://ko-fi.com/benex254).
|
||||
Contributions are welcome! Whether it's reporting a bug, proposing a feature, or writing code, your help is appreciated. Please read our [**Contributing Guidelines**](CONTRIBUTIONS.md) to get started.
|
||||
|
||||
7
bundle/Dockerfile
Normal file
7
bundle/Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
FROM python:3.12-slim-bookworm
|
||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
||||
COPY . /viu
|
||||
ENV PATH=/root/.local/bin:$PATH
|
||||
WORKDIR /viu
|
||||
RUN uv tool install .
|
||||
CMD ["bash"]
|
||||
65
bundle/pyinstaller.spec
Normal file
65
bundle/pyinstaller.spec
Normal file
@@ -0,0 +1,65 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
|
||||
|
||||
block_cipher = None
|
||||
|
||||
# Collect all required data files
|
||||
datas = [
|
||||
('viu/assets/*', 'viu/assets'),
|
||||
]
|
||||
|
||||
# Collect all required hidden imports
|
||||
hiddenimports = [
|
||||
'click',
|
||||
'rich',
|
||||
'requests',
|
||||
'yt_dlp',
|
||||
'python_mpv',
|
||||
'fuzzywuzzy',
|
||||
'viu',
|
||||
] + collect_submodules('viu')
|
||||
|
||||
a = Analysis(
|
||||
['./viu/viu.py'], # Changed entry point
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=datas,
|
||||
hiddenimports=hiddenimports,
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
strip=True, # Strip debug information
|
||||
optimize=2 # Optimize bytecode noarchive=False
|
||||
)
|
||||
|
||||
pyz = PYZ(
|
||||
a.pure,
|
||||
a.zipped_data,
|
||||
optimize=2 # Optimize bytecode cipher=block_cipher
|
||||
)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name='viu',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=True,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=True,
|
||||
disable_windowed_traceback=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
icon='viu/assets/logo.ico'
|
||||
)
|
||||
@@ -1,8 +1,8 @@
|
||||
_fastanime_completion() {
|
||||
_viu_completion() {
|
||||
local IFS=$'\n'
|
||||
local response
|
||||
|
||||
response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _FASTANIME_COMPLETE=bash_complete $1)
|
||||
response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _VIU_COMPLETE=bash_complete $1)
|
||||
|
||||
for completion in $response; do
|
||||
IFS=',' read type value <<< "$completion"
|
||||
@@ -21,9 +21,9 @@ _fastanime_completion() {
|
||||
return 0
|
||||
}
|
||||
|
||||
_fastanime_completion_setup() {
|
||||
complete -o nosort -F _fastanime_completion fastanime
|
||||
_viu_completion_setup() {
|
||||
complete -o nosort -F _viu_completion viu
|
||||
}
|
||||
|
||||
_fastanime_completion_setup;
|
||||
_viu_completion_setup;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function _fastanime_completion;
|
||||
set -l response (env _FASTANIME_COMPLETE=fish_complete COMP_WORDS=(commandline -cp) COMP_CWORD=(commandline -t) fastanime);
|
||||
function _viu_completion;
|
||||
set -l response (env _VIU_COMPLETE=fish_complete COMP_WORDS=(commandline -cp) COMP_CWORD=(commandline -t) viu);
|
||||
|
||||
for completion in $response;
|
||||
set -l metadata (string split "," $completion);
|
||||
@@ -14,5 +14,5 @@ function _fastanime_completion;
|
||||
end;
|
||||
end;
|
||||
|
||||
complete --no-files --command fastanime --arguments "(_fastanime_completion)";
|
||||
complete --no-files --command viu --arguments "(_viu_completion)";
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#compdef fastanime
|
||||
#compdef viu
|
||||
|
||||
_fastanime_completion() {
|
||||
_viu_completion() {
|
||||
local -a completions
|
||||
local -a completions_with_descriptions
|
||||
local -a response
|
||||
(( ! $+commands[fastanime] )) && return 1
|
||||
(( ! $+commands[viu] )) && return 1
|
||||
|
||||
response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) _FASTANIME_COMPLETE=zsh_complete fastanime)}")
|
||||
response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) _VIU_COMPLETE=zsh_complete viu)}")
|
||||
|
||||
for type key descr in ${response}; do
|
||||
if [[ "$type" == "plain" ]]; then
|
||||
@@ -33,9 +33,9 @@ _fastanime_completion() {
|
||||
|
||||
if [[ $zsh_eval_context[-1] == loadautofunc ]]; then
|
||||
# autoload from fpath, call function directly
|
||||
_fastanime_completion "$@"
|
||||
_viu_completion "$@"
|
||||
else
|
||||
# eval/source/. command, register function for later
|
||||
compdef _fastanime_completion fastanime
|
||||
compdef _viu_completion viu
|
||||
fi
|
||||
|
||||
66
dev/generate_anilist_media_tags.py
Executable file
66
dev/generate_anilist_media_tags.py
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env -S uv run --script
|
||||
import json
|
||||
from collections import defaultdict
|
||||
from pathlib import Path
|
||||
|
||||
import httpx
|
||||
from viu_media.core.utils.graphql import execute_graphql
|
||||
|
||||
DEV_DIR = Path(__file__).resolve().parent
|
||||
media_tags_type_py = (
|
||||
DEV_DIR.parent / "viu_media" / "libs" / "media_api" / "_media_tags.py"
|
||||
)
|
||||
media_tags_gql = DEV_DIR / "graphql" / "anilist" / "media_tags.gql"
|
||||
generated_tags_json = DEV_DIR / "generated" / "anilist" / "tags.json"
|
||||
|
||||
media_tags_response = execute_graphql(
|
||||
"https://graphql.anilist.co", httpx.Client(), media_tags_gql, {}
|
||||
)
|
||||
media_tags_response.raise_for_status()
|
||||
|
||||
template = """\
|
||||
# DO NOT EDIT THIS FILE !!! ( 。 •̀ ᴖ •́ 。)
|
||||
# ITS AUTOMATICALLY GENERATED BY RUNNING ./dev/generate_anilist_media_tags.py
|
||||
# FROM THE PROJECT ROOT
|
||||
# SO RUN THAT INSTEAD TO UPDATE THE FILE WITH THE LATEST MEDIA TAGS :)
|
||||
|
||||
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class MediaTag(Enum):\
|
||||
"""
|
||||
|
||||
# 4 spaces
|
||||
tab = " "
|
||||
tags = defaultdict(list)
|
||||
for tag in media_tags_response.json()["data"]["MediaTagCollection"]:
|
||||
tags[tag["category"]].append(
|
||||
{
|
||||
"name": tag["name"],
|
||||
"description": tag["description"],
|
||||
"is_adult": tag["isAdult"],
|
||||
}
|
||||
)
|
||||
# save copy of data used to generate the class
|
||||
json.dump(tags, generated_tags_json.open("w", encoding="utf-8"), indent=2)
|
||||
|
||||
for key, value in tags.items():
|
||||
template = f"{template}\n{tab}#\n{tab}# {key.upper()}\n{tab}#\n"
|
||||
for tag in value:
|
||||
name = tag["name"]
|
||||
_tag_name = name.replace("-", "_").replace(" ", "_").upper()
|
||||
if _tag_name.startswith(("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")):
|
||||
_tag_name = f"_{_tag_name}"
|
||||
|
||||
tag_name = ""
|
||||
# sanitize invalid characters for attribute names
|
||||
for char in _tag_name:
|
||||
if char.isidentifier() or char.isdigit():
|
||||
tag_name += char
|
||||
|
||||
desc = tag["description"].replace("\n", "")
|
||||
is_adult = tag["is_adult"]
|
||||
template = f'{template}\n{tab}# {desc} (is_adult: {is_adult})\n{tab}{tag_name} = "{name}"\n'
|
||||
|
||||
media_tags_type_py.write_text(template, "utf-8")
|
||||
14
dev/generate_completions.sh
Normal file
14
dev/generate_completions.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
APP_DIR="$(
|
||||
cd -- "$(dirname "$0")" >/dev/null 2>&1
|
||||
pwd -P
|
||||
)"
|
||||
|
||||
# fish shell completions
|
||||
_VIU_COMPLETE=fish_source viu >"$APP_DIR/completions/viu.fish"
|
||||
|
||||
# zsh completions
|
||||
_VIU_COMPLETE=zsh_source viu >"$APP_DIR/completions/viu.zsh"
|
||||
|
||||
# bash completions
|
||||
_VIU_COMPLETE=bash_source viu >"$APP_DIR/completions/viu.bash"
|
||||
2137
dev/generated/anilist/tags.json
Normal file
2137
dev/generated/anilist/tags.json
Normal file
File diff suppressed because it is too large
Load Diff
8
dev/graphql/anilist/media_tags.gql
Normal file
8
dev/graphql/anilist/media_tags.gql
Normal file
@@ -0,0 +1,8 @@
|
||||
query {
|
||||
MediaTagCollection {
|
||||
name
|
||||
description
|
||||
category
|
||||
isAdult
|
||||
}
|
||||
}
|
||||
16
dev/make_release
Executable file
16
dev/make_release
Executable file
@@ -0,0 +1,16 @@
|
||||
#! /usr/bin/env sh
|
||||
CLI_DIR="$(dirname "$(realpath "$0")")"
|
||||
VERSION=$1
|
||||
[ -z "$VERSION" ] && echo no version provided && exit 1
|
||||
[ "$VERSION" = "current" ] && viu --version && exit 0
|
||||
sed -i "s/^version.*/version = \"$VERSION\"/" "$CLI_DIR/pyproject.toml" &&
|
||||
sed -i "s/__version__.*/__version__ = \"v$VERSION\"/" "$CLI_DIR/viu/__init__.py" &&
|
||||
sed -i "s/version = .*/version = \"$VERSION\";/" "$CLI_DIR/flake.nix" &&
|
||||
git stage "$CLI_DIR/pyproject.toml" "$CLI_DIR/viu/__init__.py" "$CLI_DIR/flake.nix" &&
|
||||
git commit -m "chore: bump version (v$VERSION)" &&
|
||||
# nix flake lock &&
|
||||
uv lock &&
|
||||
git stage "$CLI_DIR/flake.lock" "$CLI_DIR/uv.lock" &&
|
||||
git commit -m "chore: update lock files" &&
|
||||
git push &&
|
||||
gh release create "v$VERSION"
|
||||
4
fa
4
fa
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# exec "${PYTHON:-python3}" -Werror -Xdev -m "$(dirname "$(realpath "$0")")/fastanime" "$@"
|
||||
cd "$(dirname "$(realpath "$0")")" || exit 1
|
||||
exec python -m fastanime "$@"
|
||||
@@ -1,128 +0,0 @@
|
||||
"""An abstraction over all providers offering added features with a simple and well typed api
|
||||
|
||||
[TODO:description]
|
||||
"""
|
||||
|
||||
import importlib
|
||||
import logging
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from .libs.anime_provider import anime_sources
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Iterator
|
||||
|
||||
from .libs.anilist.anilist_data_schema import AnilistBaseMediaDataSchema
|
||||
from .libs.anime_provider.types import Anime, SearchResults, Server
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# TODO: improve performance of this class and add cool features like auto retry
|
||||
class AnimeProvider:
|
||||
"""Class that manages all anime sources adding some extra functionality to them.
|
||||
Attributes:
|
||||
PROVIDERS: [TODO:attribute]
|
||||
provider: [TODO:attribute]
|
||||
provider: [TODO:attribute]
|
||||
dynamic: [TODO:attribute]
|
||||
retries: [TODO:attribute]
|
||||
anime_provider: [TODO:attribute]
|
||||
"""
|
||||
|
||||
PROVIDERS = list(anime_sources.keys())
|
||||
provider = PROVIDERS[0]
|
||||
|
||||
def __init__(self, provider, dynamic=False, retries=0) -> None:
|
||||
self.provider = provider
|
||||
self.dynamic = dynamic
|
||||
self.retries = retries
|
||||
self.lazyload_provider()
|
||||
|
||||
def lazyload_provider(self):
|
||||
"""updates the current provider being used"""
|
||||
_, anime_provider_cls_name = anime_sources[self.provider].split(".", 1)
|
||||
package = f"fastanime.libs.anime_provider.{self.provider}"
|
||||
provider_api = importlib.import_module(".api", package)
|
||||
anime_provider = getattr(provider_api, anime_provider_cls_name)
|
||||
self.anime_provider = anime_provider()
|
||||
|
||||
def search_for_anime(
|
||||
self,
|
||||
user_query,
|
||||
translation_type,
|
||||
anilist_obj: "AnilistBaseMediaDataSchema | None" = None,
|
||||
nsfw=True,
|
||||
unknown=True,
|
||||
) -> "SearchResults | None":
|
||||
"""core abstraction over all providers search functionality
|
||||
|
||||
Args:
|
||||
user_query ([TODO:parameter]): [TODO:description]
|
||||
translation_type ([TODO:parameter]): [TODO:description]
|
||||
nsfw ([TODO:parameter]): [TODO:description]
|
||||
unknown ([TODO:parameter]): [TODO:description]
|
||||
anilist_obj: [TODO:description]
|
||||
|
||||
Returns:
|
||||
[TODO:return]
|
||||
"""
|
||||
anime_provider = self.anime_provider
|
||||
try:
|
||||
results = anime_provider.search_for_anime(
|
||||
user_query, translation_type, nsfw, unknown
|
||||
)
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
results = None
|
||||
return results
|
||||
|
||||
def get_anime(
|
||||
self,
|
||||
anime_id: str,
|
||||
anilist_obj: "AnilistBaseMediaDataSchema | None" = None,
|
||||
) -> "Anime | None":
|
||||
"""core abstraction over getting info of an anime from all providers
|
||||
|
||||
Args:
|
||||
anime_id: [TODO:description]
|
||||
anilist_obj: [TODO:description]
|
||||
|
||||
Returns:
|
||||
[TODO:return]
|
||||
"""
|
||||
anime_provider = self.anime_provider
|
||||
try:
|
||||
results = anime_provider.get_anime(anime_id)
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
results = None
|
||||
return results
|
||||
|
||||
def get_episode_streams(
|
||||
self,
|
||||
anime,
|
||||
episode: str,
|
||||
translation_type: str,
|
||||
anilist_obj: "AnilistBaseMediaDataSchema|None" = None,
|
||||
) -> "Iterator[Server] | None":
|
||||
"""core abstractions for getting juicy streams from all providers
|
||||
|
||||
Args:
|
||||
anime ([TODO:parameter]): [TODO:description]
|
||||
episode: [TODO:description]
|
||||
translation_type: [TODO:description]
|
||||
anilist_obj: [TODO:description]
|
||||
|
||||
Returns:
|
||||
[TODO:return]
|
||||
"""
|
||||
anime_provider = self.anime_provider
|
||||
try:
|
||||
results = anime_provider.get_episode_streams(
|
||||
anime, episode, translation_type
|
||||
)
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
results = None
|
||||
return results # pyright:ignore
|
||||
@@ -1,35 +0,0 @@
|
||||
from datetime import datetime
|
||||
|
||||
from ..libs.anilist.anilist_data_schema import (
|
||||
AnilistDateObject,
|
||||
AnilistMediaNextAiringEpisode,
|
||||
)
|
||||
|
||||
|
||||
# TODO: Add formating options for the final date
|
||||
def format_anilist_date_object(anilist_date_object: AnilistDateObject):
|
||||
if anilist_date_object:
|
||||
return f"{anilist_date_object['day']}/{anilist_date_object['month']}/{anilist_date_object['year']}"
|
||||
else:
|
||||
return "Unknown"
|
||||
|
||||
|
||||
def format_anilist_timestamp(anilist_timestamp: int | None):
|
||||
if anilist_timestamp:
|
||||
return datetime.fromtimestamp(anilist_timestamp).strftime("%d/%m/%Y %H:%M:%S")
|
||||
else:
|
||||
return "Unknown"
|
||||
|
||||
|
||||
def format_list_data_with_comma(data: list | None):
|
||||
if data:
|
||||
return ", ".join(data)
|
||||
else:
|
||||
return "None"
|
||||
|
||||
|
||||
def extract_next_airing_episode(airing_episode: AnilistMediaNextAiringEpisode):
|
||||
if airing_episode:
|
||||
return f"{airing_episode['episode']} on {format_anilist_timestamp(airing_episode['airingAt'])}"
|
||||
else:
|
||||
return "Completed"
|
||||
@@ -1,14 +0,0 @@
|
||||
"""
|
||||
Just contains some useful data used across the codebase
|
||||
"""
|
||||
|
||||
# useful incases where the anilist title is too different from the provider title
|
||||
anime_normalizer = {
|
||||
"1P": "one piece",
|
||||
"Magia Record: Mahou Shoujo Madoka☆Magica Gaiden (TV)": "Mahou Shoujo Madoka☆Magica",
|
||||
"Dungeon ni Deai o Motomeru no wa Machigatte Iru Darouka": "Dungeon ni Deai wo Motomeru no wa Machigatteiru Darou ka",
|
||||
'Hazurewaku no "Joutai Ijou Skill" de Saikyou ni Natta Ore ga Subete wo Juurin suru made': "Hazure Waku no [Joutai Ijou Skill] de Saikyou ni Natta Ore ga Subete wo Juurin Suru made",
|
||||
}
|
||||
|
||||
|
||||
anilist_sort_normalizer = {"search match": "SEARCH_MATCH"}
|
||||
@@ -1,49 +0,0 @@
|
||||
import logging
|
||||
from queue import Queue
|
||||
from threading import Thread
|
||||
|
||||
import yt_dlp
|
||||
|
||||
from ..utils import sanitize_filename
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class YtDLPDownloader:
|
||||
downloads_queue = Queue()
|
||||
|
||||
def _worker(self):
|
||||
while True:
|
||||
task, args = self.downloads_queue.get()
|
||||
try:
|
||||
task(*args)
|
||||
except Exception as e:
|
||||
logger.error(f"Something went wrong {e}")
|
||||
self.downloads_queue.task_done()
|
||||
|
||||
def __init__(self):
|
||||
self._thread = Thread(target=self._worker)
|
||||
self._thread.daemon = True
|
||||
self._thread.start()
|
||||
|
||||
# Function to download the file
|
||||
# TODO: untpack the title to its actual values episode_title and anime_title
|
||||
def _download_file(self, url: str, download_dir, title, silent, vid_format="best"):
|
||||
anime_title = sanitize_filename(title[0])
|
||||
episode_title = sanitize_filename(title[1])
|
||||
ydl_opts = {
|
||||
# Specify the output path and template
|
||||
"outtmpl": f"{download_dir}/{anime_title}/{episode_title}.%(ext)s",
|
||||
"silent": silent,
|
||||
"verbose": False,
|
||||
"format": vid_format,
|
||||
}
|
||||
|
||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
||||
ydl.download([url])
|
||||
|
||||
def download_file(self, url: str, title, silent=True):
|
||||
self.downloads_queue.put((self._download_file, (url, title, silent)))
|
||||
|
||||
|
||||
downloader = YtDLPDownloader()
|
||||
@@ -1,40 +0,0 @@
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
||||
from ..constants import USER_DATA_PATH
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# TODO: merger this functionality with the config object
|
||||
class UserData:
|
||||
user_data = {"watch_history": {}, "animelist": [], "user": {}}
|
||||
|
||||
def __init__(self):
|
||||
try:
|
||||
if os.path.isfile(USER_DATA_PATH):
|
||||
with open(USER_DATA_PATH, "r") as f:
|
||||
user_data = json.load(f)
|
||||
self.user_data.update(user_data)
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
|
||||
def update_watch_history(self, watch_history: dict):
|
||||
self.user_data["watch_history"] = watch_history
|
||||
self._update_user_data()
|
||||
|
||||
def update_user_info(self, user: dict):
|
||||
self.user_data["user"] = user
|
||||
self._update_user_data()
|
||||
|
||||
def update_animelist(self, anime_list: list):
|
||||
self.user_data["animelist"] = list(set(anime_list))
|
||||
self._update_user_data()
|
||||
|
||||
def _update_user_data(self):
|
||||
with open(USER_DATA_PATH, "w") as f:
|
||||
json.dump(self.user_data, f)
|
||||
|
||||
|
||||
user_data_helper = UserData()
|
||||
@@ -1,106 +0,0 @@
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
from functools import lru_cache
|
||||
|
||||
from thefuzz import fuzz
|
||||
|
||||
from fastanime.libs.anilist.anilist_data_schema import AnilistBaseMediaDataSchema
|
||||
|
||||
from .data import anime_normalizer
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@lru_cache()
|
||||
def remove_html_tags(text: str):
|
||||
clean = re.compile("<.*?>")
|
||||
return re.sub(clean, "", text)
|
||||
|
||||
|
||||
@lru_cache()
|
||||
def sanitize_filename(filename: str):
|
||||
"""
|
||||
Sanitize a string to be safe for use as a file name.
|
||||
|
||||
:param filename: The original filename string.
|
||||
:return: A sanitized filename string.
|
||||
"""
|
||||
# List of characters not allowed in filenames on various operating systems
|
||||
invalid_chars = r'[<>:"/\\|?*\0]'
|
||||
reserved_names = {
|
||||
"CON",
|
||||
"PRN",
|
||||
"AUX",
|
||||
"NUL",
|
||||
"COM1",
|
||||
"COM2",
|
||||
"COM3",
|
||||
"COM4",
|
||||
"COM5",
|
||||
"COM6",
|
||||
"COM7",
|
||||
"COM8",
|
||||
"COM9",
|
||||
"LPT1",
|
||||
"LPT2",
|
||||
"LPT3",
|
||||
"LPT4",
|
||||
"LPT5",
|
||||
"LPT6",
|
||||
"LPT7",
|
||||
"LPT8",
|
||||
"LPT9",
|
||||
}
|
||||
|
||||
# Replace invalid characters with an underscore
|
||||
sanitized = re.sub(invalid_chars, " ", filename)
|
||||
|
||||
# Remove leading and trailing whitespace
|
||||
sanitized = sanitized.strip()
|
||||
|
||||
# Check for reserved filenames
|
||||
name, ext = os.path.splitext(sanitized)
|
||||
if name.upper() in reserved_names:
|
||||
name += "_file"
|
||||
sanitized = name + ext
|
||||
|
||||
# Ensure the filename is not empty
|
||||
if not sanitized:
|
||||
sanitized = "default_filename"
|
||||
|
||||
return sanitized
|
||||
|
||||
|
||||
def anime_title_percentage_match(
|
||||
possible_user_requested_anime_title: str, anime: AnilistBaseMediaDataSchema
|
||||
) -> float:
|
||||
"""Returns the percentage match between the possible title and user title
|
||||
|
||||
Args:
|
||||
possible_user_requested_anime_title (str): an Animdl search result title
|
||||
title (str): the anime title the user wants
|
||||
|
||||
Returns:
|
||||
int: the percentage match
|
||||
"""
|
||||
if normalized_anime_title := anime_normalizer.get(
|
||||
possible_user_requested_anime_title
|
||||
):
|
||||
possible_user_requested_anime_title = normalized_anime_title
|
||||
# compares both the romaji and english names and gets highest Score
|
||||
title_a = str(anime["title"]["romaji"])
|
||||
title_b = str(anime["title"]["english"])
|
||||
percentage_ratio = max(
|
||||
fuzz.ratio(title_a.lower(), possible_user_requested_anime_title.lower()),
|
||||
fuzz.ratio(title_b.lower(), possible_user_requested_anime_title.lower()),
|
||||
)
|
||||
logger.info(f"{locals()}")
|
||||
return percentage_ratio
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Example usage
|
||||
unsafe_filename = "CON:example?file*name.txt"
|
||||
safe_filename = sanitize_filename(unsafe_filename)
|
||||
print(safe_filename) # Output: 'CON_example_file_name.txt'
|
||||
@@ -1,20 +0,0 @@
|
||||
import sys
|
||||
|
||||
if sys.version_info < (3, 10):
|
||||
raise ImportError(
|
||||
"You are using an unsupported version of Python. Only Python versions 3.8 and above are supported by yt-dlp"
|
||||
) # noqa: F541
|
||||
|
||||
|
||||
__version__ = "v0.60.1"
|
||||
|
||||
APP_NAME = "FastAnime"
|
||||
AUTHOR = "Benex254"
|
||||
GIT_REPO = "github.com"
|
||||
REPO = f"{GIT_REPO}/{AUTHOR}/{APP_NAME}"
|
||||
|
||||
|
||||
def FastAnime():
|
||||
from .cli import run_cli
|
||||
|
||||
run_cli()
|
||||
@@ -1,3 +0,0 @@
|
||||
from .libs.anilist.api import AniListApi
|
||||
|
||||
AniList = AniListApi()
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 133 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 197 KiB |
@@ -1,254 +0,0 @@
|
||||
import signal
|
||||
|
||||
import click
|
||||
|
||||
from .. import __version__
|
||||
from ..libs.anime_provider import anime_sources
|
||||
from ..libs.anime_provider.allanime.constants import SERVERS_AVAILABLE
|
||||
from ..Utility.data import anilist_sort_normalizer
|
||||
from .commands import LazyGroup
|
||||
|
||||
commands = {
|
||||
"search": "search.search",
|
||||
"download": "download.download",
|
||||
"anilist": "anilist.anilist",
|
||||
"config": "config.config",
|
||||
"downloads": "downloads.downloads",
|
||||
"cache": "cache.cache",
|
||||
}
|
||||
|
||||
|
||||
# handle keyboard interupt
|
||||
def handle_exit(signum, frame):
|
||||
from click import clear
|
||||
|
||||
from .utils.tools import exit_app
|
||||
|
||||
clear()
|
||||
|
||||
exit_app()
|
||||
|
||||
|
||||
signal.signal(signal.SIGINT, handle_exit)
|
||||
|
||||
|
||||
@click.group(
|
||||
lazy_subcommands=commands,
|
||||
cls=LazyGroup,
|
||||
help="A command line application for streaming anime that provides a complete and featureful interface",
|
||||
short_help="Stream Anime",
|
||||
)
|
||||
@click.version_option(__version__, "--version")
|
||||
@click.option("--log", help="Allow logging to stdout", is_flag=True)
|
||||
@click.option("--log-file", help="Allow logging to a file", is_flag=True)
|
||||
@click.option("--rich-traceback", help="Use rich to output tracebacks", is_flag=True)
|
||||
@click.option("--update", help="Update fastanime to the latest version", is_flag=True)
|
||||
@click.option(
|
||||
"-p",
|
||||
"--provider",
|
||||
type=click.Choice(list(anime_sources.keys()), case_sensitive=False),
|
||||
help="Provider of your choice",
|
||||
)
|
||||
@click.option(
|
||||
"-s",
|
||||
"--server",
|
||||
type=click.Choice([*SERVERS_AVAILABLE, "top"], case_sensitive=False),
|
||||
help="Server of choice",
|
||||
)
|
||||
@click.option(
|
||||
"-f",
|
||||
"--format",
|
||||
type=str,
|
||||
help="yt-dlp format to use",
|
||||
)
|
||||
@click.option(
|
||||
"-c/-no-c",
|
||||
"--continue/--no-continue",
|
||||
"continue_",
|
||||
type=bool,
|
||||
help="Continue from last episode?",
|
||||
)
|
||||
@click.option(
|
||||
"--skip/--no-skip",
|
||||
type=bool,
|
||||
help="Skip opening and ending theme songs?",
|
||||
)
|
||||
@click.option(
|
||||
"-q",
|
||||
"--quality",
|
||||
type=click.IntRange(0, 3),
|
||||
help="set the quality of the stream",
|
||||
)
|
||||
@click.option(
|
||||
"-t",
|
||||
"--translation-type",
|
||||
type=click.Choice(["dub", "sub"]),
|
||||
help="Anime language[dub/sub]",
|
||||
)
|
||||
@click.option(
|
||||
"-A/-no-A",
|
||||
"--auto-next/--no-auto-next",
|
||||
type=bool,
|
||||
help="Auto select next episode?",
|
||||
)
|
||||
@click.option(
|
||||
"-a/-no-a",
|
||||
"--auto-select/--no-auto-select",
|
||||
type=bool,
|
||||
help="Auto select anime title?",
|
||||
)
|
||||
@click.option(
|
||||
"-S",
|
||||
"--sort-by",
|
||||
type=click.Choice(anilist_sort_normalizer.keys()), # pyright: ignore
|
||||
)
|
||||
@click.option("-d", "--downloads-dir", type=click.Path(), help="Downloads location")
|
||||
@click.option("--fzf", is_flag=True, help="Use fzf for the ui")
|
||||
@click.option("--default", is_flag=True, help="Use the default interface")
|
||||
@click.option("--preview", is_flag=True, help="Show preview when using fzf")
|
||||
@click.option("--no-preview", is_flag=True, help="Dont show preview when using fzf")
|
||||
@click.option(
|
||||
"--icons/--no-icons",
|
||||
type=bool,
|
||||
help="Use icons in the interfaces",
|
||||
)
|
||||
@click.option("--dub", help="Set the translation type to dub", is_flag=True)
|
||||
@click.option("--sub", help="Set the translation type to sub", is_flag=True)
|
||||
@click.option("--rofi", help="Use rofi for the ui", is_flag=True)
|
||||
@click.option("--rofi-theme", help="Rofi theme to use", type=click.Path())
|
||||
@click.option(
|
||||
"--rofi-theme-confirm",
|
||||
help="Rofi theme to use for the confirm prompt",
|
||||
type=click.Path(),
|
||||
)
|
||||
@click.option(
|
||||
"--rofi-theme-input",
|
||||
help="Rofi theme to use for the user input prompt",
|
||||
type=click.Path(),
|
||||
)
|
||||
@click.pass_context
|
||||
def run_cli(
|
||||
ctx: click.Context,
|
||||
log,
|
||||
log_file,
|
||||
rich_traceback,
|
||||
update,
|
||||
provider,
|
||||
server,
|
||||
format,
|
||||
continue_,
|
||||
skip,
|
||||
translation_type,
|
||||
quality,
|
||||
auto_next,
|
||||
auto_select,
|
||||
sort_by,
|
||||
downloads_dir,
|
||||
fzf,
|
||||
default,
|
||||
preview,
|
||||
no_preview,
|
||||
icons,
|
||||
dub,
|
||||
sub,
|
||||
rofi,
|
||||
rofi_theme,
|
||||
rofi_theme_confirm,
|
||||
rofi_theme_input,
|
||||
):
|
||||
from .config import Config
|
||||
|
||||
ctx.obj = Config()
|
||||
if log:
|
||||
import logging
|
||||
|
||||
from rich.logging import RichHandler
|
||||
|
||||
FORMAT = "%(message)s"
|
||||
|
||||
logging.basicConfig(
|
||||
level="NOTSET", format=FORMAT, datefmt="[%X]", handlers=[RichHandler()]
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.info("logging has been initialized")
|
||||
elif log_file:
|
||||
import logging
|
||||
|
||||
from ..constants import NOTIFIER_LOG_FILE_PATH
|
||||
|
||||
format = "%(asctime)s%(levelname)s: %(message)s"
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
filename=NOTIFIER_LOG_FILE_PATH,
|
||||
format=format,
|
||||
datefmt="[%d/%m/%Y@%H:%M:%S]",
|
||||
filemode="w",
|
||||
)
|
||||
if rich_traceback:
|
||||
from rich.traceback import install
|
||||
|
||||
install()
|
||||
if update and None:
|
||||
from .app_updater import update_app
|
||||
|
||||
update_app()
|
||||
return
|
||||
|
||||
if provider:
|
||||
ctx.obj.provider = provider
|
||||
ctx.obj.load_config()
|
||||
if server:
|
||||
ctx.obj.server = server
|
||||
if format:
|
||||
ctx.obj.format = format
|
||||
if ctx.get_parameter_source("continue_") == click.core.ParameterSource.COMMANDLINE:
|
||||
ctx.obj.continue_from_history = continue_
|
||||
if ctx.get_parameter_source("skip") == click.core.ParameterSource.COMMANDLINE:
|
||||
ctx.obj.skip = skip
|
||||
|
||||
if quality:
|
||||
ctx.obj.quality = quality
|
||||
if ctx.get_parameter_source("auto_next") == click.core.ParameterSource.COMMANDLINE:
|
||||
ctx.obj.auto_next = auto_next
|
||||
if ctx.get_parameter_source("icons") == click.core.ParameterSource.COMMANDLINE:
|
||||
ctx.obj.icons = icons
|
||||
if (
|
||||
ctx.get_parameter_source("auto_select")
|
||||
== click.core.ParameterSource.COMMANDLINE
|
||||
):
|
||||
ctx.obj.auto_select = auto_select
|
||||
if sort_by:
|
||||
ctx.obj.sort_by = sort_by
|
||||
if downloads_dir:
|
||||
ctx.obj.downloads_dir = downloads_dir
|
||||
if translation_type:
|
||||
ctx.obj.translation_type = translation_type
|
||||
if fzf:
|
||||
ctx.obj.use_fzf = True
|
||||
if default:
|
||||
ctx.obj.use_fzf = False
|
||||
if preview:
|
||||
ctx.obj.preview = True
|
||||
if no_preview:
|
||||
ctx.obj.preview = False
|
||||
if dub:
|
||||
ctx.obj.translation_type = "dub"
|
||||
if sub:
|
||||
ctx.obj.translation_type = "sub"
|
||||
if rofi:
|
||||
ctx.obj.use_fzf = False
|
||||
ctx.obj.use_rofi = True
|
||||
if rofi:
|
||||
from ..libs.rofi import Rofi
|
||||
|
||||
if rofi_theme:
|
||||
ctx.obj.rofi_theme = rofi_theme
|
||||
Rofi.rofi_theme = rofi_theme
|
||||
|
||||
if rofi_theme_input:
|
||||
ctx.obj.rofi_theme_input = rofi_theme_input
|
||||
Rofi.rofi_theme_input = rofi_theme_input
|
||||
|
||||
if rofi_theme_confirm:
|
||||
ctx.obj.rofi_theme_confirm = rofi_theme_confirm
|
||||
Rofi.rofi_theme_confirm = rofi_theme_confirm
|
||||
@@ -1,104 +0,0 @@
|
||||
import pathlib
|
||||
import re
|
||||
import shlex
|
||||
import shutil
|
||||
import sys
|
||||
from subprocess import PIPE, Popen
|
||||
|
||||
import requests
|
||||
from rich import print
|
||||
|
||||
from .. import APP_NAME, AUTHOR, GIT_REPO, __version__
|
||||
|
||||
API_URL = f"https://api.{GIT_REPO}/repos/{AUTHOR}/{APP_NAME}/releases/latest"
|
||||
|
||||
|
||||
def check_for_updates():
|
||||
USER_AGENT = f"{APP_NAME} user"
|
||||
request = requests.get(
|
||||
API_URL,
|
||||
headers={
|
||||
"User-Agent": USER_AGENT,
|
||||
"X-GitHub-Api-Version": "2022-11-28",
|
||||
"Accept": "application/vnd.github+json",
|
||||
},
|
||||
)
|
||||
|
||||
if request.status_code == 200:
|
||||
release_json = request.json()
|
||||
return (release_json["tag_name"] == __version__, release_json)
|
||||
else:
|
||||
print(request.text)
|
||||
return (False, {})
|
||||
|
||||
|
||||
def is_git_repo(author, repository):
|
||||
# Check if the current directory contains a .git folder
|
||||
if not pathlib.Path("./.git").exists():
|
||||
return False
|
||||
|
||||
repository_qualname = f"{author}/{repository}"
|
||||
|
||||
# Read the .git/config file to find the remote repository URL
|
||||
config_path = pathlib.Path("./.git/config")
|
||||
if not config_path.exists():
|
||||
return False
|
||||
print("here")
|
||||
|
||||
with open(config_path, "r") as git_config:
|
||||
git_config_content = git_config.read()
|
||||
|
||||
# Use regex to find the repository URL in the config file
|
||||
repo_name_pattern = r"\[remote \"origin\"\]\s+url = .*\/([^/]+\/[^/]+)\.git"
|
||||
match = re.search(repo_name_pattern, git_config_content)
|
||||
print(match)
|
||||
|
||||
if match is None:
|
||||
return False
|
||||
|
||||
# Extract the repository name and compare with the expected repository_qualname
|
||||
config_repo_name = match.group(1)
|
||||
return config_repo_name == repository_qualname
|
||||
|
||||
|
||||
def update_app():
|
||||
is_latest, release_json = check_for_updates()
|
||||
if is_latest:
|
||||
print("[green]App is up to date[/]")
|
||||
return
|
||||
tag_name = release_json["tag_name"]
|
||||
|
||||
print("[cyan]Updating app to version %s[/]" % tag_name)
|
||||
if is_git_repo(AUTHOR, APP_NAME):
|
||||
executable = shutil.which("git")
|
||||
args = [
|
||||
executable,
|
||||
"pull",
|
||||
]
|
||||
|
||||
print(f"Pulling latest changes from the repository via git: {shlex.join(args)}")
|
||||
|
||||
if not executable:
|
||||
return print("[red]Cannot find git.[/]")
|
||||
|
||||
process = Popen(
|
||||
args,
|
||||
stdout=PIPE,
|
||||
stderr=PIPE,
|
||||
)
|
||||
|
||||
process.communicate()
|
||||
else:
|
||||
executable = sys.executable
|
||||
|
||||
args = [
|
||||
executable,
|
||||
"-m",
|
||||
"pip",
|
||||
"install",
|
||||
APP_NAME,
|
||||
"--user",
|
||||
"--no-warn-script-location",
|
||||
]
|
||||
process = Popen(args)
|
||||
process.communicate()
|
||||
@@ -1,49 +0,0 @@
|
||||
import click
|
||||
|
||||
from ...utils.tools import QueryDict
|
||||
from .__lazyloader__ import LazyGroup
|
||||
|
||||
commands = {
|
||||
"trending": "trending.trending",
|
||||
"recent": "recent.recent",
|
||||
"search": "search.search",
|
||||
"upcoming": "upcoming.upcoming",
|
||||
"scores": "scores.scores",
|
||||
"popular": "popular.popular",
|
||||
"favourites": "favourites.favourites",
|
||||
"random": "random_anime.random_anime",
|
||||
"login": "login.login",
|
||||
"watching": "watching.watching",
|
||||
"paused": "paused.paused",
|
||||
"rewatching": "rewatching.rewatching",
|
||||
"dropped": "dropped.dropped",
|
||||
"completed": "completed.completed",
|
||||
"planning": "planning.planning",
|
||||
"notifier": "notifier.notifier",
|
||||
}
|
||||
|
||||
|
||||
@click.group(
|
||||
lazy_subcommands=commands,
|
||||
cls=LazyGroup,
|
||||
invoke_without_command=True,
|
||||
help="A beautiful interface that gives you access to a commplete streaming experience",
|
||||
short_help="Access all streaming options",
|
||||
)
|
||||
@click.pass_context
|
||||
def anilist(ctx: click.Context):
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ....anilist import AniList
|
||||
from ....AnimeProvider import AnimeProvider
|
||||
from ...interfaces.anilist_interfaces import anilist as anilist_interface
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...config import Config
|
||||
config: Config = ctx.obj
|
||||
config.anime_provider = AnimeProvider(config.provider)
|
||||
if user := ctx.obj.user:
|
||||
AniList.update_login_info(user, user["token"])
|
||||
if ctx.invoked_subcommand is None:
|
||||
anilist_config = QueryDict()
|
||||
anilist_interface(ctx.obj, anilist_config)
|
||||
@@ -1,42 +0,0 @@
|
||||
# in lazy_group.py
|
||||
import importlib
|
||||
|
||||
import click
|
||||
|
||||
|
||||
class LazyGroup(click.Group):
|
||||
def __init__(self, *args, lazy_subcommands=None, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
# lazy_subcommands is a map of the form:
|
||||
#
|
||||
# {command-name} -> {module-name}.{command-object-name}
|
||||
#
|
||||
self.lazy_subcommands = lazy_subcommands or {}
|
||||
|
||||
def list_commands(self, ctx):
|
||||
base = super().list_commands(ctx)
|
||||
lazy = sorted(self.lazy_subcommands.keys())
|
||||
return base + lazy
|
||||
|
||||
def get_command(self, ctx, cmd_name): # pyright:ignore
|
||||
if cmd_name in self.lazy_subcommands:
|
||||
return self._lazy_load(cmd_name)
|
||||
return super().get_command(ctx, cmd_name)
|
||||
|
||||
def _lazy_load(self, cmd_name: str):
|
||||
# lazily loading a command, first get the module name and attribute name
|
||||
import_path: str = self.lazy_subcommands[cmd_name]
|
||||
modname, cmd_object_name = import_path.rsplit(".", 1)
|
||||
# do the import
|
||||
mod = importlib.import_module(
|
||||
f".{modname}", package="fastanime.cli.commands.anilist"
|
||||
)
|
||||
# get the Command object from that module
|
||||
cmd_object = getattr(mod, cmd_object_name)
|
||||
# check the result to make debugging easier
|
||||
if not isinstance(cmd_object, click.BaseCommand):
|
||||
raise ValueError(
|
||||
f"Lazy loading of {import_path} failed by returning "
|
||||
"a non-command object"
|
||||
)
|
||||
return cmd_object
|
||||
@@ -1,32 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...config import Config
|
||||
|
||||
|
||||
@click.command(help="View anime you completed")
|
||||
@click.pass_obj
|
||||
def completed(config: "Config"):
|
||||
from ....anilist import AniList
|
||||
from ...interfaces import anilist_interfaces
|
||||
from ...utils.tools import QueryDict, exit_app
|
||||
|
||||
if not config.user:
|
||||
print("Not authenticated")
|
||||
print("Please run: fastanime anilist loggin")
|
||||
exit_app()
|
||||
anime_list = AniList.get_anime_list("COMPLETED")
|
||||
if not anime_list or not anime_list[1]:
|
||||
return
|
||||
if not anime_list[0]:
|
||||
return
|
||||
media = [
|
||||
mediaListItem["media"]
|
||||
for mediaListItem in anime_list[1]["data"]["Page"]["mediaList"]
|
||||
] # pyright:ignore
|
||||
anime_list[1]["data"]["Page"]["media"] = media # pyright:ignore
|
||||
anilist_config = QueryDict()
|
||||
anilist_config.data = anime_list[1]
|
||||
anilist_interfaces.select_anime(config, anilist_config)
|
||||
@@ -1,32 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastanime.cli.config import Config
|
||||
|
||||
|
||||
@click.command(help="View anime you dropped")
|
||||
@click.pass_obj
|
||||
def dropped(config: "Config"):
|
||||
from ....anilist import AniList
|
||||
from ...interfaces import anilist_interfaces
|
||||
from ...utils.tools import QueryDict, exit_app
|
||||
|
||||
if not config.user:
|
||||
print("Not authenticated")
|
||||
print("Please run: fastanime anilist loggin")
|
||||
exit_app()
|
||||
anime_list = AniList.get_anime_list("DROPPED")
|
||||
if not anime_list:
|
||||
return
|
||||
if not anime_list[0] or not anime_list[1]:
|
||||
return
|
||||
media = [
|
||||
mediaListItem["media"]
|
||||
for mediaListItem in anime_list[1]["data"]["Page"]["mediaList"]
|
||||
] # pyright:ignore
|
||||
anime_list[1]["data"]["Page"]["media"] = media # pyright:ignore
|
||||
anilist_config = QueryDict()
|
||||
anilist_config.data = anime_list[1]
|
||||
anilist_interfaces.select_anime(config, anilist_config)
|
||||
@@ -1,18 +0,0 @@
|
||||
import click
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Fetch the top 15 most favourited anime from anilist",
|
||||
short_help="View most favourited anime",
|
||||
)
|
||||
@click.pass_obj
|
||||
def favourites(config):
|
||||
from ....anilist import AniList
|
||||
from ...interfaces.anilist_interfaces import select_anime
|
||||
from ...utils.tools import QueryDict
|
||||
|
||||
anime_data = AniList.get_most_favourite()
|
||||
if anime_data[0]:
|
||||
anilist_config = QueryDict()
|
||||
anilist_config.data = anime_data[1]
|
||||
select_anime(config, anilist_config)
|
||||
@@ -1,48 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...config import Config
|
||||
|
||||
|
||||
@click.command(help="Login to your anilist account")
|
||||
@click.option("--status", "-s", help="Whether you are logged in or not", is_flag=True)
|
||||
@click.pass_obj
|
||||
def login(config: "Config", status):
|
||||
from click import launch
|
||||
from rich import print
|
||||
from rich.prompt import Confirm, Prompt
|
||||
|
||||
from ....anilist import AniList
|
||||
from ...utils.tools import exit_app
|
||||
|
||||
if status:
|
||||
is_logged_in = True if config.user else False
|
||||
message = (
|
||||
"You are logged in :happy:" if is_logged_in else "You arent logged in :cry"
|
||||
)
|
||||
print(message)
|
||||
print(config.user)
|
||||
exit_app()
|
||||
if config.user:
|
||||
print("Already logged in :confused:")
|
||||
if not Confirm.ask("or would you like to reloggin", default=True):
|
||||
exit_app()
|
||||
# ---- new loggin -----
|
||||
print(
|
||||
f"A browser session will be opened ( [link]{config.fastanime_anilist_app_login_url}[/link] )",
|
||||
)
|
||||
launch(config.fastanime_anilist_app_login_url, wait=True)
|
||||
print("Please paste the token provided here")
|
||||
token = Prompt.ask("Enter token")
|
||||
user = AniList.login_user(token)
|
||||
if not user:
|
||||
print("Sth went wrong", user)
|
||||
exit_app()
|
||||
return
|
||||
user["token"] = token
|
||||
config.update_user(user)
|
||||
print("Successfully saved credentials")
|
||||
print(user)
|
||||
exit_app()
|
||||
@@ -1,124 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...config import Config
|
||||
|
||||
|
||||
@click.command(help="Check for notifications on anime you currently watching")
|
||||
@click.pass_obj
|
||||
def notifier(config: "Config"):
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
|
||||
import requests
|
||||
from plyer import notification
|
||||
|
||||
from ....anilist import AniList
|
||||
from ....constants import APP_CACHE_DIR, APP_DATA_DIR, APP_NAME, ICON_PATH, PLATFORM
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
notified = os.path.join(APP_DATA_DIR, "last_notification.json")
|
||||
anime_image_path = os.path.join(APP_CACHE_DIR, "notification_image")
|
||||
notification_duration = config.notification_duration * 60
|
||||
notification_image_path = ""
|
||||
|
||||
if not config.user:
|
||||
print("Not Authenticated")
|
||||
print("Run the following to get started: fastanime anilist loggin")
|
||||
return
|
||||
run = True
|
||||
# WARNING: Mess around with this value at your own risk
|
||||
timeout = 2 # time is in minutes
|
||||
if os.path.exists(notified):
|
||||
with open(notified, "r") as f:
|
||||
past_notifications = json.load(f)
|
||||
else:
|
||||
past_notifications = {}
|
||||
with open(notified, "w") as f:
|
||||
json.dump(past_notifications, f)
|
||||
|
||||
while run:
|
||||
try:
|
||||
logger.info("checking for notifications")
|
||||
result = AniList.get_notification()
|
||||
if not result[0]:
|
||||
logger.warning(
|
||||
"Something went wrong this could mean anilist is down or you have lost internet connection"
|
||||
)
|
||||
logger.info("sleeping...")
|
||||
time.sleep(timeout * 60)
|
||||
continue
|
||||
data = result[1]
|
||||
if not data:
|
||||
logger.warning(
|
||||
"Something went wrong this could mean anilist is down or you have lost internet connection"
|
||||
)
|
||||
logger.info("sleeping...")
|
||||
time.sleep(timeout * 60)
|
||||
continue
|
||||
|
||||
notifications = data["data"]["Page"]["notifications"]
|
||||
if not notifications:
|
||||
logger.info("Nothing to notify")
|
||||
else:
|
||||
for notification_ in notifications:
|
||||
anime_episode = notification_["episode"]
|
||||
anime_title = notification_["media"]["title"][
|
||||
config.preferred_language
|
||||
]
|
||||
title = f"{anime_title} Episode {anime_episode} just aired"
|
||||
# pyright:ignore
|
||||
message = "Be sure to watch so you are not left out of the loop."
|
||||
# message = str(textwrap.wrap(message, width=50))
|
||||
|
||||
id = notification_["media"]["id"]
|
||||
if past_notifications.get(str(id)) == notification_["episode"]:
|
||||
logger.info(
|
||||
f"skipping id={id} title={anime_title} episode={anime_episode} already notified"
|
||||
)
|
||||
|
||||
else:
|
||||
# windows only supports ico,
|
||||
# and you still ask why linux
|
||||
if PLATFORM != "Windows":
|
||||
image_link = notification_["media"]["coverImage"]["medium"]
|
||||
logger.info("Downloading image...")
|
||||
|
||||
resp = requests.get(image_link)
|
||||
if resp.status_code == 200:
|
||||
with open(anime_image_path, "wb") as f:
|
||||
f.write(resp.content)
|
||||
notification_image_path = anime_image_path
|
||||
else:
|
||||
logger.warn(
|
||||
f"Failed to get image response_status={resp.status_code} response_content={resp.content}"
|
||||
)
|
||||
notification_image_path = ICON_PATH
|
||||
else:
|
||||
notification_image_path = ICON_PATH
|
||||
|
||||
past_notifications[f"{id}"] = notification_["episode"]
|
||||
with open(notified, "w") as f:
|
||||
json.dump(past_notifications, f)
|
||||
logger.info(message)
|
||||
notification.notify( # pyright:ignore
|
||||
title=title,
|
||||
message=message,
|
||||
app_name=APP_NAME,
|
||||
app_icon=notification_image_path,
|
||||
hints={
|
||||
"image-path": notification_image_path,
|
||||
"desktop-entry": f"{APP_NAME}.desktop",
|
||||
},
|
||||
timeout=notification_duration,
|
||||
)
|
||||
time.sleep(30)
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
logger.info("sleeping...")
|
||||
time.sleep(timeout * 60)
|
||||
@@ -1,32 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...config import Config
|
||||
|
||||
|
||||
@click.command(help="View anime you paused on watching")
|
||||
@click.pass_obj
|
||||
def paused(config: "Config"):
|
||||
from ....anilist import AniList
|
||||
from ...interfaces import anilist_interfaces
|
||||
from ...utils.tools import QueryDict, exit_app
|
||||
|
||||
if not config.user:
|
||||
print("Not authenticated")
|
||||
print("Please run: fastanime anilist loggin")
|
||||
exit_app()
|
||||
anime_list = AniList.get_anime_list("PAUSED")
|
||||
if not anime_list:
|
||||
return
|
||||
if not anime_list[0] or not anime_list[1]:
|
||||
return
|
||||
media = [
|
||||
mediaListItem["media"]
|
||||
for mediaListItem in anime_list[1]["data"]["Page"]["mediaList"]
|
||||
] # pyright:ignore
|
||||
anime_list[1]["data"]["Page"]["media"] = media # pyright:ignore
|
||||
anilist_config = QueryDict()
|
||||
anilist_config.data = anime_list[1]
|
||||
anilist_interfaces.select_anime(config, anilist_config)
|
||||
@@ -1,32 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...config import Config
|
||||
|
||||
|
||||
@click.command(help="View anime you are planning on watching")
|
||||
@click.pass_obj
|
||||
def planning(config: "Config"):
|
||||
from ....anilist import AniList
|
||||
from ...interfaces import anilist_interfaces
|
||||
from ...utils.tools import QueryDict, exit_app
|
||||
|
||||
if not config.user:
|
||||
print("Not authenticated")
|
||||
print("Please run: fastanime anilist loggin")
|
||||
exit_app()
|
||||
anime_list = AniList.get_anime_list("PLANNING")
|
||||
if not anime_list:
|
||||
return
|
||||
if not anime_list[0] or not anime_list[1]:
|
||||
return
|
||||
media = [
|
||||
mediaListItem["media"]
|
||||
for mediaListItem in anime_list[1]["data"]["Page"]["mediaList"]
|
||||
] # pyright:ignore
|
||||
anime_list[1]["data"]["Page"]["media"] = media # pyright:ignore
|
||||
anilist_config = QueryDict()
|
||||
anilist_config.data = anime_list[1]
|
||||
anilist_interfaces.select_anime(config, anilist_config)
|
||||
@@ -1,17 +0,0 @@
|
||||
import click
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Fetch the top 15 most popular anime", short_help="View most popular anime"
|
||||
)
|
||||
@click.pass_obj
|
||||
def popular(config):
|
||||
from ....anilist import AniList
|
||||
from ...interfaces.anilist_interfaces import select_anime
|
||||
from ...utils.tools import QueryDict
|
||||
|
||||
anime_data = AniList.get_most_popular()
|
||||
if anime_data[0]:
|
||||
anilist_config = QueryDict()
|
||||
anilist_config.data = anime_data[1]
|
||||
select_anime(config, anilist_config)
|
||||
@@ -1,27 +0,0 @@
|
||||
import click
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Get random anime from anilist based on a range of anilist anime ids that are seected at random",
|
||||
short_help="View random anime",
|
||||
)
|
||||
@click.pass_obj
|
||||
def random_anime(config):
|
||||
import random
|
||||
|
||||
from ....anilist import AniList
|
||||
from ...interfaces.anilist_interfaces import select_anime
|
||||
from ...utils.tools import QueryDict
|
||||
|
||||
random_anime = range(1, 15000)
|
||||
|
||||
random_anime = random.sample(random_anime, k=50)
|
||||
|
||||
anime_data = AniList.search(id_in=list(random_anime))
|
||||
|
||||
if anime_data[0]:
|
||||
anilist_config = QueryDict()
|
||||
anilist_config.data = anime_data[1]
|
||||
select_anime(config, anilist_config)
|
||||
else:
|
||||
print(anime_data[1])
|
||||
@@ -1,18 +0,0 @@
|
||||
import click
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Fetch the 15 most recently updated anime from anilist that are currently releasing",
|
||||
short_help="View recently updated anime",
|
||||
)
|
||||
@click.pass_obj
|
||||
def recent(config):
|
||||
from ....anilist import AniList
|
||||
from ...interfaces.anilist_interfaces import select_anime
|
||||
from ...utils.tools import QueryDict
|
||||
|
||||
anime_data = AniList.get_most_recently_updated()
|
||||
if anime_data[0]:
|
||||
anilist_config = QueryDict()
|
||||
anilist_config.data = anime_data[1]
|
||||
select_anime(config, anilist_config)
|
||||
@@ -1,32 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...config import Config
|
||||
|
||||
|
||||
@click.command(help="View anime you are rewatching")
|
||||
@click.pass_obj
|
||||
def rewatching(config: "Config"):
|
||||
from ....anilist import AniList
|
||||
from ...interfaces import anilist_interfaces
|
||||
from ...utils.tools import QueryDict, exit_app
|
||||
|
||||
if not config.user:
|
||||
print("Not authenticated")
|
||||
print("Please run: fastanime anilist loggin")
|
||||
exit_app()
|
||||
anime_list = AniList.get_anime_list("REPEATING")
|
||||
if not anime_list:
|
||||
return
|
||||
if not anime_list[0] or not anime_list[1]:
|
||||
return
|
||||
media = [
|
||||
mediaListItem["media"]
|
||||
for mediaListItem in anime_list[1]["data"]["Page"]["mediaList"]
|
||||
] # pyright:ignore
|
||||
anime_list[1]["data"]["Page"]["media"] = media # pyright:ignore
|
||||
anilist_config = QueryDict()
|
||||
anilist_config.data = anime_list[1]
|
||||
anilist_interfaces.select_anime(config, anilist_config)
|
||||
@@ -1,17 +0,0 @@
|
||||
import click
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Fetch the 15 most scored anime", short_help="View most scored anime"
|
||||
)
|
||||
@click.pass_obj
|
||||
def scores(config):
|
||||
from ....anilist import AniList
|
||||
from ...interfaces.anilist_interfaces import select_anime
|
||||
from ...utils.tools import QueryDict
|
||||
|
||||
anime_data = AniList.get_most_scored()
|
||||
if anime_data[0]:
|
||||
anilist_config = QueryDict()
|
||||
anilist_config.data = anime_data[1]
|
||||
select_anime(config, anilist_config)
|
||||
@@ -1,21 +0,0 @@
|
||||
import click
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Search for anime using anilists api and get top ~50 results",
|
||||
short_help="Search for anime",
|
||||
)
|
||||
@click.argument(
|
||||
"title",
|
||||
)
|
||||
@click.pass_obj
|
||||
def search(config, title):
|
||||
from ....anilist import AniList
|
||||
from ...interfaces.anilist_interfaces import select_anime
|
||||
from ...utils.tools import QueryDict
|
||||
|
||||
success, search_results = AniList.search(title)
|
||||
if success:
|
||||
anilist_config = QueryDict()
|
||||
anilist_config.data = search_results
|
||||
select_anime(config, anilist_config)
|
||||
@@ -1,18 +0,0 @@
|
||||
import click
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Fetch the top 15 anime that are currently trending",
|
||||
short_help="Trending anime 🔥🔥🔥",
|
||||
)
|
||||
@click.pass_obj
|
||||
def trending(config):
|
||||
from ....anilist import AniList
|
||||
from ...interfaces.anilist_interfaces import select_anime
|
||||
from ...utils.tools import QueryDict
|
||||
|
||||
success, data = AniList.get_trending()
|
||||
if success:
|
||||
anilist_config = QueryDict()
|
||||
anilist_config.data = data
|
||||
select_anime(config, anilist_config)
|
||||
@@ -1,17 +0,0 @@
|
||||
import click
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Fetch the 15 most anticipited anime", short_help="View upcoming anime"
|
||||
)
|
||||
@click.pass_obj
|
||||
def upcoming(config):
|
||||
from ....anilist import AniList
|
||||
from ...interfaces.anilist_interfaces import select_anime
|
||||
from ...utils.tools import QueryDict
|
||||
|
||||
success, data = AniList.get_upcoming_anime()
|
||||
if success:
|
||||
anilist_config = QueryDict()
|
||||
anilist_config.data = data
|
||||
select_anime(config, anilist_config)
|
||||
@@ -1,32 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...config import Config
|
||||
|
||||
|
||||
@click.command(help="View anime you are watching")
|
||||
@click.pass_obj
|
||||
def watching(config: "Config"):
|
||||
from ....anilist import AniList
|
||||
from ...interfaces import anilist_interfaces
|
||||
from ...utils.tools import QueryDict, exit_app
|
||||
|
||||
if not config.user:
|
||||
print("Not authenticated")
|
||||
print("Please run: fastanime anilist loggin")
|
||||
exit_app()
|
||||
anime_list = AniList.get_anime_list("CURRENT")
|
||||
if not anime_list:
|
||||
return
|
||||
if not anime_list[0] or not anime_list[1]:
|
||||
return
|
||||
media = [
|
||||
mediaListItem["media"]
|
||||
for mediaListItem in anime_list[1]["data"]["Page"]["mediaList"]
|
||||
] # pyright:ignore
|
||||
anime_list[1]["data"]["Page"]["media"] = media # pyright:ignore
|
||||
anilist_config = QueryDict()
|
||||
anilist_config.data = anime_list[1]
|
||||
anilist_interfaces.select_anime(config, anilist_config)
|
||||
@@ -1,35 +0,0 @@
|
||||
import click
|
||||
|
||||
|
||||
@click.command(help="Helper command to manage cache")
|
||||
@click.option("--clean", help="Clean the cache dir", is_flag=True)
|
||||
@click.option("--path", help="The path to the cache dir", is_flag=True)
|
||||
@click.option("--size", help="The size of the cache dir", is_flag=True)
|
||||
def cache(clean, path, size):
|
||||
from ...constants import APP_CACHE_DIR
|
||||
|
||||
if path:
|
||||
print(APP_CACHE_DIR)
|
||||
elif clean:
|
||||
import shutil
|
||||
|
||||
from rich.prompt import Confirm
|
||||
|
||||
if Confirm.ask(
|
||||
f"Are you sure you want to clean the following path: {APP_CACHE_DIR};(NOTE: !!The action is irreversible and will clean your cache!!)",
|
||||
default=False,
|
||||
):
|
||||
print("Cleaning...")
|
||||
shutil.rmtree(APP_CACHE_DIR)
|
||||
print("Successfully removed: ", APP_CACHE_DIR)
|
||||
elif size:
|
||||
import os
|
||||
|
||||
from ..utils.utils import sizeof_fmt
|
||||
|
||||
total_size = 0
|
||||
for dirpath, dirnames, filenames in os.walk(APP_CACHE_DIR):
|
||||
for f in filenames:
|
||||
fp = os.path.join(dirpath, f)
|
||||
total_size += os.path.getsize(fp)
|
||||
print("Total Size: ", sizeof_fmt(total_size))
|
||||
@@ -1,48 +0,0 @@
|
||||
import click
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Opens up your fastanime config in your preferred editor",
|
||||
short_help="Edit your config",
|
||||
)
|
||||
@click.option("--path", "-p", help="Print the config location and exit", is_flag=True)
|
||||
@click.option(
|
||||
"--desktop-entry",
|
||||
"-d",
|
||||
help="Configure the desktop entry of fastanime",
|
||||
is_flag=True,
|
||||
)
|
||||
# @click.pass_obj
|
||||
def config(path, desktop_entry):
|
||||
pass
|
||||
|
||||
from pyshortcuts import make_shortcut
|
||||
from rich import print
|
||||
|
||||
from ...constants import APP_NAME, ICON_PATH, USER_CONFIG_PATH
|
||||
|
||||
if path:
|
||||
print(USER_CONFIG_PATH)
|
||||
elif desktop_entry:
|
||||
import shutil
|
||||
|
||||
FASTANIME_EXECUTABLE = shutil.which("fastanime")
|
||||
if FASTANIME_EXECUTABLE:
|
||||
cmds = f"{FASTANIME_EXECUTABLE} --rofi anilist"
|
||||
else:
|
||||
cmds = "_ -m fastanime --rofi anilist"
|
||||
shortcut = make_shortcut(
|
||||
name=APP_NAME,
|
||||
description="Watch Anime from the terminal",
|
||||
icon=ICON_PATH,
|
||||
script=cmds,
|
||||
terminal=False,
|
||||
)
|
||||
if shortcut:
|
||||
print("Success", shortcut)
|
||||
else:
|
||||
print("Failed")
|
||||
else:
|
||||
import click
|
||||
|
||||
click.edit(filename=USER_CONFIG_PATH)
|
||||
@@ -1,151 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..config import Config
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Download anime using the anime provider for a specified range",
|
||||
short_help="Download anime",
|
||||
)
|
||||
@click.argument(
|
||||
"anime-title",
|
||||
required=True,
|
||||
)
|
||||
@click.option(
|
||||
"--episode-range",
|
||||
"-r",
|
||||
help="A range of episodes to download",
|
||||
)
|
||||
@click.option(
|
||||
"--highest_priority",
|
||||
"-h",
|
||||
help="Choose stream indicated as highest priority",
|
||||
is_flag=True,
|
||||
)
|
||||
@click.pass_obj
|
||||
def download(config: "Config", anime_title, episode_range, highest_priority):
|
||||
from click import clear
|
||||
from rich import print
|
||||
from rich.progress import Progress
|
||||
from thefuzz import fuzz
|
||||
|
||||
from ...AnimeProvider import AnimeProvider
|
||||
from ...libs.anime_provider.types import Anime
|
||||
from ...libs.fzf import fzf
|
||||
from ...Utility.downloader.downloader import downloader
|
||||
from ..utils.tools import exit_app
|
||||
from ..utils.utils import fuzzy_inquirer
|
||||
|
||||
anime_provider = AnimeProvider(config.provider)
|
||||
|
||||
translation_type = config.translation_type
|
||||
download_dir = config.downloads_dir
|
||||
|
||||
# ---- search for anime ----
|
||||
with Progress() as progress:
|
||||
progress.add_task("Fetching Search Results...", total=None)
|
||||
search_results = anime_provider.search_for_anime(
|
||||
anime_title, translation_type=translation_type
|
||||
)
|
||||
if not search_results:
|
||||
print("Search results failed")
|
||||
input("Enter to retry")
|
||||
download(config, anime_title, episode_range, highest_priority)
|
||||
return
|
||||
search_results = search_results["results"]
|
||||
search_results_ = {
|
||||
search_result["title"]: search_result for search_result in search_results
|
||||
}
|
||||
|
||||
if config.auto_select:
|
||||
search_result = max(
|
||||
search_results_.keys(), key=lambda title: fuzz.ratio(title, anime_title)
|
||||
)
|
||||
print("[cyan]Auto selecting:[/] ", search_result)
|
||||
else:
|
||||
choices = list(search_results_.keys())
|
||||
if config.use_fzf:
|
||||
search_result = fzf.run(choices, "Please Select title: ", "FastAnime")
|
||||
else:
|
||||
search_result = fuzzy_inquirer("Please Select title", choices)
|
||||
|
||||
# ---- fetch anime ----
|
||||
with Progress() as progress:
|
||||
progress.add_task("Fetching Anime...", total=None)
|
||||
anime: Anime | None = anime_provider.get_anime(
|
||||
search_results_[search_result]["id"]
|
||||
)
|
||||
if not anime:
|
||||
print("Sth went wring anime no found")
|
||||
input("Enter to continue...")
|
||||
download(config, anime_title, episode_range, highest_priority)
|
||||
return
|
||||
|
||||
episodes = anime["availableEpisodesDetail"][config.translation_type]
|
||||
if episode_range:
|
||||
episodes_start, episodes_end = episode_range.split("-")
|
||||
|
||||
else:
|
||||
episodes_start, episodes_end = 0, len(episodes)
|
||||
for episode in range(round(float(episodes_start)), round(float(episodes_end))):
|
||||
try:
|
||||
episode = str(episode)
|
||||
if episode not in episodes:
|
||||
print(f"[cyan]Warning[/]: Episode {episode} not found, skipping")
|
||||
continue
|
||||
with Progress() as progress:
|
||||
progress.add_task("Fetching Episode Streams...", total=None)
|
||||
streams = anime_provider.get_episode_streams(
|
||||
anime, episode, config.translation_type
|
||||
)
|
||||
if not streams:
|
||||
print("No streams skipping")
|
||||
continue
|
||||
|
||||
with Progress() as progress:
|
||||
if highest_priority:
|
||||
progress.add_task("Fetching highest priority stream", total=None)
|
||||
streams = list(streams)
|
||||
links = [
|
||||
(link.get("priority", 0), link["link"])
|
||||
for server in streams
|
||||
for link in server["links"]
|
||||
]
|
||||
link = max(links, key=lambda x: x[0])[1]
|
||||
episode_title = streams[0]["episode_title"]
|
||||
elif config.server == "top":
|
||||
progress.add_task("Fetching Top Server", total=None)
|
||||
server = next(streams)
|
||||
link = server["links"][config.quality]["link"]
|
||||
episode_title = server["episode_title"]
|
||||
else:
|
||||
# TODO: Make this better but no rush whats the point of manual selection
|
||||
progress.add_task("Fetching links", total=None)
|
||||
streams = list(streams)
|
||||
links = [
|
||||
link["link"] for server in streams for link in server["links"]
|
||||
]
|
||||
episode_title = streams[0]["episode_title"]
|
||||
if config.use_fzf:
|
||||
link = fzf.run(links, "Select link", "Links")
|
||||
else:
|
||||
link = fuzzy_inquirer("Select link", links)
|
||||
|
||||
print(f"[purple]Now Downloading:[/] {search_result} Episode {episode}")
|
||||
|
||||
downloader._download_file(
|
||||
link,
|
||||
download_dir,
|
||||
(anime["title"], episode_title),
|
||||
True,
|
||||
config.format,
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print("Continuing")
|
||||
clear()
|
||||
print("Done")
|
||||
exit_app()
|
||||
@@ -1,47 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..config import Config
|
||||
|
||||
|
||||
@click.command(
|
||||
help="View and watch your downloads using mpv", short_help="Watch downloads"
|
||||
)
|
||||
@click.option("--path", "-p", help="print the downloads folder and exit", is_flag=True)
|
||||
@click.pass_obj
|
||||
def downloads(config: "Config", path: bool):
|
||||
import os
|
||||
|
||||
from ...cli.utils.mpv import run_mpv
|
||||
from ...libs.fzf import fzf
|
||||
from ...libs.rofi import Rofi
|
||||
from ..utils.tools import exit_app
|
||||
from ..utils.utils import fuzzy_inquirer
|
||||
|
||||
USER_VIDEOS_DIR = config.downloads_dir
|
||||
if path:
|
||||
print(USER_VIDEOS_DIR)
|
||||
return
|
||||
if not os.path.exists(USER_VIDEOS_DIR):
|
||||
print("Downloads directory specified does not exist")
|
||||
return
|
||||
playlists = os.listdir(USER_VIDEOS_DIR)
|
||||
playlists.append("Exit")
|
||||
|
||||
def stream():
|
||||
if config.use_fzf:
|
||||
playlist_name = fzf.run(playlists, "Enter Playlist Name", "Downloads")
|
||||
elif config.use_rofi:
|
||||
playlist_name = Rofi.run(playlists, "Enter Playlist Name")
|
||||
else:
|
||||
playlist_name = fuzzy_inquirer("Enter Playlist Name: ", playlists)
|
||||
if playlist_name == "Exit":
|
||||
exit_app()
|
||||
return
|
||||
playlist = os.path.join(USER_VIDEOS_DIR, playlist_name)
|
||||
run_mpv(playlist)
|
||||
stream()
|
||||
|
||||
stream()
|
||||
@@ -1,145 +0,0 @@
|
||||
import click
|
||||
|
||||
from ...cli.config import Config
|
||||
|
||||
|
||||
@click.command(
|
||||
help="This subcommand directly interacts with the provider to enable basic streaming. Useful for binging anime.",
|
||||
short_help="Binge anime",
|
||||
)
|
||||
@click.option(
|
||||
"--episode-range",
|
||||
"-r",
|
||||
help="A range of episodes to binge",
|
||||
)
|
||||
@click.argument("anime_title", required=True, type=str)
|
||||
@click.pass_obj
|
||||
def search(config: Config, anime_title: str, episode_range: str):
|
||||
from click import clear
|
||||
from rich import print
|
||||
from rich.progress import Progress
|
||||
from thefuzz import fuzz
|
||||
|
||||
from ...AnimeProvider import AnimeProvider
|
||||
from ...libs.anime_provider.types import Anime
|
||||
from ...libs.fzf import fzf
|
||||
from ...libs.rofi import Rofi
|
||||
from ..utils.mpv import run_mpv
|
||||
from ..utils.tools import exit_app
|
||||
from ..utils.utils import fuzzy_inquirer
|
||||
|
||||
anime_provider = AnimeProvider(config.provider)
|
||||
|
||||
# ---- search for anime ----
|
||||
with Progress() as progress:
|
||||
progress.add_task("Fetching Search Results...", total=None)
|
||||
search_results = anime_provider.search_for_anime(
|
||||
anime_title, config.translation_type
|
||||
)
|
||||
if not search_results:
|
||||
print("Search results not found")
|
||||
input("Enter to retry")
|
||||
search(config, anime_title, episode_range)
|
||||
return
|
||||
search_results = search_results["results"]
|
||||
if not search_results:
|
||||
print("Anime not found :cry:")
|
||||
exit_app()
|
||||
search_results_ = {
|
||||
search_result["title"]: search_result for search_result in search_results
|
||||
}
|
||||
|
||||
if config.auto_select:
|
||||
search_result = max(
|
||||
search_results_.keys(), key=lambda title: fuzz.ratio(title, anime_title)
|
||||
)
|
||||
print("[cyan]Auto Selecting:[/] ", search_result)
|
||||
|
||||
else:
|
||||
choices = list(search_results_.keys())
|
||||
if config.use_fzf:
|
||||
search_result = fzf.run(choices, "Please Select title: ", "FastAnime")
|
||||
elif config.use_rofi:
|
||||
search_result = Rofi.run(choices, "Please Select Title")
|
||||
else:
|
||||
search_result = fuzzy_inquirer(
|
||||
"Please Select Title",
|
||||
choices,
|
||||
)
|
||||
|
||||
# ---- fetch selected anime ----
|
||||
with Progress() as progress:
|
||||
progress.add_task("Fetching Anime...", total=None)
|
||||
anime: Anime | None = anime_provider.get_anime(
|
||||
search_results_[search_result]["id"]
|
||||
)
|
||||
|
||||
if not anime:
|
||||
print("Sth went wring anime no found")
|
||||
input("Enter to continue...")
|
||||
search(config, anime_title, episode_range)
|
||||
return
|
||||
episode_range_ = None
|
||||
episodes = anime["availableEpisodesDetail"][config.translation_type]
|
||||
if episode_range:
|
||||
episodes_start, episodes_end = episode_range.split("-")
|
||||
if episodes_start and episodes_end:
|
||||
episode_range_ = iter(
|
||||
range(round(float(episodes_start)), round(float(episodes_end)) + 1)
|
||||
)
|
||||
else:
|
||||
episode_range_ = iter(sorted(episodes, key=float))
|
||||
|
||||
def stream_anime():
|
||||
clear()
|
||||
episode = None
|
||||
|
||||
if episode_range_:
|
||||
try:
|
||||
episode = str(next(episode_range_))
|
||||
print(
|
||||
f"[cyan]Auto selecting:[/] {search_result} [cyan]Episode:[/] {episode}"
|
||||
)
|
||||
except StopIteration:
|
||||
print("[green]Completed binge sequence[/]:smile:")
|
||||
|
||||
if not episode or episode not in episodes:
|
||||
if config.use_fzf:
|
||||
episode = fzf.run(episodes, "Select an episode: ", header=search_result)
|
||||
elif config.use_rofi:
|
||||
episode = Rofi.run(episodes, "Select an episode")
|
||||
else:
|
||||
episode = fuzzy_inquirer("Select episode", episodes)
|
||||
|
||||
# ---- fetch streams ----
|
||||
with Progress() as progress:
|
||||
progress.add_task("Fetching Episode Streams...", total=None)
|
||||
streams = anime_provider.get_episode_streams(
|
||||
anime, episode, config.translation_type
|
||||
)
|
||||
if not streams:
|
||||
print("Failed to get streams")
|
||||
return
|
||||
|
||||
# ---- fetch servers ----
|
||||
with Progress() as progress:
|
||||
if config.server == "top":
|
||||
progress.add_task("Fetching top server...", total=None)
|
||||
server = next(streams)
|
||||
link = server["links"][config.quality]["link"]
|
||||
else:
|
||||
progress.add_task("Fetching servers", total=None)
|
||||
links = [link["link"] for server in streams for link in server["links"]]
|
||||
if config.use_fzf:
|
||||
link = fzf.run(links, "Select an link: ", header=search_result)
|
||||
elif config.use_rofi:
|
||||
link = Rofi.run(links, "Select an link")
|
||||
else:
|
||||
link = fuzzy_inquirer("Select link", links)
|
||||
|
||||
print(f"[purple]Now Playing:[/] {search_result} Episode {episode}")
|
||||
|
||||
run_mpv(link, search_result)
|
||||
stream_anime()
|
||||
|
||||
stream_anime()
|
||||
@@ -1,199 +0,0 @@
|
||||
import os
|
||||
from configparser import ConfigParser
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from rich import print
|
||||
|
||||
from ..constants import USER_CONFIG_PATH, USER_VIDEOS_DIR
|
||||
from ..libs.rofi import Rofi
|
||||
from ..Utility.user_data_helper import user_data_helper
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..AnimeProvider import AnimeProvider
|
||||
|
||||
|
||||
class Config(object):
|
||||
anime_list: list
|
||||
watch_history: dict
|
||||
fastanime_anilist_app_login_url = (
|
||||
"https://anilist.co/api/v2/oauth/authorize?client_id=20148&response_type=token"
|
||||
)
|
||||
anime_provider: "AnimeProvider"
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.load_config()
|
||||
|
||||
def load_config(self):
|
||||
self.configparser = ConfigParser(
|
||||
{
|
||||
"server": "top",
|
||||
"continue_from_history": "True",
|
||||
"quality": "0",
|
||||
"auto_next": "False",
|
||||
"auto_select": "True",
|
||||
"sort_by": "search match",
|
||||
"downloads_dir": USER_VIDEOS_DIR,
|
||||
"translation_type": "sub",
|
||||
"preferred_language": "english",
|
||||
"use_fzf": "False",
|
||||
"preview": "False",
|
||||
"format": "best[height<=1080]/bestvideo[height<=1080]+bestaudio/best",
|
||||
"provider": "allanime",
|
||||
"error": "3",
|
||||
"icons": "false",
|
||||
"notification_duration": "2",
|
||||
"skip": "false",
|
||||
"use_rofi": "false",
|
||||
"rofi_theme": "",
|
||||
"rofi_theme_input": "",
|
||||
"rofi_theme_confirm": "",
|
||||
"use_mpv_mod": "true",
|
||||
}
|
||||
)
|
||||
self.configparser.add_section("stream")
|
||||
self.configparser.add_section("general")
|
||||
self.configparser.add_section("anilist")
|
||||
if not os.path.exists(USER_CONFIG_PATH):
|
||||
with open(USER_CONFIG_PATH, "w") as config:
|
||||
self.configparser.write(config)
|
||||
|
||||
self.configparser.read(USER_CONFIG_PATH)
|
||||
|
||||
# --- set defaults ---
|
||||
self.downloads_dir = self.get_downloads_dir()
|
||||
self.provider = self.get_provider()
|
||||
self.use_fzf = self.get_use_fzf()
|
||||
self.use_rofi = self.get_use_rofi()
|
||||
self.skip = self.get_skip()
|
||||
self.icons = self.get_icons()
|
||||
self.preview = self.get_preview()
|
||||
self.translation_type = self.get_translation_type()
|
||||
self.sort_by = self.get_sort_by()
|
||||
self.continue_from_history = self.get_continue_from_history()
|
||||
self.auto_next = self.get_auto_next()
|
||||
self.auto_select = self.get_auto_select()
|
||||
self.use_mpv_mod = self.get_use_mpv_mod()
|
||||
self.quality = self.get_quality()
|
||||
self.notification_duration = self.get_notification_duration()
|
||||
self.error = self.get_error()
|
||||
self.server = self.get_server()
|
||||
self.format = self.get_format()
|
||||
self.preferred_language = self.get_preferred_language()
|
||||
self.rofi_theme = self.get_rofi_theme()
|
||||
Rofi.rofi_theme = self.rofi_theme
|
||||
self.rofi_theme_input = self.get_rofi_theme_input()
|
||||
Rofi.rofi_theme_input = self.rofi_theme_input
|
||||
self.rofi_theme_confirm = self.get_rofi_theme_confirm()
|
||||
Rofi.rofi_theme_confirm = self.rofi_theme_confirm
|
||||
# ---- setup user data ------
|
||||
self.watch_history: dict = user_data_helper.user_data.get("watch_history", {})
|
||||
self.anime_list: list = user_data_helper.user_data.get("animelist", [])
|
||||
self.user: dict = user_data_helper.user_data.get("user", {})
|
||||
|
||||
def update_user(self, user):
|
||||
self.user = user
|
||||
user_data_helper.update_user_info(user)
|
||||
|
||||
def update_watch_history(
|
||||
self, anime_id: int, episode: str | None, start_time="0", total_time="0"
|
||||
):
|
||||
self.watch_history.update(
|
||||
{
|
||||
str(anime_id): {
|
||||
"episode": episode,
|
||||
"start_time": start_time,
|
||||
"total_time": total_time,
|
||||
}
|
||||
}
|
||||
)
|
||||
user_data_helper.update_watch_history(self.watch_history)
|
||||
|
||||
def update_anime_list(self, anime_id: int, remove=False):
|
||||
if remove:
|
||||
try:
|
||||
self.anime_list.remove(anime_id)
|
||||
print("Succesfully removed :cry:")
|
||||
except Exception:
|
||||
print(anime_id, "Nothing to remove :confused:")
|
||||
else:
|
||||
self.anime_list.append(anime_id)
|
||||
user_data_helper.update_animelist(self.anime_list)
|
||||
print("Succesfully added :smile:")
|
||||
input("Enter to continue...")
|
||||
|
||||
def get_provider(self):
|
||||
return self.configparser.get("general", "provider")
|
||||
|
||||
def get_rofi_theme(self):
|
||||
return self.configparser.get("general", "rofi_theme")
|
||||
|
||||
def get_rofi_theme_input(self):
|
||||
return self.configparser.get("general", "rofi_theme_input")
|
||||
|
||||
def get_rofi_theme_confirm(self):
|
||||
return self.configparser.get("general", "rofi_theme_confirm")
|
||||
|
||||
def get_downloads_dir(self):
|
||||
return self.configparser.get("general", "downloads_dir")
|
||||
|
||||
def get_use_fzf(self):
|
||||
return self.configparser.getboolean("general", "use_fzf")
|
||||
|
||||
def get_use_rofi(self):
|
||||
return self.configparser.getboolean("general", "use_rofi")
|
||||
|
||||
def get_skip(self):
|
||||
return self.configparser.getboolean("stream", "skip")
|
||||
|
||||
def get_icons(self):
|
||||
return self.configparser.getboolean("general", "icons")
|
||||
|
||||
def get_preview(self):
|
||||
return self.configparser.getboolean("general", "preview")
|
||||
|
||||
def get_preferred_language(self):
|
||||
return self.configparser.get("general", "preferred_language")
|
||||
|
||||
def get_sort_by(self):
|
||||
return self.configparser.get("anilist", "sort_by")
|
||||
|
||||
def get_continue_from_history(self):
|
||||
return self.configparser.getboolean("stream", "continue_from_history")
|
||||
|
||||
def get_translation_type(self):
|
||||
return self.configparser.get("stream", "translation_type")
|
||||
|
||||
def get_auto_next(self):
|
||||
return self.configparser.getboolean("stream", "auto_next")
|
||||
|
||||
def get_auto_select(self):
|
||||
return self.configparser.getboolean("stream", "auto_select")
|
||||
|
||||
def get_quality(self):
|
||||
return self.configparser.getint("stream", "quality")
|
||||
|
||||
def get_use_mpv_mod(self):
|
||||
return self.configparser.getboolean("stream", "use_mpv_mod")
|
||||
|
||||
def get_notification_duration(self):
|
||||
return self.configparser.getint("general", "notification_duration")
|
||||
|
||||
def get_error(self):
|
||||
return self.configparser.getint("stream", "error")
|
||||
|
||||
def get_server(self):
|
||||
return self.configparser.get("stream", "server")
|
||||
|
||||
def get_format(self):
|
||||
return self.configparser.get("stream", "format")
|
||||
|
||||
def update_config(self, section: str, key: str, value: str):
|
||||
self.configparser.set(section, key, value)
|
||||
with open(USER_CONFIG_PATH, "w") as config:
|
||||
self.configparser.write(config)
|
||||
|
||||
def __repr__(self):
|
||||
return f"Config(server:{self.get_server()},quality:{self.get_quality()},auto_next:{self.get_auto_next()},continue_from_history:{self.get_continue_from_history()},sort_by:{self.get_sort_by()},downloads_dir:{self.get_downloads_dir()})"
|
||||
|
||||
def __str__(self):
|
||||
return self.__repr__()
|
||||
@@ -1,998 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import random
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from click import clear
|
||||
from InquirerPy import inquirer
|
||||
from InquirerPy.validator import EmptyInputValidator
|
||||
from rich import print
|
||||
from rich.progress import Progress
|
||||
from rich.prompt import Confirm, Prompt
|
||||
|
||||
from ...anilist import AniList
|
||||
from ...constants import USER_CONFIG_PATH
|
||||
from ...libs.fzf import fzf
|
||||
from ...libs.rofi import Rofi
|
||||
from ...Utility.data import anime_normalizer
|
||||
from ...Utility.utils import anime_title_percentage_match, sanitize_filename
|
||||
from ..utils.mpv import run_mpv
|
||||
from ..utils.tools import QueryDict, exit_app
|
||||
from ..utils.utils import fuzzy_inquirer
|
||||
from .utils import aniskip
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...libs.anilist.anilist_data_schema import AnilistBaseMediaDataSchema
|
||||
from ...libs.anime_provider.types import Anime, SearchResult, Server
|
||||
from ..config import Config
|
||||
|
||||
|
||||
def calculate_time_delta(start_time, end_time):
|
||||
time_format = "%H:%M:%S"
|
||||
|
||||
# Convert string times to datetime objects
|
||||
start = datetime.strptime(start_time, time_format)
|
||||
end = datetime.strptime(end_time, time_format)
|
||||
|
||||
# Calculate the difference
|
||||
delta = end - start
|
||||
|
||||
return delta
|
||||
|
||||
|
||||
def player_controls(config: "Config", anilist_config: QueryDict):
|
||||
# user config
|
||||
config.translation_type.lower()
|
||||
|
||||
# internal config
|
||||
current_episode: str = anilist_config.episode_number
|
||||
episodes: list = sorted(anilist_config.episodes, key=float)
|
||||
links: list = anilist_config.current_stream_links
|
||||
current_link: str = anilist_config.current_stream_link
|
||||
anime_title: str = anilist_config.anime_title
|
||||
anime_id: int = anilist_config.anime_id
|
||||
|
||||
def _servers():
|
||||
config.server = ""
|
||||
|
||||
fetch_streams(config, anilist_config)
|
||||
|
||||
def _replay():
|
||||
selected_server: "Server" = anilist_config.current_server
|
||||
print(
|
||||
"[bold magenta]Now Replaying:[/]",
|
||||
anime_title,
|
||||
"[bold magenta] Episode: [/]",
|
||||
current_episode,
|
||||
)
|
||||
|
||||
start_time = config.watch_history[str(anime_id)]["start_time"]
|
||||
print("[green]Continuing from:[/] ", start_time)
|
||||
custom_args = []
|
||||
if config.skip:
|
||||
if args := aniskip(
|
||||
anilist_config.selected_anime_anilist["idMal"], current_episode
|
||||
):
|
||||
custom_args.extend(args)
|
||||
if config.use_mpv_mod:
|
||||
from ..utils.player import player
|
||||
|
||||
mpv = player.create_player(
|
||||
config.anime_provider,
|
||||
anilist_config,
|
||||
config,
|
||||
selected_server["episode_title"],
|
||||
)
|
||||
|
||||
if custom_args and None:
|
||||
chapters_file = custom_args[0].split("=", 1)
|
||||
script_opts = custom_args[1].split("=", 1)
|
||||
mpv._set_property("chapters-file", chapters_file[1])
|
||||
mpv._set_property("script-opts", script_opts[1])
|
||||
mpv.start = start_time
|
||||
mpv.play(current_link)
|
||||
mpv.wait_for_shutdown()
|
||||
mpv.terminate()
|
||||
stop_time = player.last_stop_time
|
||||
total_time = player.last_total_time
|
||||
else:
|
||||
stop_time, total_time = run_mpv(
|
||||
current_link,
|
||||
selected_server["episode_title"],
|
||||
start_time=start_time,
|
||||
custom_args=custom_args,
|
||||
)
|
||||
if stop_time == "0" or total_time == "0":
|
||||
episode = str(int(current_episode) + 1)
|
||||
else:
|
||||
error = 5 * 60
|
||||
delta = calculate_time_delta(stop_time, total_time)
|
||||
if delta.total_seconds() > error:
|
||||
episode = current_episode
|
||||
else:
|
||||
episode = str(int(current_episode) + 1)
|
||||
stop_time = "0"
|
||||
total_time = "0"
|
||||
|
||||
clear()
|
||||
config.update_watch_history(anime_id, episode, stop_time, total_time)
|
||||
player_controls(config, anilist_config)
|
||||
|
||||
def _next_episode():
|
||||
# ensures you dont accidentally erase your progress for an in complete episode
|
||||
stop_time = config.watch_history.get(str(anime_id), {}).get("start_time", "0")
|
||||
|
||||
total_time = config.watch_history.get(str(anime_id), {}).get("total_time", "0")
|
||||
|
||||
error = config.error * 60
|
||||
if stop_time == "0" or total_time == "0":
|
||||
dt = 0
|
||||
else:
|
||||
delta = calculate_time_delta(stop_time, total_time)
|
||||
dt = delta.total_seconds()
|
||||
if dt > error:
|
||||
if config.auto_next:
|
||||
if config.use_rofi:
|
||||
if not Rofi.confirm(
|
||||
"Are you sure you wish to continue to the next episode you haven't completed the current episode?"
|
||||
):
|
||||
anilist_options(config, anilist_config)
|
||||
return
|
||||
else:
|
||||
if not Confirm.ask(
|
||||
"Are you sure you wish to continue to the next episode you haven't completed the current episode?",
|
||||
default=False,
|
||||
):
|
||||
anilist_options(config, anilist_config)
|
||||
return
|
||||
elif not config.use_rofi:
|
||||
if not Confirm.ask(
|
||||
"Are you sure you wish to continue to the next episode, your progress for the current episodes will be erased?",
|
||||
default=True,
|
||||
):
|
||||
player_controls(config, anilist_config)
|
||||
return
|
||||
|
||||
# all checks have passed lets go to the next episode
|
||||
next_episode = episodes.index(current_episode) + 1
|
||||
if next_episode >= len(episodes):
|
||||
next_episode = len(episodes) - 1
|
||||
|
||||
# updateinternal config
|
||||
anilist_config.episode_number = episodes[next_episode]
|
||||
|
||||
# update user config
|
||||
config.update_watch_history(anime_id, episodes[next_episode])
|
||||
|
||||
# call interface
|
||||
fetch_streams(config, anilist_config)
|
||||
|
||||
def _episodes():
|
||||
# reset watch_history
|
||||
config.continue_from_history = False
|
||||
|
||||
# call interface
|
||||
fetch_episode(config, anilist_config)
|
||||
|
||||
def _previous_episode():
|
||||
prev_episode = episodes.index(current_episode) - 1
|
||||
if prev_episode <= 0:
|
||||
prev_episode = 0
|
||||
# anilist_config.episode_title = episode["title"]
|
||||
anilist_config.episode_number = episodes[prev_episode]
|
||||
|
||||
# update user config
|
||||
config.update_watch_history(anime_id, episodes[prev_episode])
|
||||
|
||||
# call interface
|
||||
fetch_streams(config, anilist_config)
|
||||
|
||||
def _change_quality():
|
||||
# extract the actual link urls
|
||||
options = [link["link"] for link in links]
|
||||
|
||||
# prompt for new quality
|
||||
if config.use_fzf:
|
||||
quality = fzf.run(
|
||||
options, prompt="Select Quality:", header="Quality Options"
|
||||
)
|
||||
elif config.use_rofi:
|
||||
quality = Rofi.run(options, "Select Quality")
|
||||
else:
|
||||
quality = fuzzy_inquirer("Select Quality", options)
|
||||
config.quality = options.index(quality) # set quality
|
||||
player_controls(config, anilist_config)
|
||||
|
||||
def _change_translation_type():
|
||||
# prompt for new translation type
|
||||
options = ["sub", "dub"]
|
||||
if config.use_fzf:
|
||||
translation_type = fzf.run(
|
||||
options, prompt="Select Translation Type: ", header="Lang Options"
|
||||
).lower()
|
||||
elif config.use_rofi:
|
||||
translation_type = Rofi.run(options, "Select Translation Type")
|
||||
else:
|
||||
translation_type = fuzzy_inquirer(
|
||||
"Select Translation Type", options
|
||||
).lower()
|
||||
|
||||
# update internal config
|
||||
config.translation_type = translation_type.lower()
|
||||
|
||||
# reload to controls
|
||||
player_controls(config, anilist_config)
|
||||
|
||||
icons = config.icons
|
||||
options = {
|
||||
f"{'🔂 ' if icons else ''}Replay": _replay,
|
||||
f"{'⏭ ' if icons else ''}Next Episode": _next_episode,
|
||||
f"{'⏮ ' if icons else ''}Previous Episode": _previous_episode,
|
||||
f"{'🗃️ ' if icons else ''}Episodes": _episodes,
|
||||
f"{'📀 ' if icons else ''}Change Quality": _change_quality,
|
||||
f"{'🎧 ' if icons else ''}Change Translation Type": _change_translation_type,
|
||||
f"{'💽 ' if icons else ''}Servers": _servers,
|
||||
f"{'📱 ' if icons else ''}Main Menu": lambda: anilist(config, anilist_config),
|
||||
f"{'📜 ' if icons else ''}Anime Options Menu": lambda: anilist_options(
|
||||
config, anilist_config
|
||||
),
|
||||
f"{'🔎 ' if icons else ''}Search Results": lambda: select_anime(
|
||||
config, anilist_config
|
||||
),
|
||||
f"{'❌ ' if icons else ''}Exit": exit_app,
|
||||
}
|
||||
|
||||
if config.auto_next:
|
||||
print("Auto selecting next episode")
|
||||
_next_episode()
|
||||
return
|
||||
if config.use_fzf:
|
||||
action = fzf.run(
|
||||
list(options.keys()), prompt="Select Action:", header="Player Controls"
|
||||
)
|
||||
elif config.use_rofi:
|
||||
action = Rofi.run(list(options.keys()), "Select Action")
|
||||
else:
|
||||
action = fuzzy_inquirer("Select Action", options.keys())
|
||||
options[action]()
|
||||
|
||||
|
||||
def fetch_streams(config: "Config", anilist_config: QueryDict):
|
||||
# user config
|
||||
quality: int = config.quality
|
||||
|
||||
# internal config
|
||||
episode_number: str = anilist_config.episode_number
|
||||
anime_title: str = anilist_config.anime_title
|
||||
anime_id: int = anilist_config.anime_id
|
||||
anime: "Anime" = anilist_config.anime
|
||||
translation_type = config.translation_type
|
||||
anime_provider = config.anime_provider
|
||||
|
||||
server = None
|
||||
# get streams for episode from provider
|
||||
with Progress() as progress:
|
||||
progress.add_task("Fetching Episode Streams...", total=None)
|
||||
episode_streams = anime_provider.get_episode_streams(
|
||||
anime,
|
||||
episode_number,
|
||||
translation_type,
|
||||
anilist_config.selected_anime_anilist,
|
||||
)
|
||||
if not episode_streams:
|
||||
if not config.use_rofi:
|
||||
print("Failed to fetch :cry:")
|
||||
input("Enter to retry...")
|
||||
else:
|
||||
if not Rofi.confirm("Sth went wrong!!Enter to continue..."):
|
||||
exit(1)
|
||||
return fetch_streams(config, anilist_config)
|
||||
|
||||
if config.server == "top":
|
||||
# no need to get all servers if top just works
|
||||
with Progress() as progress:
|
||||
progress.add_task("Fetching top server...", total=None)
|
||||
selected_server = next(episode_streams)
|
||||
server = "top"
|
||||
else:
|
||||
with Progress() as progress:
|
||||
progress.add_task("Fetching servers...", total=None)
|
||||
episode_streams_dict = {
|
||||
episode_stream["server"]: episode_stream
|
||||
for episode_stream in episode_streams
|
||||
}
|
||||
|
||||
# prompt for preferred server
|
||||
if config.server and config.server in episode_streams_dict.keys():
|
||||
server = config.server
|
||||
if not server:
|
||||
choices = [*episode_streams_dict.keys(), "top", "Back"]
|
||||
if config.use_fzf:
|
||||
server = fzf.run(
|
||||
choices,
|
||||
prompt="Select Server: ",
|
||||
header="Servers",
|
||||
)
|
||||
elif config.use_rofi:
|
||||
server = Rofi.run(choices, "Select Server")
|
||||
else:
|
||||
server = fuzzy_inquirer("Select Server", choices)
|
||||
if server == "Back":
|
||||
# reset watch_history
|
||||
config.update_watch_history(anime_id, None)
|
||||
|
||||
fetch_episode(config, anilist_config)
|
||||
return
|
||||
elif server == "top":
|
||||
selected_server = episode_streams_dict[list(episode_streams_dict.keys())[0]]
|
||||
else:
|
||||
selected_server = episode_streams_dict[server]
|
||||
|
||||
links = selected_server["links"]
|
||||
if quality > len(links) - 1:
|
||||
quality = config.quality = len(links) - 1
|
||||
elif quality < 0:
|
||||
quality = config.quality = 0
|
||||
stream_link = links[quality]["link"]
|
||||
|
||||
# update internal config
|
||||
anilist_config.current_stream_links = links
|
||||
anilist_config.current_stream_link = stream_link
|
||||
anilist_config.current_server = selected_server
|
||||
anilist_config.current_server_name = server
|
||||
|
||||
# play video
|
||||
print(
|
||||
"[bold magenta]Now playing:[/]",
|
||||
anime_title,
|
||||
"[bold magenta] Episode: [/]",
|
||||
episode_number,
|
||||
)
|
||||
# -- update anilist info if user --
|
||||
if config.user and episode_number:
|
||||
AniList.update_anime_list(
|
||||
{
|
||||
"mediaId": anime_id,
|
||||
# "status": "CURRENT",
|
||||
"progress": episode_number,
|
||||
}
|
||||
)
|
||||
|
||||
start_time = config.watch_history.get(str(anime_id), {}).get("start_time", "0")
|
||||
if start_time != "0":
|
||||
print("[green]Continuing from:[/] ", start_time)
|
||||
custom_args = []
|
||||
if config.skip:
|
||||
if args := aniskip(
|
||||
anilist_config.selected_anime_anilist["idMal"], episode_number
|
||||
):
|
||||
custom_args.extend(args)
|
||||
if config.use_mpv_mod:
|
||||
from ..utils.player import player
|
||||
|
||||
mpv = player.create_player(
|
||||
anime_provider, anilist_config, config, selected_server["episode_title"]
|
||||
)
|
||||
|
||||
if custom_args and None:
|
||||
chapters_file = custom_args[0].split("=", 1)
|
||||
script_opts = custom_args[1].split("=", 1)
|
||||
mpv._set_property("chapters-file", chapters_file[1])
|
||||
mpv._set_property("script-opts", script_opts[1])
|
||||
mpv.start = start_time
|
||||
mpv.play(stream_link)
|
||||
mpv.wait_for_shutdown()
|
||||
mpv.terminate()
|
||||
stop_time = player.last_stop_time
|
||||
total_time = player.last_total_time
|
||||
|
||||
else:
|
||||
stop_time, total_time = run_mpv(
|
||||
stream_link,
|
||||
selected_server["episode_title"],
|
||||
start_time=start_time,
|
||||
custom_args=custom_args,
|
||||
)
|
||||
print("Finished at: ", stop_time)
|
||||
|
||||
# update_watch_history
|
||||
if stop_time == "0" or total_time == "0":
|
||||
episode = str(int(episode_number) + 1)
|
||||
else:
|
||||
error = config.error * 60
|
||||
delta = calculate_time_delta(stop_time, total_time)
|
||||
if delta.total_seconds() > error:
|
||||
episode = episode_number
|
||||
else:
|
||||
episode = str(int(episode_number) + 1)
|
||||
stop_time = "0"
|
||||
total_time = "0"
|
||||
|
||||
config.update_watch_history(
|
||||
anime_id, episode, start_time=stop_time, total_time=total_time
|
||||
)
|
||||
|
||||
# switch to controls
|
||||
clear()
|
||||
|
||||
player_controls(config, anilist_config)
|
||||
|
||||
|
||||
def fetch_episode(config: "Config", anilist_config: QueryDict):
|
||||
# user config
|
||||
translation_type: str = config.translation_type.lower()
|
||||
continue_from_history: bool = config.continue_from_history
|
||||
user_watch_history: dict = config.watch_history
|
||||
anime_id: int = anilist_config.anime_id
|
||||
anime_title: str = anilist_config.anime_title
|
||||
|
||||
# internal config
|
||||
anime: "Anime" = anilist_config.anime
|
||||
_anime: "SearchResult" = anilist_config._anime
|
||||
selected_anime_anilist: "AnilistBaseMediaDataSchema" = (
|
||||
anilist_config.selected_anime_anilist
|
||||
)
|
||||
# prompt for episode number
|
||||
episodes = anime["availableEpisodesDetail"][translation_type]
|
||||
episode_number = ""
|
||||
if continue_from_history:
|
||||
if user_watch_history.get(str(anime_id), {}).get("episode") in episodes:
|
||||
episode_number = user_watch_history[str(anime_id)]["episode"]
|
||||
print(f"[bold cyan]Continuing from Episode:[/] [bold]{episode_number}[/]")
|
||||
elif selected_anime_anilist["mediaListEntry"]:
|
||||
episode_number = str(
|
||||
(selected_anime_anilist["mediaListEntry"] or {"progress": ""}).get(
|
||||
"progress"
|
||||
)
|
||||
)
|
||||
if episode_number not in episodes:
|
||||
episode_number = ""
|
||||
print(f"[bold cyan]Continuing from Episode:[/] [bold]{episode_number}[/]")
|
||||
else:
|
||||
episode_number = ""
|
||||
|
||||
if not episode_number:
|
||||
choices = [*episodes, "Back"]
|
||||
if config.use_fzf:
|
||||
episode_number = fzf.run(
|
||||
choices,
|
||||
prompt="Select Episode:",
|
||||
header=anime_title,
|
||||
)
|
||||
elif config.use_rofi:
|
||||
episode_number = Rofi.run(choices, "Select Episode")
|
||||
else:
|
||||
episode_number = fuzzy_inquirer("Select Episode", choices)
|
||||
|
||||
if episode_number == "Back":
|
||||
anilist_options(config, anilist_config)
|
||||
return
|
||||
start_time = user_watch_history.get(str(anime_id), {}).get("start_time", "0")
|
||||
config.update_watch_history(anime_id, episode_number, start_time=start_time)
|
||||
|
||||
# update internal config
|
||||
anilist_config.episodes = episodes
|
||||
# anilist_config.episode_title = episode["title"]
|
||||
anilist_config.episode_number = episode_number
|
||||
|
||||
# next interface
|
||||
fetch_streams(config, anilist_config)
|
||||
|
||||
|
||||
def fetch_anime_episode(config, anilist_config: QueryDict):
|
||||
selected_anime: "SearchResult" = anilist_config._anime
|
||||
anime_provider = config.anime_provider
|
||||
with Progress() as progress:
|
||||
progress.add_task("Fetching Anime Info...", total=None)
|
||||
anilist_config.anime = anime_provider.get_anime(
|
||||
selected_anime["id"], anilist_config.selected_anime_anilist
|
||||
)
|
||||
if not anilist_config.anime:
|
||||
print(
|
||||
"Sth went wrong :cry: this could mean the provider is down or your internet"
|
||||
)
|
||||
if not config.use_rofi:
|
||||
input("Enter to continue...")
|
||||
else:
|
||||
if not Rofi.confirm("Sth went wrong!!Enter to continue..."):
|
||||
exit(1)
|
||||
fetch_anime_episode(config, anilist_config)
|
||||
return
|
||||
|
||||
fetch_episode(config, anilist_config)
|
||||
|
||||
|
||||
def provide_anime(config: "Config", anilist_config: QueryDict):
|
||||
# user config
|
||||
translation_type = config.translation_type.lower()
|
||||
|
||||
# internal config
|
||||
selected_anime_title = anilist_config.selected_anime_title
|
||||
|
||||
anime_data: "AnilistBaseMediaDataSchema" = anilist_config.selected_anime_anilist
|
||||
anime_provider = config.anime_provider
|
||||
|
||||
# search and get the requested title from provider
|
||||
with Progress() as progress:
|
||||
progress.add_task("Fetching Search Results...", total=None)
|
||||
search_results = anime_provider.search_for_anime(
|
||||
selected_anime_title,
|
||||
translation_type,
|
||||
anilist_config.selected_anime_anilist,
|
||||
)
|
||||
if not search_results:
|
||||
print(
|
||||
"Sth went wrong :cry: while fetching this could mean you have poor internet connection or the provider is down"
|
||||
)
|
||||
if not config.use_rofi:
|
||||
input("Enter to continue...")
|
||||
else:
|
||||
if not Rofi.confirm("Sth went wrong!!Enter to continue..."):
|
||||
exit(1)
|
||||
provide_anime(config, anilist_config)
|
||||
return
|
||||
|
||||
search_results = {anime["title"]: anime for anime in search_results["results"]}
|
||||
_title = None
|
||||
if _title := next(
|
||||
(
|
||||
original
|
||||
for original, normalized in anime_normalizer.items()
|
||||
if normalized.lower() == selected_anime_title.lower()
|
||||
),
|
||||
None,
|
||||
):
|
||||
_title = _title
|
||||
|
||||
if config.auto_select:
|
||||
anime_title = max(
|
||||
search_results.keys(),
|
||||
key=lambda title: anime_title_percentage_match(title, anime_data),
|
||||
)
|
||||
print(f"[cyan]Auto selecting[/]: {anime_title}")
|
||||
else:
|
||||
choices = [*search_results.keys(), "Back"]
|
||||
if config.use_fzf:
|
||||
anime_title = fzf.run(
|
||||
choices,
|
||||
prompt="Select Search Result:",
|
||||
header="Anime Search Results",
|
||||
)
|
||||
|
||||
elif config.use_rofi:
|
||||
anime_title = Rofi.run(choices, "Select Search Result")
|
||||
else:
|
||||
anime_title = fuzzy_inquirer("Select Search Result", choices)
|
||||
if anime_title == "Back":
|
||||
anilist_options(config, anilist_config)
|
||||
return
|
||||
anilist_config.anime_title = anime_normalizer.get(anime_title) or anime_title
|
||||
anilist_config._anime = search_results[anime_title]
|
||||
fetch_anime_episode(config, anilist_config)
|
||||
|
||||
|
||||
def anilist_options(config, anilist_config: QueryDict):
|
||||
selected_anime: "AnilistBaseMediaDataSchema" = anilist_config.selected_anime_anilist
|
||||
selected_anime_title: str = anilist_config.selected_anime_title
|
||||
progress = (selected_anime["mediaListEntry"] or {"progress": 0}).get("progress", 0)
|
||||
episodes_total = selected_anime["episodes"] or "Inf"
|
||||
|
||||
def _watch_trailer(config: "Config", anilist_config: QueryDict):
|
||||
if trailer := selected_anime.get("trailer"):
|
||||
trailer_url = "https://youtube.com/watch?v=" + trailer["id"]
|
||||
print("[bold magenta]Watching Trailer of:[/]", selected_anime_title)
|
||||
run_mpv(
|
||||
trailer_url,
|
||||
ytdl_format=config.format,
|
||||
)
|
||||
anilist_options(config, anilist_config)
|
||||
else:
|
||||
if not config.use_rofi:
|
||||
print("no trailer available :confused:")
|
||||
input("Enter to continue...")
|
||||
else:
|
||||
if not Rofi.confirm("No trailler found!!Enter to continue"):
|
||||
exit(0)
|
||||
anilist_options(config, anilist_config)
|
||||
|
||||
def _add_to_list(config: "Config", anilist_config: QueryDict):
|
||||
# config.update_anime_list(anilist_config.anime_id)
|
||||
anime_lists = {
|
||||
"Watching": "CURRENT",
|
||||
"Paused": "PAUSED",
|
||||
"Planning": "PLANNING",
|
||||
"Dropped": "DROPPED",
|
||||
"Rewatching": "REPEATING",
|
||||
"Completed": "COMPLETED",
|
||||
}
|
||||
if config.use_fzf:
|
||||
anime_list = fzf.run(
|
||||
list(anime_lists.keys()),
|
||||
"Choose the list you want to add to",
|
||||
"Add your animelist",
|
||||
)
|
||||
elif config.use_rofi:
|
||||
anime_list = Rofi.run(
|
||||
list(anime_lists.keys()), "Choose list you want to add to"
|
||||
)
|
||||
else:
|
||||
anime_list = fuzzy_inquirer(
|
||||
"Choose the list you want to add to", list(anime_lists.keys())
|
||||
)
|
||||
result = AniList.update_anime_list(
|
||||
{"status": anime_lists[anime_list], "mediaId": selected_anime["id"]}
|
||||
)
|
||||
if not result[0]:
|
||||
print("Failed to update", result)
|
||||
else:
|
||||
print(
|
||||
f"Successfully added {selected_anime_title} to your {anime_list} list :smile:"
|
||||
)
|
||||
if not config.use_rofi:
|
||||
input("Enter to continue...")
|
||||
anilist_options(config, anilist_config)
|
||||
|
||||
def _score_anime(config: "Config", anilist_config: QueryDict):
|
||||
if config.use_rofi:
|
||||
score = Rofi.ask("Enter Score", is_int=True)
|
||||
score = max(100, min(0, score))
|
||||
else:
|
||||
score = inquirer.number(
|
||||
message="Enter the score:",
|
||||
min_allowed=0,
|
||||
max_allowed=100,
|
||||
validate=EmptyInputValidator(),
|
||||
).execute()
|
||||
|
||||
result = AniList.update_anime_list(
|
||||
{"scoreRaw": score, "mediaId": selected_anime["id"]}
|
||||
)
|
||||
if not result[0]:
|
||||
print("Failed to update", result)
|
||||
else:
|
||||
print(f"Successfully scored {selected_anime_title}; score: {score}")
|
||||
if not config.use_rofi:
|
||||
input("Enter to continue...")
|
||||
anilist_options(config, anilist_config)
|
||||
|
||||
def _remove_from_list(config: "Config", anilist_config: QueryDict):
|
||||
if Confirm.ask(
|
||||
f"Are you sure you want to procede, the folowing action will permanently remove {selected_anime_title} from your list and your progress will be erased",
|
||||
default=False,
|
||||
):
|
||||
success, data = AniList.delete_medialist_entry(selected_anime["id"])
|
||||
if not success or not data:
|
||||
print("Failed to delete", data)
|
||||
elif not data.get("deleted"):
|
||||
print("Failed to delete", data)
|
||||
else:
|
||||
print("Successfully deleted :cry:", selected_anime_title)
|
||||
else:
|
||||
print(selected_anime_title, ":relieved:")
|
||||
if not config.use_rofi:
|
||||
input("Enter to continue...")
|
||||
anilist_options(config, anilist_config)
|
||||
|
||||
def _change_translation_type(config: "Config", anilist_config: QueryDict):
|
||||
# prompt for new translation type
|
||||
options = ["Sub", "Dub"]
|
||||
if config.use_fzf:
|
||||
translation_type = fzf.run(
|
||||
options, prompt="Select Translation Type:", header="Language Options"
|
||||
)
|
||||
elif config.use_rofi:
|
||||
translation_type = Rofi.run(options, "Select Translation Type")
|
||||
else:
|
||||
translation_type = fuzzy_inquirer("Select translation type", options)
|
||||
|
||||
# update internal config
|
||||
config.translation_type = translation_type.lower()
|
||||
|
||||
anilist_options(config, anilist_config)
|
||||
|
||||
def _view_info(config, anilist_config):
|
||||
from rich.console import Console
|
||||
from rich.prompt import Confirm
|
||||
|
||||
from ...Utility import anilist_data_helper
|
||||
from ...Utility.utils import remove_html_tags
|
||||
from ..utils.print_img import print_img
|
||||
|
||||
clear()
|
||||
console = Console()
|
||||
|
||||
print_img(selected_anime["coverImage"]["large"])
|
||||
console.print("[bold cyan]Title(jp): ", selected_anime["title"]["romaji"])
|
||||
console.print("[bold cyan]Title(eng): ", selected_anime["title"]["english"])
|
||||
console.print("[bold cyan]Popularity: ", selected_anime["popularity"])
|
||||
console.print("[bold cyan]Favourites: ", selected_anime["favourites"])
|
||||
console.print("[bold cyan]Status: ", selected_anime["status"])
|
||||
console.print(
|
||||
"[bold cyan]Start Date: ",
|
||||
anilist_data_helper.format_anilist_date_object(selected_anime["startDate"]),
|
||||
)
|
||||
console.print(
|
||||
"[bold cyan]End Date: ",
|
||||
anilist_data_helper.format_anilist_date_object(selected_anime["endDate"]),
|
||||
)
|
||||
# console.print("[bold cyan]Season: ", selected_anime["season"])
|
||||
console.print("[bold cyan]Episodes: ", selected_anime["episodes"])
|
||||
console.print(
|
||||
"[bold cyan]Tags: ",
|
||||
anilist_data_helper.format_list_data_with_comma(
|
||||
[tag["name"] for tag in selected_anime["tags"]]
|
||||
),
|
||||
)
|
||||
console.print(
|
||||
"[bold cyan]Genres: ",
|
||||
anilist_data_helper.format_list_data_with_comma(selected_anime["genres"]),
|
||||
)
|
||||
# console.print("[bold cyan]Type: ", selected_anime["st"])
|
||||
if selected_anime["nextAiringEpisode"]:
|
||||
console.print(
|
||||
"[bold cyan]Next Episode: ",
|
||||
anilist_data_helper.extract_next_airing_episode(
|
||||
selected_anime["nextAiringEpisode"]
|
||||
),
|
||||
)
|
||||
console.print(
|
||||
"[bold underline cyan]Description\n[/]",
|
||||
remove_html_tags(str(selected_anime["description"])),
|
||||
)
|
||||
if Confirm.ask("Enter to continue...", default=True):
|
||||
anilist_options(config, anilist_config)
|
||||
return
|
||||
|
||||
def _toggle_auto_select(config, anilist_config):
|
||||
config.auto_select = not config.auto_select
|
||||
anilist_options(config, anilist_config)
|
||||
|
||||
def _toggle_auto_next(config, anilist_config):
|
||||
config.auto_select = not config.auto_select
|
||||
anilist_options(config, anilist_config)
|
||||
|
||||
icons = config.icons
|
||||
options = {
|
||||
f"{'📽️ ' if icons else ''}Stream ({progress}/{episodes_total})": provide_anime,
|
||||
f"{'📼 ' if icons else ''}Watch Trailer": _watch_trailer,
|
||||
f"{'✨ ' if icons else ''}Score Anime": _score_anime,
|
||||
f"{'📥 ' if icons else ''}Add to List": _add_to_list,
|
||||
f"{'📤 ' if icons else ''}Remove from List": _remove_from_list,
|
||||
f"{'📖 ' if icons else ''}View Info": _view_info,
|
||||
f"{'🎧 ' if icons else ''}Change Translation Type": _change_translation_type,
|
||||
f"{'🔘 ' if icons else ''}Toggle auto select anime": _toggle_auto_select, # problematic if you choose an anime that doesnt match id
|
||||
f"{'💠 ' if icons else ''}Toggle auto next episode": _toggle_auto_next,
|
||||
f"{'🔙 ' if icons else ''}Back": select_anime,
|
||||
f"{'❌ ' if icons else ''}Exit": exit_app,
|
||||
}
|
||||
if config.use_fzf:
|
||||
action = fzf.run(
|
||||
list(options.keys()), prompt="Select Action:", header="Anime Menu"
|
||||
)
|
||||
elif config.use_rofi:
|
||||
action = Rofi.run(list(options.keys()), "Select Action")
|
||||
else:
|
||||
action = fuzzy_inquirer("Select Action", options.keys())
|
||||
options[action](config, anilist_config)
|
||||
|
||||
|
||||
def select_anime(config: "Config", anilist_config: QueryDict):
|
||||
search_results = anilist_config.data["data"]["Page"]["media"]
|
||||
|
||||
anime_data = {}
|
||||
for anime in search_results:
|
||||
anime: "AnilistBaseMediaDataSchema"
|
||||
progress = (anime["mediaListEntry"] or {"progress": 0}).get("progress", 0)
|
||||
episodes_total = anime["episodes"] or "Inf"
|
||||
title = str(
|
||||
anime["title"][config.preferred_language] or anime["title"]["romaji"]
|
||||
)
|
||||
title = sanitize_filename(f"{title} ({progress} of {episodes_total})")
|
||||
# Check if the anime is currently airing and has new/unwatched episodes
|
||||
if (
|
||||
anime["status"] == "RELEASING"
|
||||
and anime["nextAiringEpisode"]
|
||||
and progress > 0
|
||||
):
|
||||
last_aired_episode = anime["nextAiringEpisode"]["episode"] - 1
|
||||
if last_aired_episode - progress > 0:
|
||||
title += f" 🔹{last_aired_episode - progress} new episode(s)🔹"
|
||||
anime_data[title] = anime
|
||||
|
||||
choices = [*anime_data.keys(), "Back"]
|
||||
if config.use_fzf:
|
||||
if config.preview:
|
||||
from .utils import get_preview
|
||||
|
||||
preview = get_preview(search_results, anime_data.keys())
|
||||
selected_anime_title = fzf.run(
|
||||
choices,
|
||||
prompt="Select Anime: ",
|
||||
header="Search Results",
|
||||
preview=preview,
|
||||
)
|
||||
else:
|
||||
selected_anime_title = fzf.run(
|
||||
choices,
|
||||
prompt="Select Anime: ",
|
||||
header="Search Results",
|
||||
)
|
||||
elif config.use_rofi:
|
||||
# TODO: Make this faster
|
||||
if config.preview:
|
||||
from .utils import IMAGES_DIR, get_icons
|
||||
|
||||
get_icons(search_results, anime_data.keys())
|
||||
choices = []
|
||||
for title in anime_data.keys():
|
||||
icon_path = os.path.join(IMAGES_DIR, title)
|
||||
choices.append(f"{title}\0icon\x1f{icon_path}")
|
||||
choices.append("Back")
|
||||
selected_anime_title = Rofi.run_with_icons(choices, "Select Anime")
|
||||
else:
|
||||
selected_anime_title = Rofi.run(choices, "Select Anime")
|
||||
else:
|
||||
selected_anime_title = fuzzy_inquirer("Select Anime", choices)
|
||||
# "bat %s/{}" % SEARCH_RESULTS_CACHE
|
||||
if selected_anime_title == "Back":
|
||||
anilist(config, anilist_config)
|
||||
return
|
||||
|
||||
selected_anime: "AnilistBaseMediaDataSchema" = anime_data[selected_anime_title]
|
||||
anilist_config.selected_anime_anilist = selected_anime
|
||||
anilist_config.selected_anime_title = (
|
||||
selected_anime["title"]["romaji"] or selected_anime["title"]["english"]
|
||||
)
|
||||
anilist_config.anime_id = selected_anime["id"]
|
||||
|
||||
anilist_options(config, anilist_config)
|
||||
|
||||
|
||||
def handle_animelist(anilist_config, config: "Config", list_type: str):
|
||||
if not config.user:
|
||||
if not config.use_rofi:
|
||||
print("You haven't logged in please run: fastanime anilist login")
|
||||
input("Enter to continue...")
|
||||
else:
|
||||
if not Rofi.confirm("You haven't logged in!!Enter to continue"):
|
||||
exit(1)
|
||||
anilist(config, anilist_config)
|
||||
return
|
||||
match list_type:
|
||||
case "Watching":
|
||||
status = "CURRENT"
|
||||
case "Planned":
|
||||
status = "PLANNING"
|
||||
case "Completed":
|
||||
status = "COMPLETED"
|
||||
case "Dropped":
|
||||
status = "DROPPED"
|
||||
case "Paused":
|
||||
status = "PAUSED"
|
||||
case "Repeating":
|
||||
status = "REPEATING"
|
||||
case _:
|
||||
return
|
||||
anime_list = AniList.get_anime_list(status)
|
||||
if not anime_list:
|
||||
print("Sth went wrong", anime_list)
|
||||
if not config.use_rofi:
|
||||
input("Enter to continue")
|
||||
else:
|
||||
if not Rofi.confirm("Sth went wrong!!Enter to continue..."):
|
||||
exit(1)
|
||||
anilist(config, anilist_config)
|
||||
return
|
||||
if not anime_list[0] or not anime_list[1]:
|
||||
print("Sth went wrong", anime_list)
|
||||
if not config.use_rofi:
|
||||
input("Enter to continue")
|
||||
else:
|
||||
if not Rofi.confirm("Sth went wrong!!Enter to continue..."):
|
||||
exit(1)
|
||||
|
||||
anilist(config, anilist_config)
|
||||
return
|
||||
media = [
|
||||
mediaListItem["media"]
|
||||
for mediaListItem in anime_list[1]["data"]["Page"]["mediaList"]
|
||||
] # pyright:ignore
|
||||
anime_list[1]["data"]["Page"]["media"] = media # pyright:ignore
|
||||
return anime_list
|
||||
|
||||
|
||||
def anilist(config: "Config", anilist_config: QueryDict):
|
||||
def _anilist_search():
|
||||
if config.use_rofi:
|
||||
search_term = str(Rofi.ask("Search for"))
|
||||
else:
|
||||
search_term = Prompt.ask("[cyan]Search for[/]")
|
||||
|
||||
return AniList.search(query=search_term)
|
||||
|
||||
def _anilist_random():
|
||||
random_anime = range(1, 15000)
|
||||
random_anime = random.sample(random_anime, k=50)
|
||||
|
||||
return AniList.search(id_in=list(random_anime))
|
||||
|
||||
def _watch_history():
|
||||
watch_history = list(map(int, config.watch_history.keys()))
|
||||
return AniList.search(id_in=watch_history, sort="TRENDING_DESC")
|
||||
|
||||
# NOTE: Will probably be depracated
|
||||
def _anime_list():
|
||||
anime_list = config.anime_list
|
||||
return AniList.search(id_in=anime_list)
|
||||
|
||||
def edit_config():
|
||||
import subprocess
|
||||
|
||||
subprocess.run([os.environ.get("EDITOR", "open"), USER_CONFIG_PATH])
|
||||
if config.use_rofi:
|
||||
config.load_config()
|
||||
config.use_rofi = True
|
||||
config.use_fzf = False
|
||||
else:
|
||||
config.load_config()
|
||||
|
||||
anilist(config, anilist_config)
|
||||
|
||||
icons = config.icons
|
||||
options = {
|
||||
f"{'🔥 ' if icons else ''}Trending": AniList.get_trending,
|
||||
f"{'📺 ' if icons else ''}Watching": lambda x="Watching": handle_animelist(
|
||||
anilist_config, config, x
|
||||
),
|
||||
f"{'⏸ ' if icons else ''}Paused": lambda x="Paused": handle_animelist(
|
||||
anilist_config, config, x
|
||||
),
|
||||
f"{'🚮 ' if icons else ''}Dropped": lambda x="Dropped": handle_animelist(
|
||||
anilist_config, config, x
|
||||
),
|
||||
f"{'📑 ' if icons else ''}Planned": lambda x="Planned": handle_animelist(
|
||||
anilist_config, config, x
|
||||
),
|
||||
f"{'✅ ' if icons else ''}Completed": lambda x="Completed": handle_animelist(
|
||||
anilist_config, config, x
|
||||
),
|
||||
f"{'🔁 ' if icons else ''}Rewatching": lambda x="Repeating": handle_animelist(
|
||||
anilist_config, config, x
|
||||
),
|
||||
f"{'🔔 ' if icons else ''}Recently Updated Anime": AniList.get_most_recently_updated,
|
||||
f"{'🔎 ' if icons else ''}Search": _anilist_search,
|
||||
f"{'🎞️ ' if icons else ''}Watch History": _watch_history,
|
||||
# "AnimeList": _anime_list💯,
|
||||
f"{'🎲 ' if icons else ''}Random Anime": _anilist_random,
|
||||
f"{'🌟 ' if icons else ''}Most Popular Anime": AniList.get_most_popular,
|
||||
f"{'💖 ' if icons else ''}Most Favourite Anime": AniList.get_most_favourite,
|
||||
f"{'✨ ' if icons else ''}Most Scored Anime": AniList.get_most_scored,
|
||||
f"{'🎬 ' if icons else ''}Upcoming Anime": AniList.get_upcoming_anime,
|
||||
f"{'📝 ' if icons else ''}Edit Config": edit_config,
|
||||
f"{'❌ ' if icons else ''}Exit": exit_app,
|
||||
}
|
||||
if config.use_fzf:
|
||||
action = fzf.run(
|
||||
list(options.keys()),
|
||||
prompt="Select Action: ",
|
||||
header="Anilist Menu",
|
||||
)
|
||||
elif config.use_rofi:
|
||||
action = Rofi.run(list(options.keys()), "Select Action")
|
||||
else:
|
||||
action = fuzzy_inquirer("Select Action", options.keys())
|
||||
anilist_data = options[action]()
|
||||
if anilist_data[0]:
|
||||
anilist_config.data = anilist_data[1]
|
||||
select_anime(config, anilist_config)
|
||||
|
||||
else:
|
||||
print(anilist_data[1])
|
||||
if not config.use_rofi:
|
||||
input("Enter to continue...")
|
||||
else:
|
||||
if not Rofi.confirm("Sth went wrong!!Enter to continue..."):
|
||||
exit(1)
|
||||
anilist(config, anilist_config)
|
||||
@@ -1,230 +0,0 @@
|
||||
import concurrent.futures
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import textwrap
|
||||
from threading import Thread
|
||||
|
||||
import requests
|
||||
|
||||
from ...constants import APP_CACHE_DIR
|
||||
from ...libs.anilist.anilist_data_schema import AnilistBaseMediaDataSchema
|
||||
from ...Utility import anilist_data_helper
|
||||
from ...Utility.utils import remove_html_tags
|
||||
from ..utils.utils import get_true_fg
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
fzf_preview = r"""
|
||||
#
|
||||
# The purpose of this script is to demonstrate how to preview a file or an
|
||||
# image in the preview window of fzf.
|
||||
#
|
||||
# Dependencies:
|
||||
# - https://github.com/sharkdp/bat
|
||||
# - https://github.com/hpjansson/chafa
|
||||
# - https://iterm2.com/utilities/imgcat
|
||||
fzf-preview(){
|
||||
if [[ $# -ne 1 ]]; then
|
||||
>&2 echo "usage: $0 FILENAME"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
file=${1/#\~\//$HOME/}
|
||||
type=$(file --dereference --mime -- "$file")
|
||||
|
||||
if [[ ! $type =~ image/ ]]; then
|
||||
if [[ $type =~ =binary ]]; then
|
||||
file "$1"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Sometimes bat is installed as batcat.
|
||||
if command -v batcat > /dev/null; then
|
||||
batname="batcat"
|
||||
elif command -v bat > /dev/null; then
|
||||
batname="bat"
|
||||
else
|
||||
cat "$1"
|
||||
exit
|
||||
fi
|
||||
|
||||
${batname} --style="${BAT_STYLE:-numbers}" --color=always --pager=never -- "$file"
|
||||
exit
|
||||
fi
|
||||
|
||||
dim=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}
|
||||
if [[ $dim = x ]]; then
|
||||
dim=$(stty size < /dev/tty | awk '{print $2 "x" $1}')
|
||||
elif ! [[ $KITTY_WINDOW_ID ]] && (( FZF_PREVIEW_TOP + FZF_PREVIEW_LINES == $(stty size < /dev/tty | awk '{print $1}') )); then
|
||||
# Avoid scrolling issue when the Sixel image touches the bottom of the screen
|
||||
# * https://github.com/junegunn/fzf/issues/2544
|
||||
dim=${FZF_PREVIEW_COLUMNS}x$((FZF_PREVIEW_LINES - 1))
|
||||
fi
|
||||
|
||||
# 1. Use kitty icat on kitty terminal
|
||||
if [[ $KITTY_WINDOW_ID ]]; then
|
||||
# 1. 'memory' is the fastest option but if you want the image to be scrollable,
|
||||
# you have to use 'stream'.
|
||||
#
|
||||
# 2. The last line of the output is the ANSI reset code without newline.
|
||||
# This confuses fzf and makes it render scroll offset indicator.
|
||||
# So we remove the last line and append the reset code to its previous line.
|
||||
kitty icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place="$dim@0x0" "$file" | sed '$d' | sed $'$s/$/\e[m/'
|
||||
|
||||
# 2. Use chafa with Sixel output
|
||||
elif command -v chafa > /dev/null; then
|
||||
chafa -f sixel -s "$dim" "$file"
|
||||
# Add a new line character so that fzf can display multiple images in the preview window
|
||||
echo
|
||||
|
||||
# 3. If chafa is not found but imgcat is available, use it on iTerm2
|
||||
elif command -v imgcat > /dev/null; then
|
||||
# NOTE: We should use https://iterm2.com/utilities/it2check to check if the
|
||||
# user is running iTerm2. But for the sake of simplicity, we just assume
|
||||
# that's the case here.
|
||||
imgcat -W "${dim%%x*}" -H "${dim##*x}" "$file"
|
||||
|
||||
# 4. Cannot find any suitable method to preview the image
|
||||
else
|
||||
file "$file"
|
||||
fi
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
# ---- aniskip intergration ----
|
||||
def aniskip(mal_id, episode):
|
||||
ANISKIP = shutil.which("ani-skip")
|
||||
if not ANISKIP:
|
||||
print("Aniskip not found, please install and try again")
|
||||
return
|
||||
args = [ANISKIP, "-q", str(mal_id), "-e", str(episode)]
|
||||
aniskip_result = subprocess.run(args, text=True, stdout=subprocess.PIPE)
|
||||
if aniskip_result.returncode != 0:
|
||||
return
|
||||
mpv_skip_args = aniskip_result.stdout.strip()
|
||||
return mpv_skip_args.split(" ")
|
||||
|
||||
|
||||
# ---- prevew stuff ----
|
||||
# import tempfile
|
||||
|
||||
WORKING_DIR = APP_CACHE_DIR # tempfile.gettempdir()
|
||||
IMAGES_DIR = os.path.join(WORKING_DIR, "images")
|
||||
if not os.path.exists(IMAGES_DIR):
|
||||
os.mkdir(IMAGES_DIR)
|
||||
INFO_DIR = os.path.join(WORKING_DIR, "info")
|
||||
if not os.path.exists(INFO_DIR):
|
||||
os.mkdir(INFO_DIR)
|
||||
|
||||
|
||||
def save_image_from_url(url: str, file_name: str):
|
||||
image = requests.get(url)
|
||||
with open(f"{IMAGES_DIR}/{file_name}", "wb") as f:
|
||||
f.write(image.content)
|
||||
|
||||
|
||||
def save_info_from_str(info: str, file_name: str):
|
||||
with open(f"{INFO_DIR}/{file_name}", "w") as f:
|
||||
f.write(info)
|
||||
|
||||
|
||||
def write_search_results(
|
||||
search_results: list[AnilistBaseMediaDataSchema],
|
||||
titles,
|
||||
workers=None,
|
||||
):
|
||||
H_COLOR = 215, 0, 95
|
||||
S_COLOR = 208, 208, 208
|
||||
S_WIDTH = 45
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as executor:
|
||||
future_to_task = {}
|
||||
for anime, title in zip(search_results, titles):
|
||||
image_url = anime["coverImage"]["large"]
|
||||
future_to_task[executor.submit(save_image_from_url, image_url, title)] = (
|
||||
image_url
|
||||
)
|
||||
|
||||
# handle the text data
|
||||
template = f"""
|
||||
{get_true_fg("-"*S_WIDTH,*S_COLOR,bold=False)}
|
||||
{get_true_fg('Title(jp):',*H_COLOR)} {anime['title']['romaji']}
|
||||
{get_true_fg('Title(eng):',*H_COLOR)} {anime['title']['english']}
|
||||
{get_true_fg('Popularity:',*H_COLOR)} {anime['popularity']}
|
||||
{get_true_fg('Favourites:',*H_COLOR)} {anime['favourites']}
|
||||
{get_true_fg('Status:',*H_COLOR)} {anime['status']}
|
||||
{get_true_fg('Episodes:',*H_COLOR)} {anime['episodes']}
|
||||
{get_true_fg('Genres:',*H_COLOR)} {anilist_data_helper.format_list_data_with_comma(anime['genres'])}
|
||||
{get_true_fg('Next Episode:',*H_COLOR)} {anilist_data_helper.extract_next_airing_episode(anime['nextAiringEpisode'])}
|
||||
{get_true_fg('Start Date:',*H_COLOR)} {anilist_data_helper.format_anilist_date_object(anime['startDate'])}
|
||||
{get_true_fg('End Date:',*H_COLOR)} {anilist_data_helper.format_anilist_date_object(anime['endDate'])}
|
||||
{get_true_fg("-"*S_WIDTH,*S_COLOR,bold=False)}
|
||||
{get_true_fg('Description:',*H_COLOR)}
|
||||
"""
|
||||
template = textwrap.dedent(template)
|
||||
template = f"""
|
||||
{template}
|
||||
{textwrap.fill(remove_html_tags(
|
||||
str(anime['description'])), width=45)}
|
||||
"""
|
||||
future_to_task[executor.submit(save_info_from_str, template, title)] = title
|
||||
|
||||
# execute the jobs
|
||||
for future in concurrent.futures.as_completed(future_to_task):
|
||||
task = future_to_task[future]
|
||||
try:
|
||||
future.result()
|
||||
except Exception as exc:
|
||||
logger.error("%r generated an exception: %s" % (task, exc))
|
||||
|
||||
|
||||
# get rofi icons
|
||||
def get_icons(search_results: list[AnilistBaseMediaDataSchema], titles, workers=None):
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as executor:
|
||||
# load the jobs
|
||||
future_to_url = {}
|
||||
for anime, title in zip(search_results, titles):
|
||||
image_url = anime["coverImage"]["large"]
|
||||
future_to_url[executor.submit(save_image_from_url, image_url, title)] = (
|
||||
image_url
|
||||
)
|
||||
|
||||
# execute the jobs
|
||||
for future in concurrent.futures.as_completed(future_to_url):
|
||||
url = future_to_url[future]
|
||||
try:
|
||||
future.result()
|
||||
except Exception as exc:
|
||||
logger.error("%r generated an exception: %s" % (url, exc))
|
||||
|
||||
|
||||
def get_preview(search_results: list[AnilistBaseMediaDataSchema], titles, wait=False):
|
||||
# ensure images and info exists
|
||||
background_worker = Thread(
|
||||
target=write_search_results, args=(search_results, titles)
|
||||
)
|
||||
background_worker.daemon = True
|
||||
background_worker.start()
|
||||
|
||||
os.environ["SHELL"] = shutil.which("bash") or "sh"
|
||||
preview = """
|
||||
%s
|
||||
if [ -s %s/{} ]; then fzf-preview %s/{}
|
||||
else echo Loading...
|
||||
fi
|
||||
if [ -s %s/{} ]; then cat %s/{}
|
||||
else echo Loading...
|
||||
fi
|
||||
""" % (
|
||||
fzf_preview,
|
||||
IMAGES_DIR,
|
||||
IMAGES_DIR,
|
||||
INFO_DIR,
|
||||
INFO_DIR,
|
||||
)
|
||||
# preview.replace("\n", ";")
|
||||
if wait:
|
||||
background_worker.join()
|
||||
return preview
|
||||
@@ -1,120 +0,0 @@
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
|
||||
def stream_video(MPV, url, mpv_args, custom_args):
|
||||
process = subprocess.Popen(
|
||||
[MPV, url, *mpv_args, *custom_args],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
|
||||
last_time = None
|
||||
av_time_pattern = re.compile(r"AV: ([0-9:]*) / ([0-9:]*) \(([0-9]*)%\)")
|
||||
last_time = "0"
|
||||
total_time = "0"
|
||||
|
||||
try:
|
||||
while True:
|
||||
if not process.stderr:
|
||||
continue
|
||||
output = process.stderr.readline()
|
||||
|
||||
if output:
|
||||
# Match the timestamp in the output
|
||||
match = av_time_pattern.search(output.strip())
|
||||
if match:
|
||||
current_time = match.group(1)
|
||||
total_time = match.group(2)
|
||||
match.group(3)
|
||||
last_time = current_time
|
||||
# print(f"Current stream time: {current_time}, Total time: {total_time}, Progress: {percentage}%")
|
||||
|
||||
# Check if the process has terminated
|
||||
retcode = process.poll()
|
||||
if retcode is not None:
|
||||
print("Finshed at: ", last_time)
|
||||
break
|
||||
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
finally:
|
||||
process.terminate()
|
||||
|
||||
return last_time, total_time
|
||||
|
||||
|
||||
def run_mpv(
|
||||
link: str,
|
||||
title: str | None = "",
|
||||
start_time: str = "0",
|
||||
ytdl_format="",
|
||||
custom_args=[],
|
||||
):
|
||||
# Determine if mpv is available
|
||||
MPV = shutil.which("mpv")
|
||||
|
||||
# If title is None, set a default value
|
||||
|
||||
# Regex to check if the link is a YouTube URL
|
||||
youtube_regex = r"(https?://)?(www\.)?(youtube|youtu|youtube-nocookie)\.(com|be)/.+"
|
||||
|
||||
if not MPV:
|
||||
# Determine if the link is a YouTube URL
|
||||
if re.match(youtube_regex, link):
|
||||
# Android specific commands to launch mpv with a YouTube URL
|
||||
args = [
|
||||
"nohup",
|
||||
"am",
|
||||
"start",
|
||||
"--user",
|
||||
"0",
|
||||
"-a",
|
||||
"android.intent.action.VIEW",
|
||||
"-d",
|
||||
link,
|
||||
"-n",
|
||||
"com.google.android.youtube/.UrlActivity",
|
||||
]
|
||||
return "0", "0"
|
||||
else:
|
||||
# Android specific commands to launch mpv with a regular URL
|
||||
args = [
|
||||
"nohup",
|
||||
"am",
|
||||
"start",
|
||||
"--user",
|
||||
"0",
|
||||
"-a",
|
||||
"android.intent.action.VIEW",
|
||||
"-d",
|
||||
link,
|
||||
"-n",
|
||||
"is.xyz.mpv/.MPVActivity",
|
||||
]
|
||||
|
||||
subprocess.run(args)
|
||||
return "0", "0"
|
||||
else:
|
||||
# General mpv command with custom arguments
|
||||
mpv_args = []
|
||||
if start_time != "0":
|
||||
mpv_args.append(f"--start={start_time}")
|
||||
if title:
|
||||
mpv_args.append(f"--title={title}")
|
||||
if ytdl_format:
|
||||
mpv_args.append(f"--ytdl-format={ytdl_format}")
|
||||
stop_time, total_time = stream_video(MPV, link, mpv_args, custom_args)
|
||||
return stop_time, total_time
|
||||
|
||||
|
||||
# Example usage
|
||||
if __name__ == "__main__":
|
||||
run_mpv(
|
||||
"https://www.youtube.com/watch?v=dQw4w9WgXcQ",
|
||||
"Example Video",
|
||||
"--fullscreen",
|
||||
"--volume=50",
|
||||
)
|
||||
@@ -1,235 +0,0 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import mpv
|
||||
|
||||
from ...anilist import AniList
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Literal
|
||||
|
||||
from ...AnimeProvider import AnimeProvider
|
||||
from ..config import Config
|
||||
|
||||
|
||||
def format_time(duration_in_secs: float):
|
||||
h = duration_in_secs // 3600
|
||||
m = duration_in_secs // 60
|
||||
s = duration_in_secs - ((h * 3600) + (m * 60))
|
||||
return f"{int(h):2d}:{int(m):2d}:{int(s):2d}".replace(" ", "0")
|
||||
|
||||
|
||||
class MpvPlayer(object):
|
||||
anime_provider: "AnimeProvider"
|
||||
config: "Config"
|
||||
mpv_player: "mpv.MPV"
|
||||
last_stop_time: str = "0"
|
||||
last_total_time: str = "0"
|
||||
last_stop_time_secs = 0
|
||||
last_total_time_secs = 0
|
||||
current_media_title = ""
|
||||
|
||||
def get_episode(
|
||||
self, type: "Literal['next','previous','reload','custom']", ep_no=None
|
||||
):
|
||||
anilist_config = self.anilist_config
|
||||
config = self.config
|
||||
episode_number: str = anilist_config.episode_number
|
||||
quality = config.quality
|
||||
episodes: list = sorted(anilist_config.episodes, key=float)
|
||||
anime_id: int = anilist_config.anime_id
|
||||
anime = anilist_config.anime
|
||||
translation_type = config.translation_type
|
||||
anime_provider = config.anime_provider
|
||||
self.last_stop_time: str = "0"
|
||||
self.last_total_time: str = "0"
|
||||
self.last_stop_time_secs = 0
|
||||
self.last_total_time_secs = 0
|
||||
|
||||
# next or prev
|
||||
if type == "next":
|
||||
self.mpv_player.show_text("Fetching next episode...")
|
||||
next_episode = episodes.index(episode_number) + 1
|
||||
if next_episode >= len(episodes):
|
||||
next_episode = len(episodes) - 1
|
||||
anilist_config.episode_number = episodes[next_episode]
|
||||
episode_number = anilist_config.episode_number
|
||||
config.update_watch_history(anime_id, str(episode_number))
|
||||
elif type == "reload":
|
||||
if episode_number not in episodes:
|
||||
self.mpv_player.show_text("Episode not available")
|
||||
return
|
||||
self.mpv_player.show_text("Replaying Episode...")
|
||||
elif type == "custom":
|
||||
if not ep_no or ep_no not in episodes:
|
||||
self.mpv_player.show_text("Episode number not specified or invalid")
|
||||
self.mpv_player.show_text(f"Acceptable episodes are: {episodes}")
|
||||
return
|
||||
|
||||
self.mpv_player.show_text(f"Fetching episode {ep_no}")
|
||||
episode_number = ep_no
|
||||
config.update_watch_history(anime_id, str(ep_no))
|
||||
anilist_config.episode_number = str(ep_no)
|
||||
else:
|
||||
self.mpv_player.show_text("Fetching previous episode...")
|
||||
prev_episode = episodes.index(episode_number) - 1
|
||||
if prev_episode <= 0:
|
||||
prev_episode = 0
|
||||
anilist_config.episode_number = episodes[prev_episode]
|
||||
episode_number = anilist_config.episode_number
|
||||
config.update_watch_history(anime_id, str(episode_number))
|
||||
# update episode progress
|
||||
if config.user and episode_number:
|
||||
AniList.update_anime_list(
|
||||
{
|
||||
"mediaId": anime_id,
|
||||
"progress": episode_number,
|
||||
}
|
||||
)
|
||||
# get them juicy streams
|
||||
episode_streams = anime_provider.get_episode_streams(
|
||||
anime,
|
||||
episode_number,
|
||||
translation_type,
|
||||
anilist_config.selected_anime_anilist,
|
||||
)
|
||||
if not episode_streams:
|
||||
self.mpv_player.show_text("No streams were found")
|
||||
return None
|
||||
|
||||
# always select the first
|
||||
selected_server = next(episode_streams)
|
||||
self.current_media_title = selected_server["episode_title"]
|
||||
links = selected_server["links"]
|
||||
if quality > len(links) - 1:
|
||||
quality = config.quality = len(links) - 1
|
||||
elif quality < 0:
|
||||
quality = config.quality = 0
|
||||
stream_link = links[quality]["link"]
|
||||
return stream_link
|
||||
|
||||
def create_player(
|
||||
self, anime_provider: "AnimeProvider", anilist_config, config: "Config", title
|
||||
):
|
||||
self.anime_provider = anime_provider
|
||||
self.anilist_config = anilist_config
|
||||
self.config = config
|
||||
self.last_stop_time: str = "0"
|
||||
self.last_total_time: str = "0"
|
||||
self.last_stop_time_secs = 0
|
||||
self.last_total_time_secs = 0
|
||||
self.current_media_title = ""
|
||||
|
||||
mpv_player = mpv.MPV(
|
||||
config=True,
|
||||
input_default_bindings=True,
|
||||
input_vo_keyboard=True,
|
||||
osc=True,
|
||||
)
|
||||
mpv_player.title = title
|
||||
|
||||
@mpv_player.on_key_press("shift+n")
|
||||
def _next_episode():
|
||||
url = self.get_episode("next")
|
||||
if url:
|
||||
mpv_player.loadfile(url, options=f"title={self.current_media_title}")
|
||||
mpv_player.title = self.current_media_title
|
||||
|
||||
@mpv_player.event_callback("file-loaded")
|
||||
def set_total_time(event, *args):
|
||||
d = mpv_player._get_property("duration")
|
||||
if isinstance(d, float):
|
||||
self.last_total_time = format_time(d)
|
||||
|
||||
@mpv_player.event_callback("shutdown")
|
||||
def set_total_time_on_shutdown(event, *args):
|
||||
d = mpv_player._get_property("duration")
|
||||
if isinstance(d, float):
|
||||
self.last_total_time = format_time(d)
|
||||
|
||||
@mpv_player.on_key_press("shift+p")
|
||||
def _previous_episode():
|
||||
url = self.get_episode("previous")
|
||||
if url:
|
||||
mpv_player.loadfile(
|
||||
url,
|
||||
)
|
||||
mpv_player.title = self.current_media_title
|
||||
|
||||
@mpv_player.on_key_press("shift+a")
|
||||
def _toggle_auto_next():
|
||||
config.auto_next = not config.auto_next
|
||||
if config.auto_next:
|
||||
mpv_player.show_text("Auto next enabled")
|
||||
else:
|
||||
mpv_player.show_text("Auto next disabled")
|
||||
|
||||
@mpv_player.on_key_press("shift+t")
|
||||
def _toggle_translation_type():
|
||||
translation_type = "sub" if config.translation_type == "dub" else "dub"
|
||||
anime = anime_provider.get_anime(
|
||||
anilist_config._anime["id"],
|
||||
anilist_config.selected_anime_anilist,
|
||||
)
|
||||
if not anime:
|
||||
mpv_player.show_text("Failed to update translation type")
|
||||
return
|
||||
anilist_config.episodes = anime["availableEpisodesDetail"][translation_type]
|
||||
config.translation_type = translation_type
|
||||
|
||||
if config.translation_type == "dub":
|
||||
mpv_player.show_text("Translation Type set to dub")
|
||||
else:
|
||||
mpv_player.show_text("Translation Type set to sub")
|
||||
|
||||
@mpv_player.on_key_press("shift+r")
|
||||
def _reload():
|
||||
url = self.get_episode("reload")
|
||||
if url:
|
||||
mpv_player.loadfile(
|
||||
url,
|
||||
)
|
||||
mpv_player.title = self.current_media_title
|
||||
|
||||
@mpv_player.property_observer("time-pos")
|
||||
def handle_time_start_update(*args):
|
||||
if len(args) > 1:
|
||||
value = args[1]
|
||||
if value is not None:
|
||||
self.last_stop_time_secs = value
|
||||
self.last_stop_time = format_time(value)
|
||||
|
||||
@mpv_player.property_observer("time-remaining")
|
||||
def handle_time_remaining_update(*args):
|
||||
if len(args) > 1:
|
||||
value = args[1]
|
||||
if value is not None:
|
||||
rem_time = value
|
||||
if rem_time < 10 and config.auto_next:
|
||||
url = self.get_episode("next")
|
||||
if url:
|
||||
mpv_player.loadfile(
|
||||
url,
|
||||
)
|
||||
mpv_player.title = self.current_media_title
|
||||
|
||||
@mpv_player.message_handler("select-episode")
|
||||
def select_episode(episode: bytes | None = None, *args):
|
||||
if not episode:
|
||||
return
|
||||
url = self.get_episode("custom", episode.decode())
|
||||
if url:
|
||||
mpv_player.loadfile(
|
||||
url,
|
||||
)
|
||||
mpv_player.title = self.current_media_title
|
||||
|
||||
mpv_player.register_message_handler("select-episode", select_episode)
|
||||
mpv_player.observe_property("time-pos", handle_time_start_update)
|
||||
mpv_player.register_event_callback(set_total_time)
|
||||
mpv_player.register_event_callback(set_total_time_on_shutdown)
|
||||
mpv_player.observe_property("time-remaining", handle_time_remaining_update)
|
||||
self.mpv_player = mpv_player
|
||||
return mpv_player
|
||||
|
||||
|
||||
player = MpvPlayer()
|
||||
@@ -1,24 +0,0 @@
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def print_img(url: str):
|
||||
executable = shutil.which("chafa")
|
||||
curl = shutil.which("curl")
|
||||
# curl -sL "$1" | chafa /dev/stdin
|
||||
|
||||
if executable is None or curl is None:
|
||||
print("chafa or curl not found")
|
||||
return
|
||||
|
||||
res = requests.get(url)
|
||||
if res.status_code != 200:
|
||||
print("Error fetching image")
|
||||
return
|
||||
img_bytes = res.content
|
||||
if not img_bytes:
|
||||
print("No image found")
|
||||
img_bytes = subprocess.check_output([curl, "-sL", url])
|
||||
subprocess.run([executable, url, "--size=15x15"], input=img_bytes)
|
||||
@@ -1,60 +0,0 @@
|
||||
class QueryDict(dict):
|
||||
"""dot.notation access to dictionary attributes"""
|
||||
|
||||
def __getattr__(self, attr):
|
||||
try:
|
||||
return self.__getitem__(attr)
|
||||
except KeyError:
|
||||
raise AttributeError(
|
||||
"%r object has no attribute %r" % (self.__class__.__name__, attr)
|
||||
)
|
||||
|
||||
def __setattr__(self, attr, value):
|
||||
self.__setitem__(attr, value)
|
||||
|
||||
|
||||
def exit_app(*args):
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
from ...constants import APP_NAME, ICON_PATH, USER_NAME
|
||||
|
||||
def is_running_in_terminal():
|
||||
try:
|
||||
shutil.get_terminal_size()
|
||||
return (
|
||||
sys.stdin.isatty()
|
||||
and sys.stdout.isatty()
|
||||
and os.getenv("TERM") is not None
|
||||
)
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
if not is_running_in_terminal():
|
||||
from plyer import notification
|
||||
|
||||
notification.notify(
|
||||
app_name=APP_NAME,
|
||||
app_icon=ICON_PATH,
|
||||
message=f"Have a good day {USER_NAME}",
|
||||
title="Shutting down",
|
||||
) # pyright:ignore
|
||||
else:
|
||||
from rich import print
|
||||
|
||||
print("Have a good day :smile:", USER_NAME)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def get_formatted_str(string: str, style):
|
||||
from rich.text import Text
|
||||
|
||||
# Create a Text object with desired style
|
||||
text = Text(string, style="bold red")
|
||||
|
||||
# Convert the Text object to an ANSI string
|
||||
ansi_output = text.__rich_console__(None, None) # pyright:ignore
|
||||
|
||||
# Join the ANSI strings to form the final output
|
||||
"".join(segment.text for segment in ansi_output)
|
||||
@@ -1,80 +0,0 @@
|
||||
import logging
|
||||
|
||||
from InquirerPy import inquirer
|
||||
from thefuzz import fuzz
|
||||
|
||||
from ...Utility.data import anime_normalizer
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Define ANSI escape codes as constants
|
||||
RESET = "\033[0m"
|
||||
BOLD = "\033[1m"
|
||||
INVISIBLE_CURSOR = "\033[?25l"
|
||||
VISIBLE_CURSOR = "\033[?25h"
|
||||
UNDERLINE = "\033[4m"
|
||||
|
||||
# ESC[38;2;{r};{g};{b}m
|
||||
BG_GREEN = "\033[48;2;120;233;12;m"
|
||||
GREEN = "\033[38;2;45;24;45;m"
|
||||
|
||||
|
||||
def sizeof_fmt(num, suffix="B"):
|
||||
for unit in ("", "K", "M", "G", "T", "P", "E", "Z"):
|
||||
if abs(num) < 1024.0:
|
||||
return f"{num:3.1f}{unit}{suffix}"
|
||||
num /= 1024.0
|
||||
return f"{num:.1f}Yi{suffix}"
|
||||
|
||||
|
||||
def get_true_fg(string: str, r: int, g: int, b: int, bold=True) -> str:
|
||||
if bold:
|
||||
return f"{BOLD}\033[38;2;{r};{g};{b};m{string}{RESET}"
|
||||
else:
|
||||
return f"\033[38;2;{r};{g};{b};m{string}{RESET}"
|
||||
|
||||
|
||||
def get_true_bg(string, r: int, g: int, b: int) -> str:
|
||||
return f"\033[48;2;{r};{g};{b};m{string}{RESET}"
|
||||
|
||||
|
||||
def fuzzy_inquirer(prompt: str, choices, **kwargs):
|
||||
from click import clear
|
||||
|
||||
clear()
|
||||
action = inquirer.fuzzy(
|
||||
prompt,
|
||||
choices,
|
||||
height="100%",
|
||||
border=True,
|
||||
validate=lambda result: result in choices,
|
||||
**kwargs,
|
||||
).execute()
|
||||
return action
|
||||
|
||||
|
||||
def anime_title_percentage_match(
|
||||
possible_user_requested_anime_title: str, title: tuple
|
||||
) -> float:
|
||||
"""Returns the percentage match between the possible title and user title
|
||||
|
||||
Args:
|
||||
possible_user_requested_anime_title (str): an Animdl search result title
|
||||
title (str): the anime title the user wants
|
||||
|
||||
Returns:
|
||||
int: the percentage match
|
||||
"""
|
||||
if normalized_anime_title := anime_normalizer.get(
|
||||
possible_user_requested_anime_title
|
||||
):
|
||||
possible_user_requested_anime_title = normalized_anime_title
|
||||
for key, value in locals().items():
|
||||
logger.info(f"{key}: {value}")
|
||||
# compares both the romaji and english names and gets highest Score
|
||||
percentage_ratio = max(
|
||||
fuzz.ratio(title[0].lower(), possible_user_requested_anime_title.lower()),
|
||||
fuzz.ratio(title[1].lower(), possible_user_requested_anime_title.lower()),
|
||||
)
|
||||
return percentage_ratio
|
||||
@@ -1,40 +0,0 @@
|
||||
import os
|
||||
from platform import system
|
||||
|
||||
from platformdirs import PlatformDirs
|
||||
|
||||
from . import APP_NAME, AUTHOR
|
||||
|
||||
PLATFORM = system()
|
||||
dirs = PlatformDirs(appname=APP_NAME, appauthor=AUTHOR, ensure_exists=True)
|
||||
|
||||
|
||||
# ---- app deps ----
|
||||
APP_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||
CONFIGS_DIR = os.path.join(APP_DIR, "configs")
|
||||
ASSETS_DIR = os.path.join(APP_DIR, "assets")
|
||||
|
||||
|
||||
# --- icon stuff ---
|
||||
if PLATFORM == "Windows":
|
||||
ICON_PATH = os.path.join(ASSETS_DIR, "logo.ico")
|
||||
else:
|
||||
ICON_PATH = os.path.join(ASSETS_DIR, "logo.png")
|
||||
|
||||
# ----- user configs and data -----
|
||||
APP_DATA_DIR = dirs.user_config_dir
|
||||
if not APP_DATA_DIR:
|
||||
APP_DATA_DIR = dirs.user_data_dir
|
||||
|
||||
USER_DATA_PATH = os.path.join(APP_DATA_DIR, "user_data.json")
|
||||
USER_CONFIG_PATH = os.path.join(APP_DATA_DIR, "config.ini")
|
||||
NOTIFIER_LOG_FILE_PATH = os.path.join(APP_DATA_DIR, "notifier.log")
|
||||
|
||||
# cache dir
|
||||
APP_CACHE_DIR = dirs.user_cache_dir
|
||||
|
||||
# video dir
|
||||
USER_VIDEOS_DIR = os.path.join(dirs.user_videos_dir, APP_NAME)
|
||||
|
||||
|
||||
USER_NAME = os.environ.get("USERNAME", "Anime fun")
|
||||
@@ -1,3 +0,0 @@
|
||||
"""
|
||||
his module contains an abstraction for interaction with the anilist api making it easy and efficient
|
||||
"""
|
||||
@@ -1,393 +0,0 @@
|
||||
"""
|
||||
This is the core module availing all the abstractions of the anilist api
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import requests
|
||||
|
||||
from .queries_graphql import (
|
||||
airing_schedule_query,
|
||||
anime_characters_query,
|
||||
anime_query,
|
||||
anime_relations_query,
|
||||
delete_list_entry_query,
|
||||
get_logged_in_user_query,
|
||||
get_medialist_item_query,
|
||||
media_list_mutation,
|
||||
media_list_query,
|
||||
most_favourite_query,
|
||||
most_popular_query,
|
||||
most_recently_updated_query,
|
||||
most_scored_query,
|
||||
notification_query,
|
||||
recommended_query,
|
||||
search_query,
|
||||
trending_query,
|
||||
upcoming_anime_query,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .anilist_data_schema import (
|
||||
AnilistDataSchema,
|
||||
AnilistMediaLists,
|
||||
AnilistMediaListStatus,
|
||||
AnilistNotifications,
|
||||
AnilistUser,
|
||||
AnilistUserData,
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
ANILIST_ENDPOINT = "https://graphql.anilist.co"
|
||||
|
||||
|
||||
class AniListApi:
|
||||
"""An abstraction over the anilist api offering an easy and simple interface
|
||||
|
||||
Attributes:
|
||||
session: [TODO:attribute]
|
||||
session: [TODO:attribute]
|
||||
token: [TODO:attribute]
|
||||
headers: [TODO:attribute]
|
||||
user_id: [TODO:attribute]
|
||||
token: [TODO:attribute]
|
||||
headers: [TODO:attribute]
|
||||
user_id: [TODO:attribute]
|
||||
"""
|
||||
|
||||
session: requests.Session
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.session = requests.session()
|
||||
|
||||
def login_user(self, token: str):
|
||||
"""methosd used to login a new user enabling authenticated requests
|
||||
|
||||
Args:
|
||||
token: anilist app token
|
||||
|
||||
Returns:
|
||||
the logged in user
|
||||
"""
|
||||
self.token = token
|
||||
self.headers = {"Authorization": f"Bearer {self.token}"}
|
||||
self.session.headers.update(self.headers)
|
||||
success, user = self.get_logged_in_user()
|
||||
if not user:
|
||||
return
|
||||
if not success or not user:
|
||||
return
|
||||
user_info: AnilistUser = user["data"]["Viewer"]
|
||||
self.user_id = user_info["id"]
|
||||
return user_info
|
||||
|
||||
def get_notification(
|
||||
self,
|
||||
) -> tuple[bool, "AnilistNotifications"] | tuple[bool, None]:
|
||||
"""get the top five latest notifications for anime thats airing
|
||||
|
||||
Returns:
|
||||
airing notifications
|
||||
"""
|
||||
return self._make_authenticated_request(notification_query)
|
||||
|
||||
def update_login_info(self, user: "AnilistUser", token: str):
|
||||
"""method used to login a user enabling authenticated requests
|
||||
|
||||
Args:
|
||||
user: an anilist user object
|
||||
token: the login token
|
||||
"""
|
||||
self.token = token
|
||||
self.headers = {"Authorization": f"Bearer {self.token}"}
|
||||
self.session.headers.update(self.headers)
|
||||
self.user_id = user["id"]
|
||||
|
||||
def get_logged_in_user(self) -> tuple[bool, "AnilistUserData"] | tuple[bool, None]:
|
||||
"""get the details of the user who is currently logged in
|
||||
|
||||
Returns:
|
||||
an anilist user
|
||||
"""
|
||||
if not self.headers:
|
||||
return (False, None)
|
||||
return self._make_authenticated_request(get_logged_in_user_query)
|
||||
|
||||
def update_anime_list(self, values_to_update: dict):
|
||||
"""a powerful method for managing mediaLists giving full power to the user
|
||||
|
||||
Args:
|
||||
values_to_update: a dict containing valid media list options
|
||||
|
||||
Returns:
|
||||
an anilist object indicating success
|
||||
"""
|
||||
variables = {"userId": self.user_id, **values_to_update}
|
||||
return self._make_authenticated_request(media_list_mutation, variables)
|
||||
|
||||
def get_anime_list(
|
||||
self, status: "AnilistMediaListStatus"
|
||||
) -> tuple[bool, "AnilistMediaLists"] | tuple[bool, None]:
|
||||
"""gets an anime list from your media list given the list status
|
||||
|
||||
Args:
|
||||
status: the mediaListStatus of the anime list
|
||||
|
||||
Returns:
|
||||
a media list
|
||||
"""
|
||||
variables = {"status": status, "userId": self.user_id}
|
||||
return self._make_authenticated_request(media_list_query, variables)
|
||||
|
||||
def get_medialist_entry(
|
||||
self, mediaId: int
|
||||
) -> tuple[bool, dict] | tuple[bool, None]:
|
||||
"""Get the id entry of the items in an Anilist MediaList
|
||||
|
||||
Args:
|
||||
mediaId: The mediaList item entry mediaId
|
||||
|
||||
Returns:
|
||||
a boolean indicating whether the request succeeded and either a dict object containing the id of the media list entry
|
||||
"""
|
||||
variables = {"mediaId": mediaId}
|
||||
return self._make_authenticated_request(get_medialist_item_query, variables)
|
||||
|
||||
def delete_medialist_entry(self, mediaId: int):
|
||||
"""Deletes a mediaList item given its mediaId
|
||||
|
||||
Args:
|
||||
mediaId: the media id of the anime
|
||||
|
||||
Returns:
|
||||
a tuple containing a boolean whether the operation was successful and either an anilist object or none depending on success
|
||||
"""
|
||||
result = self.get_medialist_entry(mediaId)
|
||||
data = result[1]
|
||||
if not result[0] or not data:
|
||||
return result
|
||||
id = data["data"]["MediaList"]["id"]
|
||||
variables = {"id": id}
|
||||
return self._make_authenticated_request(delete_list_entry_query, variables)
|
||||
|
||||
# TODO: unify the _make_authenticated_request with original since sessions are now in use
|
||||
def _make_authenticated_request(self, query: str, variables: dict = {}):
|
||||
"""the abstraction over all authenticated requests
|
||||
|
||||
Args:
|
||||
query: the anilist query to make
|
||||
variables: the anilist variables to use
|
||||
|
||||
Returns:
|
||||
an anilist object containing the queried data or none and a boolean indicating whether the request was successful
|
||||
"""
|
||||
try:
|
||||
response = self.session.post(
|
||||
ANILIST_ENDPOINT,
|
||||
json={"query": query, "variables": variables},
|
||||
timeout=10,
|
||||
headers=self.headers,
|
||||
)
|
||||
anilist_data = response.json()
|
||||
|
||||
# ensuring you dont get blocked
|
||||
if (
|
||||
int(response.headers.get("X-RateLimit-Remaining", 0)) < 30
|
||||
and not response.status_code == 500
|
||||
):
|
||||
print(
|
||||
"Warning you are exceeding the allowed number of calls per minute"
|
||||
)
|
||||
logger.warning(
|
||||
"You are exceeding the allowed number of calls per minute for the AniList api enforcing timeout"
|
||||
)
|
||||
print("Forced timeout will now be initiated")
|
||||
import time
|
||||
|
||||
print("sleeping...")
|
||||
time.sleep(1 * 60)
|
||||
if response.status_code == 200:
|
||||
return (True, anilist_data)
|
||||
else:
|
||||
return (False, anilist_data)
|
||||
except requests.exceptions.Timeout:
|
||||
logger.warning(
|
||||
"Timeout has been exceeded this could mean anilist is down or you have lost internet connection"
|
||||
)
|
||||
return (False, None)
|
||||
except requests.exceptions.ConnectionError:
|
||||
logger.warning(
|
||||
"ConnectionError this could mean anilist is down or you have lost internet connection"
|
||||
)
|
||||
return (False, None)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Something unexpected occured {e}")
|
||||
return (False, None) # type: ignore
|
||||
|
||||
def get_data(
|
||||
self, query: str, variables: dict = {}
|
||||
) -> tuple[bool, "AnilistDataSchema"]:
|
||||
"""the abstraction over all none authenticated requests and that returns data of a similar type
|
||||
|
||||
Args:
|
||||
query: the anilist query
|
||||
variables: the anilist api variables
|
||||
|
||||
Returns:
|
||||
a boolean indicating success and none or an anilist object depending on success
|
||||
"""
|
||||
try:
|
||||
response = self.session.post(
|
||||
ANILIST_ENDPOINT,
|
||||
json={"query": query, "variables": variables},
|
||||
timeout=10,
|
||||
)
|
||||
anilist_data: AnilistDataSchema = response.json()
|
||||
|
||||
# ensuring you dont get blocked
|
||||
if (
|
||||
int(response.headers.get("X-RateLimit-Remaining", 0)) < 30
|
||||
and not response.status_code == 500
|
||||
):
|
||||
print(
|
||||
"Warning you are exceeding the allowed number of calls per minute"
|
||||
)
|
||||
logger.warning(
|
||||
"You are exceeding the allowed number of calls per minute for the AniList api enforcing timeout"
|
||||
)
|
||||
print("Forced timeout will now be initiated")
|
||||
import time
|
||||
|
||||
print("sleeping...")
|
||||
time.sleep(1 * 60)
|
||||
if response.status_code == 200:
|
||||
return (True, anilist_data)
|
||||
else:
|
||||
return (False, anilist_data)
|
||||
except requests.exceptions.Timeout:
|
||||
logger.warning(
|
||||
"Timeout has been exceeded this could mean anilist is down or you have lost internet connection"
|
||||
)
|
||||
return (
|
||||
False,
|
||||
{
|
||||
"Error": "Timeout Exceeded for connection there might be a problem with your internet or anilist is down."
|
||||
},
|
||||
) # type: ignore
|
||||
except requests.exceptions.ConnectionError:
|
||||
logger.warning(
|
||||
"ConnectionError this could mean anilist is down or you have lost internet connection"
|
||||
)
|
||||
return (
|
||||
False,
|
||||
{
|
||||
"Error": "There might be a problem with your internet or anilist is down."
|
||||
},
|
||||
) # type: ignore
|
||||
except Exception as e:
|
||||
logger.error(f"Something unexpected occured {e}")
|
||||
return (False, {"Error": f"{e}"}) # type: ignore
|
||||
|
||||
def search(
|
||||
self,
|
||||
query: str | None = None,
|
||||
sort: str | None = None,
|
||||
genre_in: list[str] | None = None,
|
||||
id_in: list[int] | None = None,
|
||||
genre_not_in: list[str] = ["hentai"],
|
||||
popularity_greater: int | None = None,
|
||||
popularity_lesser: int | None = None,
|
||||
averageScore_greater: int | None = None,
|
||||
averageScore_lesser: int | None = None,
|
||||
tag_in: list[str] | None = None,
|
||||
tag_not_in: list[str] | None = None,
|
||||
status: str | None = None,
|
||||
status_in: list[str] | None = None,
|
||||
status_not_in: list[str] | None = None,
|
||||
endDate_greater: int | None = None,
|
||||
endDate_lesser: int | None = None,
|
||||
start_greater: int | None = None,
|
||||
start_lesser: int | None = None,
|
||||
page: int | None = None,
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
A powerful method abstracting all of anilist media queries
|
||||
"""
|
||||
variables = {}
|
||||
for key, val in list(locals().items())[1:]:
|
||||
if val is not None and key not in ["variables"]:
|
||||
variables[key] = val
|
||||
search_results = self.get_data(search_query, variables=variables)
|
||||
return search_results
|
||||
|
||||
def get_anime(self, id: int):
|
||||
"""
|
||||
Gets a single anime by a valid anilist anime id
|
||||
"""
|
||||
variables = {"id": id}
|
||||
return self.get_data(anime_query, variables)
|
||||
|
||||
def get_trending(self, *_, **kwargs):
|
||||
"""
|
||||
Gets the currently trending anime
|
||||
"""
|
||||
trending = self.get_data(trending_query)
|
||||
return trending
|
||||
|
||||
def get_most_favourite(self, *_, **kwargs):
|
||||
"""
|
||||
Gets the most favoured anime on anilist
|
||||
"""
|
||||
most_favourite = self.get_data(most_favourite_query)
|
||||
return most_favourite
|
||||
|
||||
def get_most_scored(self, *_, **kwargs):
|
||||
"""
|
||||
Gets most scored anime on anilist
|
||||
"""
|
||||
most_scored = self.get_data(most_scored_query)
|
||||
return most_scored
|
||||
|
||||
def get_most_recently_updated(self, *_, **kwargs):
|
||||
"""
|
||||
Gets most recently updated anime from anilist
|
||||
"""
|
||||
most_recently_updated = self.get_data(most_recently_updated_query)
|
||||
return most_recently_updated
|
||||
|
||||
def get_most_popular(self):
|
||||
"""
|
||||
Gets most popular anime on anilist
|
||||
"""
|
||||
most_popular = self.get_data(most_popular_query)
|
||||
return most_popular
|
||||
|
||||
def get_upcoming_anime(self, page: int = 1, *_, **kwargs):
|
||||
"""
|
||||
Gets upcoming anime from anilist
|
||||
"""
|
||||
variables = {"page": page}
|
||||
upcoming_anime = self.get_data(upcoming_anime_query, variables)
|
||||
return upcoming_anime
|
||||
|
||||
# NOTE: THe following methods will probably be scraped soon
|
||||
def get_recommended_anime_for(self, id: int, *_, **kwargs):
|
||||
recommended_anime = self.get_data(recommended_query)
|
||||
return recommended_anime
|
||||
|
||||
def get_charcters_of(self, id: int, *_, **kwargs):
|
||||
variables = {"id": id}
|
||||
characters = self.get_data(anime_characters_query, variables)
|
||||
return characters
|
||||
|
||||
def get_related_anime_for(self, id: int, *_, **kwargs):
|
||||
variables = {"id": id}
|
||||
related_anime = self.get_data(anime_relations_query, variables)
|
||||
return related_anime
|
||||
|
||||
def get_airing_schedule_for(self, id: int, *_, **kwargs):
|
||||
variables = {"id": id}
|
||||
airing_schedule = self.get_data(airing_schedule_query, variables)
|
||||
return airing_schedule
|
||||
@@ -1,979 +0,0 @@
|
||||
"""
|
||||
This module contains all the preset queries for the sake of neatness and convinience
|
||||
Mostly for internal usage
|
||||
"""
|
||||
|
||||
# TODO: Format the queries
|
||||
mark_as_read_mutation = """
|
||||
mutation{
|
||||
UpdateUser{
|
||||
unreadNotificationCount
|
||||
}
|
||||
}
|
||||
"""
|
||||
reviews_query = """
|
||||
query($id:Int){
|
||||
Page{
|
||||
pageInfo{
|
||||
total
|
||||
}
|
||||
|
||||
reviews(mediaId:$id){
|
||||
summary
|
||||
user{
|
||||
name
|
||||
avatar {
|
||||
large
|
||||
medium
|
||||
}
|
||||
}
|
||||
body
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
notification_query = """
|
||||
query{
|
||||
Page(perPage:5){
|
||||
pageInfo {
|
||||
total
|
||||
}
|
||||
notifications(resetNotificationCount:true,type:AIRING) {
|
||||
... on AiringNotification {
|
||||
id
|
||||
type
|
||||
episode
|
||||
contexts
|
||||
createdAt
|
||||
media {
|
||||
id
|
||||
idMal
|
||||
title {
|
||||
romaji
|
||||
english
|
||||
}
|
||||
coverImage{
|
||||
medium
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
get_medialist_item_query = """
|
||||
query($mediaId:Int){
|
||||
MediaList(mediaId:$mediaId){
|
||||
id
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
delete_list_entry_query = """
|
||||
mutation($id:Int){
|
||||
DeleteMediaListEntry(id:$id){
|
||||
deleted
|
||||
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
get_logged_in_user_query = """
|
||||
query{
|
||||
Viewer{
|
||||
id
|
||||
name
|
||||
bannerImage
|
||||
avatar {
|
||||
large
|
||||
medium
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
media_list_mutation = """
|
||||
mutation($mediaId:Int,$scoreRaw:Int,$repeat:Int,$progress:Int,$status:MediaListStatus){
|
||||
SaveMediaListEntry(mediaId:$mediaId,scoreRaw:$scoreRaw,progress:$progress,repeat:$repeat,status:$status){
|
||||
id
|
||||
status
|
||||
mediaId
|
||||
score
|
||||
progress
|
||||
repeat
|
||||
startedAt {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
completedAt {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
media_list_query = """
|
||||
query ($userId: Int, $status: MediaListStatus) {
|
||||
Page {
|
||||
pageInfo {
|
||||
currentPage
|
||||
total
|
||||
}
|
||||
mediaList(userId: $userId, status: $status, type: ANIME) {
|
||||
mediaId
|
||||
|
||||
media {
|
||||
id
|
||||
idMal
|
||||
title {
|
||||
romaji
|
||||
english
|
||||
}
|
||||
coverImage {
|
||||
medium
|
||||
large
|
||||
}
|
||||
trailer {
|
||||
site
|
||||
id
|
||||
}
|
||||
popularity
|
||||
favourites
|
||||
averageScore
|
||||
episodes
|
||||
genres
|
||||
studios {
|
||||
nodes {
|
||||
name
|
||||
isAnimationStudio
|
||||
}
|
||||
}
|
||||
tags {
|
||||
name
|
||||
}
|
||||
startDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
endDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
status
|
||||
description
|
||||
mediaListEntry{
|
||||
id
|
||||
progress
|
||||
}
|
||||
nextAiringEpisode {
|
||||
timeUntilAiring
|
||||
airingAt
|
||||
episode
|
||||
}
|
||||
}
|
||||
status
|
||||
progress
|
||||
score
|
||||
repeat
|
||||
notes
|
||||
startedAt {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
completedAt {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
createdAt
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
optional_variables = "\
|
||||
$page:Int,\
|
||||
$sort:[MediaSort],\
|
||||
$id_in:[Int],\
|
||||
$genre_in:[String],\
|
||||
$genre_not_in:[String],\
|
||||
$tag_in:[String],\
|
||||
$tag_not_in:[String],\
|
||||
$status_in:[MediaStatus],\
|
||||
$status:MediaStatus,\
|
||||
$status_not_in:[MediaStatus],\
|
||||
$popularity_greater:Int,\
|
||||
$popularity_lesser:Int,\
|
||||
$averageScore_greater:Int,\
|
||||
$averageScore_lesser:Int,\
|
||||
$startDate_greater:FuzzyDateInt,\
|
||||
$startDate_lesser:FuzzyDateInt,\
|
||||
$endDate_greater:FuzzyDateInt,\
|
||||
$endDate_lesser:FuzzyDateInt\
|
||||
"
|
||||
# FuzzyDateInt = (yyyymmdd)
|
||||
# MediaStatus = (FINISHED,RELEASING,NOT_YET_RELEASED,CANCELLED,HIATUS)
|
||||
search_query = (
|
||||
"""
|
||||
query($query:String,%s){
|
||||
Page(perPage:30,page:$page){
|
||||
pageInfo{
|
||||
total
|
||||
currentPage
|
||||
hasNextPage
|
||||
}
|
||||
media(
|
||||
search:$query,
|
||||
id_in:$id_in,
|
||||
genre_in:$genre_in,
|
||||
genre_not_in:$genre_not_in,
|
||||
tag_in:$tag_in,
|
||||
tag_not_in:$tag_not_in,
|
||||
status_in:$status_in,
|
||||
status:$status,
|
||||
status_not_in:$status_not_in,
|
||||
popularity_greater:$popularity_greater,
|
||||
popularity_lesser:$popularity_lesser,
|
||||
averageScore_greater:$averageScore_greater,
|
||||
averageScore_lesser:$averageScore_lesser,
|
||||
startDate_greater:$startDate_greater,
|
||||
startDate_lesser:$startDate_lesser,
|
||||
endDate_greater:$endDate_greater,
|
||||
endDate_lesser:$endDate_lesser,
|
||||
sort:$sort,
|
||||
type:ANIME
|
||||
)
|
||||
{
|
||||
id
|
||||
idMal
|
||||
title{
|
||||
romaji
|
||||
english
|
||||
}
|
||||
coverImage{
|
||||
medium
|
||||
large
|
||||
}
|
||||
trailer {
|
||||
site
|
||||
id
|
||||
|
||||
}
|
||||
mediaListEntry{
|
||||
id
|
||||
progress
|
||||
}
|
||||
popularity
|
||||
favourites
|
||||
averageScore
|
||||
episodes
|
||||
genres
|
||||
studios{
|
||||
nodes{
|
||||
name
|
||||
isAnimationStudio
|
||||
}
|
||||
}
|
||||
tags {
|
||||
name
|
||||
}
|
||||
startDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
endDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
status
|
||||
description
|
||||
nextAiringEpisode {
|
||||
timeUntilAiring
|
||||
airingAt
|
||||
episode
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
% optional_variables
|
||||
)
|
||||
|
||||
trending_query = """
|
||||
query{
|
||||
Page(perPage:15){
|
||||
|
||||
media(sort:TRENDING_DESC,type:ANIME,genre_not_in:["hentai"]){
|
||||
id
|
||||
idMal
|
||||
title{
|
||||
romaji
|
||||
english
|
||||
}
|
||||
coverImage{
|
||||
medium
|
||||
large
|
||||
}
|
||||
trailer {
|
||||
site
|
||||
id
|
||||
}
|
||||
popularity
|
||||
favourites
|
||||
averageScore
|
||||
genres
|
||||
episodes
|
||||
description
|
||||
studios {
|
||||
nodes {
|
||||
name
|
||||
isAnimationStudio
|
||||
}
|
||||
}
|
||||
tags {
|
||||
name
|
||||
}
|
||||
startDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
mediaListEntry{
|
||||
id
|
||||
progress
|
||||
}
|
||||
endDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
status
|
||||
nextAiringEpisode {
|
||||
timeUntilAiring
|
||||
airingAt
|
||||
episode
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
# mosts
|
||||
most_favourite_query = """
|
||||
query{
|
||||
Page(perPage:15){
|
||||
media(sort:FAVOURITES_DESC,type:ANIME,genre_not_in:["hentai"]){
|
||||
id
|
||||
idMal
|
||||
title{
|
||||
romaji
|
||||
english
|
||||
}
|
||||
coverImage{
|
||||
medium
|
||||
large
|
||||
}
|
||||
trailer {
|
||||
site
|
||||
id
|
||||
|
||||
}
|
||||
mediaListEntry{
|
||||
id
|
||||
progress
|
||||
}
|
||||
popularity
|
||||
favourites
|
||||
averageScore
|
||||
episodes
|
||||
description
|
||||
genres
|
||||
studios {
|
||||
nodes {
|
||||
name
|
||||
isAnimationStudio
|
||||
}
|
||||
}
|
||||
tags {
|
||||
name
|
||||
}
|
||||
startDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
endDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
status
|
||||
nextAiringEpisode {
|
||||
timeUntilAiring
|
||||
airingAt
|
||||
episode
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
most_scored_query = """
|
||||
query{
|
||||
Page(perPage:15){
|
||||
media(sort:SCORE_DESC,type:ANIME,genre_not_in:["hentai"]){
|
||||
id
|
||||
idMal
|
||||
title{
|
||||
romaji
|
||||
english
|
||||
}
|
||||
coverImage{
|
||||
medium
|
||||
large
|
||||
}
|
||||
trailer {
|
||||
site
|
||||
id
|
||||
|
||||
}
|
||||
mediaListEntry{
|
||||
id
|
||||
progress
|
||||
}
|
||||
popularity
|
||||
episodes
|
||||
favourites
|
||||
averageScore
|
||||
description
|
||||
genres
|
||||
studios {
|
||||
nodes {
|
||||
name
|
||||
isAnimationStudio
|
||||
}
|
||||
}
|
||||
tags {
|
||||
name
|
||||
}
|
||||
startDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
endDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
status
|
||||
nextAiringEpisode {
|
||||
timeUntilAiring
|
||||
airingAt
|
||||
episode
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
most_popular_query = """
|
||||
query{
|
||||
Page(perPage:15){
|
||||
media(sort:POPULARITY_DESC,type:ANIME,genre_not_in:["hentai"]){
|
||||
id
|
||||
idMal
|
||||
title{
|
||||
romaji
|
||||
english
|
||||
}
|
||||
coverImage{
|
||||
medium
|
||||
large
|
||||
}
|
||||
trailer {
|
||||
site
|
||||
id
|
||||
|
||||
}
|
||||
popularity
|
||||
favourites
|
||||
averageScore
|
||||
description
|
||||
episodes
|
||||
genres
|
||||
mediaListEntry{
|
||||
id
|
||||
progress
|
||||
}
|
||||
studios {
|
||||
nodes {
|
||||
name
|
||||
isAnimationStudio
|
||||
}
|
||||
}
|
||||
tags {
|
||||
name
|
||||
}
|
||||
startDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
endDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
status
|
||||
nextAiringEpisode {
|
||||
timeUntilAiring
|
||||
airingAt
|
||||
episode
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
most_recently_updated_query = """
|
||||
query{
|
||||
Page(perPage:15){
|
||||
media(sort:UPDATED_AT_DESC,type:ANIME,averageScore_greater:50,genre_not_in:["hentai"],status:RELEASING){
|
||||
id
|
||||
idMal
|
||||
title{
|
||||
romaji
|
||||
english
|
||||
}
|
||||
coverImage{
|
||||
medium
|
||||
large
|
||||
}
|
||||
trailer {
|
||||
site
|
||||
id
|
||||
}
|
||||
mediaListEntry{
|
||||
id
|
||||
progress
|
||||
}
|
||||
popularity
|
||||
favourites
|
||||
averageScore
|
||||
description
|
||||
genres
|
||||
episodes
|
||||
studios {
|
||||
nodes {
|
||||
name
|
||||
isAnimationStudio
|
||||
}
|
||||
}
|
||||
tags {
|
||||
name
|
||||
}
|
||||
startDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
endDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
status
|
||||
nextAiringEpisode {
|
||||
timeUntilAiring
|
||||
airingAt
|
||||
episode
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
recommended_query = """
|
||||
query {
|
||||
Page(perPage:15) {
|
||||
media( type: ANIME,genre_not_in:["hentai"]) {
|
||||
recommendations(sort:RATING_DESC){
|
||||
nodes{
|
||||
media{
|
||||
id
|
||||
idMal
|
||||
title{
|
||||
english
|
||||
romaji
|
||||
native
|
||||
}
|
||||
coverImage{
|
||||
medium
|
||||
large
|
||||
}
|
||||
mediaListEntry{
|
||||
id
|
||||
progress
|
||||
}
|
||||
description
|
||||
episodes
|
||||
trailer{
|
||||
site
|
||||
id
|
||||
}
|
||||
|
||||
genres
|
||||
averageScore
|
||||
popularity
|
||||
favourites
|
||||
tags {
|
||||
name
|
||||
}
|
||||
startDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
endDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
status
|
||||
nextAiringEpisode {
|
||||
timeUntilAiring
|
||||
airingAt
|
||||
episode
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
anime_characters_query = """
|
||||
query($id:Int){
|
||||
Page {
|
||||
media(id:$id, type: ANIME) {
|
||||
characters {
|
||||
nodes {
|
||||
name {
|
||||
first
|
||||
middle
|
||||
last
|
||||
full
|
||||
native
|
||||
}
|
||||
image {
|
||||
medium
|
||||
large
|
||||
}
|
||||
description
|
||||
gender
|
||||
dateOfBirth {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
age
|
||||
bloodType
|
||||
favourites
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
anime_relations_query = """
|
||||
query ($id: Int) {
|
||||
Page(perPage: 20) {
|
||||
media(id: $id, sort: POPULARITY_DESC, type: ANIME,genre_not_in:["hentai"]) {
|
||||
relations {
|
||||
nodes {
|
||||
id
|
||||
idMal
|
||||
title {
|
||||
english
|
||||
romaji
|
||||
native
|
||||
}
|
||||
coverImage {
|
||||
medium
|
||||
large
|
||||
}
|
||||
mediaListEntry{
|
||||
id
|
||||
progress
|
||||
}
|
||||
description
|
||||
episodes
|
||||
trailer {
|
||||
site
|
||||
id
|
||||
}
|
||||
genres
|
||||
averageScore
|
||||
popularity
|
||||
favourites
|
||||
tags {
|
||||
name
|
||||
}
|
||||
startDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
endDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
status
|
||||
nextAiringEpisode {
|
||||
timeUntilAiring
|
||||
airingAt
|
||||
episode
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
airing_schedule_query = """
|
||||
query ($id: Int) {
|
||||
Page {
|
||||
media(id: $id, sort: POPULARITY_DESC, type: ANIME) {
|
||||
airingSchedule(notYetAired:true){
|
||||
nodes{
|
||||
airingAt
|
||||
timeUntilAiring
|
||||
episode
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
upcoming_anime_query = """
|
||||
query ($page: Int) {
|
||||
Page(page: $page) {
|
||||
pageInfo {
|
||||
total
|
||||
perPage
|
||||
currentPage
|
||||
hasNextPage
|
||||
}
|
||||
media(type: ANIME, status: NOT_YET_RELEASED,sort:POPULARITY_DESC,genre_not_in:["hentai"]) {
|
||||
id
|
||||
idMal
|
||||
title {
|
||||
romaji
|
||||
english
|
||||
}
|
||||
coverImage {
|
||||
medium
|
||||
large
|
||||
}
|
||||
trailer {
|
||||
site
|
||||
id
|
||||
}
|
||||
mediaListEntry{
|
||||
id
|
||||
progress
|
||||
}
|
||||
popularity
|
||||
favourites
|
||||
averageScore
|
||||
genres
|
||||
episodes
|
||||
description
|
||||
studios {
|
||||
nodes {
|
||||
name
|
||||
isAnimationStudio
|
||||
}
|
||||
}
|
||||
tags {
|
||||
name
|
||||
}
|
||||
startDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
endDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
status
|
||||
nextAiringEpisode {
|
||||
timeUntilAiring
|
||||
airingAt
|
||||
episode
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
anime_query = """
|
||||
query($id:Int){
|
||||
Page{
|
||||
media(id:$id) {
|
||||
id
|
||||
idMal
|
||||
title {
|
||||
romaji
|
||||
english
|
||||
}
|
||||
mediaListEntry{
|
||||
id
|
||||
progress
|
||||
}
|
||||
nextAiringEpisode {
|
||||
timeUntilAiring
|
||||
airingAt
|
||||
episode
|
||||
}
|
||||
coverImage {
|
||||
extraLarge
|
||||
}
|
||||
characters(perPage: 5, sort: FAVOURITES_DESC) {
|
||||
edges {
|
||||
node {
|
||||
name {
|
||||
full
|
||||
|
||||
}
|
||||
gender
|
||||
dateOfBirth {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
age
|
||||
image {
|
||||
medium
|
||||
large
|
||||
}
|
||||
description
|
||||
}
|
||||
voiceActors {
|
||||
name {
|
||||
full
|
||||
}
|
||||
image {
|
||||
medium
|
||||
large
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
studios {
|
||||
nodes {
|
||||
name
|
||||
isAnimationStudio
|
||||
}
|
||||
}
|
||||
season
|
||||
format
|
||||
status
|
||||
seasonYear
|
||||
description
|
||||
genres
|
||||
synonyms
|
||||
startDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
endDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
duration
|
||||
countryOfOrigin
|
||||
averageScore
|
||||
popularity
|
||||
favourites
|
||||
source
|
||||
hashtag
|
||||
siteUrl
|
||||
tags {
|
||||
name
|
||||
rank
|
||||
}
|
||||
reviews(sort: SCORE_DESC, perPage: 3) {
|
||||
nodes {
|
||||
summary
|
||||
user {
|
||||
name
|
||||
avatar {
|
||||
medium
|
||||
large
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
recommendations(sort: RATING_DESC, perPage: 10) {
|
||||
nodes {
|
||||
mediaRecommendation {
|
||||
title {
|
||||
romaji
|
||||
english
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
relations {
|
||||
nodes {
|
||||
title {
|
||||
romaji
|
||||
english
|
||||
native
|
||||
}
|
||||
}
|
||||
}
|
||||
externalLinks {
|
||||
url
|
||||
site
|
||||
icon
|
||||
}
|
||||
rankings {
|
||||
rank
|
||||
context
|
||||
}
|
||||
bannerImage
|
||||
episodes
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
@@ -1,5 +0,0 @@
|
||||
anime_sources = {
|
||||
"allanime": "api.AllAnimeAPI",
|
||||
"animepahe": "api.AnimePaheApi",
|
||||
"aniwatch": "api.AniWatchApi",
|
||||
}
|
||||
@@ -1,350 +0,0 @@
|
||||
"""a module that handles the scraping of allanime
|
||||
|
||||
abstraction over allanime api
|
||||
"""
|
||||
|
||||
import json
|
||||
import logging
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from requests.exceptions import Timeout
|
||||
|
||||
from ...anime_provider.base_provider import AnimeProvider
|
||||
from ..utils import decode_hex_string
|
||||
from .constants import (
|
||||
ALLANIME_API_ENDPOINT,
|
||||
ALLANIME_BASE,
|
||||
ALLANIME_REFERER,
|
||||
USER_AGENT,
|
||||
)
|
||||
from .gql_queries import ALLANIME_EPISODES_GQL, ALLANIME_SEARCH_GQL, ALLANIME_SHOW_GQL
|
||||
from .normalizer import normalize_anime, normalize_search_results
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Iterator
|
||||
|
||||
from ....libs.anime_provider.allanime.types import AllAnimeEpisode
|
||||
from ....libs.anime_provider.types import Anime, Server
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# TODO: create tests for the api
|
||||
#
|
||||
# ** Based on ani-cli **
|
||||
class AllAnimeAPI(AnimeProvider):
|
||||
"""
|
||||
Provides a fast and effective interface to AllAnime site.
|
||||
"""
|
||||
|
||||
api_endpoint = ALLANIME_API_ENDPOINT
|
||||
|
||||
def _fetch_gql(self, query: str, variables: dict):
|
||||
"""main abstraction over all requests to the allanime api
|
||||
|
||||
Args:
|
||||
query: [TODO:description]
|
||||
variables: [TODO:description]
|
||||
|
||||
Returns:
|
||||
[TODO:return]
|
||||
"""
|
||||
try:
|
||||
response = self.session.get(
|
||||
self.api_endpoint,
|
||||
params={
|
||||
"variables": json.dumps(variables),
|
||||
"query": query,
|
||||
},
|
||||
headers={"Referer": ALLANIME_REFERER, "User-Agent": USER_AGENT},
|
||||
timeout=10,
|
||||
)
|
||||
if response.status_code == 200:
|
||||
return response.json()["data"]
|
||||
else:
|
||||
logger.error("allanime(ERROR): ", response.text)
|
||||
return {}
|
||||
except Timeout:
|
||||
logger.error(
|
||||
"allanime(Error):Timeout exceeded this could mean allanime is down or you have lost internet connection"
|
||||
)
|
||||
return {}
|
||||
except Exception as e:
|
||||
logger.error(f"allanime:Error: {e}")
|
||||
return {}
|
||||
|
||||
def search_for_anime(
|
||||
self,
|
||||
user_query: str,
|
||||
translation_type: str = "sub",
|
||||
nsfw=True,
|
||||
unknown=True,
|
||||
**kwargs,
|
||||
):
|
||||
"""search for an anime title using allanime provider
|
||||
|
||||
Args:
|
||||
nsfw ([TODO:parameter]): [TODO:description]
|
||||
unknown ([TODO:parameter]): [TODO:description]
|
||||
user_query: [TODO:description]
|
||||
translation_type: [TODO:description]
|
||||
**kwargs: [TODO:args]
|
||||
|
||||
Returns:
|
||||
[TODO:return]
|
||||
"""
|
||||
search = {"allowAdult": nsfw, "allowUnknown": unknown, "query": user_query}
|
||||
limit = 40
|
||||
translationtype = translation_type
|
||||
countryorigin = "all"
|
||||
page = 1
|
||||
variables = {
|
||||
"search": search,
|
||||
"limit": limit,
|
||||
"page": page,
|
||||
"translationtype": translationtype,
|
||||
"countryorigin": countryorigin,
|
||||
}
|
||||
try:
|
||||
search_results = self._fetch_gql(ALLANIME_SEARCH_GQL, variables)
|
||||
return normalize_search_results(search_results) # pyright:ignore
|
||||
except Exception as e:
|
||||
logger.error(f"FA(AllAnime): {e}")
|
||||
return {}
|
||||
|
||||
def get_anime(self, allanime_show_id: str):
|
||||
"""get an anime details given its id
|
||||
|
||||
Args:
|
||||
allanime_show_id: [TODO:description]
|
||||
|
||||
Returns:
|
||||
[TODO:return]
|
||||
"""
|
||||
variables = {"showId": allanime_show_id}
|
||||
try:
|
||||
anime = self._fetch_gql(ALLANIME_SHOW_GQL, variables)
|
||||
return normalize_anime(anime["show"])
|
||||
except Exception as e:
|
||||
logger.error(f"FA(AllAnime): {e}")
|
||||
return None
|
||||
|
||||
def _get_anime_episode(
|
||||
self, allanime_show_id: str, episode_string: str, translation_type: str = "sub"
|
||||
) -> "AllAnimeEpisode | dict":
|
||||
"""get the episode details and sources info
|
||||
|
||||
Args:
|
||||
allanime_show_id: [TODO:description]
|
||||
episode_string: [TODO:description]
|
||||
translation_type: [TODO:description]
|
||||
|
||||
Returns:
|
||||
[TODO:return]
|
||||
"""
|
||||
variables = {
|
||||
"showId": allanime_show_id,
|
||||
"translationType": translation_type,
|
||||
"episodeString": episode_string,
|
||||
}
|
||||
try:
|
||||
episode = self._fetch_gql(ALLANIME_EPISODES_GQL, variables)
|
||||
return episode["episode"]
|
||||
except Exception as e:
|
||||
logger.error(f"FA(AllAnime): {e}")
|
||||
return {}
|
||||
|
||||
def get_episode_streams(
|
||||
self, anime: "Anime", episode_number: str, translation_type="sub"
|
||||
) -> "Iterator[Server] | None":
|
||||
"""get the streams of an episode
|
||||
|
||||
Args:
|
||||
translation_type ([TODO:parameter]): [TODO:description]
|
||||
anime: [TODO:description]
|
||||
episode_number: [TODO:description]
|
||||
|
||||
Yields:
|
||||
[TODO:description]
|
||||
"""
|
||||
anime_id = anime["id"]
|
||||
allanime_episode = self._get_anime_episode(
|
||||
anime_id, episode_number, translation_type
|
||||
)
|
||||
if not allanime_episode:
|
||||
return []
|
||||
|
||||
embeds = allanime_episode["sourceUrls"]
|
||||
try:
|
||||
for embed in embeds:
|
||||
try:
|
||||
# filter the working streams no need to get all since the others are mostly hsl
|
||||
# TODO: should i just get all the servers and handle the hsl??
|
||||
if embed.get("sourceName", "") not in (
|
||||
"Sak",
|
||||
"Kir",
|
||||
"S-mp4",
|
||||
"Luf-mp4",
|
||||
"Default",
|
||||
):
|
||||
continue
|
||||
url = embed.get("sourceUrl")
|
||||
|
||||
if not url:
|
||||
continue
|
||||
if url.startswith("--"):
|
||||
url = url[2:]
|
||||
|
||||
# get the stream url for an episode of the defined source names
|
||||
parsed_url = decode_hex_string(url)
|
||||
embed_url = f"https://{ALLANIME_BASE}{parsed_url.replace('clock', 'clock.json')}"
|
||||
resp = self.session.get(
|
||||
embed_url,
|
||||
headers={
|
||||
"Referer": ALLANIME_REFERER,
|
||||
"User-Agent": USER_AGENT,
|
||||
},
|
||||
timeout=10,
|
||||
)
|
||||
if resp.status_code == 200:
|
||||
match embed["sourceName"]:
|
||||
case "Luf-mp4":
|
||||
logger.debug("allanime:Found streams from gogoanime")
|
||||
yield {
|
||||
"server": "gogoanime",
|
||||
"episode_title": (
|
||||
allanime_episode["notes"] or f'{anime["title"]}'
|
||||
)
|
||||
+ f"; Episode {episode_number}",
|
||||
"links": resp.json()["links"],
|
||||
} # pyright:ignore
|
||||
case "Kir":
|
||||
logger.debug("allanime:Found streams from wetransfer")
|
||||
yield {
|
||||
"server": "wetransfer",
|
||||
"episode_title": (
|
||||
allanime_episode["notes"] or f'{anime["title"]}'
|
||||
)
|
||||
+ f"; Episode {episode_number}",
|
||||
"links": resp.json()["links"],
|
||||
} # pyright:ignore
|
||||
case "S-mp4":
|
||||
logger.debug("allanime:Found streams from sharepoint")
|
||||
yield {
|
||||
"server": "sharepoint",
|
||||
"episode_title": (
|
||||
allanime_episode["notes"] or f'{anime["title"]}'
|
||||
)
|
||||
+ f"; Episode {episode_number}",
|
||||
"links": resp.json()["links"],
|
||||
} # pyright:ignore
|
||||
case "Sak":
|
||||
logger.debug("allanime:Found streams from dropbox")
|
||||
yield {
|
||||
"server": "dropbox",
|
||||
"episode_title": (
|
||||
allanime_episode["notes"] or f'{anime["title"]}'
|
||||
)
|
||||
+ f"; Episode {episode_number}",
|
||||
"links": resp.json()["links"],
|
||||
} # pyright:ignore
|
||||
case "Default":
|
||||
logger.debug("allanime:Found streams from wixmp")
|
||||
yield {
|
||||
"server": "wixmp",
|
||||
"episode_title": (
|
||||
allanime_episode["notes"] or f'{anime["title"]}'
|
||||
)
|
||||
+ f"; Episode {episode_number}",
|
||||
"links": resp.json()["links"],
|
||||
} # pyright:ignore
|
||||
except Timeout:
|
||||
logger.error(
|
||||
"Timeout has been exceeded this could mean allanime is down or you have lost internet connection"
|
||||
)
|
||||
return []
|
||||
except Exception as e:
|
||||
logger.error(f"FA(Allanime): {e}")
|
||||
return []
|
||||
except Exception as e:
|
||||
logger.error(f"FA(Allanime): {e}")
|
||||
return []
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
anime_provider = AllAnimeAPI()
|
||||
# lets see if it works :)
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from InquirerPy import inquirer, validator
|
||||
|
||||
anime = input("Enter the anime name: ")
|
||||
translation = input("Enter the translation type: ")
|
||||
|
||||
search_results = anime_provider.search_for_anime(
|
||||
anime, translation_type=translation.strip()
|
||||
)
|
||||
|
||||
if not search_results:
|
||||
raise Exception("No results found")
|
||||
|
||||
search_results = search_results["results"]
|
||||
options = {show["title"]: show for show in search_results}
|
||||
anime = inquirer.fuzzy(
|
||||
"Enter the anime title",
|
||||
list(options.keys()),
|
||||
validate=validator.EmptyInputValidator(),
|
||||
).execute()
|
||||
if anime is None:
|
||||
print("No anime was selected")
|
||||
sys.exit(1)
|
||||
|
||||
anime_result = options[anime]
|
||||
anime_data = anime_provider.get_anime(anime_result["id"])
|
||||
if not anime_data:
|
||||
raise Exception("Anime not found")
|
||||
availableEpisodesDetail = anime_data["availableEpisodesDetail"]
|
||||
if not availableEpisodesDetail.get(translation.strip()):
|
||||
raise Exception("No episodes found")
|
||||
|
||||
stream_link = True
|
||||
while stream_link != "quit":
|
||||
print("select episode")
|
||||
episode = inquirer.fuzzy(
|
||||
"Choose an episode",
|
||||
availableEpisodesDetail[translation.strip()],
|
||||
validate=validator.EmptyInputValidator(),
|
||||
).execute()
|
||||
if episode is None:
|
||||
print("No episode was selected")
|
||||
sys.exit(1)
|
||||
|
||||
if not anime_data:
|
||||
print("Sth went wrong")
|
||||
break
|
||||
episode_streams_ = anime_provider.get_episode_streams(
|
||||
anime_data, episode, translation.strip()
|
||||
)
|
||||
if episode_streams_ is None:
|
||||
raise Exception("Episode not found")
|
||||
|
||||
episode_streams = list(episode_streams_)
|
||||
stream_links = []
|
||||
for server in episode_streams:
|
||||
stream_links.extend([link["link"] for link in server["links"]])
|
||||
stream_links.append("back")
|
||||
stream_link = inquirer.fuzzy(
|
||||
"Choose a link to stream",
|
||||
stream_links,
|
||||
validate=validator.EmptyInputValidator(),
|
||||
).execute()
|
||||
if stream_link == "quit":
|
||||
print("Have a nice day")
|
||||
sys.exit()
|
||||
if not stream_link:
|
||||
raise Exception("No stream was selected")
|
||||
|
||||
title = episode_streams[0].get(
|
||||
"episode_title", "%s: Episode %s" % (anime_data["title"], episode)
|
||||
)
|
||||
subprocess.run(["mpv", f"--title={title}", stream_link])
|
||||
@@ -1,7 +0,0 @@
|
||||
from yt_dlp.utils.networking import random_user_agent
|
||||
|
||||
ALLANIME_BASE = "allanime.day"
|
||||
ALLANIME_REFERER = "https://allanime.to/"
|
||||
ALLANIME_API_ENDPOINT = "https://api.{}/api/".format(ALLANIME_BASE)
|
||||
USER_AGENT = random_user_agent()
|
||||
SERVERS_AVAILABLE = ["sharepoint", "dropbox", "gogoanime", "weTransfer", "wixmp"]
|
||||
@@ -1,56 +0,0 @@
|
||||
ALLANIME_SEARCH_GQL = """
|
||||
query(
|
||||
$search: SearchInput
|
||||
$limit: Int
|
||||
$page: Int
|
||||
$translationType: VaildTranslationTypeEnumType
|
||||
$countryOrigin: VaildCountryOriginEnumType
|
||||
) {
|
||||
shows(
|
||||
search: $search
|
||||
limit: $limit
|
||||
page: $page
|
||||
translationType: $translationType
|
||||
countryOrigin: $countryOrigin
|
||||
) {
|
||||
pageInfo {
|
||||
total
|
||||
}
|
||||
edges {
|
||||
_id
|
||||
name
|
||||
availableEpisodes
|
||||
__typename
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
ALLANIME_EPISODES_GQL = """\
|
||||
query ($showId: String!, $translationType: VaildTranslationTypeEnumType!, $episodeString: String!) {
|
||||
episode(
|
||||
showId: $showId
|
||||
translationType: $translationType
|
||||
episodeString: $episodeString
|
||||
) {
|
||||
|
||||
episodeString
|
||||
sourceUrls
|
||||
notes
|
||||
}
|
||||
}"""
|
||||
|
||||
ALLANIME_SHOW_GQL = """
|
||||
query ($showId: String!) {
|
||||
show(
|
||||
_id: $showId
|
||||
) {
|
||||
|
||||
_id
|
||||
name
|
||||
availableEpisodesDetail
|
||||
|
||||
}
|
||||
}
|
||||
"""
|
||||
@@ -1,40 +0,0 @@
|
||||
from ..types import Anime, EpisodesDetail, SearchResults
|
||||
from .types import AllAnimeEpisode, AllAnimeSearchResults, AllAnimeShow
|
||||
|
||||
|
||||
def normalize_search_results(search_results: AllAnimeSearchResults) -> SearchResults:
|
||||
page_info = search_results["shows"]["pageInfo"]
|
||||
results = []
|
||||
for result in search_results["shows"]["edges"]:
|
||||
normalized_result = {
|
||||
"id": result["_id"],
|
||||
"title": result["name"],
|
||||
"type": result["__typename"],
|
||||
"availableEpisodes": result["availableEpisodes"],
|
||||
}
|
||||
results.append(normalized_result)
|
||||
|
||||
normalized_search_results: SearchResults = {
|
||||
"pageInfo": page_info,
|
||||
"results": results,
|
||||
}
|
||||
|
||||
return normalized_search_results
|
||||
|
||||
|
||||
def normalize_anime(anime: AllAnimeShow) -> Anime:
|
||||
id: str = anime["_id"]
|
||||
title: str = anime["name"]
|
||||
availableEpisodesDetail: EpisodesDetail = anime["availableEpisodesDetail"]
|
||||
type = anime.get("__typename")
|
||||
normalized_anime: Anime = {
|
||||
"id": id,
|
||||
"title": title,
|
||||
"availableEpisodesDetail": availableEpisodesDetail,
|
||||
"type": type,
|
||||
}
|
||||
return normalized_anime
|
||||
|
||||
|
||||
def normalize_episode(episode: AllAnimeEpisode):
|
||||
pass
|
||||
@@ -1,73 +0,0 @@
|
||||
from typing import Literal, TypedDict
|
||||
|
||||
|
||||
class AllAnimeEpisodesInfo(TypedDict):
|
||||
dub: int
|
||||
sub: int
|
||||
raw: int
|
||||
|
||||
|
||||
class AllAnimePageInfo(TypedDict):
|
||||
total: int
|
||||
|
||||
|
||||
class AllAnimeShow(TypedDict):
|
||||
_id: str
|
||||
name: str
|
||||
availableEpisodesDetail: AllAnimeEpisodesInfo
|
||||
__typename: str
|
||||
|
||||
|
||||
class AllAnimeSearchResult(TypedDict):
|
||||
_id: str
|
||||
name: str
|
||||
availableEpisodes: list[str]
|
||||
__typename: str | None
|
||||
|
||||
|
||||
class AllAnimeShows(TypedDict):
|
||||
pageInfo: AllAnimePageInfo
|
||||
edges: list[AllAnimeSearchResult]
|
||||
|
||||
|
||||
class AllAnimeSearchResults(TypedDict):
|
||||
shows: AllAnimeShows
|
||||
|
||||
|
||||
class AllAnimeSourcesDownloads(TypedDict):
|
||||
sourceName: str
|
||||
dowloadUrl: str
|
||||
|
||||
|
||||
class AllAnimeSources(TypedDict):
|
||||
sourceUrl: str
|
||||
priority: float
|
||||
sandbox: str
|
||||
sourceName: str
|
||||
type: str
|
||||
className: str
|
||||
streamerId: str
|
||||
downloads: AllAnimeSourcesDownloads
|
||||
|
||||
|
||||
Server = Literal["gogoanime", "dropbox", "wetransfer", "sharepoint"]
|
||||
|
||||
|
||||
class AllAnimeEpisode(TypedDict):
|
||||
episodeString: str
|
||||
sourceUrls: list[AllAnimeSources]
|
||||
notes: str | None
|
||||
|
||||
|
||||
class AllAnimeStream:
|
||||
link: str
|
||||
mp4: bool
|
||||
hls: bool | None
|
||||
resolutionStr: str
|
||||
fromCache: str
|
||||
priority: int
|
||||
headers: dict | None
|
||||
|
||||
|
||||
class AllAnimeStreams:
|
||||
links: list[AllAnimeStream]
|
||||
@@ -1,63 +0,0 @@
|
||||
import requests
|
||||
|
||||
from .constants import ANIMEPAHE_BASE, ANIMEPAHE_ENDPOINT, REQUEST_HEADERS
|
||||
|
||||
|
||||
# TODO: hack this to completion
|
||||
class AnimePaheApi:
|
||||
def search_for_anime(self, user_query, *args):
|
||||
try:
|
||||
url = f"{ANIMEPAHE_ENDPOINT}m=search&q={user_query}"
|
||||
headers = {**REQUEST_HEADERS}
|
||||
response = requests.get(url, headers=headers)
|
||||
if not response.status_code == 200:
|
||||
return
|
||||
data = response.json()
|
||||
return {
|
||||
"pageInfo": {"total": data["total"]},
|
||||
"results": [
|
||||
{
|
||||
"id": result["session"],
|
||||
"title": result["title"],
|
||||
"availableEpisodes": result["episodes"],
|
||||
"type": result["type"],
|
||||
}
|
||||
for result in data["data"]
|
||||
],
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
input()
|
||||
|
||||
def get_anime(self, session_id: str, *args):
|
||||
url = "https://animepahe.ru/api?m=release&id=&sort=episode_asc&page=1"
|
||||
url = f"{ANIMEPAHE_ENDPOINT}m=release&id={session_id}&sort=episode_asc&page=1"
|
||||
response = requests.get(url, headers=REQUEST_HEADERS)
|
||||
if not response.status_code == 200:
|
||||
return
|
||||
data = response.json()
|
||||
self.current = data
|
||||
episodes = list(map(str, range(data["total"])))
|
||||
return {
|
||||
"id": session_id,
|
||||
"title": "none",
|
||||
"availableEpisodesDetail": {
|
||||
"sub": episodes,
|
||||
"dub": episodes,
|
||||
"raw": episodes,
|
||||
},
|
||||
}
|
||||
|
||||
def get_episode_streams(self, anime, episode, *args):
|
||||
episode_id = self.current["data"][int(episode)]["session"]
|
||||
anime_id = anime["id"]
|
||||
url = f"{ANIMEPAHE_BASE}play/{anime_id}{episode_id}"
|
||||
response = requests.get(url, headers=REQUEST_HEADERS)
|
||||
print(response.status_code)
|
||||
input()
|
||||
if not response.status_code == 200:
|
||||
print(response.text)
|
||||
return
|
||||
print(response.text)
|
||||
input()
|
||||
@@ -1,49 +0,0 @@
|
||||
from ...anilist.anilist_data_schema import AnilistBaseMediaDataSchema
|
||||
from ..base_provider import AnimeProvider
|
||||
|
||||
"""
|
||||
"Zoro": {
|
||||
"27": {
|
||||
"identifier": "27",
|
||||
"image": "https://cdn.noitatnemucod.net/thumbnail/300x400/100/ce5e539af63e42431621fc66a47fbec1.jpg",
|
||||
"malId": 1,
|
||||
"aniId": 1,
|
||||
"page": "Zoro",
|
||||
"title": "Cowboy Bebop",
|
||||
"type": "anime",
|
||||
"url": "https://hianime.to/cowboy-bebop-27"
|
||||
}
|
||||
},
|
||||
|
||||
episode info = https://hianime.to/ajax/v2/episode/list/27
|
||||
"""
|
||||
|
||||
|
||||
# TODO: complete this
|
||||
class AniWatchApi(AnimeProvider):
|
||||
def search_for_anime(
|
||||
self, anilist_selected_anime: AnilistBaseMediaDataSchema, *args
|
||||
):
|
||||
return {
|
||||
"pageInfo": 1,
|
||||
"results": [
|
||||
{
|
||||
"id": anilist_selected_anime["id"],
|
||||
"title": anilist_selected_anime["title"],
|
||||
"availableEpisodes": [],
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
def get_anime(self, id: int):
|
||||
url = f"https://raw.githubusercontent.com/bal-mackup/mal-backup/master/anilist/anime/{id}.json"
|
||||
response = self.session.get(url)
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
data["Sites"]["Zoro"]
|
||||
return {"id": ""}
|
||||
else:
|
||||
return {}
|
||||
|
||||
def get_episode_streams(self, id: int, episode: str, translation_type: str):
|
||||
pass
|
||||
@@ -1,8 +0,0 @@
|
||||
import requests
|
||||
|
||||
|
||||
class AnimeProvider:
|
||||
session: requests.Session
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.session = requests.session()
|
||||
@@ -1,48 +0,0 @@
|
||||
from typing import TypedDict
|
||||
|
||||
|
||||
class PageInfo(TypedDict):
|
||||
total: int
|
||||
|
||||
|
||||
# search data
|
||||
class SearchResult(TypedDict):
|
||||
id: str
|
||||
title: str
|
||||
availableEpisodes: list[str]
|
||||
type: str
|
||||
|
||||
|
||||
class SearchResults(TypedDict):
|
||||
pageInfo: PageInfo
|
||||
results: list[SearchResult]
|
||||
|
||||
|
||||
# anime data
|
||||
class EpisodesDetail(TypedDict):
|
||||
dub: int
|
||||
sub: int
|
||||
raw: int
|
||||
|
||||
|
||||
class Anime(TypedDict):
|
||||
id: str
|
||||
title: str
|
||||
availableEpisodesDetail: EpisodesDetail
|
||||
type: str | None
|
||||
|
||||
|
||||
class EpisodeStream(TypedDict):
|
||||
resolution: str
|
||||
link: str
|
||||
hls: bool | None
|
||||
mp4: bool
|
||||
priority: int
|
||||
headers: dict
|
||||
fromCache: str
|
||||
|
||||
|
||||
class Server(TypedDict):
|
||||
server: str
|
||||
episode_title: str | None
|
||||
links: list
|
||||
@@ -1,52 +0,0 @@
|
||||
import re
|
||||
|
||||
# Dictionary to map hex values to characters
|
||||
hex_to_char = {
|
||||
"01": "9",
|
||||
"08": "0",
|
||||
"05": "=",
|
||||
"0a": "2",
|
||||
"0b": "3",
|
||||
"0c": "4",
|
||||
"07": "?",
|
||||
"00": "8",
|
||||
"5c": "d",
|
||||
"0f": "7",
|
||||
"5e": "f",
|
||||
"17": "/",
|
||||
"54": "l",
|
||||
"09": "1",
|
||||
"48": "p",
|
||||
"4f": "w",
|
||||
"0e": "6",
|
||||
"5b": "c",
|
||||
"5d": "e",
|
||||
"0d": "5",
|
||||
"53": "k",
|
||||
"1e": "&",
|
||||
"5a": "b",
|
||||
"59": "a",
|
||||
"4a": "r",
|
||||
"4c": "t",
|
||||
"4e": "v",
|
||||
"57": "o",
|
||||
"51": "i",
|
||||
}
|
||||
|
||||
|
||||
def decode_hex_string(hex_string):
|
||||
"""some of the sources encrypt the urls into hex codes this function decrypts the urls
|
||||
|
||||
Args:
|
||||
hex_string ([TODO:parameter]): [TODO:description]
|
||||
|
||||
Returns:
|
||||
[TODO:return]
|
||||
"""
|
||||
# Split the hex string into pairs of characters
|
||||
hex_pairs = re.findall("..", hex_string)
|
||||
|
||||
# Decode each hex pair
|
||||
decoded_chars = [hex_to_char.get(pair.lower(), pair) for pair in hex_pairs]
|
||||
|
||||
return "".join(decoded_chars)
|
||||
@@ -1,22 +0,0 @@
|
||||
import requests
|
||||
|
||||
ANISKIP_ENDPOINT = "https://api.aniskip.com/v1/skip-times"
|
||||
|
||||
|
||||
# TODO: Finish own implementation of aniskip script
|
||||
class AniSkip:
|
||||
@classmethod
|
||||
def get_skip_times(
|
||||
cls, mal_id: int, episode_number: float | int, types=["op", "ed"]
|
||||
):
|
||||
url = f"{ANISKIP_ENDPOINT}/{mal_id}/{episode_number}?types=op&types=ed"
|
||||
response = requests.get(url)
|
||||
print(response.text)
|
||||
return response.json()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
mal_id = input("Mal id: ")
|
||||
episode_number = input("episode_number: ")
|
||||
skip_times = AniSkip.get_skip_times(int(mal_id), float(episode_number))
|
||||
print(skip_times)
|
||||
@@ -1,181 +0,0 @@
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Callable, List
|
||||
|
||||
# TODO: will probably scrap art not to useful
|
||||
from art import text2art
|
||||
from click import clear
|
||||
from rich import print
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
FZF_DEFAULT_OPTS = """
|
||||
--color=fg:#d0d0d0,fg+:#d0d0d0,bg:#121212,bg+:#262626
|
||||
--color=hl:#5f87af,hl+:#5fd7ff,info:#afaf87,marker:#87ff00
|
||||
--color=prompt:#d7005f,spinner:#af5fff,pointer:#af5fff,header:#87afaf
|
||||
--color=border:#262626,label:#aeaeae,query:#d9d9d9
|
||||
--border="rounded" --border-label="" --preview-window="border-rounded" --prompt="> "
|
||||
--marker=">" --pointer="◆" --separator="─" --scrollbar="│"
|
||||
"""
|
||||
|
||||
|
||||
class FZF:
|
||||
"""an abstraction over the fzf commandline utility
|
||||
|
||||
Attributes:
|
||||
FZF_EXECUTABLE: [TODO:attribute]
|
||||
default_options: [TODO:attribute]
|
||||
stdout: [TODO:attribute]
|
||||
"""
|
||||
|
||||
if not os.getenv("FZF_DEFAULT_OPTS"):
|
||||
os.environ["FZF_DEFAULT_OPTS"] = FZF_DEFAULT_OPTS
|
||||
FZF_EXECUTABLE = shutil.which("fzf")
|
||||
default_options = [
|
||||
"--cycle",
|
||||
"--info=hidden",
|
||||
"--layout=reverse",
|
||||
"--height=100%",
|
||||
"--bind=right:accept",
|
||||
"--no-margin",
|
||||
"+m",
|
||||
"-i",
|
||||
"--exact",
|
||||
"--tabstop=1",
|
||||
"--preview-window=left,35%,wrap",
|
||||
"--wrap",
|
||||
]
|
||||
|
||||
def _with_filter(self, command: str, work: Callable) -> List[str]:
|
||||
"""ported from the fzf docs demo
|
||||
|
||||
Args:
|
||||
command: [TODO:description]
|
||||
work: [TODO:description]
|
||||
|
||||
Returns:
|
||||
[TODO:return]
|
||||
"""
|
||||
try:
|
||||
process = subprocess.Popen(
|
||||
command,
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
text=True,
|
||||
shell=True,
|
||||
)
|
||||
except subprocess.SubprocessError as e:
|
||||
print(f"Failed to start subprocess: {e}", file=sys.stderr)
|
||||
return []
|
||||
|
||||
original_stdout = sys.stdout
|
||||
sys.stdout = process.stdin
|
||||
|
||||
try:
|
||||
work()
|
||||
if process.stdin:
|
||||
process.stdin.close()
|
||||
except Exception as e:
|
||||
print(f"Exception during work execution: {e}", file=sys.stderr)
|
||||
finally:
|
||||
sys.stdout = original_stdout
|
||||
|
||||
output = []
|
||||
if process.stdout:
|
||||
output = process.stdout.read().splitlines()
|
||||
process.stdout.close()
|
||||
|
||||
return output
|
||||
|
||||
def _run_fzf(self, commands: list[str], _fzf_input) -> str:
|
||||
"""core abstraction
|
||||
|
||||
Args:
|
||||
_fzf_input ([TODO:parameter]): [TODO:description]
|
||||
commands: [TODO:description]
|
||||
|
||||
Raises:
|
||||
Exception: [TODO:throw]
|
||||
|
||||
Returns:
|
||||
[TODO:return]
|
||||
"""
|
||||
fzf_input = "\n".join(_fzf_input)
|
||||
|
||||
if not self.FZF_EXECUTABLE:
|
||||
raise Exception("fzf executable not found")
|
||||
|
||||
result = subprocess.run(
|
||||
[self.FZF_EXECUTABLE, *commands],
|
||||
input=fzf_input,
|
||||
stdout=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
if not result or result.returncode != 0 or not result.stdout:
|
||||
print("sth went wrong:confused:")
|
||||
input("press enter to try again...")
|
||||
clear()
|
||||
return self._run_fzf(commands, _fzf_input)
|
||||
clear()
|
||||
|
||||
return result.stdout.strip()
|
||||
|
||||
def run(
|
||||
self,
|
||||
fzf_input: list[str],
|
||||
prompt: str,
|
||||
header: str,
|
||||
preview: str | None = None,
|
||||
expect: str | None = None,
|
||||
validator: Callable | None = None,
|
||||
) -> str:
|
||||
"""a helper method that wraps common use cases over the fzf utility
|
||||
|
||||
Args:
|
||||
fzf_input: [TODO:description]
|
||||
prompt: [TODO:description]
|
||||
header: [TODO:description]
|
||||
preview: [TODO:description]
|
||||
expect: [TODO:description]
|
||||
validator: [TODO:description]
|
||||
|
||||
Returns:
|
||||
[TODO:return]
|
||||
"""
|
||||
_commands = [
|
||||
*self.default_options,
|
||||
"--header",
|
||||
text2art(header),
|
||||
"--header-first",
|
||||
"--prompt",
|
||||
prompt.title(),
|
||||
] # pyright:ignore
|
||||
|
||||
if preview:
|
||||
_commands.append(f"--preview={preview}")
|
||||
if expect:
|
||||
_commands.append(f"--expect={expect}")
|
||||
|
||||
result = self._run_fzf(_commands, fzf_input) # pyright:ignore
|
||||
if not result:
|
||||
print("Please enter a value")
|
||||
input("Enter to do it right")
|
||||
return self.run(fzf_input, prompt, header, preview, expect, validator)
|
||||
elif validator:
|
||||
success, info = validator(result)
|
||||
if not success:
|
||||
print(info)
|
||||
input("Enter to try again")
|
||||
return self.run(fzf_input, prompt, header, preview, expect, validator)
|
||||
return result
|
||||
|
||||
|
||||
fzf = FZF()
|
||||
|
||||
if __name__ == "__main__":
|
||||
action = fzf.run([*os.listdir(), "exit"], "Prompt: ", "Header", preview="bat {}")
|
||||
print(action)
|
||||
@@ -1,138 +0,0 @@
|
||||
import subprocess
|
||||
from shutil import which
|
||||
from sys import exit
|
||||
|
||||
from plyer import notification
|
||||
|
||||
from fastanime import APP_NAME
|
||||
|
||||
from ...constants import ICON_PATH
|
||||
|
||||
|
||||
class RofiApi:
|
||||
ROFI_EXECUTABLE = which("rofi")
|
||||
|
||||
rofi_theme = ""
|
||||
rofi_theme_confirm = ""
|
||||
rofi_theme_input = ""
|
||||
|
||||
def run_with_icons(self, options: list[str], prompt_text: str) -> str:
|
||||
rofi_input = "\n".join(options)
|
||||
|
||||
if not self.ROFI_EXECUTABLE:
|
||||
raise Exception("Rofi not found")
|
||||
|
||||
args = [self.ROFI_EXECUTABLE]
|
||||
if self.rofi_theme:
|
||||
args.extend(["-no-config", "-theme", self.rofi_theme])
|
||||
args.extend(["-p", prompt_text, "-i", "-show-icons", "-dmenu"])
|
||||
result = subprocess.run(
|
||||
args,
|
||||
input=rofi_input,
|
||||
stdout=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
|
||||
choice = result.stdout.strip()
|
||||
if not choice:
|
||||
notification.notify(
|
||||
app_name=APP_NAME,
|
||||
app_icon=ICON_PATH,
|
||||
message="FastAnime is shutting down",
|
||||
title="No Valid Input Provided",
|
||||
) # pyright:ignore
|
||||
exit(1)
|
||||
|
||||
return choice
|
||||
|
||||
def run(self, options: list[str], prompt_text: str) -> str:
|
||||
rofi_input = "\n".join(options)
|
||||
|
||||
if not self.ROFI_EXECUTABLE:
|
||||
raise Exception("Rofi not found")
|
||||
|
||||
args = [self.ROFI_EXECUTABLE]
|
||||
if self.rofi_theme:
|
||||
args.extend(["-no-config", "-theme", self.rofi_theme])
|
||||
args.extend(["-p", prompt_text, "-i", "-dmenu"])
|
||||
result = subprocess.run(
|
||||
args,
|
||||
input=rofi_input,
|
||||
stdout=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
|
||||
choice = result.stdout.strip()
|
||||
if not choice or choice not in options:
|
||||
notification.notify(
|
||||
app_name=APP_NAME,
|
||||
app_icon=ICON_PATH,
|
||||
message="FastAnime is shutting down",
|
||||
title="No Valid Input Provided",
|
||||
) # pyright:ignore
|
||||
exit(1)
|
||||
|
||||
return choice
|
||||
|
||||
def confirm(self, prompt_text: str) -> bool:
|
||||
rofi_choices = "Yes\nNo"
|
||||
if not self.ROFI_EXECUTABLE:
|
||||
raise Exception("Rofi not found")
|
||||
args = [self.ROFI_EXECUTABLE]
|
||||
if self.rofi_theme_confirm:
|
||||
args.extend(["-no-config", "-theme", self.rofi_theme_confirm])
|
||||
args.extend(["-p", prompt_text, "-i", "", "-no-fixed-num-lines", "-dmenu"])
|
||||
result = subprocess.run(
|
||||
args,
|
||||
input=rofi_choices,
|
||||
stdout=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
|
||||
choice = result.stdout.strip()
|
||||
if not choice:
|
||||
notification.notify(
|
||||
app_name=APP_NAME,
|
||||
app_icon=ICON_PATH,
|
||||
message="FastAnime is shutting down",
|
||||
title="No Valid Input Provided",
|
||||
) # pyright:ignore
|
||||
exit(1)
|
||||
if choice == "Yes":
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def ask(
|
||||
self, prompt_text: str, is_int: bool = False, is_float: bool = False
|
||||
) -> str | float | int:
|
||||
if not self.ROFI_EXECUTABLE:
|
||||
raise Exception("Rofi not found")
|
||||
args = [self.ROFI_EXECUTABLE]
|
||||
if self.rofi_theme_input:
|
||||
args.extend(["-no-config", "-theme", self.rofi_theme_input])
|
||||
args.extend(["-p", prompt_text, "-i", "-no-fixed-num-lines", "-dmenu"])
|
||||
result = subprocess.run(
|
||||
args,
|
||||
stdout=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
|
||||
user_input = result.stdout.strip()
|
||||
if not user_input:
|
||||
notification.notify(
|
||||
app_name=APP_NAME,
|
||||
app_icon=ICON_PATH,
|
||||
message="FastAnime is shutting down",
|
||||
title="No Valid Input Provided",
|
||||
) # pyright:ignore
|
||||
exit(1)
|
||||
if is_float:
|
||||
user_input = float(user_input)
|
||||
elif is_int:
|
||||
user_input = int(user_input)
|
||||
|
||||
return user_input
|
||||
|
||||
|
||||
Rofi = RofiApi()
|
||||
61
flake.lock
generated
Normal file
61
flake.lock
generated
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1756386758,
|
||||
"narHash": "sha256-1wxxznpW2CKvI9VdniaUnTT2Os6rdRJcRUf65ZK9OtE=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "dfb2f12e899db4876308eba6d93455ab7da304cd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
101
flake.nix
Normal file
101
flake.nix
Normal file
@@ -0,0 +1,101 @@
|
||||
{
|
||||
description = "Viu Project Flake";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
inherit (pkgs) lib python312Packages;
|
||||
|
||||
version = "3.1.0";
|
||||
in
|
||||
{
|
||||
packages.default = python312Packages.buildPythonApplication {
|
||||
pname = "viu";
|
||||
inherit version;
|
||||
pyproject = true;
|
||||
|
||||
src = self;
|
||||
|
||||
build-system = with python312Packages; [ hatchling ];
|
||||
|
||||
dependencies = with python312Packages; [
|
||||
click
|
||||
inquirerpy
|
||||
requests
|
||||
rich
|
||||
thefuzz
|
||||
yt-dlp
|
||||
dbus-python
|
||||
hatchling
|
||||
plyer
|
||||
mpv
|
||||
fastapi
|
||||
pycryptodome
|
||||
pypresence
|
||||
httpx
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace pyproject.toml \
|
||||
--replace-fail "pydantic>=2.11.7" "pydantic>=2.11.4"
|
||||
'';
|
||||
|
||||
makeWrapperArgs = [
|
||||
"--prefix PATH : ${
|
||||
lib.makeBinPath (
|
||||
with pkgs;
|
||||
[
|
||||
mpv
|
||||
]
|
||||
)
|
||||
}"
|
||||
];
|
||||
|
||||
# Needs to be adapted for the nix derivation build
|
||||
doCheck = false;
|
||||
|
||||
meta = {
|
||||
description = "Your browser anime experience from the terminal";
|
||||
homepage = "https://github.com/viu-media/Viu";
|
||||
changelog = "https://github.com/viu-media/Viu/releases/tag/v${version}";
|
||||
mainProgram = "viu";
|
||||
license = lib.licenses.unlicense;
|
||||
maintainers = with lib.maintainers; [ theobori ];
|
||||
};
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
venvDir = ".venv";
|
||||
|
||||
env.LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ pkgs.libxcrypt-legacy ];
|
||||
|
||||
packages =
|
||||
with pkgs;
|
||||
[
|
||||
mpv
|
||||
fzf
|
||||
rofi
|
||||
uv
|
||||
pyright
|
||||
]
|
||||
++ (with python3Packages; [
|
||||
venvShellHook
|
||||
hatchling
|
||||
])
|
||||
++ self.packages.${system}.default.dependencies;
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
APP_DIR="$(
|
||||
cd -- "$(dirname "$0")" >/dev/null 2>&1
|
||||
pwd -P
|
||||
)"
|
||||
|
||||
# fish shell completions
|
||||
_FASTANIME_COMPLETE=fish_source fastanime >"$APP_DIR/completions/fastanime.fish"
|
||||
|
||||
# zsh completions
|
||||
_FASTANIME_COMPLETE=zsh_source fastanime >"$APP_DIR/completions/fastanime.zsh"
|
||||
|
||||
# bash completions
|
||||
_FASTANIME_COMPLETE=bash_source fastanime >"$APP_DIR/completions/fastanime.bash"
|
||||
1424
poetry.lock
generated
1424
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,39 +1,65 @@
|
||||
[tool.poetry]
|
||||
name = "fastanime"
|
||||
version = "0.60.1.dev1"
|
||||
[project]
|
||||
name = "viu-media"
|
||||
version = "3.3.2"
|
||||
description = "A browser anime site experience from the terminal"
|
||||
authors = ["Benextempest <benextempest@gmail.com>"]
|
||||
license = "UNLICENSE"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.11"
|
||||
dependencies = [
|
||||
"click>=8.1.7",
|
||||
"httpx>=0.28.1",
|
||||
"inquirerpy>=0.3.4",
|
||||
"pydantic>=2.11.7",
|
||||
"rich>=13.9.2",
|
||||
]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.10"
|
||||
yt-dlp = "^2024.5.27"
|
||||
rich = "^13.7.1"
|
||||
click = "^8.1.7"
|
||||
inquirerpy = "^0.3.4"
|
||||
platformdirs = "^4.2.2"
|
||||
art = "^6.2"
|
||||
python-dotenv = "^1.0.1"
|
||||
thefuzz = "^0.22.1"
|
||||
requests = "^2.32.3"
|
||||
plyer = "^2.1.0"
|
||||
pyshortcuts = "^1.9.0"
|
||||
[project.scripts]
|
||||
viu = 'viu_media:Cli'
|
||||
|
||||
mpv = "^1.0.7"
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
black = "^24.4.2"
|
||||
isort = "^5.13.2"
|
||||
pytest = "^8.2.2"
|
||||
ruff = "^0.4.10"
|
||||
pre-commit = "^3.7.1"
|
||||
autoflake = "^2.3.1"
|
||||
tox = "^4.16.0"
|
||||
[project.optional-dependencies]
|
||||
standard = [
|
||||
"thefuzz>=0.22.1",
|
||||
"yt-dlp>=2025.7.21",
|
||||
"pycryptodomex>=3.23.0",
|
||||
"pypiwin32; sys_platform == 'win32'", # For Windows-specific functionality
|
||||
"pyobjc; sys_platform == 'darwin'", # For macOS-specific functionality
|
||||
"dbus-python; sys_platform == 'linux'", # For Linux-specific functionality (e.g., notifications),
|
||||
"plyer>=2.1.0",
|
||||
"lxml>=6.0.0"
|
||||
]
|
||||
notifications = [
|
||||
"dbus-python>=1.4.0",
|
||||
"plyer>=2.1.0",
|
||||
]
|
||||
mpv = [
|
||||
"mpv>=1.0.7",
|
||||
]
|
||||
torrent = ["libtorrent>=2.0.11"]
|
||||
lxml = ["lxml>=6.0.0"]
|
||||
discord = ["pypresence>=4.3.0"]
|
||||
download = [
|
||||
"pycryptodomex>=3.23.0",
|
||||
"yt-dlp>=2025.7.21",
|
||||
]
|
||||
torrents = [
|
||||
"libtorrent>=2.0.11",
|
||||
]
|
||||
|
||||
pyright = "^1.1.374"
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
fastanime = 'fastanime:FastAnime'
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"pre-commit>=4.0.1",
|
||||
"pyinstaller>=6.11.1",
|
||||
"pyright>=1.1.384",
|
||||
"pytest>=8.3.3",
|
||||
"pytest-httpx>=0.35.0",
|
||||
"ruff>=0.6.9",
|
||||
]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
markers = [
|
||||
"integration: marks tests as integration tests that require a live network connection",
|
||||
]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"typeCheckingMode": "standard",
|
||||
"reportPrivateImportUsage": false
|
||||
"venvPath": ".",
|
||||
"venv": ".venv",
|
||||
"pythonVersion": "3.12"
|
||||
}
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
# TODO: Write tests to make sure all click commands work
|
||||
import pytest
|
||||
from click.testing import CliRunner
|
||||
|
||||
from fastanime.cli import run_cli
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def runner():
|
||||
return CliRunner()
|
||||
|
||||
|
||||
def test_main_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_config_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["config", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_config_path(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["config", "--path"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_downloads_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["downloads", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_downloads_path(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["downloads", "--path"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_download_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["download", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_search_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["search", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_completed_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "completed", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_dropped_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "dropped", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_favourites_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "favourites", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_login_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "login", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_notifier_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "notifier", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_paused_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "paused", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_planning_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "planning", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_popular_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "popular", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_random_anime_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "random", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_recent_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "recent", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_rewatching_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "rewatching", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_scores_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "scores", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_search_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "search", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_trending_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "trending", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_upcoming_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "upcoming", "--help"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_anilist_watching_help(runner: CliRunner):
|
||||
result = runner.invoke(run_cli, ["anilist", "watching", "--help"])
|
||||
assert result.exit_code == 0
|
||||
20
tox.ini
20
tox.ini
@@ -1,27 +1,27 @@
|
||||
[tox]
|
||||
requires =
|
||||
tox>=4
|
||||
env_list = lint, pyright, py{310,311}
|
||||
env_list = lint, pyright, py{311,312}
|
||||
|
||||
[testenv]
|
||||
description = run unit tests
|
||||
deps =poetry
|
||||
deps =uv
|
||||
commands =
|
||||
poetry install
|
||||
poetry run pytest
|
||||
uv sync --dev --all-extras
|
||||
uv run pytest
|
||||
|
||||
[testenv:lint]
|
||||
description = run linters
|
||||
skip_install = true
|
||||
deps =poetry
|
||||
deps =uv
|
||||
commands =
|
||||
poetry install
|
||||
poetry run black .
|
||||
uv sync --dev --all-extras
|
||||
uv run ruff format .
|
||||
|
||||
[testenv:pyright]
|
||||
description = run type checking
|
||||
skip_install = true
|
||||
deps =poetry
|
||||
deps =uv
|
||||
commands =
|
||||
poetry install --no-root
|
||||
poetry run pyright
|
||||
uv sync --dev --all-extras
|
||||
uv run pyright
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user