mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-01-16 16:18:06 +00:00
Compare commits
579 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76b4ba3c5e | ||
|
|
292d4b585b | ||
|
|
0dd08bbbb4 | ||
|
|
ac8572fd2d | ||
|
|
b300a4e8d4 | ||
|
|
b3fc995977 | ||
|
|
7f5a070406 | ||
|
|
7ccef6068b | ||
|
|
06aac98996 | ||
|
|
0f18482ba6 | ||
|
|
ffd7835ab5 | ||
|
|
fb6b103164 | ||
|
|
2de763eef9 | ||
|
|
46ab046c34 | ||
|
|
cf54a0e8be | ||
|
|
e73cf46e14 | ||
|
|
39c3b2f044 | ||
|
|
7a592a0f15 | ||
|
|
1fad64cd59 | ||
|
|
86e5dc4607 | ||
|
|
e98e4766f7 | ||
|
|
6e59671cf6 | ||
|
|
86a50367b2 | ||
|
|
0212c0b85f | ||
|
|
89d365122c | ||
|
|
9c0a8350d6 | ||
|
|
818d21718c | ||
|
|
0b551c0cd4 | ||
|
|
d8c3b26fa6 | ||
|
|
adde41c533 | ||
|
|
3925e1dced | ||
|
|
c7d1206dcb | ||
|
|
f1567c64a5 | ||
|
|
d900cc5c53 | ||
|
|
5c456231b1 | ||
|
|
abde7c0242 | ||
|
|
762d17c3df | ||
|
|
e006b7f1e1 | ||
|
|
db10f380d1 | ||
|
|
60f8aa540f | ||
|
|
7b64c696f7 | ||
|
|
0367dc21f8 | ||
|
|
7a172a9051 | ||
|
|
5bb44c36e1 | ||
|
|
3ad34de808 | ||
|
|
4025b2c6a1 | ||
|
|
6b00cc1a06 | ||
|
|
80dccdef22 | ||
|
|
b0ec5c527d | ||
|
|
5d073713b6 | ||
|
|
d93853375e | ||
|
|
26872eb2c2 | ||
|
|
119041a425 | ||
|
|
9c85566da7 | ||
|
|
575b96d03a | ||
|
|
823f648955 | ||
|
|
7203f463f4 | ||
|
|
3651755984 | ||
|
|
180fb857ed | ||
|
|
cb09459ad1 | ||
|
|
fd1bdad0e2 | ||
|
|
b2ba3a5922 | ||
|
|
749023bf02 | ||
|
|
dcc8c7b92a | ||
|
|
f63d591b08 | ||
|
|
387192610f | ||
|
|
9aec21f6b5 | ||
|
|
e183a14933 | ||
|
|
72edf5b555 | ||
|
|
7fd75bf071 | ||
|
|
d64005df40 | ||
|
|
c523e576c4 | ||
|
|
d1a6e8c99e | ||
|
|
3e1aab6b29 | ||
|
|
7a88e7fa34 | ||
|
|
cabb9aed31 | ||
|
|
61f2c41b76 | ||
|
|
3249fbb715 | ||
|
|
2d797adc08 | ||
|
|
c069496b27 | ||
|
|
c1e8087b11 | ||
|
|
427d52cf9a | ||
|
|
06d420f743 | ||
|
|
05a1510b31 | ||
|
|
1b01a6ece1 | ||
|
|
3577ef6814 | ||
|
|
75b7c9ac36 | ||
|
|
4f63bfd616 | ||
|
|
4fae733eef | ||
|
|
36a34f911e | ||
|
|
e4d5e5bf91 | ||
|
|
547a6121b0 | ||
|
|
bae5e3795e | ||
|
|
3b935d8fd0 | ||
|
|
15b83f8b55 | ||
|
|
56a879e148 | ||
|
|
fc99f1f563 | ||
|
|
4b257b7b4a | ||
|
|
172a81b22c | ||
|
|
5c7ca6b363 | ||
|
|
93b213b59f | ||
|
|
3b669521da | ||
|
|
05f01b2c45 | ||
|
|
f36b898a4d | ||
|
|
fa9b0d9da1 | ||
|
|
1c2fd4ef84 | ||
|
|
be3b05df68 | ||
|
|
601a50e430 | ||
|
|
03d60438e2 | ||
|
|
9b6720ce80 | ||
|
|
b9e0a0b1ac | ||
|
|
d22fd964c2 | ||
|
|
188ad540ee | ||
|
|
12f24674fb | ||
|
|
ac9dfa8e93 | ||
|
|
b5b7db1f32 | ||
|
|
ab7e697f30 | ||
|
|
b086f6d330 | ||
|
|
a73d87229a | ||
|
|
e9fb46b0cd | ||
|
|
0ca0d9d01e | ||
|
|
1156b8f100 | ||
|
|
c9820d30ed | ||
|
|
b8fd6a7ec3 | ||
|
|
2c2a55abab | ||
|
|
f7e9b0a27f | ||
|
|
6b33089274 | ||
|
|
229bd598b5 | ||
|
|
260dd37bd5 | ||
|
|
54d33c06c7 | ||
|
|
a7358171cf | ||
|
|
14f563d7c2 | ||
|
|
44a3e0a97b | ||
|
|
e19474d22f | ||
|
|
208c8b2b9d | ||
|
|
0562b4cf6f | ||
|
|
8ba86fe272 | ||
|
|
fad4594062 | ||
|
|
74864832ca | ||
|
|
9c95eba5a1 | ||
|
|
6f17a0b7af | ||
|
|
f8fed49225 | ||
|
|
8b438b68cc | ||
|
|
8f2ec3b197 | ||
|
|
adc2a68a98 | ||
|
|
39faadc9dc | ||
|
|
c4c7ced948 | ||
|
|
6fa1c5e214 | ||
|
|
831ce4da13 | ||
|
|
24a5bebabe | ||
|
|
42f761582f | ||
|
|
cb32bf1c4f | ||
|
|
318b9949f2 | ||
|
|
221b831bb2 | ||
|
|
cc8609d0aa | ||
|
|
03f32978c0 | ||
|
|
8fe7b6551f | ||
|
|
2919cf28ea | ||
|
|
e131078673 | ||
|
|
e1b445d133 | ||
|
|
177ca3ccba | ||
|
|
c63a53959c | ||
|
|
e8b13ea8a9 | ||
|
|
2f2010ce59 | ||
|
|
e6a1407786 | ||
|
|
3eca8b9c98 | ||
|
|
0803a916aa | ||
|
|
675754bc5c | ||
|
|
2638759b42 | ||
|
|
b4d722b9f2 | ||
|
|
baa30b41de | ||
|
|
299193e2bd | ||
|
|
fde9dd2a61 | ||
|
|
5552e8cbd7 | ||
|
|
2aecc3fa1b | ||
|
|
e2577ea1c7 | ||
|
|
11346c000e | ||
|
|
ee637e8fec | ||
|
|
cb393c215a | ||
|
|
c4eac8b3c6 | ||
|
|
852e5e29ca | ||
|
|
907b3185c2 | ||
|
|
6478cd2ea4 | ||
|
|
1616f24cee | ||
|
|
160718efe2 | ||
|
|
a266b54ad6 | ||
|
|
fde024e7b8 | ||
|
|
3a600687ea | ||
|
|
67f38006f8 | ||
|
|
627bde4b72 | ||
|
|
742102b541 | ||
|
|
5251a5ca79 | ||
|
|
ba06ef57a9 | ||
|
|
0d7adc3382 | ||
|
|
1c4755f26a | ||
|
|
93a668de8b | ||
|
|
1d5b11f7f6 | ||
|
|
b1c7b88b5b | ||
|
|
bedc2be525 | ||
|
|
a321ca5b39 | ||
|
|
14fbd845c2 | ||
|
|
e4f893a0eb | ||
|
|
a30876c3ff | ||
|
|
0aaaaab7a0 | ||
|
|
21ff63c371 | ||
|
|
3deeca43a1 | ||
|
|
503ab56a59 | ||
|
|
b711ece829 | ||
|
|
efaa668158 | ||
|
|
a2fd82137c | ||
|
|
efc4805233 | ||
|
|
dc194015c2 | ||
|
|
5dd332b63d | ||
|
|
874f02631b | ||
|
|
24775f4988 | ||
|
|
f255788383 | ||
|
|
ba0997a8db | ||
|
|
7d4bb28d18 | ||
|
|
d2c69e7733 | ||
|
|
143a408342 | ||
|
|
6be68a3656 | ||
|
|
b744ebb3b3 | ||
|
|
fb37f4a1d5 | ||
|
|
5945a638ff | ||
|
|
e87d7cfaf3 | ||
|
|
2e66361482 | ||
|
|
15b054be94 | ||
|
|
1dfd5000ff | ||
|
|
4f974122f8 | ||
|
|
dc1782d049 | ||
|
|
588db95e2a | ||
|
|
1bce9a89b6 | ||
|
|
d95c04787c | ||
|
|
d99278da1d | ||
|
|
fdc24ec2ee | ||
|
|
3fd489d1cb | ||
|
|
058e077422 | ||
|
|
d2b8672c1c | ||
|
|
c8474f734c | ||
|
|
5626709de5 | ||
|
|
f70a63d575 | ||
|
|
24fac4b191 | ||
|
|
99aea27723 | ||
|
|
94e25e898a | ||
|
|
4bb0c2d053 | ||
|
|
f48eaccc51 | ||
|
|
e7c05dcfaf | ||
|
|
82b0015b30 | ||
|
|
78441730a7 | ||
|
|
5ea1299030 | ||
|
|
817d9b3389 | ||
|
|
25a590e8cd | ||
|
|
6766e04dd6 | ||
|
|
28d707604b | ||
|
|
f1f4b1a184 | ||
|
|
f41a608f11 | ||
|
|
1bc9b42c57 | ||
|
|
4b37caa63a | ||
|
|
237db8ae92 | ||
|
|
9e3f4ac954 | ||
|
|
8d3b5c851d | ||
|
|
dc662beefe | ||
|
|
7a27dd8a1b | ||
|
|
af3c4e0ce8 | ||
|
|
e4158d9703 | ||
|
|
8d230e67a2 | ||
|
|
daf29233e6 | ||
|
|
15f7a2078b | ||
|
|
26b4fb21fe | ||
|
|
617f7e8b5b | ||
|
|
be5a819621 | ||
|
|
c0e71cdea7 | ||
|
|
b89c26ab57 | ||
|
|
499c3dbdca | ||
|
|
c699c546e4 | ||
|
|
bb04545068 | ||
|
|
11504321b5 | ||
|
|
f7f3627bb1 | ||
|
|
f4a99beb16 | ||
|
|
38b0967044 | ||
|
|
14575f0a06 | ||
|
|
685e9e4f58 | ||
|
|
535e0d2553 | ||
|
|
d62a3f0e57 | ||
|
|
ca12763adc | ||
|
|
2fdf7f1098 | ||
|
|
e5b163b86a | ||
|
|
f8202384a6 | ||
|
|
35da4ffa3e | ||
|
|
4762e2fc6c | ||
|
|
8f8d8e3d0b | ||
|
|
29623d36e8 | ||
|
|
443ccbf426 | ||
|
|
838e5d05d5 | ||
|
|
7243689215 | ||
|
|
5eaf5465a5 | ||
|
|
cb492fe3c7 | ||
|
|
003238ef5e | ||
|
|
1ad67e223f | ||
|
|
9556561a77 | ||
|
|
97d6c2db6b | ||
|
|
d521e5c36a | ||
|
|
c987203f5a | ||
|
|
a96fa7a5c7 | ||
|
|
5c366e4697 | ||
|
|
4f592e9c33 | ||
|
|
b5f3f28f41 | ||
|
|
f8ad6655fb | ||
|
|
25917db07a | ||
|
|
9b2cf8501f | ||
|
|
52c1b45feb | ||
|
|
6032f31aa6 | ||
|
|
2a58c643d2 | ||
|
|
aafa11b48b | ||
|
|
a5cb069f26 | ||
|
|
1cad93c276 | ||
|
|
0116190050 | ||
|
|
cf7290343f | ||
|
|
9fff4b060e | ||
|
|
6c58ac5c55 | ||
|
|
cf0460c7f9 | ||
|
|
779f0c637f | ||
|
|
dac22887cf | ||
|
|
da01376294 | ||
|
|
74f88b3c50 | ||
|
|
ff93b162ee | ||
|
|
89f592687e | ||
|
|
5e6e52d397 | ||
|
|
20cbbd4f4c | ||
|
|
b637cdabae | ||
|
|
0f9fd38053 | ||
|
|
20f0a8a1c4 | ||
|
|
0e6417c9fa | ||
|
|
cc4bf60092 | ||
|
|
358665d944 | ||
|
|
d05440d267 | ||
|
|
ca8e0796d9 | ||
|
|
3949048dde | ||
|
|
bf083c1429 | ||
|
|
8c15ac7fab | ||
|
|
487ba2b928 | ||
|
|
2fc1f39061 | ||
|
|
9e1adec5e0 | ||
|
|
43748d439a | ||
|
|
998017a76d | ||
|
|
5c9d041423 | ||
|
|
e4644599af | ||
|
|
e6ef6088ff | ||
|
|
b4f446fe42 | ||
|
|
da7abea9aa | ||
|
|
9faf035413 | ||
|
|
8b1bd7ac6b | ||
|
|
7faf3ab04a | ||
|
|
a8014b3942 | ||
|
|
85b277b872 | ||
|
|
a1efe4caca | ||
|
|
c6111a7fb5 | ||
|
|
80145cd5a3 | ||
|
|
d39decf918 | ||
|
|
5517d912bf | ||
|
|
fbbcba95d3 | ||
|
|
8270d0cc91 | ||
|
|
ddd1a282ea | ||
|
|
773af2eef9 | ||
|
|
e8028de4d7 | ||
|
|
595a68b822 | ||
|
|
18bc6c69d5 | ||
|
|
d56725a43d | ||
|
|
b3aaa9216d | ||
|
|
ea41155c6b | ||
|
|
b337df889e | ||
|
|
00c92e88c5 | ||
|
|
8c94187c75 | ||
|
|
cd504e6ee5 | ||
|
|
6e29b8ad6f | ||
|
|
0d9cdb98f2 | ||
|
|
c5d9480313 | ||
|
|
67e32a2c44 | ||
|
|
dadfc09c01 | ||
|
|
886c88576c | ||
|
|
4ba33eb3e1 | ||
|
|
59518ec87e | ||
|
|
953f077f9d | ||
|
|
cf2f5b2026 | ||
|
|
135c16c721 | ||
|
|
e94fa791a9 | ||
|
|
5d9fa06675 | ||
|
|
b294b802a8 | ||
|
|
7bb504d491 | ||
|
|
b1bd062709 | ||
|
|
0d3b399b61 | ||
|
|
0f8e2600e3 | ||
|
|
3d71e9b509 | ||
|
|
881f385a61 | ||
|
|
e31851d25e | ||
|
|
aff72323c6 | ||
|
|
a31a396780 | ||
|
|
8555c5fae1 | ||
|
|
da71354e82 | ||
|
|
3d0e7f6cb6 | ||
|
|
c7d12cc481 | ||
|
|
440177a43d | ||
|
|
953eb6e906 | ||
|
|
fc55b44e4b | ||
|
|
f2a56fcd80 | ||
|
|
0dbc294836 | ||
|
|
3b49c1bac0 | ||
|
|
82f041d050 | ||
|
|
4f17ed961e | ||
|
|
ba551b48e1 | ||
|
|
5fc4ad6c4e | ||
|
|
b117b364f2 | ||
|
|
3603c64fa6 | ||
|
|
d405a400aa | ||
|
|
54c6f02ebb | ||
|
|
b3f9d04501 | ||
|
|
ab7ef9c9cb | ||
|
|
0f897589ed | ||
|
|
cea6a2217e | ||
|
|
dc3eceec6a | ||
|
|
a6819ffd1d | ||
|
|
de9ee10abc | ||
|
|
43989800ba | ||
|
|
1fd827fa77 | ||
|
|
3b9766f58c | ||
|
|
2c8df07753 | ||
|
|
08421311b9 | ||
|
|
dc68fa2c8b | ||
|
|
ff373621b3 | ||
|
|
272691aacd | ||
|
|
46623bc985 | ||
|
|
3462147195 | ||
|
|
268fe5efe8 | ||
|
|
0e0c70f782 | ||
|
|
acf52b9b55 | ||
|
|
7587fe56d8 | ||
|
|
ab34a95142 | ||
|
|
9e9952d81f | ||
|
|
4f2d601f02 | ||
|
|
e722801f80 | ||
|
|
6cf9204219 | ||
|
|
b719ca5a33 | ||
|
|
29ae7b9aeb | ||
|
|
45c13141f9 | ||
|
|
9079b3e8da | ||
|
|
0ee40cb636 | ||
|
|
62105c249f | ||
|
|
a629f209b9 | ||
|
|
ecb8d8991b | ||
|
|
2e4c0fee77 | ||
|
|
d961278b3d | ||
|
|
db2765aae5 | ||
|
|
7898af4ceb | ||
|
|
edfd2d0cd9 | ||
|
|
d00ad28efd | ||
|
|
02b864e41b | ||
|
|
e88ebd748d | ||
|
|
b6954f3bfd | ||
|
|
27c29bbb4c | ||
|
|
30842656a7 | ||
|
|
e5248cfaa2 | ||
|
|
c30ba14c1f | ||
|
|
cec22ad10d | ||
|
|
c08c0272b5 | ||
|
|
c52e8a2027 | ||
|
|
1fd8164756 | ||
|
|
b3b08fecb2 | ||
|
|
3c16c34386 | ||
|
|
394d96246b | ||
|
|
fc439cc02a | ||
|
|
18e6cd429a | ||
|
|
1b2621cd30 | ||
|
|
084854d71d | ||
|
|
c2ab0ad641 | ||
|
|
dbc2cda9d4 | ||
|
|
65fa61a636 | ||
|
|
04784b4e43 | ||
|
|
7eb94e9674 | ||
|
|
0a5550b13d | ||
|
|
067200be83 | ||
|
|
2baddc1709 | ||
|
|
5554595255 | ||
|
|
65a0ca2f32 | ||
|
|
d4a42a1680 | ||
|
|
af099a9b53 | ||
|
|
6ebac0e500 | ||
|
|
b25c08e79a | ||
|
|
8fd47dd658 | ||
|
|
687255aa31 | ||
|
|
5c1fbfca03 | ||
|
|
b136f14084 | ||
|
|
253e72f667 | ||
|
|
aa30227545 | ||
|
|
d1d0ddf62f | ||
|
|
77ecb0a70c | ||
|
|
cb07822aa3 | ||
|
|
defc5f1cf9 | ||
|
|
e3a3aebbf6 | ||
|
|
c05b7c382a | ||
|
|
d7aaa1489c | ||
|
|
aee3360841 | ||
|
|
256f44a870 | ||
|
|
f631b2ecdc | ||
|
|
a623dd1921 | ||
|
|
b768ad978e | ||
|
|
6b6776042c | ||
|
|
4adaeee054 | ||
|
|
a2d9420139 | ||
|
|
3431a85adf | ||
|
|
430483c7a1 | ||
|
|
3ba709fcc3 | ||
|
|
ce1fa42f9d | ||
|
|
08ac5b6ec3 | ||
|
|
a6f9ceedd8 | ||
|
|
09dfa071dc | ||
|
|
b1f764984f | ||
|
|
2aed2d164b | ||
|
|
2d011b781e | ||
|
|
4a9b349c04 | ||
|
|
71f81c5fb0 | ||
|
|
012e4a3e63 | ||
|
|
5d85076ad5 | ||
|
|
35d7e97258 | ||
|
|
89537abdc4 | ||
|
|
abfc41f382 | ||
|
|
84ac6ea12a | ||
|
|
d9c159122f | ||
|
|
2bc378a9c3 | ||
|
|
61d7bed181 | ||
|
|
a9337033c1 | ||
|
|
a0e61ee67f | ||
|
|
08d3a5d2fe | ||
|
|
a8da122fb3 | ||
|
|
da842d5a73 | ||
|
|
0794a3edf4 | ||
|
|
7bea62adbf | ||
|
|
8f703f4744 | ||
|
|
c3532b92f7 | ||
|
|
0539861dc0 | ||
|
|
deedf2a36c | ||
|
|
e89c8dbf76 | ||
|
|
b031a55a59 | ||
|
|
65f9141764 | ||
|
|
ba12d96d23 | ||
|
|
bb807554e2 | ||
|
|
56d1050bac | ||
|
|
a6e1b23eb0 | ||
|
|
5f6ab836de | ||
|
|
a9f790e101 | ||
|
|
f888c4b641 | ||
|
|
a1d50a6d05 | ||
|
|
d7df2ac60c | ||
|
|
dcae3daf43 | ||
|
|
941ee53e7a | ||
|
|
7b4e16bb8f | ||
|
|
c72393c970 | ||
|
|
f96d1e9e69 | ||
|
|
2f33e99006 | ||
|
|
79d9b8e693 | ||
|
|
91e3b3b491 | ||
|
|
f2e2065fd4 | ||
|
|
f911fda34f | ||
|
|
41df562419 | ||
|
|
73a9079ee2 | ||
|
|
9aaeb19418 | ||
|
|
be86ea2982 | ||
|
|
d0fbd260d5 | ||
|
|
b69b19ddce | ||
|
|
b647959ec4 | ||
|
|
6c0e2e249d | ||
|
|
8ed5d154b7 | ||
|
|
157a86d0f1 | ||
|
|
ca37ca291f | ||
|
|
93e535d3a1 | ||
|
|
a332092769 | ||
|
|
2696ac5eac | ||
|
|
6566c91360 | ||
|
|
7f42dcc60f | ||
|
|
369785c184 |
@@ -2,7 +2,7 @@ name: $(Date:yyyyMMdd)$(Rev:.r)
|
||||
|
||||
variables:
|
||||
- name: TestProjects
|
||||
value: 'Jellyfin.Server.Tests/Jellyfin.Server.Tests.csproj'
|
||||
value: 'tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj'
|
||||
- name: RestoreBuildProjects
|
||||
value: 'Jellyfin.Server/Jellyfin.Server.csproj'
|
||||
|
||||
@@ -16,7 +16,7 @@ jobs:
|
||||
- job: main_build
|
||||
displayName: Main Build
|
||||
pool:
|
||||
vmImage: ubuntu-16.04
|
||||
vmImage: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
release:
|
||||
@@ -28,27 +28,43 @@ jobs:
|
||||
- checkout: self
|
||||
clean: true
|
||||
submodules: true
|
||||
persistCredentials: false
|
||||
persistCredentials: true
|
||||
|
||||
- task: DotNetCoreCLI@2
|
||||
displayName: Restore
|
||||
- task: CmdLine@2
|
||||
displayName: "Check out web"
|
||||
condition: and(succeeded(), or(contains(variables['Build.SourceBranch'], 'release'), contains(variables['Build.SourceBranch'], 'master')) ,eq(variables['BuildConfiguration'], 'Release'), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'BuildCompletion'))
|
||||
inputs:
|
||||
command: restore
|
||||
projects: '$(RestoreBuildProjects)'
|
||||
script: 'git clone --single-branch --branch $(Build.SourceBranchName) --depth=1 https://github.com/jellyfin/jellyfin-web.git $(Agent.TempDirectory)/jellyfin-web'
|
||||
|
||||
- task: DotNetCoreCLI@2
|
||||
displayName: Build
|
||||
- task: CmdLine@2
|
||||
displayName: "Check out web (PR)"
|
||||
condition: and(succeeded(), or(contains(variables['System.PullRequest.TargetBranch'], 'release'), contains(variables['System.PullRequest.TargetBranch'], 'master')) ,eq(variables['BuildConfiguration'], 'Release'), in(variables['Build.Reason'], 'PullRequest'))
|
||||
inputs:
|
||||
projects: '$(RestoreBuildProjects)'
|
||||
arguments: '--configuration $(BuildConfiguration)'
|
||||
script: 'git clone --single-branch --branch $(System.PullRequest.TargetBranch) --depth 1 https://github.com/jellyfin/jellyfin-web.git $(Agent.TempDirectory)/jellyfin-web'
|
||||
|
||||
- task: DotNetCoreCLI@2
|
||||
displayName: Test
|
||||
- task: NodeTool@0
|
||||
displayName: 'Install Node.js'
|
||||
condition: and(succeeded(), or(contains(variables['System.PullRequest.TargetBranch'], 'release'), contains(variables['System.PullRequest.TargetBranch'], 'master'), contains(variables['Build.SourceBranch'], 'release'), contains(variables['Build.SourceBranch'], 'master')) ,eq(variables['BuildConfiguration'], 'Release'), in(variables['Build.Reason'], 'PullRequest', 'IndividualCI', 'BatchedCI', 'BuildCompletion'))
|
||||
inputs:
|
||||
command: test
|
||||
projects: '$(RestoreBuildProjects)'
|
||||
arguments: '--configuration $(BuildConfiguration)'
|
||||
enabled: false
|
||||
versionSpec: '10.x'
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: "Build Web UI"
|
||||
condition: and(succeeded(), or(contains(variables['System.PullRequest.TargetBranch'], 'release'), contains(variables['System.PullRequest.TargetBranch'], 'master'), contains(variables['Build.SourceBranch'], 'release'), contains(variables['Build.SourceBranch'], 'master')) ,eq(variables['BuildConfiguration'], 'Release'), in(variables['Build.Reason'], 'PullRequest', 'IndividualCI', 'BatchedCI', 'BuildCompletion'))
|
||||
inputs:
|
||||
script: yarn install
|
||||
workingDirectory: $(Agent.TempDirectory)/jellyfin-web
|
||||
|
||||
- task: CopyFiles@2
|
||||
displayName: Copy the web UI
|
||||
condition: and(succeeded(), or(contains(variables['System.PullRequest.TargetBranch'], 'release'), contains(variables['System.PullRequest.TargetBranch'], 'master'), contains(variables['Build.SourceBranch'], 'release'), contains(variables['Build.SourceBranch'], 'master')) ,eq(variables['BuildConfiguration'], 'Release'), in(variables['Build.Reason'], 'PullRequest', 'IndividualCI', 'BatchedCI', 'BuildCompletion'))
|
||||
inputs:
|
||||
sourceFolder: $(Agent.TempDirectory)/jellyfin-web/dist # Optional
|
||||
contents: '**'
|
||||
targetFolder: $(Build.SourcesDirectory)/MediaBrowser.WebDashboard/jellyfin-web
|
||||
cleanTargetFolder: true # Optional
|
||||
overWrite: true # Optional
|
||||
flattenFolders: false # Optional
|
||||
|
||||
- task: DotNetCoreCLI@2
|
||||
displayName: Publish
|
||||
@@ -59,45 +75,205 @@ jobs:
|
||||
arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
|
||||
zipAfterPublish: false
|
||||
|
||||
# - task: PublishBuildArtifacts@1
|
||||
# displayName: 'Publish Artifact'
|
||||
# inputs:
|
||||
# PathtoPublish: '$(build.artifactstagingdirectory)'
|
||||
# artifactName: 'jellyfin-build-$(BuildConfiguration)'
|
||||
# zipAfterPublish: true
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
- task: PublishPipelineArtifact@0
|
||||
displayName: 'Publish Artifact Naming'
|
||||
condition: and(eq(variables['BuildConfiguration'], 'Release'), succeeded())
|
||||
inputs:
|
||||
PathtoPublish: '$(build.artifactstagingdirectory)/Jellyfin.Server/Emby.Naming.dll'
|
||||
targetPath: '$(build.artifactstagingdirectory)/Jellyfin.Server/Emby.Naming.dll'
|
||||
artifactName: 'Jellyfin.Naming'
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
- task: PublishPipelineArtifact@0
|
||||
displayName: 'Publish Artifact Controller'
|
||||
condition: and(eq(variables['BuildConfiguration'], 'Release'), succeeded())
|
||||
inputs:
|
||||
PathtoPublish: '$(build.artifactstagingdirectory)/Jellyfin.Server/MediaBrowser.Controller.dll'
|
||||
targetPath: '$(build.artifactstagingdirectory)/Jellyfin.Server/MediaBrowser.Controller.dll'
|
||||
artifactName: 'Jellyfin.Controller'
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
- task: PublishPipelineArtifact@0
|
||||
displayName: 'Publish Artifact Model'
|
||||
condition: and(eq(variables['BuildConfiguration'], 'Release'), succeeded())
|
||||
inputs:
|
||||
PathtoPublish: '$(build.artifactstagingdirectory)/Jellyfin.Server/MediaBrowser.Model.dll'
|
||||
targetPath: '$(build.artifactstagingdirectory)/Jellyfin.Server/MediaBrowser.Model.dll'
|
||||
artifactName: 'Jellyfin.Model'
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
- task: PublishPipelineArtifact@0
|
||||
displayName: 'Publish Artifact Common'
|
||||
condition: and(eq(variables['BuildConfiguration'], 'Release'), succeeded())
|
||||
inputs:
|
||||
PathtoPublish: '$(build.artifactstagingdirectory)/Jellyfin.Server/MediaBrowser.Common.dll'
|
||||
targetPath: '$(build.artifactstagingdirectory)/Jellyfin.Server/MediaBrowser.Common.dll'
|
||||
artifactName: 'Jellyfin.Common'
|
||||
|
||||
- job: main_test
|
||||
displayName: Main Test
|
||||
pool:
|
||||
vmImage: windows-latest
|
||||
steps:
|
||||
- checkout: self
|
||||
clean: true
|
||||
submodules: true
|
||||
persistCredentials: false
|
||||
|
||||
- task: DotNetCoreCLI@2
|
||||
displayName: Build
|
||||
inputs:
|
||||
command: build
|
||||
publishWebProjects: false
|
||||
projects: '$(TestProjects)'
|
||||
arguments: '--configuration $(BuildConfiguration)'
|
||||
zipAfterPublish: false
|
||||
|
||||
- task: VisualStudioTestPlatformInstaller@1
|
||||
inputs:
|
||||
packageFeedSelector: 'nugetOrg' # Options: nugetOrg, customFeed, netShare
|
||||
versionSelector: 'latestPreRelease' # Required when packageFeedSelector == NugetOrg || PackageFeedSelector == CustomFeed# Options: latestPreRelease, latestStable, specificVersion
|
||||
|
||||
- task: VSTest@2
|
||||
inputs:
|
||||
testSelector: 'testAssemblies' # Options: testAssemblies, testPlan, testRun
|
||||
testAssemblyVer2: | # Required when testSelector == TestAssemblies
|
||||
**\bin\$(BuildConfiguration)\**\*test*.dll
|
||||
!**\obj\**
|
||||
!**\xunit.runner.visualstudio.testadapter.dll
|
||||
!**\xunit.runner.visualstudio.dotnetcore.testadapter.dll
|
||||
#testPlan: # Required when testSelector == TestPlan
|
||||
#testSuite: # Required when testSelector == TestPlan
|
||||
#testConfiguration: # Required when testSelector == TestPlan
|
||||
#tcmTestRun: '$(test.RunId)' # Optional
|
||||
searchFolder: '$(System.DefaultWorkingDirectory)'
|
||||
#testFiltercriteria: # Optional
|
||||
#runOnlyImpactedTests: False # Optional
|
||||
#runAllTestsAfterXBuilds: '50' # Optional
|
||||
#uiTests: false # Optional
|
||||
#vstestLocationMethod: 'version' # Optional. Options: version, location
|
||||
#vsTestVersion: 'latest' # Optional. Options: latest, 16.0, 15.0, 14.0, toolsInstaller
|
||||
#vstestLocation: # Optional
|
||||
#runSettingsFile: # Optional
|
||||
#overrideTestrunParameters: # Optional
|
||||
#pathtoCustomTestAdapters: # Optional
|
||||
runInParallel: True # Optional
|
||||
runTestsInIsolation: True # Optional
|
||||
codeCoverageEnabled: True # Optional
|
||||
#otherConsoleOptions: # Optional
|
||||
#distributionBatchType: 'basedOnTestCases' # Optional. Options: basedOnTestCases, basedOnExecutionTime, basedOnAssembly
|
||||
#batchingBasedOnAgentsOption: 'autoBatchSize' # Optional. Options: autoBatchSize, customBatchSize
|
||||
#customBatchSizeValue: '10' # Required when distributionBatchType == BasedOnTestCases && BatchingBasedOnAgentsOption == CustomBatchSize
|
||||
#batchingBasedOnExecutionTimeOption: 'autoBatchSize' # Optional. Options: autoBatchSize, customTimeBatchSize
|
||||
#customRunTimePerBatchValue: '60' # Required when distributionBatchType == BasedOnExecutionTime && BatchingBasedOnExecutionTimeOption == CustomTimeBatchSize
|
||||
#dontDistribute: False # Optional
|
||||
#testRunTitle: # Optional
|
||||
#platform: # Optional
|
||||
configuration: 'Debug' # Optional
|
||||
publishRunAttachments: true # Optional
|
||||
#diagnosticsEnabled: false # Optional
|
||||
#collectDumpOn: 'onAbortOnly' # Optional. Options: onAbortOnly, always, never
|
||||
#rerunFailedTests: False # Optional
|
||||
#rerunType: 'basedOnTestFailurePercentage' # Optional. Options: basedOnTestFailurePercentage, basedOnTestFailureCount
|
||||
#rerunFailedThreshold: '30' # Optional
|
||||
#rerunFailedTestCasesMaxLimit: '5' # Optional
|
||||
#rerunMaxAttempts: '3' # Optional
|
||||
|
||||
# - task: PublishTestResults@2
|
||||
# inputs:
|
||||
# testResultsFormat: 'VSTest' # Options: JUnit, NUnit, VSTest, xUnit, cTest
|
||||
# testResultsFiles: '**/*.trx'
|
||||
# #searchFolder: '$(System.DefaultWorkingDirectory)' # Optional
|
||||
# mergeTestResults: true # Optional
|
||||
# #failTaskOnFailedTests: false # Optional
|
||||
# #testRunTitle: # Optional
|
||||
# #buildPlatform: # Optional
|
||||
# #buildConfiguration: # Optional
|
||||
# #publishRunAttachments: true # Optional
|
||||
|
||||
- job: main_build_win
|
||||
displayName: Main Build Windows
|
||||
pool:
|
||||
vmImage: windows-latest
|
||||
strategy:
|
||||
matrix:
|
||||
release:
|
||||
BuildConfiguration: Release
|
||||
maxParallel: 2
|
||||
steps:
|
||||
- checkout: self
|
||||
clean: true
|
||||
submodules: true
|
||||
persistCredentials: true
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: "Check out web"
|
||||
condition: and(succeeded(), or(contains(variables['Build.SourceBranch'], 'release'), contains(variables['Build.SourceBranch'], 'master')) ,eq(variables['BuildConfiguration'], 'Release'), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'BuildCompletion'))
|
||||
inputs:
|
||||
script: 'git clone --single-branch --branch $(Build.SourceBranchName) --depth=1 https://github.com/jellyfin/jellyfin-web.git $(Agent.TempDirectory)/jellyfin-web'
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: "Check out web (PR)"
|
||||
condition: and(succeeded(), or(contains(variables['System.PullRequest.TargetBranch'], 'release'), contains(variables['System.PullRequest.TargetBranch'], 'master')) ,eq(variables['BuildConfiguration'], 'Release'), in(variables['Build.Reason'], 'PullRequest'))
|
||||
inputs:
|
||||
script: 'git clone --single-branch --branch $(System.PullRequest.TargetBranch) --depth 1 https://github.com/jellyfin/jellyfin-web.git $(Agent.TempDirectory)/jellyfin-web'
|
||||
|
||||
- task: NodeTool@0
|
||||
displayName: 'Install Node.js'
|
||||
condition: and(succeeded(), or(contains(variables['System.PullRequest.TargetBranch'], 'release'), contains(variables['System.PullRequest.TargetBranch'], 'master'), contains(variables['Build.SourceBranch'], 'release'), contains(variables['Build.SourceBranch'], 'master')) ,eq(variables['BuildConfiguration'], 'Release'), in(variables['Build.Reason'], 'PullRequest', 'IndividualCI', 'BatchedCI', 'BuildCompletion'))
|
||||
inputs:
|
||||
versionSpec: '10.x'
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: "Build Web UI"
|
||||
condition: and(succeeded(), or(contains(variables['System.PullRequest.TargetBranch'], 'release'), contains(variables['System.PullRequest.TargetBranch'], 'master'), contains(variables['Build.SourceBranch'], 'release'), contains(variables['Build.SourceBranch'], 'master')) ,eq(variables['BuildConfiguration'], 'Release'), in(variables['Build.Reason'], 'PullRequest', 'IndividualCI', 'BatchedCI', 'BuildCompletion'))
|
||||
inputs:
|
||||
script: yarn install
|
||||
workingDirectory: $(Agent.TempDirectory)/jellyfin-web
|
||||
|
||||
- task: CopyFiles@2
|
||||
displayName: Copy the web UI
|
||||
condition: and(succeeded(), or(contains(variables['System.PullRequest.TargetBranch'], 'release'), contains(variables['System.PullRequest.TargetBranch'], 'master'), contains(variables['Build.SourceBranch'], 'release'), contains(variables['Build.SourceBranch'], 'master')) ,eq(variables['BuildConfiguration'], 'Release'), in(variables['Build.Reason'], 'PullRequest', 'IndividualCI', 'BatchedCI', 'BuildCompletion'))
|
||||
inputs:
|
||||
sourceFolder: $(Agent.TempDirectory)/jellyfin-web/dist # Optional
|
||||
contents: '**'
|
||||
targetFolder: $(Build.SourcesDirectory)/MediaBrowser.WebDashboard/jellyfin-web
|
||||
cleanTargetFolder: true # Optional
|
||||
overWrite: true # Optional
|
||||
flattenFolders: false # Optional
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: Clone the UX repository
|
||||
inputs:
|
||||
script: git clone --depth=1 https://github.com/jellyfin/jellyfin-ux $(Agent.TempDirectory)\jellyfin-ux
|
||||
|
||||
- task: PowerShell@2
|
||||
displayName: Build the NSIS Installer
|
||||
inputs:
|
||||
targetType: 'filePath' # Optional. Options: filePath, inline
|
||||
filePath: ./deployment/windows/build-jellyfin.ps1 # Required when targetType == FilePath
|
||||
arguments: -InstallFFMPEG -InstallNSSM -MakeNSIS -InstallTrayApp -UXLocation $(Agent.TempDirectory)\jellyfin-ux -InstallLocation $(build.artifactstagingdirectory)
|
||||
#script: '# Write your PowerShell commands here.Write-Host Hello World' # Required when targetType == Inline
|
||||
errorActionPreference: 'stop' # Optional. Options: stop, continue, silentlyContinue
|
||||
#failOnStderr: false # Optional
|
||||
#ignoreLASTEXITCODE: false # Optional
|
||||
#pwsh: false # Optional
|
||||
workingDirectory: $(Build.SourcesDirectory) # Optional
|
||||
|
||||
- task: CopyFiles@2
|
||||
displayName: Copy the NSIS Installer to the artifact directory
|
||||
inputs:
|
||||
sourceFolder: $(Build.SourcesDirectory)/deployment/windows/ # Optional
|
||||
contents: 'jellyfin*.exe'
|
||||
targetFolder: $(System.ArtifactsDirectory)/setup
|
||||
cleanTargetFolder: true # Optional
|
||||
overWrite: true # Optional
|
||||
flattenFolders: true # Optional
|
||||
|
||||
- task: PublishPipelineArtifact@0
|
||||
displayName: 'Publish Setup Artifact'
|
||||
condition: and(eq(variables['BuildConfiguration'], 'Release'), succeeded())
|
||||
inputs:
|
||||
targetPath: '$(build.artifactstagingdirectory)/setup'
|
||||
artifactName: 'Jellyfin Server Setup'
|
||||
|
||||
- job: dotnet_compat
|
||||
displayName: Compatibility Check
|
||||
pool:
|
||||
vmImage: ubuntu-16.04
|
||||
vmImage: ubuntu-latest
|
||||
dependsOn: main_build
|
||||
condition: and(succeeded(), variables['System.PullRequest.PullRequestNumber']) # Only execute if the pullrequest numer is defined. (So not for normal CI builds)
|
||||
strategy:
|
||||
@@ -118,45 +294,23 @@ jobs:
|
||||
steps:
|
||||
- checkout: none
|
||||
|
||||
- task: DownloadBuildArtifacts@0
|
||||
displayName: Download the Reference Assembly Build Artifact
|
||||
inputs:
|
||||
buildType: 'specific' # Options: current, specific
|
||||
project: $(System.TeamProjectId) # Required when buildType == Specific
|
||||
pipeline: $(System.DefinitionId) # Required when buildType == Specific, not sure if this will take a name too
|
||||
#specificBuildWithTriggering: false # Optional
|
||||
buildVersionToDownload: 'latestFromBranch' # Required when buildType == Specific# Options: latest, latestFromBranch, specific
|
||||
allowPartiallySucceededBuilds: false # Optional
|
||||
branchName: '$(System.PullRequest.TargetBranch)' # Required when buildType == Specific && BuildVersionToDownload == LatestFromBranch
|
||||
#buildId: # Required when buildType == Specific && BuildVersionToDownload == Specific
|
||||
#tags: # Optional
|
||||
downloadType: 'single' # Options: single, specific
|
||||
artifactName: '$(NugetPackageName)'# Required when downloadType == Single
|
||||
#itemPattern: '**' # Optional
|
||||
downloadPath: '$(System.ArtifactsDirectory)/current-artifacts'
|
||||
#parallelizationLimit: '8' # Optional
|
||||
|
||||
- task: CopyFiles@2
|
||||
displayName: Copy Nuget Assembly to current-release folder
|
||||
inputs:
|
||||
sourceFolder: $(System.ArtifactsDirectory)/current-artifacts # Optional
|
||||
contents: '**/*.dll'
|
||||
targetFolder: $(System.ArtifactsDirectory)/current-release
|
||||
cleanTargetFolder: true # Optional
|
||||
overWrite: true # Optional
|
||||
flattenFolders: true # Optional
|
||||
|
||||
- task: DownloadBuildArtifacts@0
|
||||
- task: DownloadPipelineArtifact@2
|
||||
displayName: Download the New Assembly Build Artifact
|
||||
inputs:
|
||||
buildType: 'current' # Options: current, specific
|
||||
allowPartiallySucceededBuilds: false # Optional
|
||||
downloadType: 'single' # Options: single, specific
|
||||
artifactName: '$(NugetPackageName)' # Required when downloadType == Single
|
||||
downloadPath: '$(System.ArtifactsDirectory)/new-artifacts'
|
||||
source: 'current' # Options: current, specific
|
||||
#preferTriggeringPipeline: false # Optional
|
||||
#tags: # Optional
|
||||
artifact: '$(NugetPackageName)' # Optional
|
||||
#patterns: '**' # Optional
|
||||
path: '$(System.ArtifactsDirectory)/new-artifacts'
|
||||
#project: # Required when source == Specific
|
||||
#pipeline: # Required when source == Specific
|
||||
runVersion: 'latest' # Required when source == Specific. Options: latest, latestFromBranch, specific
|
||||
#runBranch: 'refs/heads/master' # Required when source == Specific && runVersion == LatestFromBranch
|
||||
#runId: # Required when source == Specific && runVersion == Specific
|
||||
|
||||
- task: CopyFiles@2
|
||||
displayName: Copy Artifact Assembly to new-release folder
|
||||
displayName: Copy New Assembly to new-release folder
|
||||
inputs:
|
||||
sourceFolder: $(System.ArtifactsDirectory)/new-artifacts # Optional
|
||||
contents: '**/*.dll'
|
||||
@@ -165,10 +319,35 @@ jobs:
|
||||
overWrite: true # Optional
|
||||
flattenFolders: true # Optional
|
||||
|
||||
- task: DownloadPipelineArtifact@2
|
||||
displayName: Download the Reference Assembly Build Artifact
|
||||
inputs:
|
||||
source: 'specific' # Options: current, specific
|
||||
#preferTriggeringPipeline: false # Optional
|
||||
#tags: # Optional
|
||||
artifact: '$(NugetPackageName)' # Optional
|
||||
#patterns: '**' # Optional
|
||||
path: '$(System.ArtifactsDirectory)/current-artifacts'
|
||||
project: '$(System.TeamProjectId)' # Required when source == Specific
|
||||
pipeline: '$(System.DefinitionId)' # Required when source == Specific
|
||||
runVersion: 'latestFromBranch' # Required when source == Specific. Options: latest, latestFromBranch, specific
|
||||
runBranch: 'refs/heads/$(System.PullRequest.TargetBranch)' # Required when source == Specific && runVersion == LatestFromBranch
|
||||
#runId: # Required when source == Specific && runVersion == Specific
|
||||
|
||||
- task: CopyFiles@2
|
||||
displayName: Copy Reference Assembly to current-release folder
|
||||
inputs:
|
||||
sourceFolder: $(System.ArtifactsDirectory)/current-artifacts # Optional
|
||||
contents: '**/*.dll'
|
||||
targetFolder: $(System.ArtifactsDirectory)/current-release
|
||||
cleanTargetFolder: true # Optional
|
||||
overWrite: true # Optional
|
||||
flattenFolders: true # Optional
|
||||
|
||||
- task: DownloadGitHubRelease@0
|
||||
displayName: Download ABI compatibility check tool from GitHub
|
||||
inputs:
|
||||
connection: Jellyfin GitHub
|
||||
connection: Jellyfin Release Download
|
||||
userRepository: EraYaN/dotnet-compatibility
|
||||
defaultVersionType: 'latest' # Options: latest, specificVersion, specificTag
|
||||
#version: # Required when defaultVersionType != Latest
|
||||
@@ -185,7 +364,7 @@ jobs:
|
||||
- task: CmdLine@2
|
||||
displayName: Execute ABI compatibility check tool
|
||||
inputs:
|
||||
script: 'dotnet tools/CompatibilityCheckerCoreCLI.dll current-release/$(AssemblyFileName) new-release/$(AssemblyFileName)'
|
||||
script: 'dotnet tools/CompatibilityCheckerCoreCLI.dll current-release/$(AssemblyFileName) new-release/$(AssemblyFileName) --azure-pipelines'
|
||||
workingDirectory: $(System.ArtifactsDirectory) # Optional
|
||||
#failOnStderr: false # Optional
|
||||
|
||||
|
||||
46
.ci/publish-nightly.yml
Normal file
46
.ci/publish-nightly.yml
Normal file
@@ -0,0 +1,46 @@
|
||||
name: Nightly-$(date:yyyyMMdd).$(rev:r)
|
||||
|
||||
variables:
|
||||
- name: Version
|
||||
value: '1.0.0'
|
||||
|
||||
trigger: none
|
||||
pr: none
|
||||
|
||||
jobs:
|
||||
- job: publish_artifacts_nightly
|
||||
displayName: Publish Artifacts Nightly
|
||||
pool:
|
||||
vmImage: ubuntu-latest
|
||||
steps:
|
||||
- checkout: none
|
||||
- task: DownloadPipelineArtifact@2
|
||||
displayName: Download the Windows Setup Artifact
|
||||
inputs:
|
||||
source: 'specific' # Options: current, specific
|
||||
artifact: 'Jellyfin Server Setup' # Optional
|
||||
path: '$(System.ArtifactsDirectory)/win-installer'
|
||||
project: '$(System.TeamProjectId)' # Required when source == Specific
|
||||
pipelineId: 1 # Required when source == Specific
|
||||
runVersion: 'latestFromBranch' # Required when source == Specific. Options: latest, latestFromBranch, specific
|
||||
runBranch: 'refs/heads/master' # Required when source == Specific && runVersion == LatestFromBranch
|
||||
|
||||
- task: SSH@0
|
||||
displayName: 'Create Drop directory'
|
||||
inputs:
|
||||
sshEndpoint: 'Jellyfin Build Server'
|
||||
commands: 'mkdir -p /srv/incoming/jellyfin_$(Version)/win-installer && ln -s /srv/incoming/jellyfin_$(Version) /srv/incoming/jellyfin_nightly_azure_upload'
|
||||
|
||||
- task: CopyFilesOverSSH@0
|
||||
displayName: 'Copy the Windows Setup to the Repo'
|
||||
inputs:
|
||||
sshEndpoint: 'Jellyfin Build Server'
|
||||
sourceFolder: '$(System.ArtifactsDirectory)/win-installer'
|
||||
contents: 'jellyfin_*.exe'
|
||||
targetFolder: '/srv/incoming/jellyfin_nightly_azure_upload/win-installer'
|
||||
|
||||
- task: SSH@0
|
||||
displayName: 'Clean up SCP symlink'
|
||||
inputs:
|
||||
sshEndpoint: 'Jellyfin Build Server'
|
||||
commands: 'rm -f /srv/incoming/jellyfin_nightly_azure_upload'
|
||||
48
.ci/publish-release.yml
Normal file
48
.ci/publish-release.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
name: Release-$(Version)-$(date:yyyyMMdd).$(rev:r)
|
||||
|
||||
variables:
|
||||
- name: Version
|
||||
value: '1.0.0'
|
||||
- name: UsedRunId
|
||||
value: 0
|
||||
|
||||
trigger: none
|
||||
pr: none
|
||||
|
||||
jobs:
|
||||
- job: publish_artifacts_release
|
||||
displayName: Publish Artifacts Release
|
||||
pool:
|
||||
vmImage: ubuntu-latest
|
||||
steps:
|
||||
- checkout: none
|
||||
- task: DownloadPipelineArtifact@2
|
||||
displayName: Download the Windows Setup Artifact
|
||||
inputs:
|
||||
source: 'specific' # Options: current, specific
|
||||
artifact: 'Jellyfin Server Setup' # Optional
|
||||
path: '$(System.ArtifactsDirectory)/win-installer'
|
||||
project: '$(System.TeamProjectId)' # Required when source == Specific
|
||||
pipelineId: 1 # Required when source == Specific
|
||||
runVersion: 'specific' # Required when source == Specific. Options: latest, latestFromBranch, specific
|
||||
runId: $(UsedRunId)
|
||||
|
||||
- task: SSH@0
|
||||
displayName: 'Create Drop directory'
|
||||
inputs:
|
||||
sshEndpoint: 'Jellyfin Build Server'
|
||||
commands: 'mkdir -p /srv/incoming/jellyfin_$(Version)/win-installer && ln -s /srv/incoming/jellyfin_$(Version) /srv/incoming/jellyfin_release_azure_upload'
|
||||
|
||||
- task: CopyFilesOverSSH@0
|
||||
displayName: 'Copy the Windows Setup to the Repo'
|
||||
inputs:
|
||||
sshEndpoint: 'Jellyfin Build Server'
|
||||
sourceFolder: '$(System.ArtifactsDirectory)/win-installer'
|
||||
contents: 'jellyfin_*.exe'
|
||||
targetFolder: '/srv/incoming/jellyfin_release_azure_upload/win-installer'
|
||||
|
||||
- task: SSH@0
|
||||
displayName: 'Clean up SCP symlink'
|
||||
inputs:
|
||||
sshEndpoint: 'Jellyfin Build Server'
|
||||
commands: 'rm -f /srv/incoming/jellyfin_release_azure_upload'
|
||||
@@ -1,8 +1,59 @@
|
||||
srpm:
|
||||
dnf -y install git
|
||||
git submodule update --init --recursive
|
||||
cd deployment/fedora-package-x64; \
|
||||
./create_tarball.sh; \
|
||||
rpmbuild -bs pkg-src/jellyfin.spec \
|
||||
--define "_sourcedir $$PWD/pkg-src/" \
|
||||
--define "_srcrpmdir $(outdir)"
|
||||
VERSION := $(shell sed -ne '/^Version:/s/.* *//p' \
|
||||
deployment/fedora-package-x64/pkg-src/jellyfin.spec)
|
||||
|
||||
deployment/fedora-package-x64/pkg-src/jellyfin-web-$(VERSION).tar.gz:
|
||||
curl -f -L -o deployment/fedora-package-x64/pkg-src/jellyfin-web-$(VERSION).tar.gz \
|
||||
https://github.com/jellyfin/jellyfin-web/archive/v$(VERSION).tar.gz \
|
||||
|| curl -f -L -o deployment/fedora-package-x64/pkg-src/jellyfin-web-$(VERSION).tar.gz \
|
||||
https://github.com/jellyfin/jellyfin-web/archive/master.tar.gz \
|
||||
|
||||
srpm: deployment/fedora-package-x64/pkg-src/jellyfin-web-$(VERSION).tar.gz
|
||||
cd deployment/fedora-package-x64; \
|
||||
SOURCE_DIR=../.. \
|
||||
WORKDIR="$${PWD}"; \
|
||||
package_temporary_dir="$${WORKDIR}/pkg-dist-tmp"; \
|
||||
pkg_src_dir="$${WORKDIR}/pkg-src"; \
|
||||
GNU_TAR=1; \
|
||||
tar \
|
||||
--transform "s,^\.,jellyfin-$(VERSION)," \
|
||||
--exclude='.git*' \
|
||||
--exclude='**/.git' \
|
||||
--exclude='**/.hg' \
|
||||
--exclude='**/.vs' \
|
||||
--exclude='**/.vscode' \
|
||||
--exclude='deployment' \
|
||||
--exclude='**/bin' \
|
||||
--exclude='**/obj' \
|
||||
--exclude='**/.nuget' \
|
||||
--exclude='*.deb' \
|
||||
--exclude='*.rpm' \
|
||||
-czf "pkg-src/jellyfin-$(VERSION).tar.gz" \
|
||||
-C $${SOURCE_DIR} ./ || GNU_TAR=0; \
|
||||
if [ $${GNU_TAR} -eq 0 ]; then \
|
||||
package_temporary_dir="$$(mktemp -d)"; \
|
||||
mkdir -p "$${package_temporary_dir}/jellyfin"; \
|
||||
tar \
|
||||
--exclude='.git*' \
|
||||
--exclude='**/.git' \
|
||||
--exclude='**/.hg' \
|
||||
--exclude='**/.vs' \
|
||||
--exclude='**/.vscode' \
|
||||
--exclude='deployment' \
|
||||
--exclude='**/bin' \
|
||||
--exclude='**/obj' \
|
||||
--exclude='**/.nuget' \
|
||||
--exclude='*.deb' \
|
||||
--exclude='*.rpm' \
|
||||
-czf "$${package_temporary_dir}/jellyfin/jellyfin-$(VERSION).tar.gz" \
|
||||
-C $${SOURCE_DIR} ./; \
|
||||
mkdir -p "$${package_temporary_dir}/jellyfin-$(VERSION)"; \
|
||||
tar -xzf "$${package_temporary_dir}/jellyfin/jellyfin-$(VERSION).tar.gz" \
|
||||
-C "$${package_temporary_dir}/jellyfin-$(VERSION); \
|
||||
rm -f "$${package_temporary_dir}/jellyfin/jellyfin-$(VERSION).tar.gz"; \
|
||||
tar -czf "$${SOURCE_DIR}/SOURCES/pkg-src/jellyfin-$(VERSION).tar.gz" \
|
||||
-C "$${package_temporary_dir}" "jellyfin-$(VERSION); \
|
||||
rm -rf $${package_temporary_dir}; \
|
||||
fi; \
|
||||
rpmbuild -bs pkg-src/jellyfin.spec \
|
||||
--define "_sourcedir $$PWD/pkg-src/" \
|
||||
--define "_srcrpmdir $(outdir)"
|
||||
|
||||
4
.gitattributes
vendored
4
.gitattributes
vendored
@@ -1 +1,5 @@
|
||||
* text=auto eol=lf
|
||||
*.png binary
|
||||
*.jpg binary
|
||||
|
||||
CONTRIBUTORS.md merge=union
|
||||
|
||||
20
.github/ISSUE_TEMPLATE/enhancement-request.md
vendored
20
.github/ISSUE_TEMPLATE/enhancement-request.md
vendored
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: Enhancement request
|
||||
about: Suggest an modification to an existing feature
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
|
||||
|
||||
**Describe the solution you'd like**
|
||||
<!-- A clear and concise description of what you want to happen. -->
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
|
||||
|
||||
**Additional context**
|
||||
<!-- Add any other context or screenshots about the feature request here. -->
|
||||
14
.github/ISSUE_TEMPLATE/feature_request.md
vendored
14
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,14 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest a new feature
|
||||
title: ''
|
||||
labels: feature
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the feature you'd like**
|
||||
<!-- A clear and concise description of what you want to happen. -->
|
||||
|
||||
**Additional context**
|
||||
<!-- Add any other context or screenshots about the feature request here. -->
|
||||
32
.github/ISSUE_TEMPLATE/media_playback.md
vendored
Normal file
32
.github/ISSUE_TEMPLATE/media_playback.md
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
name: Media playback issue
|
||||
about: Create a media playback issue report
|
||||
title: ''
|
||||
labels: mediaplayback
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Media Info of the file**
|
||||
<!-- Use the Media Info tool (set to text format, download here: https://mediaarea.net/en/MediaInfo) or copy the info from the web ui for the file with the playback issue. -->
|
||||
|
||||
**Logs**
|
||||
<!-- Please paste any log message from during the playback issue, for example the ffmpeg command line can be very useful. -->
|
||||
|
||||
**Stats for Nerds Screenshots**
|
||||
<!-- If available, add screenshots of the stats for nerds screen to help show the issue problem. -->
|
||||
|
||||
**Server System (please complete the following information):**
|
||||
- OS: [e.g. Docker on Linux, Docker on Windows, Debian, Windows]
|
||||
- Jellyfin Version: [e.g. 10.0.1]
|
||||
- Hardware settings & device: [e.g. NVENC on GTX1060, VAAPI on Intel i7 8700K]
|
||||
- Reverse proxy: [e.g. no, nginx, apache, etc.]
|
||||
- Other hardware notes: [e.g. Media mounted in CIFS/SMB share, Media mounted from Google Drive]
|
||||
|
||||
**Client System (please complete the following information):**
|
||||
- Device: [e.g. Apple iPhone XS, Xbox One S, LG OLED55C8, Samsung Galaxy Note9, Custom HTPC]
|
||||
- OS: [e.g. iOS, Android, Windows, macOS]
|
||||
- Client: [e.g. Web/Browser, webOS, Android, Android TV, Electron]
|
||||
- Browser (if Web client): [e.g. Firefox, Chrome, Safari]
|
||||
- Client and Browser Version: [e.g. 10.3.4 and 68.0]
|
||||
|
||||
2
.github/pull_request_template.md
vendored
2
.github/pull_request_template.md
vendored
@@ -1,6 +1,6 @@
|
||||
<!--
|
||||
Ensure your title is short, descriptive, and in the imperative mood (Fix X, Change Y, instead of Fixed X, Changed Y).
|
||||
For a good inspiration of what to write in commit messages and PRs please review https://chris.beams.io/posts/git-commit/ and our https://jellyfin.readthedocs.io/en/latest/developer-docs/contributing/ page.
|
||||
For a good inspiration of what to write in commit messages and PRs please review https://chris.beams.io/posts/git-commit/ and our documentation.
|
||||
-->
|
||||
|
||||
**Changes**
|
||||
|
||||
22
.github/stale.yml
vendored
Normal file
22
.github/stale.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 90
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 14
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- regression
|
||||
- security
|
||||
- dotnet-3.0-future
|
||||
- roadmap
|
||||
- future
|
||||
- feature
|
||||
- enhancement
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: stale
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
Issues go stale after 90d of inactivity. Mark the issue as fresh by adding a comment or commit. Stale issues close after an additional 14d of inactivity.
|
||||
If this issue is safe to close now please do so.
|
||||
If you have any questions you can reach us on [Matrix or Social Media](https://docs.jellyfin.org/general/getting-help.html).
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
||||
11
.gitignore
vendored
11
.gitignore
vendored
@@ -239,11 +239,6 @@ pip-log.txt
|
||||
##########
|
||||
.idea/
|
||||
|
||||
##########
|
||||
# Visual Studio Code
|
||||
##########
|
||||
.vscode/
|
||||
|
||||
#########################
|
||||
# Build artifacts
|
||||
#########################
|
||||
@@ -268,4 +263,8 @@ jellyfin_version.ini
|
||||
ci/
|
||||
|
||||
# Doxygen
|
||||
doc/
|
||||
doc/
|
||||
|
||||
# Deployment artifacts
|
||||
dist
|
||||
*.exe
|
||||
|
||||
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -1,4 +0,0 @@
|
||||
[submodule "MediaBrowser.WebDashboard/jellyfin-web"]
|
||||
path = MediaBrowser.WebDashboard/jellyfin-web
|
||||
url = https://github.com/jellyfin/jellyfin-web.git
|
||||
branch = .
|
||||
@@ -11,6 +11,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -212,7 +212,6 @@ namespace BDInfo
|
||||
|
||||
public void Scan()
|
||||
{
|
||||
var errorStreamClipFiles = new List<TSStreamClipFile>();
|
||||
foreach (var streamClipFile in StreamClipFiles.Values)
|
||||
{
|
||||
try
|
||||
@@ -221,7 +220,6 @@ namespace BDInfo
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errorStreamClipFiles.Add(streamClipFile);
|
||||
if (StreamClipFileScanError != null)
|
||||
{
|
||||
if (StreamClipFileScanError(streamClipFile, ex))
|
||||
@@ -250,7 +248,6 @@ namespace BDInfo
|
||||
StreamFiles.Values.CopyTo(streamFiles, 0);
|
||||
Array.Sort(streamFiles, CompareStreamFiles);
|
||||
|
||||
var errorPlaylistFiles = new List<TSPlaylistFile>();
|
||||
foreach (var playlistFile in PlaylistFiles.Values)
|
||||
{
|
||||
try
|
||||
@@ -259,7 +256,6 @@ namespace BDInfo
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errorPlaylistFiles.Add(playlistFile);
|
||||
if (PlaylistFileScanError != null)
|
||||
{
|
||||
if (PlaylistFileScanError(playlistFile, ex))
|
||||
@@ -275,7 +271,6 @@ namespace BDInfo
|
||||
}
|
||||
}
|
||||
|
||||
var errorStreamFiles = new List<TSStreamFile>();
|
||||
foreach (var streamFile in streamFiles)
|
||||
{
|
||||
try
|
||||
@@ -296,7 +291,6 @@ namespace BDInfo
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errorStreamFiles.Add(streamFile);
|
||||
if (StreamFileScanError != null)
|
||||
{
|
||||
if (StreamFileScanError(streamFile, ex))
|
||||
@@ -431,7 +425,7 @@ namespace BDInfo
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if ((x != null || x.FileInfo != null) && (y == null || y.FileInfo == null))
|
||||
else if ((x != null && x.FileInfo != null) && (y == null || y.FileInfo == null))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -451,6 +445,5 @@ namespace BDInfo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,13 @@
|
||||
- [fruhnow](https://github.com/fruhnow)
|
||||
- [Lynxy](https://github.com/Lynxy)
|
||||
- [fasheng](https://github.com/fasheng)
|
||||
- [ploughpuff](https://github.com/ploughpuff)
|
||||
- [ploughpuff](https://github.com/ploughpuff)
|
||||
- [pjeanjean](https://github.com/pjeanjean)
|
||||
- [DrPandemic](https://github.com/drpandemic)
|
||||
- [joern-h](https://github.com/joern-h)
|
||||
- [Khinenw](https://github.com/HelloWorld017)
|
||||
- [fhriley](https://github.com/fhriley)
|
||||
- [nevado](https://github.com/nevado)
|
||||
|
||||
# Emby Contributors
|
||||
|
||||
|
||||
32
Dockerfile
32
Dockerfile
@@ -1,30 +1,38 @@
|
||||
ARG DOTNET_VERSION=2.2
|
||||
ARG FFMPEG_VERSION=latest
|
||||
|
||||
FROM node:alpine as web-builder
|
||||
ARG JELLYFIN_WEB_VERSION=v10.4.3
|
||||
RUN apk add curl \
|
||||
&& curl -L https://github.com/jellyfin/jellyfin-web/archive/${JELLYFIN_WEB_VERSION}.tar.gz | tar zxf - \
|
||||
&& cd jellyfin-web-* \
|
||||
&& yarn install \
|
||||
&& yarn build \
|
||||
&& mv dist /dist
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/core/sdk:${DOTNET_VERSION} as builder
|
||||
WORKDIR /repo
|
||||
COPY . .
|
||||
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||
RUN bash -c "source deployment/common.build.sh && \
|
||||
build_jellyfin Jellyfin.Server Release linux-x64 /jellyfin"
|
||||
RUN dotnet publish Jellyfin.Server --configuration Release --output="/jellyfin" --self-contained --runtime linux-x64 "-p:GenerateDocumentationFile=false;DebugSymbols=false;DebugType=none"
|
||||
|
||||
FROM jellyfin/ffmpeg:${FFMPEG_VERSION} as ffmpeg
|
||||
|
||||
FROM jellyfin/ffmpeg as ffmpeg
|
||||
FROM mcr.microsoft.com/dotnet/core/runtime:${DOTNET_VERSION}
|
||||
# libfontconfig1 is required for Skia
|
||||
COPY --from=ffmpeg / /
|
||||
COPY --from=builder /jellyfin /jellyfin
|
||||
COPY --from=web-builder /dist /jellyfin/jellyfin-web
|
||||
# Install dependencies:
|
||||
# libfontconfig1: needed for Skia
|
||||
# mesa-va-drivers: needed for VAAPI
|
||||
RUN apt-get update \
|
||||
&& apt-get install --no-install-recommends --no-install-suggests -y \
|
||||
libfontconfig1 \
|
||||
libfontconfig1 mesa-va-drivers \
|
||||
&& apt-get clean autoclean \
|
||||
&& apt-get autoremove \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& mkdir -p /cache /config /media \
|
||||
&& chmod 777 /cache /config /media
|
||||
COPY --from=ffmpeg / /
|
||||
COPY --from=builder /jellyfin /jellyfin
|
||||
|
||||
ARG JELLYFIN_WEB_VERSION=10.3.5
|
||||
RUN curl -L https://github.com/jellyfin/jellyfin-web/archive/v${JELLYFIN_WEB_VERSION}.tar.gz | tar zxf - \
|
||||
&& rm -rf /jellyfin/jellyfin-web \
|
||||
&& mv jellyfin-web-${JELLYFIN_WEB_VERSION} /jellyfin/jellyfin-web
|
||||
|
||||
EXPOSE 8096
|
||||
VOLUME /cache /config /media
|
||||
|
||||
@@ -3,6 +3,16 @@
|
||||
ARG DOTNET_VERSION=3.0
|
||||
|
||||
|
||||
FROM node:alpine as web-builder
|
||||
ARG JELLYFIN_WEB_VERSION=v10.4.3
|
||||
RUN apk add curl \
|
||||
&& curl -L https://github.com/jellyfin/jellyfin-web/archive/${JELLYFIN_WEB_VERSION}.tar.gz | tar zxf - \
|
||||
&& cd jellyfin-web-* \
|
||||
&& yarn install \
|
||||
&& yarn build \
|
||||
&& mv dist /dist
|
||||
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/core/sdk:${DOTNET_VERSION} as builder
|
||||
WORKDIR /repo
|
||||
COPY . .
|
||||
@@ -12,8 +22,7 @@ RUN find . -type f -exec sed -i 's/netcoreapp2.1/netcoreapp3.0/g' {} \;
|
||||
# Discard objs - may cause failures if exists
|
||||
RUN find . -type d -name obj | xargs -r rm -r
|
||||
# Build
|
||||
RUN bash -c "source deployment/common.build.sh && \
|
||||
build_jellyfin Jellyfin.Server Release linux-arm /jellyfin"
|
||||
RUN dotnet publish Jellyfin.Server --configuration Release --output="/jellyfin" --self-contained --runtime linux-arm "-p:GenerateDocumentationFile=false;DebugSymbols=false;DebugType=none"
|
||||
|
||||
|
||||
FROM multiarch/qemu-user-static:x86_64-arm as qemu
|
||||
@@ -25,11 +34,7 @@ RUN apt-get update \
|
||||
&& mkdir -p /cache /config /media \
|
||||
&& chmod 777 /cache /config /media
|
||||
COPY --from=builder /jellyfin /jellyfin
|
||||
|
||||
ARG JELLYFIN_WEB_VERSION=10.3.5
|
||||
RUN curl -L https://github.com/jellyfin/jellyfin-web/archive/v${JELLYFIN_WEB_VERSION}.tar.gz | tar zxf - \
|
||||
&& rm -rf /jellyfin/jellyfin-web \
|
||||
&& mv jellyfin-web-${JELLYFIN_WEB_VERSION} /jellyfin/jellyfin-web
|
||||
COPY --from=web-builder /dist /jellyfin/jellyfin-web
|
||||
|
||||
EXPOSE 8096
|
||||
VOLUME /cache /config /media
|
||||
|
||||
@@ -3,6 +3,16 @@
|
||||
ARG DOTNET_VERSION=3.0
|
||||
|
||||
|
||||
FROM node:alpine as web-builder
|
||||
ARG JELLYFIN_WEB_VERSION=v10.4.3
|
||||
RUN apk add curl \
|
||||
&& curl -L https://github.com/jellyfin/jellyfin-web/archive/${JELLYFIN_WEB_VERSION}.tar.gz | tar zxf - \
|
||||
&& cd jellyfin-web-* \
|
||||
&& yarn install \
|
||||
&& yarn build \
|
||||
&& mv dist /dist
|
||||
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/core/sdk:${DOTNET_VERSION} as builder
|
||||
WORKDIR /repo
|
||||
COPY . .
|
||||
@@ -12,8 +22,7 @@ RUN find . -type f -exec sed -i 's/netcoreapp2.1/netcoreapp3.0/g' {} \;
|
||||
# Discard objs - may cause failures if exists
|
||||
RUN find . -type d -name obj | xargs -r rm -r
|
||||
# Build
|
||||
RUN bash -c "source deployment/common.build.sh && \
|
||||
build_jellyfin Jellyfin.Server Release linux-arm64 /jellyfin"
|
||||
RUN dotnet publish Jellyfin.Server --configuration Release --output="/jellyfin" --self-contained --runtime linux-arm64 "-p:GenerateDocumentationFile=false;DebugSymbols=false;DebugType=none"
|
||||
|
||||
|
||||
FROM multiarch/qemu-user-static:x86_64-aarch64 as qemu
|
||||
@@ -25,11 +34,7 @@ RUN apt-get update \
|
||||
&& mkdir -p /cache /config /media \
|
||||
&& chmod 777 /cache /config /media
|
||||
COPY --from=builder /jellyfin /jellyfin
|
||||
|
||||
ARG JELLYFIN_WEB_VERSION=10.3.5
|
||||
RUN curl -L https://github.com/jellyfin/jellyfin-web/archive/v${JELLYFIN_WEB_VERSION}.tar.gz | tar zxf - \
|
||||
&& rm -rf /jellyfin/jellyfin-web \
|
||||
&& mv jellyfin-web-${JELLYFIN_WEB_VERSION} /jellyfin/jellyfin-web
|
||||
COPY --from=web-builder /dist /jellyfin/jellyfin-web
|
||||
|
||||
EXPOSE 8096
|
||||
VOLUME /cache /config /media
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Emby.Dlna.Main;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Dlna;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Services;
|
||||
@@ -108,12 +109,13 @@ namespace Emby.Dlna.Api
|
||||
|
||||
public class DlnaServerService : IService, IRequiresRequest
|
||||
{
|
||||
private readonly IDlnaManager _dlnaManager;
|
||||
|
||||
private const string XMLContentType = "text/xml; charset=UTF-8";
|
||||
|
||||
private readonly IDlnaManager _dlnaManager;
|
||||
private readonly IHttpResultFactory _resultFactory;
|
||||
private readonly IServerConfigurationManager _configurationManager;
|
||||
|
||||
public IRequest Request { get; set; }
|
||||
private IHttpResultFactory _resultFactory;
|
||||
|
||||
private IContentDirectory ContentDirectory => DlnaEntryPoint.Current.ContentDirectory;
|
||||
|
||||
@@ -121,10 +123,14 @@ namespace Emby.Dlna.Api
|
||||
|
||||
private IMediaReceiverRegistrar MediaReceiverRegistrar => DlnaEntryPoint.Current.MediaReceiverRegistrar;
|
||||
|
||||
public DlnaServerService(IDlnaManager dlnaManager, IHttpResultFactory httpResultFactory)
|
||||
public DlnaServerService(
|
||||
IDlnaManager dlnaManager,
|
||||
IHttpResultFactory httpResultFactory,
|
||||
IServerConfigurationManager configurationManager)
|
||||
{
|
||||
_dlnaManager = dlnaManager;
|
||||
_resultFactory = httpResultFactory;
|
||||
_configurationManager = configurationManager;
|
||||
}
|
||||
|
||||
private string GetHeader(string name)
|
||||
@@ -205,19 +211,32 @@ namespace Emby.Dlna.Api
|
||||
var pathInfo = Parse(Request.PathInfo);
|
||||
var first = pathInfo[0];
|
||||
|
||||
string baseUrl = _configurationManager.Configuration.BaseUrl;
|
||||
|
||||
// backwards compatibility
|
||||
// TODO: Work out what this is doing.
|
||||
if (string.Equals(first, "mediabrowser", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(first, "emby", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(first, "jellyfin", StringComparison.OrdinalIgnoreCase))
|
||||
if (baseUrl.Length == 0)
|
||||
{
|
||||
if (string.Equals(first, "mediabrowser", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(first, "emby", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
index++;
|
||||
}
|
||||
}
|
||||
else if (string.Equals(first, baseUrl.Remove(0, 1)))
|
||||
{
|
||||
index++;
|
||||
var second = pathInfo[1];
|
||||
if (string.Equals(second, "mediabrowser", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(second, "emby", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
return pathInfo[index];
|
||||
}
|
||||
|
||||
private List<string> Parse(string pathUri)
|
||||
private static string[] Parse(string pathUri)
|
||||
{
|
||||
var actionParts = pathUri.Split(new[] { "://" }, StringSplitOptions.None);
|
||||
|
||||
@@ -231,7 +250,7 @@ namespace Emby.Dlna.Api
|
||||
|
||||
var args = pathInfo.Split('/');
|
||||
|
||||
return args.Skip(1).ToList();
|
||||
return args.Skip(1).ToArray();
|
||||
}
|
||||
|
||||
public object Get(GetIcon request)
|
||||
|
||||
@@ -289,7 +289,7 @@ namespace Emby.Dlna.ContentDirectory
|
||||
var childrenResult = GetUserItems(item, serverItem.StubType, user, sortCriteria, start, requestedCount);
|
||||
totalCount = childrenResult.TotalRecordCount;
|
||||
|
||||
provided = childrenResult.Items.Length;
|
||||
provided = childrenResult.Items.Count;
|
||||
|
||||
foreach (var i in childrenResult.Items)
|
||||
{
|
||||
@@ -309,6 +309,7 @@ namespace Emby.Dlna.ContentDirectory
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writer.WriteFullEndElement();
|
||||
//writer.WriteEndDocument();
|
||||
}
|
||||
@@ -386,7 +387,7 @@ namespace Emby.Dlna.ContentDirectory
|
||||
|
||||
totalCount = childrenResult.TotalRecordCount;
|
||||
|
||||
provided = childrenResult.Items.Length;
|
||||
provided = childrenResult.Items.Count;
|
||||
|
||||
var dlnaOptions = _config.GetDlnaConfiguration();
|
||||
|
||||
@@ -677,7 +678,7 @@ namespace Emby.Dlna.ContentDirectory
|
||||
|
||||
return new QueryResult<ServerItem>
|
||||
{
|
||||
Items = list.ToArray(),
|
||||
Items = list,
|
||||
TotalRecordCount = list.Count
|
||||
};
|
||||
}
|
||||
@@ -755,7 +756,7 @@ namespace Emby.Dlna.ContentDirectory
|
||||
|
||||
return new QueryResult<ServerItem>
|
||||
{
|
||||
Items = list.ToArray(),
|
||||
Items = list,
|
||||
TotalRecordCount = list.Count
|
||||
};
|
||||
}
|
||||
@@ -860,7 +861,7 @@ namespace Emby.Dlna.ContentDirectory
|
||||
|
||||
return new QueryResult<ServerItem>
|
||||
{
|
||||
Items = list.ToArray(),
|
||||
Items = list,
|
||||
TotalRecordCount = list.Count
|
||||
};
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace Emby.Dlna.Didl
|
||||
|
||||
AddGeneralProperties(item, null, context, writer, filter);
|
||||
|
||||
AddSamsungBookmarkInfo(item, user, writer);
|
||||
AddSamsungBookmarkInfo(item, user, writer, streamInfo);
|
||||
|
||||
// refID?
|
||||
// storeAttribute(itemNode, object, ClassProperties.REF_ID, false);
|
||||
@@ -181,19 +181,6 @@ namespace Emby.Dlna.Didl
|
||||
writer.WriteFullEndElement();
|
||||
}
|
||||
|
||||
private string GetMimeType(string input)
|
||||
{
|
||||
var mime = MimeTypes.GetMimeType(input);
|
||||
|
||||
// TODO: Instead of being hard-coded here, this should probably be moved into all of the existing profiles
|
||||
if (string.Equals(mime, "video/mp2t", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
mime = "video/mpeg";
|
||||
}
|
||||
|
||||
return mime;
|
||||
}
|
||||
|
||||
private void AddVideoResource(DlnaOptions options, XmlWriter writer, BaseItem video, string deviceId, Filter filter, StreamInfo streamInfo = null)
|
||||
{
|
||||
if (streamInfo == null)
|
||||
@@ -384,7 +371,7 @@ namespace Emby.Dlna.Didl
|
||||
var filename = url.Substring(0, url.IndexOf('?'));
|
||||
|
||||
var mimeType = mediaProfile == null || string.IsNullOrEmpty(mediaProfile.MimeType)
|
||||
? GetMimeType(filename)
|
||||
? MimeTypes.GetMimeType(filename)
|
||||
: mediaProfile.MimeType;
|
||||
|
||||
writer.WriteAttributeString("protocolInfo", string.Format(
|
||||
@@ -520,7 +507,7 @@ namespace Emby.Dlna.Didl
|
||||
var filename = url.Substring(0, url.IndexOf('?'));
|
||||
|
||||
var mimeType = mediaProfile == null || string.IsNullOrEmpty(mediaProfile.MimeType)
|
||||
? GetMimeType(filename)
|
||||
? MimeTypes.GetMimeType(filename)
|
||||
: mediaProfile.MimeType;
|
||||
|
||||
var contentFeatures = new ContentFeatureBuilder(_profile).BuildAudioHeader(streamInfo.Container,
|
||||
@@ -545,17 +532,10 @@ namespace Emby.Dlna.Didl
|
||||
}
|
||||
|
||||
public static bool IsIdRoot(string id)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(id)
|
||||
=> string.IsNullOrWhiteSpace(id)
|
||||
|| string.Equals(id, "0", StringComparison.OrdinalIgnoreCase)
|
||||
// Samsung sometimes uses 1 as root
|
||||
|| string.Equals(id, "1", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|| string.Equals(id, "1", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
public void WriteFolderElement(XmlWriter writer, BaseItem folder, StubType? stubType, BaseItem context, int childCount, Filter filter, string requestedId = null)
|
||||
{
|
||||
@@ -601,7 +581,7 @@ namespace Emby.Dlna.Didl
|
||||
writer.WriteFullEndElement();
|
||||
}
|
||||
|
||||
private void AddSamsungBookmarkInfo(BaseItem item, User user, XmlWriter writer)
|
||||
private void AddSamsungBookmarkInfo(BaseItem item, User user, XmlWriter writer, StreamInfo streamInfo)
|
||||
{
|
||||
if (!item.SupportsPositionTicksResume || item is Folder)
|
||||
{
|
||||
@@ -625,10 +605,11 @@ namespace Emby.Dlna.Didl
|
||||
}
|
||||
|
||||
var userdata = _userDataManager.GetUserData(user, item);
|
||||
var playbackPositionTicks = (streamInfo != null && streamInfo.StartPositionTicks > 0) ? streamInfo.StartPositionTicks : userdata.PlaybackPositionTicks;
|
||||
|
||||
if (userdata.PlaybackPositionTicks > 0)
|
||||
if (playbackPositionTicks > 0)
|
||||
{
|
||||
var elementValue = string.Format("BM={0}", Convert.ToInt32(TimeSpan.FromTicks(userdata.PlaybackPositionTicks).TotalSeconds).ToString(_usCulture));
|
||||
var elementValue = string.Format("BM={0}", Convert.ToInt32(TimeSpan.FromTicks(playbackPositionTicks).TotalSeconds).ToString(_usCulture));
|
||||
AddValue(writer, "sec", "dcmInfo", elementValue, secAttribute.Value);
|
||||
}
|
||||
}
|
||||
@@ -971,7 +952,7 @@ namespace Emby.Dlna.Didl
|
||||
|
||||
writer.WriteAttributeString("protocolInfo", string.Format(
|
||||
"http-get:*:{0}:{1}",
|
||||
GetMimeType("file." + format),
|
||||
MimeTypes.GetMimeType("file." + format),
|
||||
contentFeatures
|
||||
));
|
||||
|
||||
@@ -1102,7 +1083,7 @@ namespace Emby.Dlna.Didl
|
||||
|
||||
public static string GetClientId(Guid idValue, StubType? stubType)
|
||||
{
|
||||
var id = idValue.ToString("N");
|
||||
var id = idValue.ToString("N", CultureInfo.InvariantCulture);
|
||||
|
||||
if (stubType.HasValue)
|
||||
{
|
||||
@@ -1116,7 +1097,7 @@ namespace Emby.Dlna.Didl
|
||||
{
|
||||
var url = string.Format("{0}/Items/{1}/Images/{2}/0/{3}/{4}/{5}/{6}/0/0",
|
||||
_serverAddress,
|
||||
info.ItemId.ToString("N"),
|
||||
info.ItemId.ToString("N", CultureInfo.InvariantCulture),
|
||||
info.Type,
|
||||
info.ImageTag,
|
||||
format,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -300,7 +301,7 @@ namespace Emby.Dlna
|
||||
|
||||
profile = ReserializeProfile(tempProfile);
|
||||
|
||||
profile.Id = path.ToLowerInvariant().GetMD5().ToString("N");
|
||||
profile.Id = path.ToLowerInvariant().GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||
|
||||
_profiles[path] = new Tuple<InternalProfileInfo, DeviceProfile>(GetInternalProfileInfo(_fileSystem.GetFileInfo(path), type), profile);
|
||||
|
||||
@@ -352,7 +353,7 @@ namespace Emby.Dlna
|
||||
|
||||
Info = new DeviceProfileInfo
|
||||
{
|
||||
Id = file.FullName.ToLowerInvariant().GetMD5().ToString("N"),
|
||||
Id = file.FullName.ToLowerInvariant().GetMD5().ToString("N", CultureInfo.InvariantCulture),
|
||||
Name = _fileSystem.GetFileNameWithoutExtension(file),
|
||||
Type = type
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Emby.Dlna.Eventing
|
||||
public EventSubscriptionResponse CreateEventSubscription(string notificationType, string requestedTimeoutString, string callbackUrl)
|
||||
{
|
||||
var timeout = ParseTimeout(requestedTimeoutString) ?? 300;
|
||||
var id = "uuid:" + Guid.NewGuid().ToString("N");
|
||||
var id = "uuid:" + Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
|
||||
|
||||
// Remove logging for now because some devices are sending this very frequently
|
||||
// TODO re-enable with dlna debug logging setting
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Emby.Dlna.PlayTo;
|
||||
@@ -247,7 +249,7 @@ namespace Emby.Dlna.Main
|
||||
|
||||
foreach (var address in addresses)
|
||||
{
|
||||
if (address.AddressFamily == IpAddressFamily.InterNetworkV6)
|
||||
if (address.AddressFamily == AddressFamily.InterNetworkV6)
|
||||
{
|
||||
// Not support IPv6 right now
|
||||
continue;
|
||||
@@ -306,7 +308,7 @@ namespace Emby.Dlna.Main
|
||||
{
|
||||
guid = text.GetMD5();
|
||||
}
|
||||
return guid.ToString("N");
|
||||
return guid.ToString("N", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
private void SetProperies(SsdpDevice device, string fullDeviceType)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
@@ -14,7 +16,6 @@ using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Events;
|
||||
using MediaBrowser.Model.Globalization;
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.Session;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -141,7 +142,7 @@ namespace Emby.Dlna.PlayTo
|
||||
return usn;
|
||||
}
|
||||
|
||||
return usn.GetMD5().ToString("N");
|
||||
return usn.GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
private async Task AddDevice(UpnpDeviceInfo info, string location, CancellationToken cancellationToken)
|
||||
@@ -156,7 +157,7 @@ namespace Emby.Dlna.PlayTo
|
||||
}
|
||||
else
|
||||
{
|
||||
uuid = location.GetMD5().ToString("N");
|
||||
uuid = location.GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
var sessionInfo = _sessionManager.LogSessionActivity("DLNA", _appHost.ApplicationVersion, uuid, null, uri.OriginalString, null);
|
||||
@@ -172,7 +173,7 @@ namespace Emby.Dlna.PlayTo
|
||||
_sessionManager.UpdateDeviceName(sessionInfo.Id, deviceName);
|
||||
|
||||
string serverAddress;
|
||||
if (info.LocalIpAddress == null || info.LocalIpAddress.Equals(IpAddressInfo.Any) || info.LocalIpAddress.Equals(IpAddressInfo.IPv6Any))
|
||||
if (info.LocalIpAddress == null || info.LocalIpAddress.Equals(IPAddress.Any) || info.LocalIpAddress.Equals(IPAddress.IPv6Any))
|
||||
{
|
||||
serverAddress = await _appHost.GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace Emby.Dlna.PlayTo
|
||||
private const string USERAGENT = "Microsoft-Windows/6.2 UPnP/1.0 Microsoft-DLNA DLNADOC/1.50";
|
||||
private const string FriendlyName = "Jellyfin";
|
||||
|
||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||
|
||||
private readonly IHttpClient _httpClient;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
|
||||
@@ -25,7 +27,8 @@ namespace Emby.Dlna.PlayTo
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public async Task<XDocument> SendCommandAsync(string baseUrl,
|
||||
public async Task<XDocument> SendCommandAsync(
|
||||
string baseUrl,
|
||||
DeviceService service,
|
||||
string command,
|
||||
string postData,
|
||||
@@ -34,16 +37,21 @@ namespace Emby.Dlna.PlayTo
|
||||
{
|
||||
var cancellationToken = CancellationToken.None;
|
||||
|
||||
using (var response = await PostSoapDataAsync(NormalizeServiceUrl(baseUrl, service.ControlUrl), "\"" + service.ServiceType + "#" + command + "\"", postData, header, logRequest, cancellationToken)
|
||||
var url = NormalizeServiceUrl(baseUrl, service.ControlUrl);
|
||||
using (var response = await PostSoapDataAsync(
|
||||
url,
|
||||
$"\"{service.ServiceType}#{command}\"",
|
||||
postData,
|
||||
header,
|
||||
logRequest,
|
||||
cancellationToken)
|
||||
.ConfigureAwait(false))
|
||||
using (var stream = response.Content)
|
||||
using (var reader = new StreamReader(stream, Encoding.UTF8))
|
||||
{
|
||||
using (var stream = response.Content)
|
||||
{
|
||||
using (var reader = new StreamReader(stream, Encoding.UTF8))
|
||||
{
|
||||
return XDocument.Parse(reader.ReadToEnd(), LoadOptions.PreserveWhitespace);
|
||||
}
|
||||
}
|
||||
return XDocument.Parse(
|
||||
await reader.ReadToEndAsync().ConfigureAwait(false),
|
||||
LoadOptions.PreserveWhitespace);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,9 +69,8 @@ namespace Emby.Dlna.PlayTo
|
||||
return baseUrl + serviceUrl;
|
||||
}
|
||||
|
||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||
|
||||
public async Task SubscribeAsync(string url,
|
||||
public async Task SubscribeAsync(
|
||||
string url,
|
||||
string ip,
|
||||
int port,
|
||||
string localIp,
|
||||
@@ -76,9 +83,6 @@ namespace Emby.Dlna.PlayTo
|
||||
UserAgent = USERAGENT,
|
||||
LogErrorResponseBody = true,
|
||||
BufferContent = false,
|
||||
|
||||
// The periodic requests may keep some devices awake
|
||||
LogRequestAsDebug = true
|
||||
};
|
||||
|
||||
options.RequestHeaders["HOST"] = ip + ":" + port.ToString(_usCulture);
|
||||
@@ -101,47 +105,41 @@ namespace Emby.Dlna.PlayTo
|
||||
LogErrorResponseBody = true,
|
||||
BufferContent = false,
|
||||
|
||||
// The periodic requests may keep some devices awake
|
||||
LogRequestAsDebug = true,
|
||||
|
||||
CancellationToken = cancellationToken
|
||||
};
|
||||
|
||||
options.RequestHeaders["FriendlyName.DLNA.ORG"] = FriendlyName;
|
||||
|
||||
using (var response = await _httpClient.SendAsync(options, "GET").ConfigureAwait(false))
|
||||
using (var stream = response.Content)
|
||||
using (var reader = new StreamReader(stream, Encoding.UTF8))
|
||||
{
|
||||
using (var stream = response.Content)
|
||||
{
|
||||
using (var reader = new StreamReader(stream, Encoding.UTF8))
|
||||
{
|
||||
return XDocument.Parse(reader.ReadToEnd(), LoadOptions.PreserveWhitespace);
|
||||
}
|
||||
}
|
||||
return XDocument.Parse(
|
||||
await reader.ReadToEndAsync().ConfigureAwait(false),
|
||||
LoadOptions.PreserveWhitespace);
|
||||
}
|
||||
}
|
||||
|
||||
private Task<HttpResponseInfo> PostSoapDataAsync(string url,
|
||||
private Task<HttpResponseInfo> PostSoapDataAsync(
|
||||
string url,
|
||||
string soapAction,
|
||||
string postData,
|
||||
string header,
|
||||
bool logRequest,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (!soapAction.StartsWith("\""))
|
||||
soapAction = "\"" + soapAction + "\"";
|
||||
if (soapAction[0] != '\"')
|
||||
{
|
||||
soapAction = $"\"{soapAction}\"";
|
||||
}
|
||||
|
||||
var options = new HttpRequestOptions
|
||||
{
|
||||
Url = url,
|
||||
UserAgent = USERAGENT,
|
||||
LogRequest = logRequest || _config.GetDlnaConfiguration().EnableDebugLog,
|
||||
LogErrorResponseBody = true,
|
||||
BufferContent = false,
|
||||
|
||||
// The periodic requests may keep some devices awake
|
||||
LogRequestAsDebug = true,
|
||||
|
||||
CancellationToken = cancellationToken
|
||||
};
|
||||
|
||||
@@ -155,7 +153,6 @@ namespace Emby.Dlna.PlayTo
|
||||
}
|
||||
|
||||
options.RequestContentType = "text/xml";
|
||||
options.AppendCharsetToMimeType = true;
|
||||
options.RequestContent = postData;
|
||||
|
||||
return _httpClient.Post(options);
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Emby.Dlna.Profiles
|
||||
{
|
||||
Name = "Dish Hopper-Joey";
|
||||
|
||||
ProtocolInfo = "http-get:*:video/mp2t:*,http-get:*:video/MP1S:*,http-get:*:video/mpeg2:*,http-get:*:video/mp4:*,http-get:*:video/x-matroska:*,http-get:*:audio/mpeg:*,http-get:*:audio/mpeg3:*,http-get:*:audio/mp3:*,http-get:*:audio/mp4:*,http-get:*:audio/mp4a-latm:*,http-get:*:image/jpeg:*";
|
||||
ProtocolInfo = "http-get:*:video/mp2t:*,http-get:*:video/mpeg:*,http-get:*:video/MP1S:*,http-get:*:video/mpeg2:*,http-get:*:video/mp4:*,http-get:*:video/x-matroska:*,http-get:*:audio/mpeg:*,http-get:*:audio/mpeg3:*,http-get:*:audio/mp3:*,http-get:*:audio/mp4:*,http-get:*:audio/mp4a-latm:*,http-get:*:image/jpeg:*";
|
||||
|
||||
Identification = new DeviceIdentification
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<MaxStaticBitrate>140000000</MaxStaticBitrate>
|
||||
<MusicStreamingTranscodingBitrate>192000</MusicStreamingTranscodingBitrate>
|
||||
<MaxStaticMusicBitrate xsi:nil="true" />
|
||||
<ProtocolInfo>http-get:*:video/mp2t:*,http-get:*:video/MP1S:*,http-get:*:video/mpeg2:*,http-get:*:video/mp4:*,http-get:*:video/x-matroska:*,http-get:*:audio/mpeg:*,http-get:*:audio/mpeg3:*,http-get:*:audio/mp3:*,http-get:*:audio/mp4:*,http-get:*:audio/mp4a-latm:*,http-get:*:image/jpeg:*</ProtocolInfo>
|
||||
<ProtocolInfo>http-get:*:video/mp2t:http-get:*:video/mpeg:*,http-get:*:video/MP1S:*,http-get:*:video/mpeg2:*,http-get:*:video/mp4:*,http-get:*:video/x-matroska:*,http-get:*:audio/mpeg:*,http-get:*:audio/mpeg3:*,http-get:*:audio/mp3:*,http-get:*:audio/mp4:*,http-get:*:audio/mp4a-latm:*,http-get:*:image/jpeg:*</ProtocolInfo>
|
||||
<TimelineOffsetSeconds>0</TimelineOffsetSeconds>
|
||||
<RequiresPlainVideoItems>false</RequiresPlainVideoItems>
|
||||
<RequiresPlainFolders>false</RequiresPlainFolders>
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -15,4 +17,9 @@
|
||||
<Compile Include="..\SharedVersion.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- We need at least C# 7.1 for the "default literal" feature-->
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -22,42 +22,47 @@ using Microsoft.Extensions.Logging;
|
||||
namespace Emby.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// Class ImageProcessor
|
||||
/// Class ImageProcessor.
|
||||
/// </summary>
|
||||
public class ImageProcessor : IImageProcessor, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The us culture
|
||||
/// </summary>
|
||||
protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
// Increment this when there's a change requiring caches to be invalidated
|
||||
private const string Version = "3";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of currently registered image processors
|
||||
/// Image processors are specialized metadata providers that run after the normal ones
|
||||
/// </summary>
|
||||
/// <value>The image enhancers.</value>
|
||||
public IImageEnhancer[] ImageEnhancers { get; private set; }
|
||||
private static readonly HashSet<string> _transparentImageTypes
|
||||
= new HashSet<string>(StringComparer.OrdinalIgnoreCase) { ".png", ".webp", ".gif" };
|
||||
|
||||
/// <summary>
|
||||
/// The _logger
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IServerApplicationPaths _appPaths;
|
||||
private IImageEncoder _imageEncoder;
|
||||
private readonly Func<ILibraryManager> _libraryManager;
|
||||
private readonly Func<IMediaEncoder> _mediaEncoder;
|
||||
|
||||
private readonly Dictionary<string, LockInfo> _locks = new Dictionary<string, LockInfo>();
|
||||
private bool _disposed = false;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="appPaths"></param>
|
||||
/// <param name="fileSystem"></param>
|
||||
/// <param name="imageEncoder"></param>
|
||||
/// <param name="libraryManager"></param>
|
||||
/// <param name="mediaEncoder"></param>
|
||||
public ImageProcessor(
|
||||
ILoggerFactory loggerFactory,
|
||||
ILogger<ImageProcessor> logger,
|
||||
IServerApplicationPaths appPaths,
|
||||
IFileSystem fileSystem,
|
||||
IImageEncoder imageEncoder,
|
||||
Func<ILibraryManager> libraryManager,
|
||||
Func<IMediaEncoder> mediaEncoder)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger(nameof(ImageProcessor));
|
||||
_logger = logger;
|
||||
_fileSystem = fileSystem;
|
||||
_imageEncoder = imageEncoder;
|
||||
_libraryManager = libraryManager;
|
||||
@@ -69,20 +74,11 @@ namespace Emby.Drawing
|
||||
ImageHelper.ImageProcessor = this;
|
||||
}
|
||||
|
||||
public IImageEncoder ImageEncoder
|
||||
{
|
||||
get => _imageEncoder;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
private string ResizedImageCachePath => Path.Combine(_appPaths.ImageCachePath, "resized-images");
|
||||
|
||||
_imageEncoder = value;
|
||||
}
|
||||
}
|
||||
private string EnhancedImageCachePath => Path.Combine(_appPaths.ImageCachePath, "enhanced-images");
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<string> SupportedInputFormats =>
|
||||
new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
@@ -115,18 +111,20 @@ namespace Emby.Drawing
|
||||
"wbmp"
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<IImageEnhancer> ImageEnhancers { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool SupportsImageCollageCreation => _imageEncoder.SupportsImageCollageCreation;
|
||||
|
||||
private string ResizedImageCachePath => Path.Combine(_appPaths.ImageCachePath, "resized-images");
|
||||
|
||||
private string EnhancedImageCachePath => Path.Combine(_appPaths.ImageCachePath, "enhanced-images");
|
||||
|
||||
public void AddParts(IEnumerable<IImageEnhancer> enhancers)
|
||||
/// <inheritdoc />
|
||||
public IImageEncoder ImageEncoder
|
||||
{
|
||||
ImageEnhancers = enhancers.ToArray();
|
||||
get => _imageEncoder;
|
||||
set => _imageEncoder = value ?? throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task ProcessImage(ImageProcessingOptions options, Stream toStream)
|
||||
{
|
||||
var file = await ProcessImage(options).ConfigureAwait(false);
|
||||
@@ -137,15 +135,15 @@ namespace Emby.Drawing
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<ImageFormat> GetSupportedImageOutputFormats()
|
||||
=> _imageEncoder.SupportedOutputFormats;
|
||||
|
||||
private static readonly HashSet<string> TransparentImageTypes
|
||||
= new HashSet<string>(StringComparer.OrdinalIgnoreCase) { ".png", ".webp", ".gif" };
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool SupportsTransparency(string path)
|
||||
=> TransparentImageTypes.Contains(Path.GetExtension(path));
|
||||
=> _transparentImageTypes.Contains(Path.GetExtension(path));
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<(string path, string mimeType, DateTime dateModified)> ProcessImage(ImageProcessingOptions options)
|
||||
{
|
||||
if (options == null)
|
||||
@@ -187,9 +185,9 @@ namespace Emby.Drawing
|
||||
}
|
||||
|
||||
dateModified = supportedImageInfo.dateModified;
|
||||
bool requiresTransparency = TransparentImageTypes.Contains(Path.GetExtension(originalImagePath));
|
||||
bool requiresTransparency = _transparentImageTypes.Contains(Path.GetExtension(originalImagePath));
|
||||
|
||||
if (options.Enhancers.Length > 0)
|
||||
if (options.Enhancers.Count > 0)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
@@ -279,7 +277,7 @@ namespace Emby.Drawing
|
||||
}
|
||||
}
|
||||
|
||||
private ImageFormat GetOutputFormat(ImageFormat[] clientSupportedFormats, bool requiresTransparency)
|
||||
private ImageFormat GetOutputFormat(IReadOnlyCollection<ImageFormat> clientSupportedFormats, bool requiresTransparency)
|
||||
{
|
||||
var serverFormats = GetSupportedImageOutputFormats();
|
||||
|
||||
@@ -320,11 +318,6 @@ namespace Emby.Drawing
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increment this when there's a change requiring caches to be invalidated
|
||||
/// </summary>
|
||||
private const string Version = "3";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cache file path based on a set of parameters
|
||||
/// </summary>
|
||||
@@ -372,9 +365,11 @@ namespace Emby.Drawing
|
||||
return GetCachePath(ResizedImageCachePath, filename, "." + format.ToString().ToLowerInvariant());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ImageDimensions GetImageDimensions(BaseItem item, ItemImageInfo info)
|
||||
=> GetImageDimensions(item, info, true);
|
||||
|
||||
/// <inheritdoc />
|
||||
public ImageDimensions GetImageDimensions(BaseItem item, ItemImageInfo info, bool updateItem)
|
||||
{
|
||||
int width = info.Width;
|
||||
@@ -400,26 +395,19 @@ namespace Emby.Drawing
|
||||
return size;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size of the image.
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public ImageDimensions GetImageDimensions(string path)
|
||||
=> _imageEncoder.GetImageSize(path);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the image cache tag.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="image">The image.</param>
|
||||
/// <returns>Guid.</returns>
|
||||
/// <exception cref="ArgumentNullException">item</exception>
|
||||
/// <inheritdoc />
|
||||
public string GetImageCacheTag(BaseItem item, ItemImageInfo image)
|
||||
{
|
||||
var supportedEnhancers = GetSupportedEnhancers(item, image.Type);
|
||||
var supportedEnhancers = GetSupportedEnhancers(item, image.Type).ToArray();
|
||||
|
||||
return GetImageCacheTag(item, image, supportedEnhancers);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string GetImageCacheTag(BaseItem item, ChapterInfo chapter)
|
||||
{
|
||||
try
|
||||
@@ -437,31 +425,24 @@ namespace Emby.Drawing
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the image cache tag.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="image">The image.</param>
|
||||
/// <param name="imageEnhancers">The image enhancers.</param>
|
||||
/// <returns>Guid.</returns>
|
||||
/// <exception cref="ArgumentNullException">item</exception>
|
||||
public string GetImageCacheTag(BaseItem item, ItemImageInfo image, IImageEnhancer[] imageEnhancers)
|
||||
/// <inheritdoc />
|
||||
public string GetImageCacheTag(BaseItem item, ItemImageInfo image, IReadOnlyCollection<IImageEnhancer> imageEnhancers)
|
||||
{
|
||||
string originalImagePath = image.Path;
|
||||
DateTime dateModified = image.DateModified;
|
||||
ImageType imageType = image.Type;
|
||||
|
||||
// Optimization
|
||||
if (imageEnhancers.Length == 0)
|
||||
if (imageEnhancers.Count == 0)
|
||||
{
|
||||
return (originalImagePath + dateModified.Ticks).GetMD5().ToString("N");
|
||||
return (originalImagePath + dateModified.Ticks).GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
// Cache name is created with supported enhancers combined with the last config change so we pick up new config changes
|
||||
var cacheKeys = imageEnhancers.Select(i => i.GetConfigurationCacheKey(item, imageType)).ToList();
|
||||
cacheKeys.Add(originalImagePath + dateModified.Ticks);
|
||||
|
||||
return string.Join("|", cacheKeys).GetMD5().ToString("N");
|
||||
return string.Join("|", cacheKeys).GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
private async Task<(string path, DateTime dateModified)> GetSupportedImage(string originalImagePath, DateTime dateModified)
|
||||
@@ -480,7 +461,7 @@ namespace Emby.Drawing
|
||||
{
|
||||
try
|
||||
{
|
||||
string filename = (originalImagePath + dateModified.Ticks.ToString(UsCulture)).GetMD5().ToString("N");
|
||||
string filename = (originalImagePath + dateModified.Ticks.ToString(CultureInfo.InvariantCulture)).GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||
|
||||
string cacheExtension = _mediaEncoder().SupportsEncoder("libwebp") ? ".webp" : ".png";
|
||||
var outputPath = Path.Combine(_appPaths.ImageCachePath, "converted-images", filename + cacheExtension);
|
||||
@@ -507,16 +488,10 @@ namespace Emby.Drawing
|
||||
return (originalImagePath, dateModified);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the enhanced image.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="imageType">Type of the image.</param>
|
||||
/// <param name="imageIndex">Index of the image.</param>
|
||||
/// <returns>Task{System.String}.</returns>
|
||||
/// <inheritdoc />
|
||||
public async Task<string> GetEnhancedImage(BaseItem item, ImageType imageType, int imageIndex)
|
||||
{
|
||||
var enhancers = GetSupportedEnhancers(item, imageType);
|
||||
var enhancers = GetSupportedEnhancers(item, imageType).ToArray();
|
||||
|
||||
ItemImageInfo imageInfo = item.GetImageInfo(imageType, imageIndex);
|
||||
|
||||
@@ -532,7 +507,7 @@ namespace Emby.Drawing
|
||||
bool inputImageSupportsTransparency,
|
||||
BaseItem item,
|
||||
int imageIndex,
|
||||
IImageEnhancer[] enhancers,
|
||||
IReadOnlyCollection<IImageEnhancer> enhancers,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var originalImagePath = image.Path;
|
||||
@@ -573,6 +548,7 @@ namespace Emby.Drawing
|
||||
/// <param name="imageIndex">Index of the image.</param>
|
||||
/// <param name="supportedEnhancers">The supported enhancers.</param>
|
||||
/// <param name="cacheGuid">The cache unique identifier.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task<System.String>.</returns>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// originalImagePath
|
||||
@@ -584,9 +560,9 @@ namespace Emby.Drawing
|
||||
BaseItem item,
|
||||
ImageType imageType,
|
||||
int imageIndex,
|
||||
IImageEnhancer[] supportedEnhancers,
|
||||
IReadOnlyCollection<IImageEnhancer> supportedEnhancers,
|
||||
string cacheGuid,
|
||||
CancellationToken cancellationToken)
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (string.IsNullOrEmpty(originalImagePath))
|
||||
{
|
||||
@@ -680,6 +656,7 @@ namespace Emby.Drawing
|
||||
{
|
||||
throw new ArgumentNullException(nameof(path));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(uniqueName))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(uniqueName));
|
||||
@@ -722,6 +699,7 @@ namespace Emby.Drawing
|
||||
return Path.Combine(path, prefix, filename);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void CreateImageCollage(ImageCollageOptions options)
|
||||
{
|
||||
_logger.LogInformation("Creating image collage and saving to {Path}", options.OutputPath);
|
||||
@@ -731,38 +709,25 @@ namespace Emby.Drawing
|
||||
_logger.LogInformation("Completed creation of image collage and saved to {Path}", options.OutputPath);
|
||||
}
|
||||
|
||||
public IImageEnhancer[] GetSupportedEnhancers(BaseItem item, ImageType imageType)
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<IImageEnhancer> GetSupportedEnhancers(BaseItem item, ImageType imageType)
|
||||
{
|
||||
List<IImageEnhancer> list = null;
|
||||
|
||||
foreach (var i in ImageEnhancers)
|
||||
{
|
||||
try
|
||||
if (i.Supports(item, imageType))
|
||||
{
|
||||
if (i.Supports(item, imageType))
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
list = new List<IImageEnhancer>();
|
||||
}
|
||||
list.Add(i);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error in image enhancer: {0}", i.GetType().Name);
|
||||
yield return i;
|
||||
}
|
||||
}
|
||||
|
||||
return list == null ? Array.Empty<IImageEnhancer>() : list.ToArray();
|
||||
}
|
||||
|
||||
private Dictionary<string, LockInfo> _locks = new Dictionary<string, LockInfo>();
|
||||
|
||||
private class LockInfo
|
||||
{
|
||||
public SemaphoreSlim Lock = new SemaphoreSlim(1, 1);
|
||||
public int Count = 1;
|
||||
}
|
||||
|
||||
private LockInfo GetLock(string key)
|
||||
{
|
||||
lock (_locks)
|
||||
@@ -795,7 +760,7 @@ namespace Emby.Drawing
|
||||
}
|
||||
}
|
||||
|
||||
private bool _disposed;
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
_disposed = true;
|
||||
|
||||
@@ -5,38 +5,42 @@ using MediaBrowser.Model.Drawing;
|
||||
|
||||
namespace Emby.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// A fallback implementation of <see cref="IImageEncoder" />.
|
||||
/// </summary>
|
||||
public class NullImageEncoder : IImageEncoder
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<string> SupportedInputFormats
|
||||
=> new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "png", "jpeg", "jpg" };
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<ImageFormat> SupportedOutputFormats
|
||||
=> new HashSet<ImageFormat>() { ImageFormat.Jpg, ImageFormat.Png };
|
||||
|
||||
public void CropWhiteSpace(string inputPath, string outputPath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public string Name => "Null Image Encoder";
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool SupportsImageCollageCreation => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool SupportsImageEncoding => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ImageDimensions GetImageSize(string path)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string EncodeImage(string inputPath, DateTime dateModified, string outputPath, bool autoOrient, ImageOrientation? orientation, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void CreateImageCollage(ImageCollageOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string Name => "Null Image Encoder";
|
||||
|
||||
public bool SupportsImageCollageCreation => false;
|
||||
|
||||
public bool SupportsImageEncoding => false;
|
||||
|
||||
public ImageDimensions GetImageSize(string path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
108
Emby.IsoMounting/.gitignore
vendored
108
Emby.IsoMounting/.gitignore
vendored
@@ -1,108 +0,0 @@
|
||||
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# mstest test results
|
||||
TestResults
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.docstates
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
x64/
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*
|
||||
|
||||
# NCrunch
|
||||
*.ncrunch*
|
||||
.*crunch*.local.xml
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish
|
||||
|
||||
# Publish Web Output
|
||||
*.Publish.xml
|
||||
|
||||
# NuGet Packages Directory
|
||||
packages
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Others
|
||||
[Bb]in
|
||||
[Oo]bj
|
||||
sql
|
||||
TestResults
|
||||
[Tt]est[Rr]esult*
|
||||
*.Cache
|
||||
ClientBin
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*.dbmdl
|
||||
Generated_Code #added for RIA/Silverlight projects
|
||||
|
||||
# Backup & report files from converting an old project file to a newer
|
||||
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27004.2009
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IsoMounter", "IsoMounter\IsoMounter.csproj", "{B94C929C-6552-4620-9BE5-422DD9A151BA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B94C929C-6552-4620-9BE5-422DD9A151BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B94C929C-6552-4620-9BE5-422DD9A151BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B94C929C-6552-4620-9BE5-422DD9A151BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B94C929C-6552-4620-9BE5-422DD9A151BA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {C0E8EAD1-E4D7-44CD-B801-03BD12F30B1B}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,8 +0,0 @@
|
||||
using MediaBrowser.Model.Plugins;
|
||||
|
||||
namespace IsoMounter.Configuration
|
||||
{
|
||||
public class PluginConfiguration : BasePluginConfiguration
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\SharedVersion.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\MediaBrowser.Model\MediaBrowser.Model.csproj" />
|
||||
<ProjectReference Include="..\..\MediaBrowser.Common\MediaBrowser.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,477 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Diagnostics;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.System;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
|
||||
|
||||
namespace IsoMounter
|
||||
{
|
||||
public class LinuxIsoManager : IIsoMounter
|
||||
{
|
||||
[DllImport("libc", SetLastError = true)]
|
||||
static extern uint getuid();
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly bool ExecutablesAvailable;
|
||||
private readonly ILogger _logger;
|
||||
private readonly string MountCommand;
|
||||
private readonly string MountPointRoot;
|
||||
private readonly IProcessFactory ProcessFactory;
|
||||
private readonly string SudoCommand;
|
||||
private readonly string UmountCommand;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor(s)
|
||||
|
||||
public LinuxIsoManager(ILogger logger, IProcessFactory processFactory)
|
||||
{
|
||||
_logger = logger;
|
||||
ProcessFactory = processFactory;
|
||||
|
||||
MountPointRoot = Path.DirectorySeparatorChar + "tmp" + Path.DirectorySeparatorChar + "Emby";
|
||||
|
||||
_logger.LogDebug(
|
||||
"[{0}] System PATH is currently set to [{1}].",
|
||||
Name,
|
||||
Environment.GetEnvironmentVariable("PATH") ?? ""
|
||||
);
|
||||
|
||||
_logger.LogDebug(
|
||||
"[{0}] System path separator is [{1}].",
|
||||
Name,
|
||||
Path.PathSeparator
|
||||
);
|
||||
|
||||
_logger.LogDebug(
|
||||
"[{0}] Mount point root is [{1}].",
|
||||
Name,
|
||||
MountPointRoot
|
||||
);
|
||||
|
||||
//
|
||||
// Get the location of the executables we need to support mounting/unmounting ISO images.
|
||||
//
|
||||
|
||||
SudoCommand = GetFullPathForExecutable("sudo");
|
||||
|
||||
_logger.LogInformation(
|
||||
"[{0}] Using version of [sudo] located at [{1}].",
|
||||
Name,
|
||||
SudoCommand
|
||||
);
|
||||
|
||||
MountCommand = GetFullPathForExecutable("mount");
|
||||
|
||||
_logger.LogInformation(
|
||||
"[{0}] Using version of [mount] located at [{1}].",
|
||||
Name,
|
||||
MountCommand
|
||||
);
|
||||
|
||||
UmountCommand = GetFullPathForExecutable("umount");
|
||||
|
||||
_logger.LogInformation(
|
||||
"[{0}] Using version of [umount] located at [{1}].",
|
||||
Name,
|
||||
UmountCommand
|
||||
);
|
||||
|
||||
if (!string.IsNullOrEmpty(SudoCommand) && !string.IsNullOrEmpty(MountCommand) && !string.IsNullOrEmpty(UmountCommand))
|
||||
{
|
||||
ExecutablesAvailable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ExecutablesAvailable = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Interface Implementation for IIsoMounter
|
||||
|
||||
public bool IsInstalled => true;
|
||||
|
||||
public string Name => "LinuxMount";
|
||||
|
||||
public bool RequiresInstallation => false;
|
||||
|
||||
public bool CanMount(string path)
|
||||
{
|
||||
|
||||
if (OperatingSystem.Id != OperatingSystemId.Linux)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_logger.LogInformation(
|
||||
"[{0}] Checking we can attempt to mount [{1}], Extension = [{2}], Operating System = [{3}], Executables Available = [{4}].",
|
||||
Name,
|
||||
path,
|
||||
Path.GetExtension(path),
|
||||
OperatingSystem.Name,
|
||||
ExecutablesAvailable
|
||||
);
|
||||
|
||||
if (ExecutablesAvailable)
|
||||
{
|
||||
return string.Equals(Path.GetExtension(path), ".iso", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Task Install(CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
|
||||
public Task<IIsoMount> Mount(string isoPath, CancellationToken cancellationToken)
|
||||
{
|
||||
if (MountISO(isoPath, out LinuxMount mountedISO))
|
||||
{
|
||||
return Task.FromResult<IIsoMount>(mountedISO);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IOException(string.Format(
|
||||
"An error occurred trying to mount image [$0].",
|
||||
isoPath
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Interface Implementation for IDisposable
|
||||
|
||||
// Flag: Has Dispose already been called?
|
||||
private bool disposed = false;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
// Dispose of unmanaged resources.
|
||||
Dispose(true);
|
||||
|
||||
// Suppress finalization.
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
|
||||
if (disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation(
|
||||
"[{0}] Disposing [{1}].",
|
||||
Name,
|
||||
disposing
|
||||
);
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
|
||||
//
|
||||
// Free managed objects here.
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Free any unmanaged objects here.
|
||||
//
|
||||
|
||||
disposed = true;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private string GetFullPathForExecutable(string name)
|
||||
{
|
||||
|
||||
foreach (string test in (Environment.GetEnvironmentVariable("PATH") ?? "").Split(Path.PathSeparator))
|
||||
{
|
||||
string path = test.Trim();
|
||||
|
||||
if (!string.IsNullOrEmpty(path) && File.Exists(path = Path.Combine(path, name)))
|
||||
{
|
||||
return Path.GetFullPath(path);
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private uint GetUID()
|
||||
{
|
||||
|
||||
var uid = getuid();
|
||||
|
||||
_logger.LogDebug(
|
||||
"[{0}] GetUserId() returned [{2}].",
|
||||
Name,
|
||||
uid
|
||||
);
|
||||
|
||||
return uid;
|
||||
|
||||
}
|
||||
|
||||
private bool ExecuteCommand(string cmdFilename, string cmdArguments)
|
||||
{
|
||||
|
||||
bool processFailed = false;
|
||||
|
||||
var process = ProcessFactory.Create(
|
||||
new ProcessOptions
|
||||
{
|
||||
CreateNoWindow = true,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
UseShellExecute = false,
|
||||
FileName = cmdFilename,
|
||||
Arguments = cmdArguments,
|
||||
IsHidden = true,
|
||||
ErrorDialog = false,
|
||||
EnableRaisingEvents = true
|
||||
}
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
process.Start();
|
||||
|
||||
//StreamReader outputReader = process.StandardOutput.;
|
||||
//StreamReader errorReader = process.StandardError;
|
||||
|
||||
_logger.LogDebug(
|
||||
"[{Name}] Standard output from process is [{Error}].",
|
||||
Name,
|
||||
process.StandardOutput.ReadToEnd()
|
||||
);
|
||||
|
||||
_logger.LogDebug(
|
||||
"[{Name}] Standard error from process is [{Error}].",
|
||||
Name,
|
||||
process.StandardError.ReadToEnd()
|
||||
);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
processFailed = true;
|
||||
_logger.LogDebug(ex, "[{Name}] Unhandled exception executing command.", Name);
|
||||
}
|
||||
|
||||
if (!processFailed && process.ExitCode == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private bool MountISO(string isoPath, out LinuxMount mountedISO)
|
||||
{
|
||||
|
||||
string cmdArguments;
|
||||
string cmdFilename;
|
||||
string mountPoint = Path.Combine(MountPointRoot, Guid.NewGuid().ToString());
|
||||
|
||||
if (!string.IsNullOrEmpty(isoPath))
|
||||
{
|
||||
|
||||
_logger.LogInformation(
|
||||
"[{Name}] Attempting to mount [{Path}].",
|
||||
Name,
|
||||
isoPath
|
||||
);
|
||||
|
||||
_logger.LogDebug(
|
||||
"[{Name}] ISO will be mounted at [{Path}].",
|
||||
Name,
|
||||
mountPoint
|
||||
);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
throw new ArgumentNullException(nameof(isoPath));
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(mountPoint);
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
throw new IOException("Unable to create mount point(Permission denied) for " + isoPath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new IOException("Unable to create mount point for " + isoPath);
|
||||
}
|
||||
|
||||
if (GetUID() == 0)
|
||||
{
|
||||
cmdFilename = MountCommand;
|
||||
cmdArguments = string.Format("\"{0}\" \"{1}\"", isoPath, mountPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmdFilename = SudoCommand;
|
||||
cmdArguments = string.Format("\"{0}\" \"{1}\" \"{2}\"", MountCommand, isoPath, mountPoint);
|
||||
}
|
||||
|
||||
_logger.LogDebug(
|
||||
"[{0}] Mount command [{1}], mount arguments [{2}].",
|
||||
Name,
|
||||
cmdFilename,
|
||||
cmdArguments
|
||||
);
|
||||
|
||||
if (ExecuteCommand(cmdFilename, cmdArguments))
|
||||
{
|
||||
|
||||
_logger.LogInformation(
|
||||
"[{0}] ISO mount completed successfully.",
|
||||
Name
|
||||
);
|
||||
|
||||
mountedISO = new LinuxMount(this, isoPath, mountPoint);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
_logger.LogInformation(
|
||||
"[{0}] ISO mount completed with errors.",
|
||||
Name
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
Directory.Delete(mountPoint, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogInformation(ex, "[{Name}] Unhandled exception removing mount point.", Name);
|
||||
}
|
||||
|
||||
mountedISO = null;
|
||||
|
||||
}
|
||||
|
||||
return mountedISO != null;
|
||||
|
||||
}
|
||||
|
||||
private void UnmountISO(LinuxMount mount)
|
||||
{
|
||||
|
||||
string cmdArguments;
|
||||
string cmdFilename;
|
||||
|
||||
if (mount != null)
|
||||
{
|
||||
|
||||
_logger.LogInformation(
|
||||
"[{0}] Attempting to unmount ISO [{1}] mounted on [{2}].",
|
||||
Name,
|
||||
mount.IsoPath,
|
||||
mount.MountedPath
|
||||
);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
throw new ArgumentNullException(nameof(mount));
|
||||
|
||||
}
|
||||
|
||||
if (GetUID() == 0)
|
||||
{
|
||||
cmdFilename = UmountCommand;
|
||||
cmdArguments = string.Format("\"{0}\"", mount.MountedPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmdFilename = SudoCommand;
|
||||
cmdArguments = string.Format("\"{0}\" \"{1}\"", UmountCommand, mount.MountedPath);
|
||||
}
|
||||
|
||||
_logger.LogDebug(
|
||||
"[{0}] Umount command [{1}], umount arguments [{2}].",
|
||||
Name,
|
||||
cmdFilename,
|
||||
cmdArguments
|
||||
);
|
||||
|
||||
if (ExecuteCommand(cmdFilename, cmdArguments))
|
||||
{
|
||||
|
||||
_logger.LogInformation(
|
||||
"[{0}] ISO unmount completed successfully.",
|
||||
Name
|
||||
);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
_logger.LogInformation(
|
||||
"[{0}] ISO unmount completed with errors.",
|
||||
Name
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Directory.Delete(mount.MountedPath, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogInformation(ex, "[{Name}] Unhandled exception removing mount point.", Name);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
internal void OnUnmount(LinuxMount mount)
|
||||
{
|
||||
|
||||
UnmountISO(mount);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
using System;
|
||||
using MediaBrowser.Model.IO;
|
||||
|
||||
namespace IsoMounter
|
||||
{
|
||||
internal class LinuxMount : IIsoMount
|
||||
{
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly LinuxIsoManager linuxIsoManager;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor(s)
|
||||
|
||||
internal LinuxMount(LinuxIsoManager isoManager, string isoPath, string mountFolder)
|
||||
{
|
||||
|
||||
linuxIsoManager = isoManager;
|
||||
|
||||
IsoPath = isoPath;
|
||||
MountedPath = mountFolder;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Interface Implementation for IDisposable
|
||||
|
||||
// Flag: Has Dispose already been called?
|
||||
private bool disposed = false;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
// Dispose of unmanaged resources.
|
||||
Dispose(true);
|
||||
|
||||
// Suppress finalization.
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
|
||||
if (disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
|
||||
//
|
||||
// Free managed objects here.
|
||||
//
|
||||
|
||||
linuxIsoManager.OnUnmount(this);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Free any unmanaged objects here.
|
||||
//
|
||||
|
||||
disposed = true;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Interface Implementation for IIsoMount
|
||||
|
||||
public string IsoPath { get; private set; }
|
||||
public string MountedPath { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using IsoMounter.Configuration;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Plugins;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
|
||||
namespace IsoMounter
|
||||
{
|
||||
public class Plugin : BasePlugin<PluginConfiguration>
|
||||
{
|
||||
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) : base(applicationPaths, xmlSerializer)
|
||||
{
|
||||
}
|
||||
|
||||
private Guid _id = new Guid("4682DD4C-A675-4F1B-8E7C-79ADF137A8F8");
|
||||
public override Guid Id => _id;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the plugin
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public override string Name => "Iso Mounter";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description.
|
||||
/// </summary>
|
||||
/// <value>The description.</value>
|
||||
public override string Description => "Mount and stream ISO contents";
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("IsoMounter")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Jellyfin Project")]
|
||||
[assembly: AssemblyProduct("Jellyfin Server")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: NeutralResourcesLanguage("en")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
@@ -1,339 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{description}
|
||||
Copyright (C) {year} {fullname}
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
{signature of Ty Coon}, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -1,14 +0,0 @@
|
||||
# MediaBrowser.IsoMounting.Linux
|
||||
This implements two core interfaces, IIsoManager, and IIsoMount.
|
||||
### IIsoManager
|
||||
The manager class can be used to create a mount, and also determine if the mounter is capable of mounting a given file.
|
||||
### IIsoMount
|
||||
IIsoMount then represents a mount instance, which will be unmounted on disposal.
|
||||
***
|
||||
This Linux version use sudo, mount and umount.
|
||||
|
||||
You need to add this to your sudo file via visudo(change the username):
|
||||
|
||||
Defaults:jsmith !requiretty
|
||||
jsmith ALL=(root) NOPASSWD: /bin/mount
|
||||
jsmith ALL=(root) NOPASSWD: /bin/umount
|
||||
@@ -33,27 +33,29 @@ namespace Emby.Naming.Audio
|
||||
|
||||
// Normalize
|
||||
// Remove whitespace
|
||||
filename = filename.Replace("-", " ");
|
||||
filename = filename.Replace(".", " ");
|
||||
filename = filename.Replace("(", " ");
|
||||
filename = filename.Replace(")", " ");
|
||||
filename = filename.Replace('-', ' ');
|
||||
filename = filename.Replace('.', ' ');
|
||||
filename = filename.Replace('(', ' ');
|
||||
filename = filename.Replace(')', ' ');
|
||||
filename = Regex.Replace(filename, @"\s+", " ");
|
||||
|
||||
filename = filename.TrimStart();
|
||||
|
||||
foreach (var prefix in _options.AlbumStackingPrefixes)
|
||||
{
|
||||
if (filename.IndexOf(prefix, StringComparison.OrdinalIgnoreCase) == 0)
|
||||
if (filename.IndexOf(prefix, StringComparison.OrdinalIgnoreCase) != 0)
|
||||
{
|
||||
var tmp = filename.Substring(prefix.Length);
|
||||
continue;
|
||||
}
|
||||
|
||||
tmp = tmp.Trim().Split(' ').FirstOrDefault() ?? string.Empty;
|
||||
var tmp = filename.Substring(prefix.Length);
|
||||
|
||||
if (int.TryParse(tmp, NumberStyles.Integer, CultureInfo.InvariantCulture, out var val))
|
||||
{
|
||||
result.IsMultiPart = true;
|
||||
break;
|
||||
}
|
||||
tmp = tmp.Trim().Split(' ').FirstOrDefault() ?? string.Empty;
|
||||
|
||||
if (int.TryParse(tmp, NumberStyles.Integer, CultureInfo.InvariantCulture, out _))
|
||||
{
|
||||
result.IsMultiPart = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,13 @@ namespace Emby.Naming.Audio
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the part.
|
||||
/// </summary>
|
||||
/// <value>The part.</value>
|
||||
public string Part { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is multi part.
|
||||
/// </summary>
|
||||
|
||||
@@ -12,35 +12,56 @@ namespace Emby.Naming.AudioBook
|
||||
/// </summary>
|
||||
/// <value>The path.</value>
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the container.
|
||||
/// </summary>
|
||||
/// <value>The container.</value>
|
||||
public string Container { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the part number.
|
||||
/// </summary>
|
||||
/// <value>The part number.</value>
|
||||
public int? PartNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the chapter number.
|
||||
/// </summary>
|
||||
/// <value>The chapter number.</value>
|
||||
public int? ChapterNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type.
|
||||
/// </summary>
|
||||
/// <value>The type.</value>
|
||||
public bool IsDirectory { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int CompareTo(AudioBookFileInfo other)
|
||||
{
|
||||
if (ReferenceEquals(this, other)) return 0;
|
||||
if (ReferenceEquals(null, other)) return 1;
|
||||
if (ReferenceEquals(this, other))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ReferenceEquals(null, other))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
var chapterNumberComparison = Nullable.Compare(ChapterNumber, other.ChapterNumber);
|
||||
if (chapterNumberComparison != 0) return chapterNumberComparison;
|
||||
if (chapterNumberComparison != 0)
|
||||
{
|
||||
return chapterNumberComparison;
|
||||
}
|
||||
|
||||
var partNumberComparison = Nullable.Compare(PartNumber, other.PartNumber);
|
||||
if (partNumberComparison != 0) return partNumberComparison;
|
||||
if (partNumberComparison != 0)
|
||||
{
|
||||
return partNumberComparison;
|
||||
}
|
||||
|
||||
return string.Compare(Path, other.Path, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -14,14 +15,13 @@ namespace Emby.Naming.AudioBook
|
||||
_options = options;
|
||||
}
|
||||
|
||||
public AudioBookFilePathParserResult Parse(string path, bool IsDirectory)
|
||||
public AudioBookFilePathParserResult Parse(string path)
|
||||
{
|
||||
var result = Parse(path);
|
||||
return !result.Success ? new AudioBookFilePathParserResult() : result;
|
||||
}
|
||||
if (path == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(path));
|
||||
}
|
||||
|
||||
private AudioBookFilePathParserResult Parse(string path)
|
||||
{
|
||||
var result = new AudioBookFilePathParserResult();
|
||||
var fileName = Path.GetFileNameWithoutExtension(path);
|
||||
foreach (var expression in _options.AudioBookPartsExpressions)
|
||||
@@ -40,6 +40,7 @@ namespace Emby.Naming.AudioBook
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!result.PartNumber.HasValue)
|
||||
{
|
||||
var value = match.Groups["part"];
|
||||
|
||||
@@ -3,7 +3,9 @@ namespace Emby.Naming.AudioBook
|
||||
public class AudioBookFilePathParserResult
|
||||
{
|
||||
public int? PartNumber { get; set; }
|
||||
|
||||
public int? ChapterNumber { get; set; }
|
||||
|
||||
public bool Success { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,33 +7,40 @@ namespace Emby.Naming.AudioBook
|
||||
/// </summary>
|
||||
public class AudioBookInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
public int? Year { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the files.
|
||||
/// </summary>
|
||||
/// <value>The files.</value>
|
||||
public List<AudioBookFileInfo> Files { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the extras.
|
||||
/// </summary>
|
||||
/// <value>The extras.</value>
|
||||
public List<AudioBookFileInfo> Extras { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the alternate versions.
|
||||
/// </summary>
|
||||
/// <value>The alternate versions.</value>
|
||||
public List<AudioBookFileInfo> AlternateVersions { get; set; }
|
||||
|
||||
public AudioBookInfo()
|
||||
{
|
||||
Files = new List<AudioBookFileInfo>();
|
||||
Extras = new List<AudioBookFileInfo>();
|
||||
AlternateVersions = new List<AudioBookFileInfo>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the year.
|
||||
/// </summary>
|
||||
public int? Year { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the files.
|
||||
/// </summary>
|
||||
/// <value>The files.</value>
|
||||
public List<AudioBookFileInfo> Files { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the extras.
|
||||
/// </summary>
|
||||
/// <value>The extras.</value>
|
||||
public List<AudioBookFileInfo> Extras { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alternate versions.
|
||||
/// </summary>
|
||||
/// <value>The alternate versions.</value>
|
||||
public List<AudioBookFileInfo> AlternateVersions { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Emby.Naming.AudioBook
|
||||
_options = options;
|
||||
}
|
||||
|
||||
public IEnumerable<AudioBookInfo> Resolve(List<FileSystemMetadata> files)
|
||||
public IEnumerable<AudioBookInfo> Resolve(IEnumerable<FileSystemMetadata> files)
|
||||
{
|
||||
var audioBookResolver = new AudioBookResolver(_options);
|
||||
|
||||
|
||||
@@ -24,19 +24,21 @@ namespace Emby.Naming.AudioBook
|
||||
return Resolve(path, true);
|
||||
}
|
||||
|
||||
public AudioBookFileInfo Resolve(string path, bool IsDirectory = false)
|
||||
public AudioBookFileInfo Resolve(string path, bool isDirectory = false)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(path));
|
||||
}
|
||||
|
||||
if (IsDirectory) // TODO
|
||||
// TODO
|
||||
if (isDirectory)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var extension = Path.GetExtension(path);
|
||||
|
||||
// Check supported extensions
|
||||
if (!_options.AudioFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -45,8 +47,7 @@ namespace Emby.Naming.AudioBook
|
||||
|
||||
var container = extension.TrimStart('.');
|
||||
|
||||
var parsingResult = new AudioBookFilePathParser(_options)
|
||||
.Parse(path, IsDirectory);
|
||||
var parsingResult = new AudioBookFilePathParser(_options).Parse(path);
|
||||
|
||||
return new AudioBookFileInfo
|
||||
{
|
||||
@@ -54,7 +55,7 @@ namespace Emby.Naming.AudioBook
|
||||
Container = container,
|
||||
PartNumber = parsingResult.PartNumber,
|
||||
ChapterNumber = parsingResult.ChapterNumber,
|
||||
IsDirectory = IsDirectory
|
||||
IsDirectory = isDirectory
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,17 +6,28 @@ namespace Emby.Naming.Common
|
||||
public class EpisodeExpression
|
||||
{
|
||||
private string _expression;
|
||||
public string Expression { get => _expression;
|
||||
set { _expression = value; _regex = null; } }
|
||||
private Regex _regex;
|
||||
|
||||
public string Expression
|
||||
{
|
||||
get => _expression;
|
||||
set
|
||||
{
|
||||
_expression = value;
|
||||
_regex = null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsByDate { get; set; }
|
||||
|
||||
public bool IsOptimistic { get; set; }
|
||||
|
||||
public bool IsNamed { get; set; }
|
||||
|
||||
public bool SupportsAbsoluteEpisodeNumbers { get; set; }
|
||||
|
||||
public string[] DateTimeFormats { get; set; }
|
||||
|
||||
private Regex _regex;
|
||||
public Regex Regex => _regex ?? (_regex = new Regex(Expression, RegexOptions.IgnoreCase | RegexOptions.Compiled));
|
||||
|
||||
public EpisodeExpression(string expression, bool byDate)
|
||||
|
||||
@@ -6,10 +6,12 @@ namespace Emby.Naming.Common
|
||||
/// The audio
|
||||
/// </summary>
|
||||
Audio = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The photo
|
||||
/// </summary>
|
||||
Photo = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The video
|
||||
/// </summary>
|
||||
|
||||
@@ -8,19 +8,25 @@ namespace Emby.Naming.Common
|
||||
public class NamingOptions
|
||||
{
|
||||
public string[] AudioFileExtensions { get; set; }
|
||||
|
||||
public string[] AlbumStackingPrefixes { get; set; }
|
||||
|
||||
public string[] SubtitleFileExtensions { get; set; }
|
||||
|
||||
public char[] SubtitleFlagDelimiters { get; set; }
|
||||
|
||||
public string[] SubtitleForcedFlags { get; set; }
|
||||
|
||||
public string[] SubtitleDefaultFlags { get; set; }
|
||||
|
||||
public EpisodeExpression[] EpisodeExpressions { get; set; }
|
||||
|
||||
public string[] EpisodeWithoutSeasonExpressions { get; set; }
|
||||
|
||||
public string[] EpisodeMultiPartExpressions { get; set; }
|
||||
|
||||
public string[] VideoFileExtensions { get; set; }
|
||||
|
||||
public string[] StubFileExtensions { get; set; }
|
||||
|
||||
public string[] AudioBookPartsExpressions { get; set; }
|
||||
@@ -28,12 +34,14 @@ namespace Emby.Naming.Common
|
||||
public StubTypeRule[] StubTypes { get; set; }
|
||||
|
||||
public char[] VideoFlagDelimiters { get; set; }
|
||||
|
||||
public Format3DRule[] Format3DRules { get; set; }
|
||||
|
||||
public string[] VideoFileStackingExpressions { get; set; }
|
||||
public string[] CleanDateTimes { get; set; }
|
||||
public string[] CleanStrings { get; set; }
|
||||
|
||||
public string[] CleanDateTimes { get; set; }
|
||||
|
||||
public string[] CleanStrings { get; set; }
|
||||
|
||||
public EpisodeExpression[] MultipleEpisodeExpressions { get; set; }
|
||||
|
||||
@@ -41,7 +49,7 @@ namespace Emby.Naming.Common
|
||||
|
||||
public NamingOptions()
|
||||
{
|
||||
VideoFileExtensions = new string[]
|
||||
VideoFileExtensions = new[]
|
||||
{
|
||||
".m4v",
|
||||
".3gp",
|
||||
@@ -106,53 +114,53 @@ namespace Emby.Naming.Common
|
||||
{
|
||||
new StubTypeRule
|
||||
{
|
||||
StubType = "dvd",
|
||||
Token = "dvd"
|
||||
StubType = "dvd",
|
||||
Token = "dvd"
|
||||
},
|
||||
new StubTypeRule
|
||||
{
|
||||
StubType = "hddvd",
|
||||
Token = "hddvd"
|
||||
StubType = "hddvd",
|
||||
Token = "hddvd"
|
||||
},
|
||||
new StubTypeRule
|
||||
{
|
||||
StubType = "bluray",
|
||||
Token = "bluray"
|
||||
StubType = "bluray",
|
||||
Token = "bluray"
|
||||
},
|
||||
new StubTypeRule
|
||||
{
|
||||
StubType = "bluray",
|
||||
Token = "brrip"
|
||||
StubType = "bluray",
|
||||
Token = "brrip"
|
||||
},
|
||||
new StubTypeRule
|
||||
{
|
||||
StubType = "bluray",
|
||||
Token = "bd25"
|
||||
StubType = "bluray",
|
||||
Token = "bd25"
|
||||
},
|
||||
new StubTypeRule
|
||||
{
|
||||
StubType = "bluray",
|
||||
Token = "bd50"
|
||||
StubType = "bluray",
|
||||
Token = "bd50"
|
||||
},
|
||||
new StubTypeRule
|
||||
{
|
||||
StubType = "vhs",
|
||||
Token = "vhs"
|
||||
StubType = "vhs",
|
||||
Token = "vhs"
|
||||
},
|
||||
new StubTypeRule
|
||||
{
|
||||
StubType = "tv",
|
||||
Token = "HDTV"
|
||||
StubType = "tv",
|
||||
Token = "HDTV"
|
||||
},
|
||||
new StubTypeRule
|
||||
{
|
||||
StubType = "tv",
|
||||
Token = "PDTV"
|
||||
StubType = "tv",
|
||||
Token = "PDTV"
|
||||
},
|
||||
new StubTypeRule
|
||||
{
|
||||
StubType = "tv",
|
||||
Token = "DSR"
|
||||
StubType = "tv",
|
||||
Token = "DSR"
|
||||
}
|
||||
};
|
||||
|
||||
@@ -286,7 +294,7 @@ namespace Emby.Naming.Common
|
||||
new EpisodeExpression(@"[\._ -]()[Ee][Pp]_?([0-9]+)([^\\/]*)$"),
|
||||
new EpisodeExpression("([0-9]{4})[\\.-]([0-9]{2})[\\.-]([0-9]{2})", true)
|
||||
{
|
||||
DateTimeFormats = new []
|
||||
DateTimeFormats = new[]
|
||||
{
|
||||
"yyyy.MM.dd",
|
||||
"yyyy-MM-dd",
|
||||
@@ -295,7 +303,7 @@ namespace Emby.Naming.Common
|
||||
},
|
||||
new EpisodeExpression("([0-9]{2})[\\.-]([0-9]{2})[\\.-]([0-9]{4})", true)
|
||||
{
|
||||
DateTimeFormats = new []
|
||||
DateTimeFormats = new[]
|
||||
{
|
||||
"dd.MM.yyyy",
|
||||
"dd-MM-yyyy",
|
||||
@@ -303,6 +311,14 @@ namespace Emby.Naming.Common
|
||||
}
|
||||
},
|
||||
|
||||
// This isn't a Kodi naming rule, but the expression below causes false positives,
|
||||
// so we make sure this one gets tested first.
|
||||
// "Foo Bar 889"
|
||||
new EpisodeExpression(@".*[\\\/](?![Ee]pisode)(?<seriesname>[\w\s]+?)\s(?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*[^\\\/]*$")
|
||||
{
|
||||
IsNamed = true
|
||||
},
|
||||
|
||||
new EpisodeExpression("[\\\\/\\._ \\[\\(-]([0-9]+)x([0-9]+(?:(?:[a-i]|\\.[1-9])(?![0-9]))?)([^\\\\/]*)$")
|
||||
{
|
||||
SupportsAbsoluteEpisodeNumbers = true
|
||||
@@ -320,37 +336,40 @@ namespace Emby.Naming.Common
|
||||
|
||||
// *** End Kodi Standard Naming
|
||||
|
||||
new EpisodeExpression(@".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})[^\\\/]*$")
|
||||
// [bar] Foo - 1 [baz]
|
||||
new EpisodeExpression(@".*?(\[.*?\])+.*?(?<seriesname>[\w\s]+?)[-\s_]+(?<epnumber>\d+).*$")
|
||||
{
|
||||
IsNamed = true
|
||||
},
|
||||
new EpisodeExpression(@".*(\\|\/)[sS]?(?<seasonnumber>\d+)[xX](?<epnumber>\d+)[^\\\/]*$")
|
||||
{
|
||||
IsNamed = true
|
||||
},
|
||||
|
||||
new EpisodeExpression(@".*(\\|\/)[sS](?<seasonnumber>\d{1,4})[x,X]?[eE](?<epnumber>\d{1,3})[^\\\/]*$")
|
||||
new EpisodeExpression(@".*(\\|\/)[sS](?<seasonnumber>\d+)[x,X]?[eE](?<epnumber>\d+)[^\\\/]*$")
|
||||
{
|
||||
IsNamed = true
|
||||
},
|
||||
|
||||
new EpisodeExpression(@".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))[^\\\/]*$")
|
||||
new EpisodeExpression(@".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d+))[^\\\/]*$")
|
||||
{
|
||||
IsNamed = true
|
||||
},
|
||||
|
||||
new EpisodeExpression(@".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})[^\\\/]*$")
|
||||
new EpisodeExpression(@".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d+)[^\\\/]*$")
|
||||
{
|
||||
IsNamed = true
|
||||
},
|
||||
|
||||
// "01.avi"
|
||||
new EpisodeExpression(@".*[\\\/](?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*\.\w+$")
|
||||
new EpisodeExpression(@".*[\\\/](?<epnumber>\d+)(-(?<endingepnumber>\d+))*\.\w+$")
|
||||
{
|
||||
IsOptimistic = true,
|
||||
IsNamed = true
|
||||
},
|
||||
|
||||
// "1-12 episode title"
|
||||
new EpisodeExpression(@"([0-9]+)-([0-9]+)")
|
||||
{
|
||||
},
|
||||
new EpisodeExpression(@"([0-9]+)-([0-9]+)"),
|
||||
|
||||
// "01 - blah.avi", "01-blah.avi"
|
||||
new EpisodeExpression(@".*(\\|\/)(?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*\s?-\s?[^\\\/]*$")
|
||||
@@ -427,7 +446,7 @@ namespace Emby.Naming.Common
|
||||
Token = "_trailer",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "trailer",
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
@@ -462,7 +481,7 @@ namespace Emby.Naming.Common
|
||||
Token = "_sample",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "sample",
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
@@ -476,7 +495,6 @@ namespace Emby.Naming.Common
|
||||
Token = "theme",
|
||||
MediaType = MediaType.Audio
|
||||
},
|
||||
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "scene",
|
||||
@@ -526,8 +544,8 @@ namespace Emby.Naming.Common
|
||||
Token = "-short",
|
||||
MediaType = MediaType.Video
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Format3DRules = new[]
|
||||
{
|
||||
// Kodi rules:
|
||||
@@ -648,11 +666,9 @@ namespace Emby.Naming.Common
|
||||
@".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))(-[xX]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
@".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$",
|
||||
@".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})(-[xX]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$"
|
||||
|
||||
}.Select(i => new EpisodeExpression(i)
|
||||
{
|
||||
IsNamed = true
|
||||
|
||||
}).ToArray();
|
||||
|
||||
VideoFileExtensions = extensions
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
@@ -10,7 +10,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj" />
|
||||
<ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
@@ -18,6 +18,19 @@
|
||||
<PackageId>Jellyfin.Naming</PackageId>
|
||||
<PackageLicenseUrl>https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt</PackageLicenseUrl>
|
||||
<RepositoryUrl>https://github.com/jellyfin/jellyfin</RepositoryUrl>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Code analysers-->
|
||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4" PrivateAssets="All" />
|
||||
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
|
||||
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Emby.Naming.Extensions
|
||||
{
|
||||
public static class StringExtensions
|
||||
{
|
||||
// TODO: @bond remove this when moving to netstandard2.1
|
||||
public static string Replace(this string str, string oldValue, string newValue, StringComparison comparison)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Emby.Naming
|
||||
{
|
||||
internal static class StringExtensions
|
||||
{
|
||||
public static string Replace(this string str, string oldValue, string newValue, StringComparison comparison)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
var previousIndex = 0;
|
||||
var index = str.IndexOf(oldValue, comparison);
|
||||
|
||||
while (index != -1)
|
||||
{
|
||||
sb.Append(str.Substring(previousIndex, index - previousIndex));
|
||||
sb.Append(newValue);
|
||||
index += oldValue.Length;
|
||||
|
||||
previousIndex = index;
|
||||
index = str.IndexOf(oldValue, index, comparison);
|
||||
}
|
||||
|
||||
sb.Append(str.Substring(previousIndex));
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,16 +7,19 @@ namespace Emby.Naming.Subtitles
|
||||
/// </summary>
|
||||
/// <value>The path.</value>
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the language.
|
||||
/// </summary>
|
||||
/// <value>The language.</value>
|
||||
public string Language { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is default.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is default; otherwise, <c>false</c>.</value>
|
||||
public bool IsDefault { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is forced.
|
||||
/// </summary>
|
||||
|
||||
@@ -7,31 +7,37 @@ namespace Emby.Naming.TV
|
||||
/// </summary>
|
||||
/// <value>The path.</value>
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the container.
|
||||
/// </summary>
|
||||
/// <value>The container.</value>
|
||||
public string Container { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the series.
|
||||
/// </summary>
|
||||
/// <value>The name of the series.</value>
|
||||
public string SeriesName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the format3 d.
|
||||
/// </summary>
|
||||
/// <value>The format3 d.</value>
|
||||
public string Format3D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether [is3 d].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [is3 d]; otherwise, <c>false</c>.</value>
|
||||
public bool Is3D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is stub.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is stub; otherwise, <c>false</c>.</value>
|
||||
public bool IsStub { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the stub.
|
||||
/// </summary>
|
||||
@@ -39,12 +45,17 @@ namespace Emby.Naming.TV
|
||||
public string StubType { get; set; }
|
||||
|
||||
public int? SeasonNumber { get; set; }
|
||||
|
||||
public int? EpisodeNumber { get; set; }
|
||||
|
||||
public int? EndingEpsiodeNumber { get; set; }
|
||||
|
||||
public int? Year { get; set; }
|
||||
|
||||
public int? Month { get; set; }
|
||||
|
||||
public int? Day { get; set; }
|
||||
|
||||
public bool IsByDate { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ namespace Emby.Naming.TV
|
||||
_options = options;
|
||||
}
|
||||
|
||||
public EpisodePathParserResult Parse(string path, bool IsDirectory, bool? isNamed = null, bool? isOptimistic = null, bool? supportsAbsoluteNumbers = null, bool fillExtendedInfo = true)
|
||||
public EpisodePathParserResult Parse(string path, bool isDirectory, bool? isNamed = null, bool? isOptimistic = null, bool? supportsAbsoluteNumbers = null, bool fillExtendedInfo = true)
|
||||
{
|
||||
// Added to be able to use regex patterns which require a file extension.
|
||||
// There were no failed tests without this block, but to be safe, we can keep it until
|
||||
// the regex which require file extensions are modified so that they don't need them.
|
||||
if (IsDirectory)
|
||||
if (isDirectory)
|
||||
{
|
||||
path += ".mp4";
|
||||
}
|
||||
@@ -29,28 +29,20 @@ namespace Emby.Naming.TV
|
||||
|
||||
foreach (var expression in _options.EpisodeExpressions)
|
||||
{
|
||||
if (supportsAbsoluteNumbers.HasValue)
|
||||
if (supportsAbsoluteNumbers.HasValue
|
||||
&& expression.SupportsAbsoluteEpisodeNumbers != supportsAbsoluteNumbers.Value)
|
||||
{
|
||||
if (expression.SupportsAbsoluteEpisodeNumbers != supportsAbsoluteNumbers.Value)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isNamed.HasValue)
|
||||
if (isNamed.HasValue && expression.IsNamed != isNamed.Value)
|
||||
{
|
||||
if (expression.IsNamed != isNamed.Value)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isOptimistic.HasValue)
|
||||
if (isOptimistic.HasValue && expression.IsOptimistic != isOptimistic.Value)
|
||||
{
|
||||
if (expression.IsOptimistic != isOptimistic.Value)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
var currentResult = Parse(path, expression);
|
||||
@@ -97,7 +89,8 @@ namespace Emby.Naming.TV
|
||||
DateTime date;
|
||||
if (expression.DateTimeFormats.Length > 0)
|
||||
{
|
||||
if (DateTime.TryParseExact(match.Groups[0].Value,
|
||||
if (DateTime.TryParseExact(
|
||||
match.Groups[0].Value,
|
||||
expression.DateTimeFormats,
|
||||
CultureInfo.InvariantCulture,
|
||||
DateTimeStyles.None,
|
||||
@@ -109,15 +102,12 @@ namespace Emby.Naming.TV
|
||||
result.Success = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (DateTime.TryParse(match.Groups[0].Value, out date))
|
||||
{
|
||||
if (DateTime.TryParse(match.Groups[0].Value, out date))
|
||||
{
|
||||
result.Year = date.Year;
|
||||
result.Month = date.Month;
|
||||
result.Day = date.Day;
|
||||
result.Success = true;
|
||||
}
|
||||
result.Year = date.Year;
|
||||
result.Month = date.Month;
|
||||
result.Day = date.Day;
|
||||
result.Success = true;
|
||||
}
|
||||
|
||||
// TODO: Only consider success if date successfully parsed?
|
||||
@@ -142,7 +132,8 @@ namespace Emby.Naming.TV
|
||||
// or a 'p' or 'i' as what you would get with a pixel resolution specification.
|
||||
// It avoids erroneous parsing of something like "series-s09e14-1080p.mkv" as a multi-episode from E14 to E108
|
||||
int nextIndex = endingNumberGroup.Index + endingNumberGroup.Length;
|
||||
if (nextIndex >= name.Length || "0123456789iIpP".IndexOf(name[nextIndex]) == -1)
|
||||
if (nextIndex >= name.Length
|
||||
|| "0123456789iIpP".IndexOf(name[nextIndex]) == -1)
|
||||
{
|
||||
if (int.TryParse(endingNumberGroup.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out num))
|
||||
{
|
||||
@@ -160,6 +151,7 @@ namespace Emby.Naming.TV
|
||||
{
|
||||
result.SeasonNumber = num;
|
||||
}
|
||||
|
||||
if (int.TryParse(match.Groups[2].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out num))
|
||||
{
|
||||
result.EpisodeNumber = num;
|
||||
@@ -171,8 +163,11 @@ namespace Emby.Naming.TV
|
||||
// Invalidate match when the season is 200 through 1927 or above 2500
|
||||
// because it is an error unless the TV show is intentionally using false season numbers.
|
||||
// It avoids erroneous parsing of something like "Series Special (1920x1080).mkv" as being season 1920 episode 1080.
|
||||
if (result.SeasonNumber >= 200 && result.SeasonNumber < 1928 || result.SeasonNumber > 2500)
|
||||
if ((result.SeasonNumber >= 200 && result.SeasonNumber < 1928)
|
||||
|| result.SeasonNumber > 2500)
|
||||
{
|
||||
result.Success = false;
|
||||
}
|
||||
|
||||
result.IsByDate = expression.IsByDate;
|
||||
}
|
||||
|
||||
@@ -3,14 +3,21 @@ namespace Emby.Naming.TV
|
||||
public class EpisodePathParserResult
|
||||
{
|
||||
public int? SeasonNumber { get; set; }
|
||||
|
||||
public int? EpisodeNumber { get; set; }
|
||||
|
||||
public int? EndingEpsiodeNumber { get; set; }
|
||||
|
||||
public string SeriesName { get; set; }
|
||||
|
||||
public bool Success { get; set; }
|
||||
|
||||
public bool IsByDate { get; set; }
|
||||
|
||||
public int? Year { get; set; }
|
||||
|
||||
public int? Month { get; set; }
|
||||
|
||||
public int? Day { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,13 @@ namespace Emby.Naming.TV
|
||||
_options = options;
|
||||
}
|
||||
|
||||
public EpisodeInfo Resolve(string path, bool IsDirectory, bool? isNamed = null, bool? isOptimistic = null, bool? supportsAbsoluteNumbers = null, bool fillExtendedInfo = true)
|
||||
public EpisodeInfo Resolve(
|
||||
string path,
|
||||
bool isDirectory,
|
||||
bool? isNamed = null,
|
||||
bool? isOptimistic = null,
|
||||
bool? supportsAbsoluteNumbers = null,
|
||||
bool fillExtendedInfo = true)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
@@ -26,7 +32,7 @@ namespace Emby.Naming.TV
|
||||
string container = null;
|
||||
string stubType = null;
|
||||
|
||||
if (!IsDirectory)
|
||||
if (!isDirectory)
|
||||
{
|
||||
var extension = Path.GetExtension(path);
|
||||
// Check supported extensions
|
||||
@@ -52,7 +58,7 @@ namespace Emby.Naming.TV
|
||||
var format3DResult = new Format3DParser(_options).Parse(flags);
|
||||
|
||||
var parsingResult = new EpisodePathParser(_options)
|
||||
.Parse(path, IsDirectory, isNamed, isOptimistic, supportsAbsoluteNumbers, fillExtendedInfo);
|
||||
.Parse(path, isDirectory, isNamed, isOptimistic, supportsAbsoluteNumbers, fillExtendedInfo);
|
||||
|
||||
return new EpisodeInfo
|
||||
{
|
||||
|
||||
@@ -3,30 +3,24 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Emby.Naming.Common;
|
||||
using Emby.Naming.Extensions;
|
||||
|
||||
namespace Emby.Naming.TV
|
||||
{
|
||||
public class SeasonPathParser
|
||||
{
|
||||
private readonly NamingOptions _options;
|
||||
|
||||
public SeasonPathParser(NamingOptions options)
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
public SeasonPathParserResult Parse(string path, bool supportSpecialAliases, bool supportNumericSeasonFolders)
|
||||
{
|
||||
var result = new SeasonPathParserResult();
|
||||
|
||||
var seasonNumberInfo = GetSeasonNumberFromPath(path, supportSpecialAliases, supportNumericSeasonFolders);
|
||||
|
||||
result.SeasonNumber = seasonNumberInfo.Item1;
|
||||
result.SeasonNumber = seasonNumberInfo.seasonNumber;
|
||||
|
||||
if (result.SeasonNumber.HasValue)
|
||||
{
|
||||
result.Success = true;
|
||||
result.IsSeasonFolder = seasonNumberInfo.Item2;
|
||||
result.IsSeasonFolder = seasonNumberInfo.isSeasonFolder;
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -35,7 +29,7 @@ namespace Emby.Naming.TV
|
||||
/// <summary>
|
||||
/// A season folder must contain one of these somewhere in the name
|
||||
/// </summary>
|
||||
private static readonly string[] SeasonFolderNames =
|
||||
private static readonly string[] _seasonFolderNames =
|
||||
{
|
||||
"season",
|
||||
"sæson",
|
||||
@@ -54,19 +48,23 @@ namespace Emby.Naming.TV
|
||||
/// <param name="supportSpecialAliases">if set to <c>true</c> [support special aliases].</param>
|
||||
/// <param name="supportNumericSeasonFolders">if set to <c>true</c> [support numeric season folders].</param>
|
||||
/// <returns>System.Nullable{System.Int32}.</returns>
|
||||
private Tuple<int?, bool> GetSeasonNumberFromPath(string path, bool supportSpecialAliases, bool supportNumericSeasonFolders)
|
||||
private static (int? seasonNumber, bool isSeasonFolder) GetSeasonNumberFromPath(
|
||||
string path,
|
||||
bool supportSpecialAliases,
|
||||
bool supportNumericSeasonFolders)
|
||||
{
|
||||
var filename = Path.GetFileName(path);
|
||||
var filename = Path.GetFileName(path) ?? string.Empty;
|
||||
|
||||
if (supportSpecialAliases)
|
||||
{
|
||||
if (string.Equals(filename, "specials", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return new Tuple<int?, bool>(0, true);
|
||||
return (0, true);
|
||||
}
|
||||
|
||||
if (string.Equals(filename, "extras", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return new Tuple<int?, bool>(0, true);
|
||||
return (0, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +72,7 @@ namespace Emby.Naming.TV
|
||||
{
|
||||
if (int.TryParse(filename, NumberStyles.Integer, CultureInfo.InvariantCulture, out var val))
|
||||
{
|
||||
return new Tuple<int?, bool>(val, true);
|
||||
return (val, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,12 +82,12 @@ namespace Emby.Naming.TV
|
||||
|
||||
if (int.TryParse(testFilename, NumberStyles.Integer, CultureInfo.InvariantCulture, out var val))
|
||||
{
|
||||
return new Tuple<int?, bool>(val, true);
|
||||
return (val, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Look for one of the season folder names
|
||||
foreach (var name in SeasonFolderNames)
|
||||
foreach (var name in _seasonFolderNames)
|
||||
{
|
||||
var index = filename.IndexOf(name, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
@@ -107,10 +105,10 @@ namespace Emby.Naming.TV
|
||||
|
||||
var parts = filename.Split(new[] { '.', '_', ' ', '-' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var resultNumber = parts.Select(GetSeasonNumberFromPart).FirstOrDefault(i => i.HasValue);
|
||||
return new Tuple<int?, bool>(resultNumber, true);
|
||||
return (resultNumber, true);
|
||||
}
|
||||
|
||||
private int? GetSeasonNumberFromPart(string part)
|
||||
private static int? GetSeasonNumberFromPart(string part)
|
||||
{
|
||||
if (part.Length < 2 || !part.StartsWith("s", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -132,7 +130,7 @@ namespace Emby.Naming.TV
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>System.Nullable{System.Int32}.</returns>
|
||||
private Tuple<int?, bool> GetSeasonNumberFromPathSubstring(string path)
|
||||
private static (int? seasonNumber, bool isSeasonFolder) GetSeasonNumberFromPathSubstring(string path)
|
||||
{
|
||||
var numericStart = -1;
|
||||
var length = 0;
|
||||
@@ -174,10 +172,10 @@ namespace Emby.Naming.TV
|
||||
|
||||
if (numericStart == -1)
|
||||
{
|
||||
return new Tuple<int?, bool>(null, isSeasonFolder);
|
||||
return (null, isSeasonFolder);
|
||||
}
|
||||
|
||||
return new Tuple<int?, bool>(int.Parse(path.Substring(numericStart, length), CultureInfo.InvariantCulture), isSeasonFolder);
|
||||
return (int.Parse(path.Substring(numericStart, length), CultureInfo.InvariantCulture), isSeasonFolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,13 @@ namespace Emby.Naming.TV
|
||||
/// </summary>
|
||||
/// <value>The season number.</value>
|
||||
public int? SeasonNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this <see cref="SeasonPathParserResult"/> is success.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if success; otherwise, <c>false</c>.</value>
|
||||
public bool Success { get; set; }
|
||||
|
||||
public bool IsSeasonFolder { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace Emby.Naming.Video
|
||||
{
|
||||
var extension = Path.GetExtension(name) ?? string.Empty;
|
||||
// Check supported extensions
|
||||
if (!_options.VideoFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase) &&
|
||||
!_options.AudioFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
|
||||
if (!_options.VideoFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase)
|
||||
&& !_options.AudioFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
// Dummy up a file extension because the expressions will fail without one
|
||||
// This is tricky because we can't just check Path.GetExtension for empty
|
||||
@@ -38,7 +38,6 @@ namespace Emby.Naming.Video
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
var result = _options.CleanDateTimeRegexes.Select(i => Clean(name, i))
|
||||
@@ -69,14 +68,15 @@ namespace Emby.Naming.Video
|
||||
|
||||
var match = expression.Match(name);
|
||||
|
||||
if (match.Success && match.Groups.Count == 4)
|
||||
if (match.Success
|
||||
&& match.Groups.Count == 4
|
||||
&& match.Groups[1].Success
|
||||
&& match.Groups[2].Success
|
||||
&& int.TryParse(match.Groups[2].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var year))
|
||||
{
|
||||
if (match.Groups[1].Success && match.Groups[2].Success && int.TryParse(match.Groups[2].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var year))
|
||||
{
|
||||
name = match.Groups[1].Value;
|
||||
result.Year = year;
|
||||
result.HasChanged = true;
|
||||
}
|
||||
name = match.Groups[1].Value;
|
||||
result.Year = year;
|
||||
result.HasChanged = true;
|
||||
}
|
||||
|
||||
result.Name = name;
|
||||
|
||||
@@ -56,7 +56,6 @@ namespace Emby.Naming.Video
|
||||
result.Rule = rule;
|
||||
}
|
||||
}
|
||||
|
||||
else if (rule.RuleType == ExtraRuleType.Suffix)
|
||||
{
|
||||
var filename = Path.GetFileNameWithoutExtension(path);
|
||||
@@ -67,7 +66,6 @@ namespace Emby.Naming.Video
|
||||
result.Rule = rule;
|
||||
}
|
||||
}
|
||||
|
||||
else if (rule.RuleType == ExtraRuleType.Regex)
|
||||
{
|
||||
var filename = Path.GetFileName(path);
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace Emby.Naming.Video
|
||||
Files = new List<string>();
|
||||
}
|
||||
|
||||
public bool ContainsFile(string file, bool IsDirectory)
|
||||
public bool ContainsFile(string file, bool isDirectory)
|
||||
{
|
||||
if (IsDirectoryStack == IsDirectory)
|
||||
if (IsDirectoryStack == isDirectory)
|
||||
{
|
||||
return Files.Contains(file, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
@@ -15,10 +15,12 @@ namespace Emby.Naming.Video
|
||||
|
||||
public Format3DResult Parse(string path)
|
||||
{
|
||||
var delimeters = _options.VideoFlagDelimiters.ToList();
|
||||
delimeters.Add(' ');
|
||||
int oldLen = _options.VideoFlagDelimiters.Length;
|
||||
var delimeters = new char[oldLen + 1];
|
||||
_options.VideoFlagDelimiters.CopyTo(delimeters, 0);
|
||||
delimeters[oldLen] = ' ';
|
||||
|
||||
return Parse(new FlagParser(_options).GetFlags(path, delimeters.ToArray()));
|
||||
return Parse(new FlagParser(_options).GetFlags(path, delimeters));
|
||||
}
|
||||
|
||||
internal Format3DResult Parse(string[] videoFlags)
|
||||
@@ -66,8 +68,10 @@ namespace Emby.Naming.Video
|
||||
format = flag;
|
||||
result.Tokens.Add(rule.Token);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
foundPrefix = string.Equals(flag, rule.PreceedingToken, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,25 +4,27 @@ namespace Emby.Naming.Video
|
||||
{
|
||||
public class Format3DResult
|
||||
{
|
||||
public Format3DResult()
|
||||
{
|
||||
Tokens = new List<string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether [is3 d].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [is3 d]; otherwise, <c>false</c>.</value>
|
||||
public bool Is3D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the format3 d.
|
||||
/// </summary>
|
||||
/// <value>The format3 d.</value>
|
||||
public string Format3D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the tokens.
|
||||
/// </summary>
|
||||
/// <value>The tokens.</value>
|
||||
public List<string> Tokens { get; set; }
|
||||
|
||||
public Format3DResult()
|
||||
{
|
||||
Tokens = new List<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,17 +40,24 @@ namespace Emby.Naming.Video
|
||||
var result = new StackResult();
|
||||
foreach (var directory in files.GroupBy(file => file.IsDirectory ? file.FullName : Path.GetDirectoryName(file.FullName)))
|
||||
{
|
||||
var stack = new FileStack();
|
||||
stack.Name = Path.GetFileName(directory.Key);
|
||||
stack.IsDirectoryStack = false;
|
||||
var stack = new FileStack()
|
||||
{
|
||||
Name = Path.GetFileName(directory.Key),
|
||||
IsDirectoryStack = false
|
||||
};
|
||||
foreach (var file in directory)
|
||||
{
|
||||
if (file.IsDirectory)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
stack.Files.Add(file.FullName);
|
||||
}
|
||||
|
||||
result.Stacks.Add(stack);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -114,16 +121,16 @@ namespace Emby.Naming.Video
|
||||
{
|
||||
if (!string.Equals(volume1, volume2, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (string.Equals(ignore1, ignore2, StringComparison.OrdinalIgnoreCase) &&
|
||||
string.Equals(extension1, extension2, StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(ignore1, ignore2, StringComparison.OrdinalIgnoreCase)
|
||||
&& string.Equals(extension1, extension2, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (stack.Files.Count == 0)
|
||||
{
|
||||
stack.Name = title1 + ignore1;
|
||||
stack.IsDirectoryStack = file1.IsDirectory;
|
||||
//stack.Name = title1 + ignore1 + extension1;
|
||||
stack.Files.Add(file1.FullName);
|
||||
}
|
||||
|
||||
stack.Files.Add(file2.FullName);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -9,24 +9,32 @@ namespace Emby.Naming.Video
|
||||
{
|
||||
public static StubResult ResolveFile(string path, NamingOptions options)
|
||||
{
|
||||
var result = new StubResult();
|
||||
var extension = Path.GetExtension(path) ?? string.Empty;
|
||||
|
||||
if (options.StubFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
|
||||
if (path == null)
|
||||
{
|
||||
result.IsStub = true;
|
||||
return default(StubResult);
|
||||
}
|
||||
|
||||
path = Path.GetFileNameWithoutExtension(path);
|
||||
var extension = Path.GetExtension(path);
|
||||
|
||||
var token = (Path.GetExtension(path) ?? string.Empty).TrimStart('.');
|
||||
if (!options.StubFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return default(StubResult);
|
||||
}
|
||||
|
||||
foreach (var rule in options.StubTypes)
|
||||
var result = new StubResult()
|
||||
{
|
||||
IsStub = true
|
||||
};
|
||||
|
||||
path = Path.GetFileNameWithoutExtension(path);
|
||||
var token = Path.GetExtension(path).TrimStart('.');
|
||||
|
||||
foreach (var rule in options.StubTypes)
|
||||
{
|
||||
if (string.Equals(rule.Token, token, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (string.Equals(rule.Token, token, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
result.StubType = rule.StubType;
|
||||
break;
|
||||
}
|
||||
result.StubType = rule.StubType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Emby.Naming.Video
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is stub; otherwise, <c>false</c>.</value>
|
||||
public bool IsStub { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the stub.
|
||||
/// </summary>
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Emby.Naming.Video
|
||||
/// </summary>
|
||||
/// <value>The token.</value>
|
||||
public string Token { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the stub.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
/// <summary>
|
||||
@@ -11,56 +10,67 @@ namespace Emby.Naming.Video
|
||||
/// </summary>
|
||||
/// <value>The path.</value>
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the container.
|
||||
/// </summary>
|
||||
/// <value>The container.</value>
|
||||
public string Container { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the year.
|
||||
/// </summary>
|
||||
/// <value>The year.</value>
|
||||
public int? Year { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the extra, e.g. trailer, theme song, behing the scenes, etc.
|
||||
/// </summary>
|
||||
/// <value>The type of the extra.</value>
|
||||
public string ExtraType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the extra rule.
|
||||
/// </summary>
|
||||
/// <value>The extra rule.</value>
|
||||
public ExtraRule ExtraRule { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the format3 d.
|
||||
/// </summary>
|
||||
/// <value>The format3 d.</value>
|
||||
public string Format3D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether [is3 d].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [is3 d]; otherwise, <c>false</c>.</value>
|
||||
public bool Is3D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is stub.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is stub; otherwise, <c>false</c>.</value>
|
||||
public bool IsStub { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the stub.
|
||||
/// </summary>
|
||||
/// <value>The type of the stub.</value>
|
||||
public string StubType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type.
|
||||
/// </summary>
|
||||
/// <value>The type.</value>
|
||||
public bool IsDirectory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the file name without extension.
|
||||
/// </summary>
|
||||
|
||||
@@ -12,21 +12,25 @@ namespace Emby.Naming.Video
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the year.
|
||||
/// </summary>
|
||||
/// <value>The year.</value>
|
||||
public int? Year { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the files.
|
||||
/// </summary>
|
||||
/// <value>The files.</value>
|
||||
public List<VideoFileInfo> Files { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the extras.
|
||||
/// </summary>
|
||||
/// <value>The extras.</value>
|
||||
public List<VideoFileInfo> Extras { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alternate versions.
|
||||
/// </summary>
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Emby.Naming.Video
|
||||
Name = stack.Name
|
||||
};
|
||||
|
||||
info.Year = info.Files.First().Year;
|
||||
info.Year = info.Files[0].Year;
|
||||
|
||||
var extraBaseNames = new List<string>
|
||||
{
|
||||
@@ -87,7 +87,7 @@ namespace Emby.Naming.Video
|
||||
Name = media.Name
|
||||
};
|
||||
|
||||
info.Year = info.Files.First().Year;
|
||||
info.Year = info.Files[0].Year;
|
||||
|
||||
var extras = GetExtras(remainingFiles, new List<string> { media.FileNameWithoutExtension });
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Emby.Naming.Video
|
||||
|
||||
if (!string.IsNullOrEmpty(parentPath))
|
||||
{
|
||||
var folderName = Path.GetFileName(Path.GetDirectoryName(videoPath));
|
||||
var folderName = Path.GetFileName(parentPath);
|
||||
if (!string.IsNullOrEmpty(folderName))
|
||||
{
|
||||
var extras = GetExtras(remainingFiles, new List<string> { folderName });
|
||||
@@ -163,9 +163,7 @@ namespace Emby.Naming.Video
|
||||
Year = i.Year
|
||||
}));
|
||||
|
||||
var orderedList = list.OrderBy(i => i.Name);
|
||||
|
||||
return orderedList;
|
||||
return list.OrderBy(i => i.Name);
|
||||
}
|
||||
|
||||
private IEnumerable<VideoInfo> GetVideosGroupedByVersion(List<VideoInfo> videos)
|
||||
@@ -179,23 +177,21 @@ namespace Emby.Naming.Video
|
||||
|
||||
var folderName = Path.GetFileName(Path.GetDirectoryName(videos[0].Files[0].Path));
|
||||
|
||||
if (!string.IsNullOrEmpty(folderName) && folderName.Length > 1)
|
||||
if (!string.IsNullOrEmpty(folderName)
|
||||
&& folderName.Length > 1
|
||||
&& videos.All(i => i.Files.Count == 1
|
||||
&& IsEligibleForMultiVersion(folderName, i.Files[0].Path))
|
||||
&& HaveSameYear(videos))
|
||||
{
|
||||
if (videos.All(i => i.Files.Count == 1 && IsEligibleForMultiVersion(folderName, i.Files[0].Path)))
|
||||
{
|
||||
if (HaveSameYear(videos))
|
||||
{
|
||||
var ordered = videos.OrderBy(i => i.Name).ToList();
|
||||
var ordered = videos.OrderBy(i => i.Name).ToList();
|
||||
|
||||
list.Add(ordered[0]);
|
||||
list.Add(ordered[0]);
|
||||
|
||||
list[0].AlternateVersions = ordered.Skip(1).Select(i => i.Files[0]).ToList();
|
||||
list[0].Name = folderName;
|
||||
list[0].Extras.AddRange(ordered.Skip(1).SelectMany(i => i.Extras));
|
||||
list[0].AlternateVersions = ordered.Skip(1).Select(i => i.Files[0]).ToList();
|
||||
list[0].Name = folderName;
|
||||
list[0].Extras.AddRange(ordered.Skip(1).SelectMany(i => i.Extras));
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
return videos;
|
||||
@@ -213,9 +209,9 @@ namespace Emby.Naming.Video
|
||||
if (testFilename.StartsWith(folderName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
testFilename = testFilename.Substring(folderName.Length).Trim();
|
||||
return string.IsNullOrEmpty(testFilename) ||
|
||||
testFilename.StartsWith("-") ||
|
||||
string.IsNullOrWhiteSpace(Regex.Replace(testFilename, @"\[([^]]*)\]", string.Empty)) ;
|
||||
return string.IsNullOrEmpty(testFilename)
|
||||
|| testFilename[0] == '-'
|
||||
|| string.IsNullOrWhiteSpace(Regex.Replace(testFilename, @"\[([^]]*)\]", string.Empty));
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -38,10 +38,11 @@ namespace Emby.Naming.Video
|
||||
/// Resolves the specified path.
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <param name="IsDirectory">if set to <c>true</c> [is folder].</param>
|
||||
/// <param name="isDirectory">if set to <c>true</c> [is folder].</param>
|
||||
/// <param name="parseName">Whether or not the name should be parsed for info</param>
|
||||
/// <returns>VideoFileInfo.</returns>
|
||||
/// <exception cref="ArgumentNullException">path</exception>
|
||||
public VideoFileInfo Resolve(string path, bool IsDirectory, bool parseName = true)
|
||||
public VideoFileInfo Resolve(string path, bool isDirectory, bool parseName = true)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
@@ -52,9 +53,10 @@ namespace Emby.Naming.Video
|
||||
string container = null;
|
||||
string stubType = null;
|
||||
|
||||
if (!IsDirectory)
|
||||
if (!isDirectory)
|
||||
{
|
||||
var extension = Path.GetExtension(path);
|
||||
|
||||
// Check supported extensions
|
||||
if (!_options.VideoFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -79,7 +81,7 @@ namespace Emby.Naming.Video
|
||||
|
||||
var extraResult = new ExtraResolver(_options).GetExtraInfo(path);
|
||||
|
||||
var name = IsDirectory
|
||||
var name = isDirectory
|
||||
? Path.GetFileName(path)
|
||||
: Path.GetFileNameWithoutExtension(path);
|
||||
|
||||
@@ -108,7 +110,7 @@ namespace Emby.Naming.Video
|
||||
Is3D = format3DResult.Is3D,
|
||||
Format3D = format3DResult.Format3D,
|
||||
ExtraType = extraResult.ExtraType,
|
||||
IsDirectory = IsDirectory,
|
||||
IsDirectory = isDirectory,
|
||||
ExtraRule = extraResult.Rule
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -88,7 +89,7 @@ namespace Emby.Notifications
|
||||
return _userManager.Users.Where(i => i.Policy.IsAdministrator)
|
||||
.Select(i => i.Id);
|
||||
case SendToUserType.All:
|
||||
return _userManager.Users.Select(i => i.Id);
|
||||
return _userManager.UsersIds;
|
||||
case SendToUserType.Custom:
|
||||
return request.UserIds;
|
||||
default:
|
||||
@@ -101,7 +102,7 @@ namespace Emby.Notifications
|
||||
var config = GetConfiguration();
|
||||
|
||||
return _userManager.Users
|
||||
.Where(i => config.IsEnabledToSendToUser(request.NotificationType, i.Id.ToString("N"), i.Policy))
|
||||
.Where(i => config.IsEnabledToSendToUser(request.NotificationType, i.Id.ToString("N", CultureInfo.InvariantCulture), i.Policy))
|
||||
.Select(i => i.Id);
|
||||
}
|
||||
|
||||
@@ -197,7 +198,7 @@ namespace Emby.Notifications
|
||||
return _services.Select(i => new NameIdPair
|
||||
{
|
||||
Name = i.Name,
|
||||
Id = i.Name.GetMD5().ToString("N")
|
||||
Id = i.Name.GetMD5().ToString("N", CultureInfo.InvariantCulture)
|
||||
|
||||
}).OrderBy(i => i.Name);
|
||||
}
|
||||
|
||||
@@ -209,47 +209,48 @@ namespace Emby.Notifications
|
||||
public static string GetItemName(BaseItem item)
|
||||
{
|
||||
var name = item.Name;
|
||||
var episode = item as Episode;
|
||||
if (episode != null)
|
||||
if (item is Episode episode)
|
||||
{
|
||||
if (episode.IndexNumber.HasValue)
|
||||
{
|
||||
name = string.Format("Ep{0} - {1}", episode.IndexNumber.Value.ToString(CultureInfo.InvariantCulture), name);
|
||||
name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"Ep{0} - {1}",
|
||||
episode.IndexNumber.Value,
|
||||
name);
|
||||
}
|
||||
if (episode.ParentIndexNumber.HasValue)
|
||||
{
|
||||
name = string.Format("S{0}, {1}", episode.ParentIndexNumber.Value.ToString(CultureInfo.InvariantCulture), name);
|
||||
name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"S{0}, {1}",
|
||||
episode.ParentIndexNumber.Value,
|
||||
name);
|
||||
}
|
||||
}
|
||||
|
||||
var hasSeries = item as IHasSeries;
|
||||
|
||||
if (hasSeries != null)
|
||||
if (item is IHasSeries hasSeries)
|
||||
{
|
||||
name = hasSeries.SeriesName + " - " + name;
|
||||
}
|
||||
|
||||
var hasAlbumArtist = item as IHasAlbumArtist;
|
||||
if (hasAlbumArtist != null)
|
||||
if (item is IHasAlbumArtist hasAlbumArtist)
|
||||
{
|
||||
var artists = hasAlbumArtist.AlbumArtists;
|
||||
|
||||
if (artists.Length > 0)
|
||||
if (artists.Count > 0)
|
||||
{
|
||||
name = artists[0] + " - " + name;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (item is IHasArtist hasArtist)
|
||||
{
|
||||
var hasArtist = item as IHasArtist;
|
||||
if (hasArtist != null)
|
||||
{
|
||||
var artists = hasArtist.Artists;
|
||||
var artists = hasArtist.Artists;
|
||||
|
||||
if (artists.Length > 0)
|
||||
{
|
||||
name = artists[0] + " - " + name;
|
||||
}
|
||||
if (artists.Count > 0)
|
||||
{
|
||||
name = artists[0] + " - " + name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,13 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="TagLibSharp" Version="2.2.0-beta" />
|
||||
<PackageReference Include="TagLibSharp" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -20,7 +20,10 @@ namespace Emby.Photos
|
||||
public class PhotoProvider : ICustomMetadataProvider<Photo>, IForcedProvider, IHasItemChangeMonitor
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private IImageProcessor _imageProcessor;
|
||||
private readonly IImageProcessor _imageProcessor;
|
||||
|
||||
// These are causing taglib to hang
|
||||
private string[] _includextensions = new string[] { ".jpg", ".jpeg", ".png", ".tiff", ".cr2" };
|
||||
|
||||
public PhotoProvider(ILogger logger, IImageProcessor imageProcessor)
|
||||
{
|
||||
@@ -28,75 +31,55 @@ namespace Emby.Photos
|
||||
_imageProcessor = imageProcessor;
|
||||
}
|
||||
|
||||
public string Name => "Embedded Information";
|
||||
|
||||
public bool HasChanged(BaseItem item, IDirectoryService directoryService)
|
||||
{
|
||||
if (item.IsFileProtocol)
|
||||
{
|
||||
var file = directoryService.GetFile(item.Path);
|
||||
if (file != null && file.LastWriteTimeUtc != item.DateModified)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return (file != null && file.LastWriteTimeUtc != item.DateModified);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// These are causing taglib to hang
|
||||
private string[] _includextensions = new string[] { ".jpg", ".jpeg", ".png", ".tiff", ".cr2" };
|
||||
|
||||
public Task<ItemUpdateType> FetchAsync(Photo item, MetadataRefreshOptions options, CancellationToken cancellationToken)
|
||||
{
|
||||
item.SetImagePath(ImageType.Primary, item.Path);
|
||||
|
||||
// Examples: https://github.com/mono/taglib-sharp/blob/a5f6949a53d09ce63ee7495580d6802921a21f14/tests/fixtures/TagLib.Tests.Images/NullOrientationTest.cs
|
||||
if (_includextensions.Contains(Path.GetExtension(item.Path) ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
||||
if (_includextensions.Contains(Path.GetExtension(item.Path), StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var file = TagLib.File.Create(item.Path))
|
||||
{
|
||||
var image = file as TagLib.Image.File;
|
||||
|
||||
var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag;
|
||||
|
||||
if (tag != null)
|
||||
if (file.GetTag(TagTypes.TiffIFD) is IFDTag tag)
|
||||
{
|
||||
var structure = tag.Structure;
|
||||
|
||||
if (structure != null)
|
||||
if (structure != null
|
||||
&& structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) is SubIFDEntry exif)
|
||||
{
|
||||
var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry;
|
||||
|
||||
if (exif != null)
|
||||
var exifStructure = exif.Structure;
|
||||
if (exifStructure != null)
|
||||
{
|
||||
var exifStructure = exif.Structure;
|
||||
|
||||
if (exifStructure != null)
|
||||
var entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue) as RationalIFDEntry;
|
||||
if (entry != null)
|
||||
{
|
||||
var entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue) as RationalIFDEntry;
|
||||
item.Aperture = (double)entry.Value.Numerator / entry.Value.Denominator;
|
||||
}
|
||||
|
||||
if (entry != null)
|
||||
{
|
||||
double val = entry.Value.Numerator;
|
||||
val /= entry.Value.Denominator;
|
||||
item.Aperture = val;
|
||||
}
|
||||
|
||||
entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue) as RationalIFDEntry;
|
||||
|
||||
if (entry != null)
|
||||
{
|
||||
double val = entry.Value.Numerator;
|
||||
val /= entry.Value.Denominator;
|
||||
item.ShutterSpeed = val;
|
||||
}
|
||||
entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue) as RationalIFDEntry;
|
||||
if (entry != null)
|
||||
{
|
||||
item.ShutterSpeed = (double)entry.Value.Numerator / entry.Value.Denominator;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (image != null)
|
||||
if (file is TagLib.Image.File image)
|
||||
{
|
||||
item.CameraMake = image.ImageTag.Make;
|
||||
item.CameraModel = image.ImageTag.Model;
|
||||
@@ -116,12 +99,10 @@ namespace Emby.Photos
|
||||
|
||||
item.Overview = image.ImageTag.Comment;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(image.ImageTag.Title))
|
||||
if (!string.IsNullOrWhiteSpace(image.ImageTag.Title)
|
||||
&& !item.LockedFields.Contains(MetadataFields.Name))
|
||||
{
|
||||
if (!item.LockedFields.Contains(MetadataFields.Name))
|
||||
{
|
||||
item.Name = image.ImageTag.Title;
|
||||
}
|
||||
item.Name = image.ImageTag.Title;
|
||||
}
|
||||
|
||||
var dateTaken = image.ImageTag.DateTime;
|
||||
@@ -140,12 +121,9 @@ namespace Emby.Photos
|
||||
{
|
||||
item.Orientation = null;
|
||||
}
|
||||
else
|
||||
else if (Enum.TryParse(image.ImageTag.Orientation.ToString(), true, out ImageOrientation orientation))
|
||||
{
|
||||
if (Enum.TryParse(image.ImageTag.Orientation.ToString(), true, out ImageOrientation orientation))
|
||||
{
|
||||
item.Orientation = orientation;
|
||||
}
|
||||
item.Orientation = orientation;
|
||||
}
|
||||
|
||||
item.ExposureTime = image.ImageTag.ExposureTime;
|
||||
@@ -192,10 +170,8 @@ namespace Emby.Photos
|
||||
}
|
||||
}
|
||||
|
||||
const ItemUpdateType result = ItemUpdateType.ImageUpdate | ItemUpdateType.MetadataImport;
|
||||
return Task.FromResult(result);
|
||||
const ItemUpdateType Result = ItemUpdateType.ImageUpdate | ItemUpdateType.MetadataImport;
|
||||
return Task.FromResult(Result);
|
||||
}
|
||||
|
||||
public string Name => "Embedded Information";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Plugins;
|
||||
using MediaBrowser.Common.Updates;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Authentication;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Devices;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
@@ -29,31 +28,39 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
public class ActivityLogEntryPoint : IServerEntryPoint
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IInstallationManager _installationManager;
|
||||
private readonly ISessionManager _sessionManager;
|
||||
private readonly ITaskManager _taskManager;
|
||||
private readonly IActivityManager _activityManager;
|
||||
private readonly ILocalizationManager _localization;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly ISubtitleManager _subManager;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
private readonly IDeviceManager _deviceManager;
|
||||
|
||||
public ActivityLogEntryPoint(ISessionManager sessionManager, IDeviceManager deviceManager, ITaskManager taskManager, IActivityManager activityManager, ILocalizationManager localization, IInstallationManager installationManager, ILibraryManager libraryManager, ISubtitleManager subManager, IUserManager userManager, IServerConfigurationManager config, IServerApplicationHost appHost)
|
||||
public ActivityLogEntryPoint(
|
||||
ILogger<ActivityLogEntryPoint> logger,
|
||||
ISessionManager sessionManager,
|
||||
IDeviceManager deviceManager,
|
||||
ITaskManager taskManager,
|
||||
IActivityManager activityManager,
|
||||
ILocalizationManager localization,
|
||||
IInstallationManager installationManager,
|
||||
ISubtitleManager subManager,
|
||||
IUserManager userManager,
|
||||
IServerApplicationHost appHost)
|
||||
{
|
||||
_logger = logger;
|
||||
_sessionManager = sessionManager;
|
||||
_deviceManager = deviceManager;
|
||||
_taskManager = taskManager;
|
||||
_activityManager = activityManager;
|
||||
_localization = localization;
|
||||
_installationManager = installationManager;
|
||||
_libraryManager = libraryManager;
|
||||
_subManager = subManager;
|
||||
_userManager = userManager;
|
||||
_config = config;
|
||||
_appHost = appHost;
|
||||
_deviceManager = deviceManager;
|
||||
}
|
||||
|
||||
public Task RunAsync()
|
||||
@@ -69,7 +76,6 @@ namespace Emby.Server.Implementations.Activity
|
||||
_sessionManager.AuthenticationFailed += OnAuthenticationFailed;
|
||||
_sessionManager.AuthenticationSucceeded += OnAuthenticationSucceeded;
|
||||
_sessionManager.SessionEnded += OnSessionEnded;
|
||||
|
||||
_sessionManager.PlaybackStart += OnPlaybackStart;
|
||||
_sessionManager.PlaybackStopped += OnPlaybackStopped;
|
||||
|
||||
@@ -83,8 +89,6 @@ namespace Emby.Server.Implementations.Activity
|
||||
|
||||
_deviceManager.CameraImageUploaded += OnCameraImageUploaded;
|
||||
|
||||
_appHost.ApplicationUpdated += OnApplicationUpdated;
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -92,7 +96,10 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("CameraImageUploadedFrom"), e.Argument.Device.Name),
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("CameraImageUploadedFrom"),
|
||||
e.Argument.Device.Name),
|
||||
Type = NotificationType.CameraImageUploaded.ToString()
|
||||
});
|
||||
}
|
||||
@@ -101,7 +108,10 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("UserLockedOutWithName"), e.Argument.Name),
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserLockedOutWithName"),
|
||||
e.Argument.Name),
|
||||
Type = NotificationType.UserLockedOut.ToString(),
|
||||
UserId = e.Argument.Id
|
||||
});
|
||||
@@ -111,9 +121,13 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("SubtitleDownloadFailureFromForItem"), e.Provider, Notifications.Notifications.GetItemName(e.Item)),
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("SubtitleDownloadFailureFromForItem"),
|
||||
e.Provider,
|
||||
Notifications.Notifications.GetItemName(e.Item)),
|
||||
Type = "SubtitleDownloadFailure",
|
||||
ItemId = e.Item.Id.ToString("N"),
|
||||
ItemId = e.Item.Id.ToString("N", CultureInfo.InvariantCulture),
|
||||
ShortOverview = e.Exception.Message
|
||||
});
|
||||
}
|
||||
@@ -124,7 +138,7 @@ namespace Emby.Server.Implementations.Activity
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
//_logger.LogWarning("PlaybackStopped reported with null media info.");
|
||||
_logger.LogWarning("PlaybackStopped reported with null media info.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -155,7 +169,7 @@ namespace Emby.Server.Implementations.Activity
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
//_logger.LogWarning("PlaybackStart reported with null media info.");
|
||||
_logger.LogWarning("PlaybackStart reported with null media info.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -174,7 +188,12 @@ namespace Emby.Server.Implementations.Activity
|
||||
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("UserStartedPlayingItemWithValues"), user.Name, GetItemName(item), e.DeviceName),
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserStartedPlayingItemWithValues"),
|
||||
user.Name,
|
||||
GetItemName(item),
|
||||
e.DeviceName),
|
||||
Type = GetPlaybackNotificationType(item.MediaType),
|
||||
UserId = user.Id
|
||||
});
|
||||
@@ -189,7 +208,7 @@ namespace Emby.Server.Implementations.Activity
|
||||
name = item.SeriesName + " - " + name;
|
||||
}
|
||||
|
||||
if (item.Artists != null && item.Artists.Length > 0)
|
||||
if (item.Artists != null && item.Artists.Count > 0)
|
||||
{
|
||||
name = item.Artists[0] + " - " + name;
|
||||
}
|
||||
@@ -203,6 +222,7 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
return NotificationType.AudioPlayback.ToString();
|
||||
}
|
||||
|
||||
if (string.Equals(mediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return NotificationType.VideoPlayback.ToString();
|
||||
@@ -217,6 +237,7 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
return NotificationType.AudioPlaybackStopped.ToString();
|
||||
}
|
||||
|
||||
if (string.Equals(mediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return NotificationType.VideoPlaybackStopped.ToString();
|
||||
@@ -232,21 +253,31 @@ namespace Emby.Server.Implementations.Activity
|
||||
|
||||
if (string.IsNullOrEmpty(session.UserName))
|
||||
{
|
||||
name = string.Format(_localization.GetLocalizedString("DeviceOfflineWithName"), session.DeviceName);
|
||||
name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("DeviceOfflineWithName"),
|
||||
session.DeviceName);
|
||||
|
||||
// Causing too much spam for now
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = string.Format(_localization.GetLocalizedString("UserOfflineFromDevice"), session.UserName, session.DeviceName);
|
||||
name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserOfflineFromDevice"),
|
||||
session.UserName,
|
||||
session.DeviceName);
|
||||
}
|
||||
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = name,
|
||||
Type = "SessionEnded",
|
||||
ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), session.RemoteEndPoint),
|
||||
ShortOverview = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("LabelIpAddressValue"),
|
||||
session.RemoteEndPoint),
|
||||
UserId = session.UserId
|
||||
});
|
||||
}
|
||||
@@ -257,9 +288,15 @@ namespace Emby.Server.Implementations.Activity
|
||||
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("AuthenticationSucceededWithUserName"), user.Name),
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("AuthenticationSucceededWithUserName"),
|
||||
user.Name),
|
||||
Type = "AuthenticationSucceeded",
|
||||
ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), e.Argument.SessionInfo.RemoteEndPoint),
|
||||
ShortOverview = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("LabelIpAddressValue"),
|
||||
e.Argument.SessionInfo.RemoteEndPoint),
|
||||
UserId = user.Id
|
||||
});
|
||||
}
|
||||
@@ -268,28 +305,27 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("FailedLoginAttemptWithUserName"), e.Argument.Username),
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("FailedLoginAttemptWithUserName"),
|
||||
e.Argument.Username),
|
||||
Type = "AuthenticationFailed",
|
||||
ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), e.Argument.RemoteEndPoint),
|
||||
ShortOverview = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("LabelIpAddressValue"),
|
||||
e.Argument.RemoteEndPoint),
|
||||
Severity = LogLevel.Error
|
||||
});
|
||||
}
|
||||
|
||||
private void OnApplicationUpdated(object sender, GenericEventArgs<PackageVersionInfo> e)
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("MessageApplicationUpdatedTo"), e.Argument.versionStr),
|
||||
Type = NotificationType.ApplicationUpdateInstalled.ToString(),
|
||||
Overview = e.Argument.description
|
||||
});
|
||||
}
|
||||
|
||||
private void OnUserPolicyUpdated(object sender, GenericEventArgs<User> e)
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("UserPolicyUpdatedWithName"), e.Argument.Name),
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserPolicyUpdatedWithName"),
|
||||
e.Argument.Name),
|
||||
Type = "UserPolicyUpdated",
|
||||
UserId = e.Argument.Id
|
||||
});
|
||||
@@ -299,7 +335,10 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("UserDeletedWithName"), e.Argument.Name),
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserDeletedWithName"),
|
||||
e.Argument.Name),
|
||||
Type = "UserDeleted"
|
||||
});
|
||||
}
|
||||
@@ -308,7 +347,10 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("UserPasswordChangedWithName"), e.Argument.Name),
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserPasswordChangedWithName"),
|
||||
e.Argument.Name),
|
||||
Type = "UserPasswordChanged",
|
||||
UserId = e.Argument.Id
|
||||
});
|
||||
@@ -318,7 +360,10 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("UserCreatedWithName"), e.Argument.Name),
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserCreatedWithName"),
|
||||
e.Argument.Name),
|
||||
Type = "UserCreated",
|
||||
UserId = e.Argument.Id
|
||||
});
|
||||
@@ -331,32 +376,48 @@ namespace Emby.Server.Implementations.Activity
|
||||
|
||||
if (string.IsNullOrEmpty(session.UserName))
|
||||
{
|
||||
name = string.Format(_localization.GetLocalizedString("DeviceOnlineWithName"), session.DeviceName);
|
||||
name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("DeviceOnlineWithName"),
|
||||
session.DeviceName);
|
||||
|
||||
// Causing too much spam for now
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = string.Format(_localization.GetLocalizedString("UserOnlineFromDevice"), session.UserName, session.DeviceName);
|
||||
name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserOnlineFromDevice"),
|
||||
session.UserName,
|
||||
session.DeviceName);
|
||||
}
|
||||
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = name,
|
||||
Type = "SessionStarted",
|
||||
ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), session.RemoteEndPoint),
|
||||
ShortOverview = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("LabelIpAddressValue"),
|
||||
session.RemoteEndPoint),
|
||||
UserId = session.UserId
|
||||
});
|
||||
}
|
||||
|
||||
private void OnPluginUpdated(object sender, GenericEventArgs<Tuple<IPlugin, PackageVersionInfo>> e)
|
||||
private void OnPluginUpdated(object sender, GenericEventArgs<(IPlugin, PackageVersionInfo)> e)
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("PluginUpdatedWithName"), e.Argument.Item1.Name),
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("PluginUpdatedWithName"),
|
||||
e.Argument.Item1.Name),
|
||||
Type = NotificationType.PluginUpdateInstalled.ToString(),
|
||||
ShortOverview = string.Format(_localization.GetLocalizedString("VersionNumber"), e.Argument.Item2.versionStr),
|
||||
ShortOverview = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("VersionNumber"),
|
||||
e.Argument.Item2.versionStr),
|
||||
Overview = e.Argument.Item2.description
|
||||
});
|
||||
}
|
||||
@@ -365,7 +426,10 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("PluginUninstalledWithName"), e.Argument.Name),
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("PluginUninstalledWithName"),
|
||||
e.Argument.Name),
|
||||
Type = NotificationType.PluginUninstalled.ToString()
|
||||
});
|
||||
}
|
||||
@@ -374,9 +438,15 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("PluginInstalledWithName"), e.Argument.name),
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("PluginInstalledWithName"),
|
||||
e.Argument.name),
|
||||
Type = NotificationType.PluginInstalled.ToString(),
|
||||
ShortOverview = string.Format(_localization.GetLocalizedString("VersionNumber"), e.Argument.versionStr)
|
||||
ShortOverview = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("VersionNumber"),
|
||||
e.Argument.versionStr)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -386,9 +456,15 @@ namespace Emby.Server.Implementations.Activity
|
||||
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("NameInstallFailed"), installationInfo.Name),
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("NameInstallFailed"),
|
||||
installationInfo.Name),
|
||||
Type = NotificationType.InstallationFailed.ToString(),
|
||||
ShortOverview = string.Format(_localization.GetLocalizedString("VersionNumber"), installationInfo.Version),
|
||||
ShortOverview = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("VersionNumber"),
|
||||
installationInfo.Version),
|
||||
Overview = e.Exception.Message
|
||||
});
|
||||
}
|
||||
@@ -405,7 +481,10 @@ namespace Emby.Server.Implementations.Activity
|
||||
}
|
||||
|
||||
var time = result.EndTimeUtc - result.StartTimeUtc;
|
||||
var runningTime = string.Format(_localization.GetLocalizedString("LabelRunningTimeValue"), ToUserFriendlyString(time));
|
||||
var runningTime = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("LabelRunningTimeValue"),
|
||||
ToUserFriendlyString(time));
|
||||
|
||||
if (result.Status == TaskCompletionStatus.Failed)
|
||||
{
|
||||
@@ -415,6 +494,7 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
vals.Add(e.Result.ErrorMessage);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(e.Result.LongErrorMessage))
|
||||
{
|
||||
vals.Add(e.Result.LongErrorMessage);
|
||||
@@ -422,9 +502,12 @@ namespace Emby.Server.Implementations.Activity
|
||||
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("ScheduledTaskFailedWithName"), task.Name),
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("ScheduledTaskFailedWithName"),
|
||||
task.Name),
|
||||
Type = NotificationType.TaskFailed.ToString(),
|
||||
Overview = string.Join(Environment.NewLine, vals.ToArray()),
|
||||
Overview = string.Join(Environment.NewLine, vals),
|
||||
ShortOverview = runningTime,
|
||||
Severity = LogLevel.Error
|
||||
});
|
||||
@@ -460,8 +543,6 @@ namespace Emby.Server.Implementations.Activity
|
||||
_userManager.UserLockedOut -= OnUserLockedOut;
|
||||
|
||||
_deviceManager.CameraImageUploaded -= OnCameraImageUploaded;
|
||||
|
||||
_appHost.ApplicationUpdated -= OnApplicationUpdated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -503,6 +584,7 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
values.Add(CreateValueString(span.Hours, "hour"));
|
||||
}
|
||||
|
||||
// Number of minutes
|
||||
if (span.Minutes >= 1)
|
||||
{
|
||||
@@ -526,6 +608,7 @@ namespace Emby.Server.Implementations.Activity
|
||||
|
||||
builder.Append(values[i]);
|
||||
}
|
||||
|
||||
// Return result
|
||||
return builder.ToString();
|
||||
}
|
||||
@@ -537,8 +620,11 @@ namespace Emby.Server.Implementations.Activity
|
||||
/// <param name="description">The name of this item (singular form)</param>
|
||||
private static string CreateValueString(int value, string description)
|
||||
{
|
||||
return string.Format("{0:#,##0} {1}",
|
||||
value, value == 1 ? description : string.Format("{0}s", description));
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0:#,##0} {1}",
|
||||
value,
|
||||
value == 1 ? description : string.Format(CultureInfo.InvariantCulture, "{0}s", description));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
public class ActivityRepository : BaseSqliteRepository, IActivityRepository
|
||||
{
|
||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||
protected IFileSystem FileSystem { get; private set; }
|
||||
private static readonly CultureInfo _usCulture = CultureInfo.ReadOnly(new CultureInfo("en-US"));
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public ActivityRepository(ILoggerFactory loggerFactory, IServerApplicationPaths appPaths, IFileSystem fileSystem)
|
||||
: base(loggerFactory.CreateLogger(nameof(ActivityRepository)))
|
||||
{
|
||||
DbFilePath = Path.Combine(appPaths.DataPath, "activitylog.db");
|
||||
FileSystem = fileSystem;
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
@@ -35,7 +35,7 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
Logger.LogError(ex, "Error loading database file. Will reset and retry.");
|
||||
|
||||
FileSystem.DeleteFile(DbFilePath);
|
||||
_fileSystem.DeleteFile(DbFilePath);
|
||||
|
||||
InitializeInternal();
|
||||
}
|
||||
@@ -43,10 +43,8 @@ namespace Emby.Server.Implementations.Activity
|
||||
|
||||
private void InitializeInternal()
|
||||
{
|
||||
using (var connection = CreateConnection())
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
RunDefaultInitialization(connection);
|
||||
|
||||
connection.RunQueries(new[]
|
||||
{
|
||||
"create table if not exists ActivityLog (Id INTEGER PRIMARY KEY, Name TEXT NOT NULL, Overview TEXT, ShortOverview TEXT, Type TEXT NOT NULL, ItemId TEXT, UserId TEXT, DateCreated DATETIME NOT NULL, LogSeverity TEXT NOT NULL)",
|
||||
@@ -85,8 +83,7 @@ namespace Emby.Server.Implementations.Activity
|
||||
throw new ArgumentNullException(nameof(entry));
|
||||
}
|
||||
|
||||
using (WriteLock.Write())
|
||||
using (var connection = CreateConnection())
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
connection.RunInTransaction(db =>
|
||||
{
|
||||
@@ -105,7 +102,7 @@ namespace Emby.Server.Implementations.Activity
|
||||
}
|
||||
else
|
||||
{
|
||||
statement.TryBind("@UserId", entry.UserId.ToString("N"));
|
||||
statement.TryBind("@UserId", entry.UserId.ToString("N", CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
statement.TryBind("@DateCreated", entry.Date.ToDateTimeParamValue());
|
||||
@@ -124,8 +121,7 @@ namespace Emby.Server.Implementations.Activity
|
||||
throw new ArgumentNullException(nameof(entry));
|
||||
}
|
||||
|
||||
using (WriteLock.Write())
|
||||
using (var connection = CreateConnection())
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
connection.RunInTransaction(db =>
|
||||
{
|
||||
@@ -145,7 +141,7 @@ namespace Emby.Server.Implementations.Activity
|
||||
}
|
||||
else
|
||||
{
|
||||
statement.TryBind("@UserId", entry.UserId.ToString("N"));
|
||||
statement.TryBind("@UserId", entry.UserId.ToString("N", CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
statement.TryBind("@DateCreated", entry.Date.ToDateTimeParamValue());
|
||||
@@ -159,95 +155,100 @@ namespace Emby.Server.Implementations.Activity
|
||||
|
||||
public QueryResult<ActivityLogEntry> GetActivityLogEntries(DateTime? minDate, bool? hasUserId, int? startIndex, int? limit)
|
||||
{
|
||||
using (WriteLock.Read())
|
||||
using (var connection = CreateConnection(true))
|
||||
var commandText = BaseActivitySelectText;
|
||||
var whereClauses = new List<string>();
|
||||
|
||||
if (minDate.HasValue)
|
||||
{
|
||||
var commandText = BaseActivitySelectText;
|
||||
var whereClauses = new List<string>();
|
||||
|
||||
if (minDate.HasValue)
|
||||
whereClauses.Add("DateCreated>=@DateCreated");
|
||||
}
|
||||
if (hasUserId.HasValue)
|
||||
{
|
||||
if (hasUserId.Value)
|
||||
{
|
||||
whereClauses.Add("DateCreated>=@DateCreated");
|
||||
whereClauses.Add("UserId not null");
|
||||
}
|
||||
if (hasUserId.HasValue)
|
||||
else
|
||||
{
|
||||
if (hasUserId.Value)
|
||||
{
|
||||
whereClauses.Add("UserId not null");
|
||||
}
|
||||
else
|
||||
{
|
||||
whereClauses.Add("UserId is null");
|
||||
}
|
||||
whereClauses.Add("UserId is null");
|
||||
}
|
||||
}
|
||||
|
||||
var whereTextWithoutPaging = whereClauses.Count == 0 ?
|
||||
string.Empty :
|
||||
" where " + string.Join(" AND ", whereClauses.ToArray());
|
||||
var whereTextWithoutPaging = whereClauses.Count == 0 ?
|
||||
string.Empty :
|
||||
" where " + string.Join(" AND ", whereClauses.ToArray());
|
||||
|
||||
if (startIndex.HasValue && startIndex.Value > 0)
|
||||
{
|
||||
var pagingWhereText = whereClauses.Count == 0 ?
|
||||
string.Empty :
|
||||
" where " + string.Join(" AND ", whereClauses.ToArray());
|
||||
|
||||
whereClauses.Add(string.Format("Id NOT IN (SELECT Id FROM ActivityLog {0} ORDER BY DateCreated DESC LIMIT {1})",
|
||||
pagingWhereText,
|
||||
startIndex.Value.ToString(_usCulture)));
|
||||
}
|
||||
|
||||
var whereText = whereClauses.Count == 0 ?
|
||||
if (startIndex.HasValue && startIndex.Value > 0)
|
||||
{
|
||||
var pagingWhereText = whereClauses.Count == 0 ?
|
||||
string.Empty :
|
||||
" where " + string.Join(" AND ", whereClauses.ToArray());
|
||||
|
||||
commandText += whereText;
|
||||
|
||||
commandText += " ORDER BY DateCreated DESC";
|
||||
|
||||
if (limit.HasValue)
|
||||
{
|
||||
commandText += " LIMIT " + limit.Value.ToString(_usCulture);
|
||||
}
|
||||
|
||||
var statementTexts = new List<string>();
|
||||
statementTexts.Add(commandText);
|
||||
statementTexts.Add("select count (Id) from ActivityLog" + whereTextWithoutPaging);
|
||||
|
||||
return connection.RunInTransaction(db =>
|
||||
{
|
||||
var list = new List<ActivityLogEntry>();
|
||||
var result = new QueryResult<ActivityLogEntry>();
|
||||
|
||||
var statements = PrepareAllSafe(db, statementTexts).ToList();
|
||||
|
||||
using (var statement = statements[0])
|
||||
{
|
||||
if (minDate.HasValue)
|
||||
{
|
||||
statement.TryBind("@DateCreated", minDate.Value.ToDateTimeParamValue());
|
||||
}
|
||||
|
||||
foreach (var row in statement.ExecuteQuery())
|
||||
{
|
||||
list.Add(GetEntry(row));
|
||||
}
|
||||
}
|
||||
|
||||
using (var statement = statements[1])
|
||||
{
|
||||
if (minDate.HasValue)
|
||||
{
|
||||
statement.TryBind("@DateCreated", minDate.Value.ToDateTimeParamValue());
|
||||
}
|
||||
|
||||
result.TotalRecordCount = statement.ExecuteQuery().SelectScalarInt().First();
|
||||
}
|
||||
|
||||
result.Items = list.ToArray();
|
||||
return result;
|
||||
|
||||
}, ReadTransactionMode);
|
||||
whereClauses.Add(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"Id NOT IN (SELECT Id FROM ActivityLog {0} ORDER BY DateCreated DESC LIMIT {1})",
|
||||
pagingWhereText,
|
||||
startIndex.Value));
|
||||
}
|
||||
|
||||
var whereText = whereClauses.Count == 0 ?
|
||||
string.Empty :
|
||||
" where " + string.Join(" AND ", whereClauses.ToArray());
|
||||
|
||||
commandText += whereText;
|
||||
|
||||
commandText += " ORDER BY DateCreated DESC";
|
||||
|
||||
if (limit.HasValue)
|
||||
{
|
||||
commandText += " LIMIT " + limit.Value.ToString(_usCulture);
|
||||
}
|
||||
|
||||
var statementTexts = new[]
|
||||
{
|
||||
commandText,
|
||||
"select count (Id) from ActivityLog" + whereTextWithoutPaging
|
||||
};
|
||||
|
||||
var list = new List<ActivityLogEntry>();
|
||||
var result = new QueryResult<ActivityLogEntry>();
|
||||
|
||||
using (var connection = GetConnection(true))
|
||||
{
|
||||
connection.RunInTransaction(
|
||||
db =>
|
||||
{
|
||||
var statements = PrepareAll(db, statementTexts).ToList();
|
||||
|
||||
using (var statement = statements[0])
|
||||
{
|
||||
if (minDate.HasValue)
|
||||
{
|
||||
statement.TryBind("@DateCreated", minDate.Value.ToDateTimeParamValue());
|
||||
}
|
||||
|
||||
foreach (var row in statement.ExecuteQuery())
|
||||
{
|
||||
list.Add(GetEntry(row));
|
||||
}
|
||||
}
|
||||
|
||||
using (var statement = statements[1])
|
||||
{
|
||||
if (minDate.HasValue)
|
||||
{
|
||||
statement.TryBind("@DateCreated", minDate.Value.ToDateTimeParamValue());
|
||||
}
|
||||
|
||||
result.TotalRecordCount = statement.ExecuteQuery().SelectScalarInt().First();
|
||||
}
|
||||
},
|
||||
ReadTransactionMode);
|
||||
}
|
||||
|
||||
result.Items = list;
|
||||
return result;
|
||||
}
|
||||
|
||||
private static ActivityLogEntry GetEntry(IReadOnlyList<IResultSetValue> reader)
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace Emby.Server.Implementations.AppBase
|
||||
/// </summary>
|
||||
public abstract class BaseApplicationPaths : IApplicationPaths
|
||||
{
|
||||
private string _dataPath;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class.
|
||||
/// </summary>
|
||||
@@ -30,27 +32,27 @@ namespace Emby.Server.Implementations.AppBase
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the program data folder
|
||||
/// Gets the path to the program data folder.
|
||||
/// </summary>
|
||||
/// <value>The program data path.</value>
|
||||
public string ProgramDataPath { get; private set; }
|
||||
public string ProgramDataPath { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the web UI resources folder
|
||||
/// Gets the path to the web UI resources folder.
|
||||
/// </summary>
|
||||
/// <value>The web UI resources path.</value>
|
||||
public string WebPath { get; set; }
|
||||
public string WebPath { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the system folder
|
||||
/// Gets the path to the system folder.
|
||||
/// </summary>
|
||||
/// <value>The path to the system folder.</value>
|
||||
public string ProgramSystemPath { get; } = AppContext.BaseDirectory;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the folder path to the data directory
|
||||
/// Gets the folder path to the data directory.
|
||||
/// </summary>
|
||||
/// <value>The data directory.</value>
|
||||
private string _dataPath;
|
||||
public string DataPath
|
||||
{
|
||||
get => _dataPath;
|
||||
@@ -58,8 +60,9 @@ namespace Emby.Server.Implementations.AppBase
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the magic strings used for virtual path manipulation.
|
||||
/// Gets the magic string used for virtual path manipulation.
|
||||
/// </summary>
|
||||
/// <value>The magic string used for virtual path manipulation.</value>
|
||||
public string VirtualDataPath { get; } = "%AppDataPath%";
|
||||
|
||||
/// <summary>
|
||||
@@ -69,43 +72,43 @@ namespace Emby.Server.Implementations.AppBase
|
||||
public string ImageCachePath => Path.Combine(CachePath, "images");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the plugin directory
|
||||
/// Gets the path to the plugin directory.
|
||||
/// </summary>
|
||||
/// <value>The plugins path.</value>
|
||||
public string PluginsPath => Path.Combine(ProgramDataPath, "plugins");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the plugin configurations directory
|
||||
/// Gets the path to the plugin configurations directory.
|
||||
/// </summary>
|
||||
/// <value>The plugin configurations path.</value>
|
||||
public string PluginConfigurationsPath => Path.Combine(PluginsPath, "configurations");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the log directory
|
||||
/// Gets the path to the log directory.
|
||||
/// </summary>
|
||||
/// <value>The log directory path.</value>
|
||||
public string LogDirectoryPath { get; private set; }
|
||||
public string LogDirectoryPath { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the application configuration root directory
|
||||
/// Gets the path to the application configuration root directory.
|
||||
/// </summary>
|
||||
/// <value>The configuration directory path.</value>
|
||||
public string ConfigurationDirectoryPath { get; private set; }
|
||||
public string ConfigurationDirectoryPath { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the system configuration file
|
||||
/// Gets the path to the system configuration file.
|
||||
/// </summary>
|
||||
/// <value>The system configuration file path.</value>
|
||||
public string SystemConfigurationFilePath => Path.Combine(ConfigurationDirectoryPath, "system.xml");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the folder path to the cache directory
|
||||
/// Gets or sets the folder path to the cache directory.
|
||||
/// </summary>
|
||||
/// <value>The cache directory.</value>
|
||||
public string CachePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the folder path to the temp directory within the cache folder
|
||||
/// Gets the folder path to the temp directory within the cache folder.
|
||||
/// </summary>
|
||||
/// <value>The temp directory.</value>
|
||||
public string TempDirectory => Path.Combine(CachePath, "temp");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@@ -19,11 +20,44 @@ namespace Emby.Server.Implementations.AppBase
|
||||
/// </summary>
|
||||
public abstract class BaseConfigurationManager : IConfigurationManager
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
private readonly ConcurrentDictionary<string, object> _configurations = new ConcurrentDictionary<string, object>();
|
||||
|
||||
private ConfigurationStore[] _configurationStores = Array.Empty<ConfigurationStore>();
|
||||
private IConfigurationFactory[] _configurationFactories = Array.Empty<IConfigurationFactory>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the configuration.
|
||||
/// The _configuration loaded.
|
||||
/// </summary>
|
||||
/// <value>The type of the configuration.</value>
|
||||
protected abstract Type ConfigurationType { get; }
|
||||
private bool _configurationLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// The _configuration sync lock.
|
||||
/// </summary>
|
||||
private object _configurationSyncLock = new object();
|
||||
|
||||
/// <summary>
|
||||
/// The _configuration.
|
||||
/// </summary>
|
||||
private BaseApplicationConfiguration _configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseConfigurationManager" /> class.
|
||||
/// </summary>
|
||||
/// <param name="applicationPaths">The application paths.</param>
|
||||
/// <param name="loggerFactory">The logger factory.</param>
|
||||
/// <param name="xmlSerializer">The XML serializer.</param>
|
||||
/// <param name="fileSystem">The file system</param>
|
||||
protected BaseConfigurationManager(IApplicationPaths applicationPaths, ILoggerFactory loggerFactory, IXmlSerializer xmlSerializer, IFileSystem fileSystem)
|
||||
{
|
||||
CommonApplicationPaths = applicationPaths;
|
||||
XmlSerializer = xmlSerializer;
|
||||
_fileSystem = fileSystem;
|
||||
Logger = loggerFactory.CreateLogger(GetType().Name);
|
||||
|
||||
UpdateCachePath();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [configuration updated].
|
||||
@@ -40,6 +74,12 @@ namespace Emby.Server.Implementations.AppBase
|
||||
/// </summary>
|
||||
public event EventHandler<ConfigurationUpdateEventArgs> NamedConfigurationUpdated;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the configuration.
|
||||
/// </summary>
|
||||
/// <value>The type of the configuration.</value>
|
||||
protected abstract Type ConfigurationType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the logger.
|
||||
/// </summary>
|
||||
@@ -56,20 +96,7 @@ namespace Emby.Server.Implementations.AppBase
|
||||
/// </summary>
|
||||
/// <value>The application paths.</value>
|
||||
public IApplicationPaths CommonApplicationPaths { get; private set; }
|
||||
public readonly IFileSystem FileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// The _configuration loaded
|
||||
/// </summary>
|
||||
private bool _configurationLoaded;
|
||||
/// <summary>
|
||||
/// The _configuration sync lock
|
||||
/// </summary>
|
||||
private object _configurationSyncLock = new object();
|
||||
/// <summary>
|
||||
/// The _configuration
|
||||
/// </summary>
|
||||
private BaseApplicationConfiguration _configuration;
|
||||
/// <summary>
|
||||
/// Gets the system configuration
|
||||
/// </summary>
|
||||
@@ -90,26 +117,6 @@ namespace Emby.Server.Implementations.AppBase
|
||||
}
|
||||
}
|
||||
|
||||
private ConfigurationStore[] _configurationStores = { };
|
||||
private IConfigurationFactory[] _configurationFactories = { };
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseConfigurationManager" /> class.
|
||||
/// </summary>
|
||||
/// <param name="applicationPaths">The application paths.</param>
|
||||
/// <param name="loggerFactory">The logger factory.</param>
|
||||
/// <param name="xmlSerializer">The XML serializer.</param>
|
||||
/// <param name="fileSystem">The file system</param>
|
||||
protected BaseConfigurationManager(IApplicationPaths applicationPaths, ILoggerFactory loggerFactory, IXmlSerializer xmlSerializer, IFileSystem fileSystem)
|
||||
{
|
||||
CommonApplicationPaths = applicationPaths;
|
||||
XmlSerializer = xmlSerializer;
|
||||
FileSystem = fileSystem;
|
||||
Logger = loggerFactory.CreateLogger(GetType().Name);
|
||||
|
||||
UpdateCachePath();
|
||||
}
|
||||
|
||||
public virtual void AddParts(IEnumerable<IConfigurationFactory> factories)
|
||||
{
|
||||
_configurationFactories = factories.ToArray();
|
||||
@@ -171,6 +178,7 @@ namespace Emby.Server.Implementations.AppBase
|
||||
private void UpdateCachePath()
|
||||
{
|
||||
string cachePath;
|
||||
|
||||
// If the configuration file has no entry (i.e. not set in UI)
|
||||
if (string.IsNullOrWhiteSpace(CommonConfiguration.CachePath))
|
||||
{
|
||||
@@ -207,12 +215,16 @@ namespace Emby.Server.Implementations.AppBase
|
||||
var newPath = newConfig.CachePath;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(newPath)
|
||||
&& !string.Equals(CommonConfiguration.CachePath ?? string.Empty, newPath))
|
||||
&& !string.Equals(CommonConfiguration.CachePath ?? string.Empty, newPath, StringComparison.Ordinal))
|
||||
{
|
||||
// Validate
|
||||
if (!Directory.Exists(newPath))
|
||||
{
|
||||
throw new FileNotFoundException(string.Format("{0} does not exist.", newPath));
|
||||
throw new FileNotFoundException(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} does not exist.",
|
||||
newPath));
|
||||
}
|
||||
|
||||
EnsureWriteAccess(newPath);
|
||||
@@ -223,11 +235,9 @@ namespace Emby.Server.Implementations.AppBase
|
||||
{
|
||||
var file = Path.Combine(path, Guid.NewGuid().ToString());
|
||||
File.WriteAllText(file, string.Empty);
|
||||
FileSystem.DeleteFile(file);
|
||||
_fileSystem.DeleteFile(file);
|
||||
}
|
||||
|
||||
private readonly ConcurrentDictionary<string, object> _configurations = new ConcurrentDictionary<string, object>();
|
||||
|
||||
private string GetConfigurationFile(string key)
|
||||
{
|
||||
return Path.Combine(CommonApplicationPaths.ConfigurationDirectoryPath, key.ToLowerInvariant() + ".xml");
|
||||
|
||||
@@ -6,6 +6,8 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
@@ -106,9 +108,9 @@ using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ServiceStack;
|
||||
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
|
||||
|
||||
@@ -119,6 +121,10 @@ namespace Emby.Server.Implementations
|
||||
/// </summary>
|
||||
public abstract class ApplicationHost : IServerApplicationHost, IDisposable
|
||||
{
|
||||
private SqliteUserRepository _userRepository;
|
||||
|
||||
private SqliteDisplayPreferencesRepository _displayPreferencesRepository;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this instance can self restart.
|
||||
/// </summary>
|
||||
@@ -154,11 +160,6 @@ namespace Emby.Server.Implementations
|
||||
/// </summary>
|
||||
public event EventHandler HasPendingRestartChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [application updated].
|
||||
/// </summary>
|
||||
public event EventHandler<GenericEventArgs<PackageVersionInfo>> ApplicationUpdated;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this instance has changes that require the entire application to restart.
|
||||
/// </summary>
|
||||
@@ -201,10 +202,10 @@ namespace Emby.Server.Implementations
|
||||
/// Gets or sets all concrete types.
|
||||
/// </summary>
|
||||
/// <value>All concrete types.</value>
|
||||
public Type[] AllConcreteTypes { get; protected set; }
|
||||
private Type[] _allConcreteTypes;
|
||||
|
||||
/// <summary>
|
||||
/// The disposable parts
|
||||
/// The disposable parts.
|
||||
/// </summary>
|
||||
private readonly List<IDisposable> _disposableParts = new List<IDisposable>();
|
||||
|
||||
@@ -236,11 +237,6 @@ namespace Emby.Server.Implementations
|
||||
/// <value>The server configuration manager.</value>
|
||||
public IServerConfigurationManager ServerConfigurationManager => (IServerConfigurationManager)ConfigurationManager;
|
||||
|
||||
protected virtual IResourceFileManager CreateResourceFileManager()
|
||||
{
|
||||
return new ResourceFileManager(HttpResultFactory, LoggerFactory, FileSystemManager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user manager.
|
||||
/// </summary>
|
||||
@@ -299,8 +295,6 @@ namespace Emby.Server.Implementations
|
||||
/// <value>The user data repository.</value>
|
||||
private IUserDataManager UserDataManager { get; set; }
|
||||
|
||||
private IUserRepository UserRepository { get; set; }
|
||||
|
||||
internal SqliteItemRepository ItemRepository { get; set; }
|
||||
|
||||
private INotificationManager NotificationManager { get; set; }
|
||||
@@ -321,8 +315,6 @@ namespace Emby.Server.Implementations
|
||||
|
||||
private IMediaSourceManager MediaSourceManager { get; set; }
|
||||
|
||||
private IPlaylistManager PlaylistManager { get; set; }
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
/// <summary>
|
||||
@@ -331,14 +323,6 @@ namespace Emby.Server.Implementations
|
||||
/// <value>The installation manager.</value>
|
||||
protected IInstallationManager InstallationManager { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the zip client.
|
||||
/// </summary>
|
||||
/// <value>The zip client.</value>
|
||||
protected IZipClient ZipClient { get; private set; }
|
||||
|
||||
protected IHttpResultFactory HttpResultFactory { get; private set; }
|
||||
|
||||
protected IAuthService AuthService { get; private set; }
|
||||
|
||||
public IStartupOptions StartupOptions { get; }
|
||||
@@ -394,7 +378,7 @@ namespace Emby.Server.Implementations
|
||||
|
||||
fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
|
||||
|
||||
NetworkManager.NetworkChanged += NetworkManager_NetworkChanged;
|
||||
NetworkManager.NetworkChanged += OnNetworkChanged;
|
||||
}
|
||||
|
||||
public string ExpandVirtualPath(string path)
|
||||
@@ -418,7 +402,7 @@ namespace Emby.Server.Implementations
|
||||
return ServerConfigurationManager.Configuration.LocalNetworkSubnets;
|
||||
}
|
||||
|
||||
private void NetworkManager_NetworkChanged(object sender, EventArgs e)
|
||||
private void OnNetworkChanged(object sender, EventArgs e)
|
||||
{
|
||||
_validAddressResults.Clear();
|
||||
}
|
||||
@@ -426,10 +410,10 @@ namespace Emby.Server.Implementations
|
||||
public string ApplicationVersion { get; } = typeof(ApplicationHost).Assembly.GetName().Version.ToString(3);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current application user agent
|
||||
/// Gets the current application user agent.
|
||||
/// </summary>
|
||||
/// <value>The application user agent.</value>
|
||||
public string ApplicationUserAgent => Name.Replace(' ','-') + "/" + ApplicationVersion;
|
||||
public string ApplicationUserAgent => Name.Replace(' ', '-') + "/" + ApplicationVersion;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the email address for use within a comment section of a user agent field.
|
||||
@@ -437,14 +421,11 @@ namespace Emby.Server.Implementations
|
||||
/// </summary>
|
||||
public string ApplicationUserAgentAddress { get; } = "team@jellyfin.org";
|
||||
|
||||
private string _productName;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current application name
|
||||
/// Gets the current application name.
|
||||
/// </summary>
|
||||
/// <value>The application name.</value>
|
||||
public string ApplicationProductName
|
||||
=> _productName ?? (_productName = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location).ProductName);
|
||||
public string ApplicationProductName { get; } = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location).ProductName;
|
||||
|
||||
private DeviceId _deviceId;
|
||||
|
||||
@@ -478,8 +459,8 @@ namespace Emby.Server.Implementations
|
||||
/// <summary>
|
||||
/// Creates an instance of type and resolves all constructor dependencies
|
||||
/// </summary>
|
||||
/// /// <typeparam name="T">The type</typeparam>
|
||||
/// <returns>T</returns>
|
||||
/// /// <typeparam name="T">The type.</typeparam>
|
||||
/// <returns>T.</returns>
|
||||
public T CreateInstance<T>()
|
||||
=> ActivatorUtilities.CreateInstance<T>(_serviceProvider);
|
||||
|
||||
@@ -518,16 +499,11 @@ namespace Emby.Server.Implementations
|
||||
{
|
||||
var currentType = typeof(T);
|
||||
|
||||
return AllConcreteTypes.Where(i => currentType.IsAssignableFrom(i));
|
||||
return _allConcreteTypes.Where(i => currentType.IsAssignableFrom(i));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the exports.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type</typeparam>
|
||||
/// <param name="manageLifetime">if set to <c>true</c> [manage lifetime].</param>
|
||||
/// <returns>IEnumerable{``0}.</returns>
|
||||
public IEnumerable<T> GetExports<T>(bool manageLifetime = true)
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<T> GetExports<T>(bool manageLifetime = true)
|
||||
{
|
||||
var parts = GetExportTypes<T>()
|
||||
.Select(CreateInstanceSafe)
|
||||
@@ -549,6 +525,7 @@ namespace Emby.Server.Implementations
|
||||
/// <summary>
|
||||
/// Runs the startup tasks.
|
||||
/// </summary>
|
||||
/// <returns><see cref="Task" />.</returns>
|
||||
public async Task RunStartupTasksAsync()
|
||||
{
|
||||
Logger.LogInformation("Running startup tasks");
|
||||
@@ -561,7 +538,7 @@ namespace Emby.Server.Implementations
|
||||
|
||||
Logger.LogInformation("ServerId: {0}", SystemId);
|
||||
|
||||
var entryPoints = GetExports<IServerEntryPoint>().ToList();
|
||||
var entryPoints = GetExports<IServerEntryPoint>();
|
||||
|
||||
var stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
@@ -612,16 +589,19 @@ namespace Emby.Server.Implementations
|
||||
|
||||
foreach (var plugin in Plugins)
|
||||
{
|
||||
pluginBuilder.AppendLine(string.Format("{0} {1}", plugin.Name, plugin.Version));
|
||||
pluginBuilder.AppendLine(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1}",
|
||||
plugin.Name,
|
||||
plugin.Version));
|
||||
}
|
||||
|
||||
Logger.LogInformation("Plugins: {plugins}", pluginBuilder.ToString());
|
||||
Logger.LogInformation("Plugins: {Plugins}", pluginBuilder.ToString());
|
||||
}
|
||||
|
||||
DiscoverTypes();
|
||||
|
||||
SetHttpLimit();
|
||||
|
||||
await RegisterResources(serviceCollection).ConfigureAwait(false);
|
||||
|
||||
FindParts();
|
||||
@@ -635,11 +615,34 @@ namespace Emby.Server.Implementations
|
||||
var host = new WebHostBuilder()
|
||||
.UseKestrel(options =>
|
||||
{
|
||||
options.ListenAnyIP(HttpPort);
|
||||
|
||||
if (EnableHttps && Certificate != null)
|
||||
var addresses = ServerConfigurationManager
|
||||
.Configuration
|
||||
.LocalNetworkAddresses
|
||||
.Select(NormalizeConfiguredLocalAddress)
|
||||
.Where(i => i != null)
|
||||
.ToList();
|
||||
if (addresses.Any())
|
||||
{
|
||||
options.ListenAnyIP(HttpsPort, listenOptions => { listenOptions.UseHttps(Certificate); });
|
||||
foreach (var address in addresses)
|
||||
{
|
||||
Logger.LogInformation("Kestrel listening on {ipaddr}", address);
|
||||
options.Listen(address, HttpPort);
|
||||
|
||||
if (EnableHttps && Certificate != null)
|
||||
{
|
||||
options.Listen(address, HttpsPort, listenOptions => listenOptions.UseHttps(Certificate));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogInformation("Kestrel listening on all interfaces");
|
||||
options.ListenAnyIP(HttpPort);
|
||||
|
||||
if (EnableHttps && Certificate != null)
|
||||
{
|
||||
options.ListenAnyIP(HttpsPort, listenOptions => listenOptions.UseHttps(Certificate));
|
||||
}
|
||||
}
|
||||
})
|
||||
.UseContentRoot(contentRoot)
|
||||
@@ -653,13 +656,22 @@ namespace Emby.Server.Implementations
|
||||
app.UseWebSockets();
|
||||
|
||||
app.UseResponseCompression();
|
||||
|
||||
// TODO app.UseMiddleware<WebSocketMiddleware>();
|
||||
app.Use(ExecuteWebsocketHandlerAsync);
|
||||
app.Use(ExecuteHttpHandlerAsync);
|
||||
})
|
||||
.Build();
|
||||
|
||||
await host.StartAsync().ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await host.StartAsync().ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Logger.LogError("Kestrel failed to start! This is most likely due to an invalid address or port bind - correct your bind configuration in system.xml and try again.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ExecuteWebsocketHandlerAsync(HttpContext context, Func<Task> next)
|
||||
@@ -686,16 +698,9 @@ namespace Emby.Server.Implementations
|
||||
var localPath = context.Request.Path.ToString();
|
||||
|
||||
var req = new WebSocketSharpRequest(request, response, request.Path, Logger);
|
||||
await HttpServer.RequestHandler(req, request.GetDisplayUrl(), request.Host.ToString(), localPath, CancellationToken.None).ConfigureAwait(false);
|
||||
await HttpServer.RequestHandler(req, request.GetDisplayUrl(), request.Host.ToString(), localPath, context.RequestAborted).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
protected virtual IHttpClient CreateHttpClient()
|
||||
{
|
||||
return new HttpClientManager.HttpClientManager(ApplicationPaths, LoggerFactory, FileSystemManager, () => ApplicationUserAgent);
|
||||
}
|
||||
|
||||
public static IStreamHelper StreamHelper { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Registers resources that classes will depend on
|
||||
/// </summary>
|
||||
@@ -719,7 +724,11 @@ namespace Emby.Server.Implementations
|
||||
serviceCollection.AddSingleton(FileSystemManager);
|
||||
serviceCollection.AddSingleton<TvDbClientManager>();
|
||||
|
||||
HttpClient = CreateHttpClient();
|
||||
HttpClient = new HttpClientManager.HttpClientManager(
|
||||
ApplicationPaths,
|
||||
LoggerFactory.CreateLogger<HttpClientManager.HttpClientManager>(),
|
||||
FileSystemManager,
|
||||
() => ApplicationUserAgent);
|
||||
serviceCollection.AddSingleton(HttpClient);
|
||||
|
||||
serviceCollection.AddSingleton(NetworkManager);
|
||||
@@ -735,28 +744,26 @@ namespace Emby.Server.Implementations
|
||||
ProcessFactory = new ProcessFactory();
|
||||
serviceCollection.AddSingleton(ProcessFactory);
|
||||
|
||||
ApplicationHost.StreamHelper = new StreamHelper();
|
||||
serviceCollection.AddSingleton(StreamHelper);
|
||||
serviceCollection.AddSingleton(typeof(IStreamHelper), typeof(StreamHelper));
|
||||
|
||||
serviceCollection.AddSingleton(typeof(ICryptoProvider), typeof(CryptographyProvider));
|
||||
var cryptoProvider = new CryptographyProvider();
|
||||
serviceCollection.AddSingleton<ICryptoProvider>(cryptoProvider);
|
||||
|
||||
SocketFactory = new SocketFactory();
|
||||
serviceCollection.AddSingleton(SocketFactory);
|
||||
|
||||
serviceCollection.AddSingleton(typeof(IInstallationManager), typeof(InstallationManager));
|
||||
|
||||
ZipClient = new ZipClient();
|
||||
serviceCollection.AddSingleton(ZipClient);
|
||||
serviceCollection.AddSingleton(typeof(IZipClient), typeof(ZipClient));
|
||||
|
||||
HttpResultFactory = new HttpResultFactory(LoggerFactory, FileSystemManager, JsonSerializer, StreamHelper);
|
||||
serviceCollection.AddSingleton(HttpResultFactory);
|
||||
serviceCollection.AddSingleton(typeof(IHttpResultFactory), typeof(HttpResultFactory));
|
||||
|
||||
serviceCollection.AddSingleton<IServerApplicationHost>(this);
|
||||
serviceCollection.AddSingleton<IServerApplicationPaths>(ApplicationPaths);
|
||||
|
||||
serviceCollection.AddSingleton(ServerConfigurationManager);
|
||||
|
||||
LocalizationManager = new LocalizationManager(ServerConfigurationManager, JsonSerializer, LoggerFactory);
|
||||
LocalizationManager = new LocalizationManager(ServerConfigurationManager, JsonSerializer, LoggerFactory.CreateLogger<LocalizationManager>());
|
||||
await LocalizationManager.LoadAll().ConfigureAwait(false);
|
||||
serviceCollection.AddSingleton<ILocalizationManager>(LocalizationManager);
|
||||
|
||||
@@ -765,12 +772,12 @@ namespace Emby.Server.Implementations
|
||||
UserDataManager = new UserDataManager(LoggerFactory, ServerConfigurationManager, () => UserManager);
|
||||
serviceCollection.AddSingleton(UserDataManager);
|
||||
|
||||
UserRepository = GetUserRepository();
|
||||
// This is only needed for disposal purposes. If removing this, make sure to have the manager handle disposing it
|
||||
serviceCollection.AddSingleton(UserRepository);
|
||||
|
||||
var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LoggerFactory, JsonSerializer, ApplicationPaths, FileSystemManager);
|
||||
serviceCollection.AddSingleton<IDisplayPreferencesRepository>(displayPreferencesRepo);
|
||||
_displayPreferencesRepository = new SqliteDisplayPreferencesRepository(
|
||||
LoggerFactory.CreateLogger<SqliteDisplayPreferencesRepository>(),
|
||||
JsonSerializer,
|
||||
ApplicationPaths,
|
||||
FileSystemManager);
|
||||
serviceCollection.AddSingleton<IDisplayPreferencesRepository>(_displayPreferencesRepository);
|
||||
|
||||
ItemRepository = new SqliteItemRepository(ServerConfigurationManager, this, JsonSerializer, LoggerFactory, LocalizationManager);
|
||||
serviceCollection.AddSingleton<IItemRepository>(ItemRepository);
|
||||
@@ -778,7 +785,20 @@ namespace Emby.Server.Implementations
|
||||
AuthenticationRepository = GetAuthenticationRepository();
|
||||
serviceCollection.AddSingleton(AuthenticationRepository);
|
||||
|
||||
UserManager = new UserManager(LoggerFactory, ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, this, JsonSerializer, FileSystemManager);
|
||||
_userRepository = GetUserRepository();
|
||||
|
||||
UserManager = new UserManager(
|
||||
LoggerFactory.CreateLogger<UserManager>(),
|
||||
_userRepository,
|
||||
XmlSerializer,
|
||||
NetworkManager,
|
||||
() => ImageProcessor,
|
||||
() => DtoService,
|
||||
this,
|
||||
JsonSerializer,
|
||||
FileSystemManager,
|
||||
cryptoProvider);
|
||||
|
||||
serviceCollection.AddSingleton(UserManager);
|
||||
|
||||
LibraryManager = new LibraryManager(this, LoggerFactory, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager);
|
||||
@@ -798,7 +818,7 @@ namespace Emby.Server.Implementations
|
||||
|
||||
HttpServer = new HttpListenerHost(
|
||||
this,
|
||||
LoggerFactory,
|
||||
LoggerFactory.CreateLogger<HttpListenerHost>(),
|
||||
ServerConfigurationManager,
|
||||
_configuration,
|
||||
NetworkManager,
|
||||
@@ -811,14 +831,13 @@ namespace Emby.Server.Implementations
|
||||
|
||||
serviceCollection.AddSingleton(HttpServer);
|
||||
|
||||
ImageProcessor = GetImageProcessor();
|
||||
ImageProcessor = new ImageProcessor(LoggerFactory.CreateLogger<ImageProcessor>(), ServerConfigurationManager.ApplicationPaths, FileSystemManager, ImageEncoder, () => LibraryManager, () => MediaEncoder);
|
||||
serviceCollection.AddSingleton(ImageProcessor);
|
||||
|
||||
TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager, ServerConfigurationManager);
|
||||
serviceCollection.AddSingleton(TVSeriesManager);
|
||||
|
||||
DeviceManager = new DeviceManager(AuthenticationRepository, JsonSerializer, LibraryManager, LocalizationManager, UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager);
|
||||
|
||||
serviceCollection.AddSingleton(DeviceManager);
|
||||
|
||||
MediaSourceManager = new MediaSourceManager(ItemRepository, ApplicationPaths, LocalizationManager, UserManager, LibraryManager, LoggerFactory, JsonSerializer, FileSystemManager, UserDataManager, () => MediaEncoder);
|
||||
@@ -833,10 +852,10 @@ namespace Emby.Server.Implementations
|
||||
DtoService = new DtoService(LoggerFactory, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ProviderManager, this, () => MediaSourceManager, () => LiveTvManager);
|
||||
serviceCollection.AddSingleton(DtoService);
|
||||
|
||||
ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, LoggerFactory, ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, LocalizationManager, HttpClient, ProviderManager);
|
||||
ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, LoggerFactory, ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, ProviderManager);
|
||||
serviceCollection.AddSingleton(ChannelManager);
|
||||
|
||||
SessionManager = new SessionManager(UserDataManager, LoggerFactory, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager, MediaSourceManager);
|
||||
SessionManager = new SessionManager(UserDataManager, LoggerFactory, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, this, AuthenticationRepository, DeviceManager, MediaSourceManager);
|
||||
serviceCollection.AddSingleton(SessionManager);
|
||||
|
||||
serviceCollection.AddSingleton<IDlnaManager>(
|
||||
@@ -845,8 +864,7 @@ namespace Emby.Server.Implementations
|
||||
CollectionManager = new CollectionManager(LibraryManager, ApplicationPaths, LocalizationManager, FileSystemManager, LibraryMonitor, LoggerFactory, ProviderManager);
|
||||
serviceCollection.AddSingleton(CollectionManager);
|
||||
|
||||
PlaylistManager = new PlaylistManager(LibraryManager, FileSystemManager, LibraryMonitor, LoggerFactory, UserManager, ProviderManager);
|
||||
serviceCollection.AddSingleton(PlaylistManager);
|
||||
serviceCollection.AddSingleton(typeof(IPlaylistManager), typeof(PlaylistManager));
|
||||
|
||||
LiveTvManager = new LiveTvManager(this, ServerConfigurationManager, LoggerFactory, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, FileSystemManager, () => ChannelManager);
|
||||
serviceCollection.AddSingleton(LiveTvManager);
|
||||
@@ -887,15 +905,15 @@ namespace Emby.Server.Implementations
|
||||
serviceCollection.AddSingleton<IAuthorizationContext>(authContext);
|
||||
serviceCollection.AddSingleton<ISessionContext>(new SessionContext(UserManager, authContext, SessionManager));
|
||||
|
||||
AuthService = new AuthService(UserManager, authContext, ServerConfigurationManager, SessionManager, NetworkManager);
|
||||
AuthService = new AuthService(authContext, ServerConfigurationManager, SessionManager, NetworkManager);
|
||||
serviceCollection.AddSingleton(AuthService);
|
||||
|
||||
SubtitleEncoder = new MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder(LibraryManager, LoggerFactory, ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer, HttpClient, MediaSourceManager, ProcessFactory);
|
||||
serviceCollection.AddSingleton(SubtitleEncoder);
|
||||
|
||||
serviceCollection.AddSingleton(CreateResourceFileManager());
|
||||
serviceCollection.AddSingleton(typeof(IResourceFileManager), typeof(ResourceFileManager));
|
||||
|
||||
displayPreferencesRepo.Initialize();
|
||||
_displayPreferencesRepository.Initialize();
|
||||
|
||||
var userDataRepo = new SqliteUserDataRepository(LoggerFactory, ApplicationPaths);
|
||||
|
||||
@@ -918,8 +936,7 @@ namespace Emby.Server.Implementations
|
||||
.Distinct();
|
||||
|
||||
logger.LogInformation("Arguments: {Args}", commandLineArgs);
|
||||
// FIXME: @bond this logs the kernel version, not the OS version
|
||||
logger.LogInformation("Operating system: {OS} {OSVersion}", OperatingSystem.Name, Environment.OSVersion.Version);
|
||||
logger.LogInformation("Operating system: {OS}", OperatingSystem.Name);
|
||||
logger.LogInformation("Architecture: {Architecture}", RuntimeInformation.OSArchitecture);
|
||||
logger.LogInformation("64-Bit Process: {Is64Bit}", Environment.Is64BitProcess);
|
||||
logger.LogInformation("User Interactive: {IsUserInteractive}", Environment.UserInteractive);
|
||||
@@ -929,19 +946,6 @@ namespace Emby.Server.Implementations
|
||||
logger.LogInformation("Application directory: {ApplicationPath}", appPaths.ProgramSystemPath);
|
||||
}
|
||||
|
||||
private void SetHttpLimit()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Increase the max http request limit
|
||||
ServicePointManager.DefaultConnectionLimit = Math.Max(96, ServicePointManager.DefaultConnectionLimit);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error setting http limit");
|
||||
}
|
||||
}
|
||||
|
||||
private X509Certificate2 GetCertificate(CertificateInfo info)
|
||||
{
|
||||
var certificateLocation = info?.Path;
|
||||
@@ -978,18 +982,16 @@ namespace Emby.Server.Implementations
|
||||
}
|
||||
}
|
||||
|
||||
private IImageProcessor GetImageProcessor()
|
||||
{
|
||||
return new ImageProcessor(LoggerFactory, ServerConfigurationManager.ApplicationPaths, FileSystemManager, ImageEncoder, () => LibraryManager, () => MediaEncoder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user repository.
|
||||
/// </summary>
|
||||
/// <returns>Task{IUserRepository}.</returns>
|
||||
private IUserRepository GetUserRepository()
|
||||
/// <returns><see cref="Task{SqliteUserRepository}" />.</returns>
|
||||
private SqliteUserRepository GetUserRepository()
|
||||
{
|
||||
var repo = new SqliteUserRepository(LoggerFactory, ApplicationPaths, JsonSerializer);
|
||||
var repo = new SqliteUserRepository(
|
||||
LoggerFactory.CreateLogger<SqliteUserRepository>(),
|
||||
ApplicationPaths,
|
||||
JsonSerializer);
|
||||
|
||||
repo.Initialize();
|
||||
|
||||
@@ -1035,7 +1037,6 @@ namespace Emby.Server.Implementations
|
||||
Video.LiveTvManager = LiveTvManager;
|
||||
Folder.UserViewManager = UserViewManager;
|
||||
UserView.TVSeriesManager = TVSeriesManager;
|
||||
UserView.PlaylistManager = PlaylistManager;
|
||||
UserView.CollectionManager = CollectionManager;
|
||||
BaseItem.MediaSourceManager = MediaSourceManager;
|
||||
CollectionFolder.XmlSerializer = XmlSerializer;
|
||||
@@ -1051,9 +1052,11 @@ namespace Emby.Server.Implementations
|
||||
.Select(x => Assembly.LoadFrom(x))
|
||||
.SelectMany(x => x.ExportedTypes)
|
||||
.Where(x => x.IsClass && !x.IsAbstract && !x.IsInterface && !x.IsGenericType)
|
||||
.ToList();
|
||||
.ToArray();
|
||||
|
||||
types.AddRange(types);
|
||||
int oldLen = _allConcreteTypes.Length;
|
||||
Array.Resize(ref _allConcreteTypes, oldLen + types.Length);
|
||||
types.CopyTo(_allConcreteTypes, oldLen);
|
||||
|
||||
var plugins = types.Where(x => x.IsAssignableFrom(typeof(IPlugin)))
|
||||
.Select(CreateInstanceSafe)
|
||||
@@ -1063,8 +1066,8 @@ namespace Emby.Server.Implementations
|
||||
.Where(x => x != null)
|
||||
.ToArray();
|
||||
|
||||
int oldLen = _plugins.Length;
|
||||
Array.Resize<IPlugin>(ref _plugins, _plugins.Length + plugins.Length);
|
||||
oldLen = _plugins.Length;
|
||||
Array.Resize(ref _plugins, oldLen + plugins.Length);
|
||||
plugins.CopyTo(_plugins, oldLen);
|
||||
|
||||
var entries = types.Where(x => x.IsAssignableFrom(typeof(IServerEntryPoint)))
|
||||
@@ -1073,8 +1076,8 @@ namespace Emby.Server.Implementations
|
||||
.Cast<IServerEntryPoint>()
|
||||
.ToList();
|
||||
|
||||
await Task.WhenAll(StartEntryPoints(entries, true));
|
||||
await Task.WhenAll(StartEntryPoints(entries, false));
|
||||
await Task.WhenAll(StartEntryPoints(entries, true)).ConfigureAwait(false);
|
||||
await Task.WhenAll(StartEntryPoints(entries, false)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1113,7 +1116,7 @@ namespace Emby.Server.Implementations
|
||||
GetExports<IMetadataSaver>(),
|
||||
GetExports<IExternalId>());
|
||||
|
||||
ImageProcessor.AddParts(GetExports<IImageEnhancer>());
|
||||
ImageProcessor.ImageEnhancers = GetExports<IImageEnhancer>();
|
||||
|
||||
LiveTvManager.AddParts(GetExports<ILiveTvService>(), GetExports<ITunerHost>(), GetExports<IListingsProvider>());
|
||||
|
||||
@@ -1181,7 +1184,7 @@ namespace Emby.Server.Implementations
|
||||
{
|
||||
Logger.LogInformation("Loading assemblies");
|
||||
|
||||
AllConcreteTypes = GetTypes(GetComposablePartAssemblies()).ToArray();
|
||||
_allConcreteTypes = GetTypes(GetComposablePartAssemblies()).ToArray();
|
||||
}
|
||||
|
||||
private IEnumerable<Type> GetTypes(IEnumerable<Assembly> assemblies)
|
||||
@@ -1237,25 +1240,11 @@ namespace Emby.Server.Implementations
|
||||
|
||||
private CertificateInfo GetCertificateInfo(bool generateCertificate)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(ServerConfigurationManager.Configuration.CertificatePath))
|
||||
{
|
||||
// Custom cert
|
||||
return new CertificateInfo
|
||||
{
|
||||
Path = ServerConfigurationManager.Configuration.CertificatePath,
|
||||
Password = ServerConfigurationManager.Configuration.CertificatePassword
|
||||
};
|
||||
}
|
||||
|
||||
// Generate self-signed cert
|
||||
var certHost = GetHostnameFromExternalDns(ServerConfigurationManager.Configuration.WanDdns);
|
||||
var certPath = Path.Combine(ServerConfigurationManager.ApplicationPaths.ProgramDataPath, "ssl", "cert_" + (certHost + "2").GetMD5().ToString("N") + ".pfx");
|
||||
const string Password = "embycert";
|
||||
|
||||
// Custom cert
|
||||
return new CertificateInfo
|
||||
{
|
||||
Path = certPath,
|
||||
Password = Password
|
||||
Path = ServerConfigurationManager.Configuration.CertificatePath,
|
||||
Password = ServerConfigurationManager.Configuration.CertificatePassword
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1441,17 +1430,6 @@ namespace Emby.Server.Implementations
|
||||
public async Task<SystemInfo> GetSystemInfo(CancellationToken cancellationToken)
|
||||
{
|
||||
var localAddress = await GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
string wanAddress;
|
||||
|
||||
if (string.IsNullOrEmpty(ServerConfigurationManager.Configuration.WanDdns))
|
||||
{
|
||||
wanAddress = await GetWanApiUrlFromExternal(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
wanAddress = GetWanApiUrl(ServerConfigurationManager.Configuration.WanDdns);
|
||||
}
|
||||
|
||||
return new SystemInfo
|
||||
{
|
||||
@@ -1474,7 +1452,6 @@ namespace Emby.Server.Implementations
|
||||
OperatingSystemDisplayName = OperatingSystem.Name,
|
||||
CanSelfRestart = CanSelfRestart,
|
||||
CanLaunchWebBrowser = CanLaunchWebBrowser,
|
||||
WanAddress = wanAddress,
|
||||
HasUpdateAvailable = HasUpdateAvailable,
|
||||
TranscodingTempPath = ApplicationPaths.TranscodingTempPath,
|
||||
ServerName = FriendlyName,
|
||||
@@ -1487,37 +1464,21 @@ namespace Emby.Server.Implementations
|
||||
};
|
||||
}
|
||||
|
||||
public WakeOnLanInfo[] GetWakeOnLanInfo()
|
||||
{
|
||||
return NetworkManager.GetMacAddresses()
|
||||
.Select(i => new WakeOnLanInfo
|
||||
{
|
||||
MacAddress = i
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
public IEnumerable<WakeOnLanInfo> GetWakeOnLanInfo()
|
||||
=> NetworkManager.GetMacAddresses()
|
||||
.Select(i => new WakeOnLanInfo(i))
|
||||
.ToList();
|
||||
|
||||
public async Task<PublicSystemInfo> GetPublicSystemInfo(CancellationToken cancellationToken)
|
||||
{
|
||||
var localAddress = await GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
string wanAddress;
|
||||
|
||||
if (string.IsNullOrEmpty(ServerConfigurationManager.Configuration.WanDdns))
|
||||
{
|
||||
wanAddress = await GetWanApiUrlFromExternal(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
wanAddress = GetWanApiUrl(ServerConfigurationManager.Configuration.WanDdns);
|
||||
}
|
||||
var localAddress = await GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return new PublicSystemInfo
|
||||
{
|
||||
Version = ApplicationVersion,
|
||||
ProductName = ApplicationProductName,
|
||||
Id = SystemId,
|
||||
OperatingSystem = OperatingSystem.Id.ToString(),
|
||||
WanAddress = wanAddress,
|
||||
ServerName = FriendlyName,
|
||||
LocalAddress = localAddress
|
||||
};
|
||||
@@ -1549,40 +1510,32 @@ namespace Emby.Server.Implementations
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task<string> GetWanApiUrlFromExternal(CancellationToken cancellationToken)
|
||||
/// <summary>
|
||||
/// Removes the scope id from IPv6 addresses.
|
||||
/// </summary>
|
||||
/// <param name="address">The IPv6 address.</param>
|
||||
/// <returns>The IPv6 address without the scope id.</returns>
|
||||
private string RemoveScopeId(string address)
|
||||
{
|
||||
const string Url = "http://ipv4.icanhazip.com";
|
||||
try
|
||||
var index = address.IndexOf('%');
|
||||
if (index == -1)
|
||||
{
|
||||
using (var response = await HttpClient.Get(new HttpRequestOptions
|
||||
{
|
||||
Url = Url,
|
||||
LogErrorResponseBody = false,
|
||||
LogErrors = false,
|
||||
LogRequest = false,
|
||||
TimeoutMs = 10000,
|
||||
BufferContent = false,
|
||||
CancellationToken = cancellationToken
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
return GetWanApiUrl(response.ReadToEnd().Trim());
|
||||
}
|
||||
return address;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error getting WAN Ip address information");
|
||||
}
|
||||
return null;
|
||||
|
||||
return address.Substring(0, index);
|
||||
}
|
||||
|
||||
public string GetLocalApiUrl(IpAddressInfo ipAddress)
|
||||
public string GetLocalApiUrl(IPAddress ipAddress)
|
||||
{
|
||||
if (ipAddress.AddressFamily == IpAddressFamily.InterNetworkV6)
|
||||
if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
|
||||
{
|
||||
return GetLocalApiUrl("[" + ipAddress.Address + "]");
|
||||
var str = RemoveScopeId(ipAddress.ToString());
|
||||
|
||||
return GetLocalApiUrl("[" + str + "]");
|
||||
}
|
||||
|
||||
return GetLocalApiUrl(ipAddress.Address);
|
||||
return GetLocalApiUrl(ipAddress.ToString());
|
||||
}
|
||||
|
||||
public string GetLocalApiUrl(string host)
|
||||
@@ -1593,40 +1546,18 @@ namespace Emby.Server.Implementations
|
||||
host,
|
||||
HttpsPort.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
return string.Format("http://{0}:{1}",
|
||||
host,
|
||||
HttpPort.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
public string GetWanApiUrl(IpAddressInfo ipAddress)
|
||||
{
|
||||
if (ipAddress.AddressFamily == IpAddressFamily.InterNetworkV6)
|
||||
{
|
||||
return GetWanApiUrl("[" + ipAddress.Address + "]");
|
||||
}
|
||||
|
||||
return GetWanApiUrl(ipAddress.Address);
|
||||
}
|
||||
|
||||
public string GetWanApiUrl(string host)
|
||||
{
|
||||
if (EnableHttps)
|
||||
{
|
||||
return string.Format("https://{0}:{1}",
|
||||
host,
|
||||
ServerConfigurationManager.Configuration.PublicHttpsPort.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
return string.Format("http://{0}:{1}",
|
||||
host,
|
||||
ServerConfigurationManager.Configuration.PublicPort.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
public Task<List<IpAddressInfo>> GetLocalIpAddresses(CancellationToken cancellationToken)
|
||||
public Task<List<IPAddress>> GetLocalIpAddresses(CancellationToken cancellationToken)
|
||||
{
|
||||
return GetLocalIpAddressesInternal(true, 0, cancellationToken);
|
||||
}
|
||||
|
||||
private async Task<List<IpAddressInfo>> GetLocalIpAddressesInternal(bool allowLoopback, int limit, CancellationToken cancellationToken)
|
||||
private async Task<List<IPAddress>> GetLocalIpAddressesInternal(bool allowLoopback, int limit, CancellationToken cancellationToken)
|
||||
{
|
||||
var addresses = ServerConfigurationManager
|
||||
.Configuration
|
||||
@@ -1640,13 +1571,13 @@ namespace Emby.Server.Implementations
|
||||
addresses.AddRange(NetworkManager.GetLocalIpAddresses(ServerConfigurationManager.Configuration.IgnoreVirtualInterfaces));
|
||||
}
|
||||
|
||||
var resultList = new List<IpAddressInfo>();
|
||||
var resultList = new List<IPAddress>();
|
||||
|
||||
foreach (var address in addresses)
|
||||
{
|
||||
if (!allowLoopback)
|
||||
{
|
||||
if (address.Equals(IpAddressInfo.Loopback) || address.Equals(IpAddressInfo.IPv6Loopback))
|
||||
if (address.Equals(IPAddress.Loopback) || address.Equals(IPAddress.IPv6Loopback))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -1667,7 +1598,7 @@ namespace Emby.Server.Implementations
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private IpAddressInfo NormalizeConfiguredLocalAddress(string address)
|
||||
private IPAddress NormalizeConfiguredLocalAddress(string address)
|
||||
{
|
||||
var index = address.Trim('/').IndexOf('/');
|
||||
|
||||
@@ -1676,7 +1607,7 @@ namespace Emby.Server.Implementations
|
||||
address = address.Substring(index + 1);
|
||||
}
|
||||
|
||||
if (NetworkManager.TryParseIpAddress(address.Trim('/'), out IpAddressInfo result))
|
||||
if (IPAddress.TryParse(address.Trim('/'), out IPAddress result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
@@ -1686,10 +1617,10 @@ namespace Emby.Server.Implementations
|
||||
|
||||
private readonly ConcurrentDictionary<string, bool> _validAddressResults = new ConcurrentDictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private async Task<bool> IsIpAddressValidAsync(IpAddressInfo address, CancellationToken cancellationToken)
|
||||
private async Task<bool> IsIpAddressValidAsync(IPAddress address, CancellationToken cancellationToken)
|
||||
{
|
||||
if (address.Equals(IpAddressInfo.Loopback) ||
|
||||
address.Equals(IpAddressInfo.IPv6Loopback))
|
||||
if (address.Equals(IPAddress.Loopback)
|
||||
|| address.Equals(IPAddress.IPv6Loopback))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -1702,12 +1633,6 @@ namespace Emby.Server.Implementations
|
||||
return cachedResult;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
const bool LogPing = true;
|
||||
#else
|
||||
const bool LogPing = false;
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
using (var response = await HttpClient.SendAsync(
|
||||
@@ -1715,17 +1640,13 @@ namespace Emby.Server.Implementations
|
||||
{
|
||||
Url = apiUrl,
|
||||
LogErrorResponseBody = false,
|
||||
LogErrors = LogPing,
|
||||
LogRequest = LogPing,
|
||||
TimeoutMs = 5000,
|
||||
BufferContent = false,
|
||||
|
||||
CancellationToken = cancellationToken
|
||||
}, "POST").ConfigureAwait(false))
|
||||
}, HttpMethod.Post).ConfigureAwait(false))
|
||||
{
|
||||
using (var reader = new StreamReader(response.Content))
|
||||
{
|
||||
var result = reader.ReadToEnd();
|
||||
var result = await reader.ReadToEndAsync().ConfigureAwait(false);
|
||||
var valid = string.Equals(Name, result, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
_validAddressResults.AddOrUpdate(apiUrl, valid, (k, v) => valid);
|
||||
@@ -1874,24 +1795,6 @@ namespace Emby.Server.Implementations
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when [application updated].
|
||||
/// </summary>
|
||||
/// <param name="package">The package.</param>
|
||||
protected void OnApplicationUpdated(PackageVersionInfo package)
|
||||
{
|
||||
Logger.LogInformation("Application has been updated to version {0}", package.versionStr);
|
||||
|
||||
ApplicationUpdated?.Invoke(
|
||||
this,
|
||||
new GenericEventArgs<PackageVersionInfo>()
|
||||
{
|
||||
Argument = package
|
||||
});
|
||||
|
||||
NotifyPendingRestart();
|
||||
}
|
||||
|
||||
private bool _disposed = false;
|
||||
|
||||
/// <summary>
|
||||
@@ -1936,8 +1839,14 @@ namespace Emby.Server.Implementations
|
||||
Logger.LogError(ex, "Error disposing {Type}", part.GetType().Name);
|
||||
}
|
||||
}
|
||||
|
||||
_userRepository?.Dispose();
|
||||
_displayPreferencesRepository.Dispose();
|
||||
}
|
||||
|
||||
_userRepository = null;
|
||||
_displayPreferencesRepository = null;
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Common.Progress;
|
||||
using MediaBrowser.Controller.Channels;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
@@ -20,7 +20,6 @@ using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Channels;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Globalization;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
@@ -40,11 +39,8 @@ namespace Emby.Server.Implementations.Channels
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
private readonly IHttpClient _httpClient;
|
||||
private readonly IProviderManager _providerManager;
|
||||
|
||||
private readonly ILocalizationManager _localization;
|
||||
|
||||
public ChannelManager(
|
||||
IUserManager userManager,
|
||||
IDtoService dtoService,
|
||||
@@ -54,8 +50,6 @@ namespace Emby.Server.Implementations.Channels
|
||||
IFileSystem fileSystem,
|
||||
IUserDataManager userDataManager,
|
||||
IJsonSerializer jsonSerializer,
|
||||
ILocalizationManager localization,
|
||||
IHttpClient httpClient,
|
||||
IProviderManager providerManager)
|
||||
{
|
||||
_userManager = userManager;
|
||||
@@ -66,8 +60,6 @@ namespace Emby.Server.Implementations.Channels
|
||||
_fileSystem = fileSystem;
|
||||
_userDataManager = userDataManager;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_localization = localization;
|
||||
_httpClient = httpClient;
|
||||
_providerManager = providerManager;
|
||||
}
|
||||
|
||||
@@ -215,7 +207,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
|
||||
try
|
||||
{
|
||||
return GetChannelProvider(i).IsEnabledFor(user.Id.ToString("N"));
|
||||
return GetChannelProvider(i).IsEnabledFor(user.Id.ToString("N", CultureInfo.InvariantCulture));
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -520,7 +512,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
IncludeItemTypes = new[] { typeof(Channel).Name },
|
||||
OrderBy = new ValueTuple<string, SortOrder>[] { new ValueTuple<string, SortOrder>(ItemSortBy.SortName, SortOrder.Ascending) }
|
||||
|
||||
}).Select(i => GetChannelFeatures(i.ToString("N"))).ToArray();
|
||||
}).Select(i => GetChannelFeatures(i.ToString("N", CultureInfo.InvariantCulture))).ToArray();
|
||||
}
|
||||
|
||||
public ChannelFeatures GetChannelFeatures(string id)
|
||||
@@ -561,7 +553,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
SupportsSortOrderToggle = features.SupportsSortOrderToggle,
|
||||
SupportsLatestMedia = supportsLatest,
|
||||
Name = channel.Name,
|
||||
Id = channel.Id.ToString("N"),
|
||||
Id = channel.Id.ToString("N", CultureInfo.InvariantCulture),
|
||||
SupportsContentDownloading = features.SupportsContentDownloading,
|
||||
AutoRefreshLevels = features.AutoRefreshLevels
|
||||
};
|
||||
@@ -749,7 +741,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
bool sortDescending,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var userId = user == null ? null : user.Id.ToString("N");
|
||||
var userId = user == null ? null : user.Id.ToString("N", CultureInfo.InvariantCulture);
|
||||
|
||||
var cacheLength = CacheLength;
|
||||
var cachePath = GetChannelDataCachePath(channel, userId, externalFolderId, sortField, sortDescending);
|
||||
@@ -845,7 +837,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
ChannelItemSortField? sortField,
|
||||
bool sortDescending)
|
||||
{
|
||||
var channelId = GetInternalChannelId(channel.Name).ToString("N");
|
||||
var channelId = GetInternalChannelId(channel.Name).ToString("N", CultureInfo.InvariantCulture);
|
||||
|
||||
var userCacheKey = string.Empty;
|
||||
|
||||
@@ -855,10 +847,10 @@ namespace Emby.Server.Implementations.Channels
|
||||
userCacheKey = hasCacheKey.GetCacheKey(userId) ?? string.Empty;
|
||||
}
|
||||
|
||||
var filename = string.IsNullOrEmpty(externalFolderId) ? "root" : externalFolderId.GetMD5().ToString("N");
|
||||
var filename = string.IsNullOrEmpty(externalFolderId) ? "root" : externalFolderId.GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||
filename += userCacheKey;
|
||||
|
||||
var version = ((channel.DataVersion ?? string.Empty) + "2").GetMD5().ToString("N");
|
||||
var version = ((channel.DataVersion ?? string.Empty) + "2").GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||
|
||||
if (sortField.HasValue)
|
||||
{
|
||||
@@ -869,7 +861,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
filename += "-sortDescending";
|
||||
}
|
||||
|
||||
filename = filename.GetMD5().ToString("N");
|
||||
filename = filename.GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||
|
||||
return Path.Combine(_config.ApplicationPaths.CachePath,
|
||||
"channels",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@@ -182,7 +183,7 @@ namespace Emby.Server.Implementations.Collections
|
||||
|
||||
public void AddToCollection(Guid collectionId, IEnumerable<Guid> ids)
|
||||
{
|
||||
AddToCollection(collectionId, ids.Select(i => i.ToString("N")), true, new MetadataRefreshOptions(new DirectoryService(_logger, _fileSystem)));
|
||||
AddToCollection(collectionId, ids.Select(i => i.ToString("N", CultureInfo.InvariantCulture)), true, new MetadataRefreshOptions(new DirectoryService(_logger, _fileSystem)));
|
||||
}
|
||||
|
||||
private void AddToCollection(Guid collectionId, IEnumerable<string> ids, bool fireEvent, MetadataRefreshOptions refreshOptions)
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Emby.Server.Implementations.Configuration
|
||||
{
|
||||
base.AddParts(factories);
|
||||
|
||||
UpdateTranscodingTempPath();
|
||||
UpdateTranscodePath();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -87,13 +87,13 @@ namespace Emby.Server.Implementations.Configuration
|
||||
/// <summary>
|
||||
/// Updates the transcoding temporary path.
|
||||
/// </summary>
|
||||
private void UpdateTranscodingTempPath()
|
||||
private void UpdateTranscodePath()
|
||||
{
|
||||
var encodingConfig = this.GetConfiguration<EncodingOptions>("encoding");
|
||||
|
||||
((ServerApplicationPaths)ApplicationPaths).TranscodingTempPath = string.IsNullOrEmpty(encodingConfig.TranscodingTempPath) ?
|
||||
null :
|
||||
Path.Combine(encodingConfig.TranscodingTempPath, "transcoding-temp");
|
||||
Path.Combine(encodingConfig.TranscodingTempPath, "transcodes");
|
||||
}
|
||||
|
||||
protected override void OnNamedConfigurationUpdated(string key, object configuration)
|
||||
@@ -102,7 +102,7 @@ namespace Emby.Server.Implementations.Configuration
|
||||
|
||||
if (string.Equals(key, "encoding", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
UpdateTranscodingTempPath();
|
||||
UpdateTranscodePath();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace Emby.Server.Implementations
|
||||
{
|
||||
public static readonly Dictionary<string, string> Configuration = new Dictionary<string, string>
|
||||
{
|
||||
{"HttpListenerHost:DefaultRedirectPath", "web/index.html"},
|
||||
{"MusicBrainz:BaseUrl", "https://www.musicbrainz.org"}
|
||||
{ "HttpListenerHost:DefaultRedirectPath", "web/index.html" },
|
||||
{ "MusicBrainz:BaseUrl", "https://www.musicbrainz.org" }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using MediaBrowser.Model.Cryptography;
|
||||
using static MediaBrowser.Common.Cryptography.Constants;
|
||||
|
||||
namespace Emby.Server.Implementations.Cryptography
|
||||
{
|
||||
public class CryptographyProvider : ICryptoProvider
|
||||
public class CryptographyProvider : ICryptoProvider, IDisposable
|
||||
{
|
||||
private static readonly HashSet<string> _supportedHashMethods = new HashSet<string>()
|
||||
{
|
||||
@@ -28,59 +26,28 @@ namespace Emby.Server.Implementations.Cryptography
|
||||
"System.Security.Cryptography.SHA512"
|
||||
};
|
||||
|
||||
public string DefaultHashMethod => "PBKDF2";
|
||||
|
||||
private RandomNumberGenerator _randomNumberGenerator;
|
||||
|
||||
private const int _defaultIterations = 1000;
|
||||
private bool _disposed = false;
|
||||
|
||||
public CryptographyProvider()
|
||||
{
|
||||
//FIXME: When we get DotNet Standard 2.1 we need to revisit how we do the crypto
|
||||
//Currently supported hash methods from https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.cryptoconfig?view=netcore-2.1
|
||||
//there might be a better way to autogenerate this list as dotnet updates, but I couldn't find one
|
||||
//Please note the default method of PBKDF2 is not included, it cannot be used to generate hashes cleanly as it is actually a pbkdf with sha1
|
||||
// FIXME: When we get DotNet Standard 2.1 we need to revisit how we do the crypto
|
||||
// Currently supported hash methods from https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.cryptoconfig?view=netcore-2.1
|
||||
// there might be a better way to autogenerate this list as dotnet updates, but I couldn't find one
|
||||
// Please note the default method of PBKDF2 is not included, it cannot be used to generate hashes cleanly as it is actually a pbkdf with sha1
|
||||
_randomNumberGenerator = RandomNumberGenerator.Create();
|
||||
}
|
||||
|
||||
public Guid GetMD5(string str)
|
||||
{
|
||||
return new Guid(ComputeMD5(Encoding.Unicode.GetBytes(str)));
|
||||
}
|
||||
|
||||
public byte[] ComputeSHA1(byte[] bytes)
|
||||
{
|
||||
using (var provider = SHA1.Create())
|
||||
{
|
||||
return provider.ComputeHash(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] ComputeMD5(Stream str)
|
||||
{
|
||||
using (var provider = MD5.Create())
|
||||
{
|
||||
return provider.ComputeHash(str);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] ComputeMD5(byte[] bytes)
|
||||
{
|
||||
using (var provider = MD5.Create())
|
||||
{
|
||||
return provider.ComputeHash(bytes);
|
||||
}
|
||||
}
|
||||
public string DefaultHashMethod => "PBKDF2";
|
||||
|
||||
public IEnumerable<string> GetSupportedHashMethods()
|
||||
{
|
||||
return _supportedHashMethods;
|
||||
}
|
||||
=> _supportedHashMethods;
|
||||
|
||||
private byte[] PBKDF2(string method, byte[] bytes, byte[] salt, int iterations)
|
||||
{
|
||||
//downgrading for now as we need this library to be dotnetstandard compliant
|
||||
//with this downgrade we'll add a check to make sure we're on the downgrade method at the moment
|
||||
// downgrading for now as we need this library to be dotnetstandard compliant
|
||||
// with this downgrade we'll add a check to make sure we're on the downgrade method at the moment
|
||||
if (method == DefaultHashMethod)
|
||||
{
|
||||
using (var r = new Rfc2898DeriveBytes(bytes, salt, iterations))
|
||||
@@ -93,20 +60,16 @@ namespace Emby.Server.Implementations.Cryptography
|
||||
}
|
||||
|
||||
public byte[] ComputeHash(string hashMethod, byte[] bytes)
|
||||
{
|
||||
return ComputeHash(hashMethod, bytes, Array.Empty<byte>());
|
||||
}
|
||||
=> ComputeHash(hashMethod, bytes, Array.Empty<byte>());
|
||||
|
||||
public byte[] ComputeHashWithDefaultMethod(byte[] bytes)
|
||||
{
|
||||
return ComputeHash(DefaultHashMethod, bytes);
|
||||
}
|
||||
=> ComputeHash(DefaultHashMethod, bytes);
|
||||
|
||||
public byte[] ComputeHash(string hashMethod, byte[] bytes, byte[] salt)
|
||||
{
|
||||
if (hashMethod == DefaultHashMethod)
|
||||
{
|
||||
return PBKDF2(hashMethod, bytes, salt, _defaultIterations);
|
||||
return PBKDF2(hashMethod, bytes, salt, DefaultIterations);
|
||||
}
|
||||
else if (_supportedHashMethods.Contains(hashMethod))
|
||||
{
|
||||
@@ -125,44 +88,46 @@ namespace Emby.Server.Implementations.Cryptography
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new CryptographicException($"Requested hash method is not supported: {hashMethod}");
|
||||
}
|
||||
|
||||
throw new CryptographicException($"Requested hash method is not supported: {hashMethod}");
|
||||
|
||||
}
|
||||
|
||||
public byte[] ComputeHashWithDefaultMethod(byte[] bytes, byte[] salt)
|
||||
{
|
||||
return PBKDF2(DefaultHashMethod, bytes, salt, _defaultIterations);
|
||||
}
|
||||
|
||||
public byte[] ComputeHash(PasswordHash hash)
|
||||
{
|
||||
int iterations = _defaultIterations;
|
||||
if (!hash.Parameters.ContainsKey("iterations"))
|
||||
{
|
||||
hash.Parameters.Add("iterations", _defaultIterations.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
iterations = int.Parse(hash.Parameters["iterations"]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new InvalidDataException($"Couldn't successfully parse iterations value from string: {hash.Parameters["iterations"]}", e);
|
||||
}
|
||||
}
|
||||
|
||||
return PBKDF2(hash.Id, hash.HashBytes, hash.SaltBytes, iterations);
|
||||
}
|
||||
=> PBKDF2(DefaultHashMethod, bytes, salt, DefaultIterations);
|
||||
|
||||
public byte[] GenerateSalt()
|
||||
=> GenerateSalt(DefaultSaltLength);
|
||||
|
||||
public byte[] GenerateSalt(int length)
|
||||
{
|
||||
byte[] salt = new byte[64];
|
||||
byte[] salt = new byte[length];
|
||||
_randomNumberGenerator.GetBytes(salt);
|
||||
return salt;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
_randomNumberGenerator.Dispose();
|
||||
}
|
||||
|
||||
_randomNumberGenerator = null;
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,183 +1,144 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SQLitePCL;
|
||||
using SQLitePCL.pretty;
|
||||
|
||||
namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
public abstract class BaseSqliteRepository : IDisposable
|
||||
{
|
||||
protected string DbFilePath { get; set; }
|
||||
protected ReaderWriterLockSlim WriteLock;
|
||||
|
||||
protected ILogger Logger { get; private set; }
|
||||
private bool _disposed = false;
|
||||
|
||||
protected BaseSqliteRepository(ILogger logger)
|
||||
{
|
||||
Logger = logger;
|
||||
|
||||
WriteLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the path to the DB file.
|
||||
/// </summary>
|
||||
/// <value>Path to the DB file.</value>
|
||||
protected string DbFilePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the logger.
|
||||
/// </summary>
|
||||
/// <value>The logger.</value>
|
||||
protected ILogger Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default connection flags.
|
||||
/// </summary>
|
||||
/// <value>The default connection flags.</value>
|
||||
protected virtual ConnectionFlags DefaultConnectionFlags => ConnectionFlags.NoMutex;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the transaction mode.
|
||||
/// </summary>
|
||||
/// <value>The transaction mode.</value>>
|
||||
protected TransactionMode TransactionMode => TransactionMode.Deferred;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the transaction mode for read-only operations.
|
||||
/// </summary>
|
||||
/// <value>The transaction mode.</value>
|
||||
protected TransactionMode ReadTransactionMode => TransactionMode.Deferred;
|
||||
|
||||
internal static int ThreadSafeMode { get; set; }
|
||||
/// <summary>
|
||||
/// Gets the cache size.
|
||||
/// </summary>
|
||||
/// <value>The cache size or null.</value>
|
||||
protected virtual int? CacheSize => null;
|
||||
|
||||
static BaseSqliteRepository()
|
||||
/// <summary>
|
||||
/// Gets the journal mode. <see href="https://www.sqlite.org/pragma.html#pragma_journal_mode" />
|
||||
/// </summary>
|
||||
/// <value>The journal mode.</value>
|
||||
protected virtual string JournalMode => "TRUNCATE";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the page size.
|
||||
/// </summary>
|
||||
/// <value>The page size or null.</value>
|
||||
protected virtual int? PageSize => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the temp store mode.
|
||||
/// </summary>
|
||||
/// <value>The temp store mode.</value>
|
||||
/// <see cref="TempStoreMode"/>
|
||||
protected virtual TempStoreMode TempStore => TempStoreMode.Default;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the synchronous mode.
|
||||
/// </summary>
|
||||
/// <value>The synchronous mode or null.</value>
|
||||
/// <see cref="SynchronousMode"/>
|
||||
protected virtual SynchronousMode? Synchronous => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the write lock.
|
||||
/// </summary>
|
||||
/// <value>The write lock.</value>
|
||||
protected SemaphoreSlim WriteLock { get; set; } = new SemaphoreSlim(1, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the write connection.
|
||||
/// </summary>
|
||||
/// <value>The write connection.</value>
|
||||
protected SQLiteDatabaseConnection WriteConnection { get; set; }
|
||||
|
||||
protected ManagedConnection GetConnection(bool _ = false)
|
||||
{
|
||||
SQLite3.EnableSharedCache = false;
|
||||
|
||||
int rc = raw.sqlite3_config(raw.SQLITE_CONFIG_MEMSTATUS, 0);
|
||||
//CheckOk(rc);
|
||||
|
||||
rc = raw.sqlite3_config(raw.SQLITE_CONFIG_MULTITHREAD, 1);
|
||||
//rc = raw.sqlite3_config(raw.SQLITE_CONFIG_SINGLETHREAD, 1);
|
||||
//rc = raw.sqlite3_config(raw.SQLITE_CONFIG_SERIALIZED, 1);
|
||||
//CheckOk(rc);
|
||||
|
||||
rc = raw.sqlite3_enable_shared_cache(1);
|
||||
|
||||
ThreadSafeMode = raw.sqlite3_threadsafe();
|
||||
}
|
||||
|
||||
private static bool _versionLogged;
|
||||
|
||||
private string _defaultWal;
|
||||
protected ManagedConnection _connection;
|
||||
|
||||
protected virtual bool EnableSingleConnection => true;
|
||||
|
||||
protected ManagedConnection CreateConnection(bool isReadOnly = false)
|
||||
{
|
||||
if (_connection != null)
|
||||
WriteLock.Wait();
|
||||
if (WriteConnection != null)
|
||||
{
|
||||
return _connection;
|
||||
return new ManagedConnection(WriteConnection, WriteLock);
|
||||
}
|
||||
|
||||
lock (WriteLock)
|
||||
WriteConnection = SQLite3.Open(
|
||||
DbFilePath,
|
||||
DefaultConnectionFlags | ConnectionFlags.Create | ConnectionFlags.ReadWrite,
|
||||
null);
|
||||
|
||||
if (CacheSize.HasValue)
|
||||
{
|
||||
if (!_versionLogged)
|
||||
{
|
||||
_versionLogged = true;
|
||||
Logger.LogInformation("Sqlite version: " + SQLite3.Version);
|
||||
Logger.LogInformation("Sqlite compiler options: " + string.Join(",", SQLite3.CompilerOptions.ToArray()));
|
||||
}
|
||||
|
||||
ConnectionFlags connectionFlags;
|
||||
|
||||
if (isReadOnly)
|
||||
{
|
||||
//Logger.LogInformation("Opening read connection");
|
||||
//connectionFlags = ConnectionFlags.ReadOnly;
|
||||
connectionFlags = ConnectionFlags.Create;
|
||||
connectionFlags |= ConnectionFlags.ReadWrite;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Logger.LogInformation("Opening write connection");
|
||||
connectionFlags = ConnectionFlags.Create;
|
||||
connectionFlags |= ConnectionFlags.ReadWrite;
|
||||
}
|
||||
|
||||
if (EnableSingleConnection)
|
||||
{
|
||||
connectionFlags |= ConnectionFlags.PrivateCache;
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionFlags |= ConnectionFlags.SharedCached;
|
||||
}
|
||||
|
||||
connectionFlags |= ConnectionFlags.NoMutex;
|
||||
|
||||
var db = SQLite3.Open(DbFilePath, connectionFlags, null);
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_defaultWal))
|
||||
{
|
||||
_defaultWal = db.Query("PRAGMA journal_mode").SelectScalarString().First();
|
||||
|
||||
Logger.LogInformation("Default journal_mode for {0} is {1}", DbFilePath, _defaultWal);
|
||||
}
|
||||
|
||||
var queries = new List<string>
|
||||
{
|
||||
//"PRAGMA cache size=-10000"
|
||||
//"PRAGMA read_uncommitted = true",
|
||||
"PRAGMA synchronous=Normal"
|
||||
};
|
||||
|
||||
if (CacheSize.HasValue)
|
||||
{
|
||||
queries.Add("PRAGMA cache_size=" + CacheSize.Value.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
if (EnableTempStoreMemory)
|
||||
{
|
||||
queries.Add("PRAGMA temp_store = memory");
|
||||
}
|
||||
else
|
||||
{
|
||||
queries.Add("PRAGMA temp_store = file");
|
||||
}
|
||||
|
||||
foreach (var query in queries)
|
||||
{
|
||||
db.Execute(query);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
using (db)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
_connection = new ManagedConnection(db, false);
|
||||
|
||||
return _connection;
|
||||
WriteConnection.Execute("PRAGMA cache_size=" + CacheSize.Value);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(JournalMode))
|
||||
{
|
||||
WriteConnection.Execute("PRAGMA journal_mode=" + JournalMode);
|
||||
}
|
||||
|
||||
if (Synchronous.HasValue)
|
||||
{
|
||||
WriteConnection.Execute("PRAGMA synchronous=" + (int)Synchronous.Value);
|
||||
}
|
||||
|
||||
if (PageSize.HasValue)
|
||||
{
|
||||
WriteConnection.Execute("PRAGMA page_size=" + PageSize.Value);
|
||||
}
|
||||
|
||||
WriteConnection.Execute("PRAGMA temp_store=" + (int)TempStore);
|
||||
|
||||
// Configuration and pragmas can affect VACUUM so it needs to be last.
|
||||
WriteConnection.Execute("VACUUM");
|
||||
|
||||
return new ManagedConnection(WriteConnection, WriteLock);
|
||||
}
|
||||
|
||||
public IStatement PrepareStatement(ManagedConnection connection, string sql)
|
||||
{
|
||||
return connection.PrepareStatement(sql);
|
||||
}
|
||||
|
||||
public IStatement PrepareStatementSafe(ManagedConnection connection, string sql)
|
||||
{
|
||||
return connection.PrepareStatement(sql);
|
||||
}
|
||||
=> connection.PrepareStatement(sql);
|
||||
|
||||
public IStatement PrepareStatement(IDatabaseConnection connection, string sql)
|
||||
{
|
||||
return connection.PrepareStatement(sql);
|
||||
}
|
||||
=> connection.PrepareStatement(sql);
|
||||
|
||||
public IStatement PrepareStatementSafe(IDatabaseConnection connection, string sql)
|
||||
{
|
||||
return connection.PrepareStatement(sql);
|
||||
}
|
||||
|
||||
public List<IStatement> PrepareAll(IDatabaseConnection connection, IEnumerable<string> sql)
|
||||
{
|
||||
return PrepareAllSafe(connection, sql);
|
||||
}
|
||||
|
||||
public List<IStatement> PrepareAllSafe(IDatabaseConnection connection, IEnumerable<string> sql)
|
||||
{
|
||||
return sql.Select(connection.PrepareStatement).ToList();
|
||||
}
|
||||
public IEnumerable<IStatement> PrepareAll(IDatabaseConnection connection, IEnumerable<string> sql)
|
||||
=> sql.Select(connection.PrepareStatement);
|
||||
|
||||
protected bool TableExists(ManagedConnection connection, string name)
|
||||
{
|
||||
@@ -199,103 +160,9 @@ namespace Emby.Server.Implementations.Data
|
||||
}, ReadTransactionMode);
|
||||
}
|
||||
|
||||
protected void RunDefaultInitialization(ManagedConnection db)
|
||||
{
|
||||
var queries = new List<string>
|
||||
{
|
||||
"PRAGMA journal_mode=WAL",
|
||||
"PRAGMA page_size=4096",
|
||||
"PRAGMA synchronous=Normal"
|
||||
};
|
||||
|
||||
if (EnableTempStoreMemory)
|
||||
{
|
||||
queries.AddRange(new List<string>
|
||||
{
|
||||
"pragma default_temp_store = memory",
|
||||
"pragma temp_store = memory"
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
queries.AddRange(new List<string>
|
||||
{
|
||||
"pragma temp_store = file"
|
||||
});
|
||||
}
|
||||
|
||||
db.ExecuteAll(string.Join(";", queries));
|
||||
Logger.LogInformation("PRAGMA synchronous=" + db.Query("PRAGMA synchronous").SelectScalarString().First());
|
||||
}
|
||||
|
||||
protected virtual bool EnableTempStoreMemory => false;
|
||||
|
||||
protected virtual int? CacheSize => null;
|
||||
|
||||
private bool _disposed;
|
||||
protected void CheckDisposed()
|
||||
{
|
||||
if (_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException(GetType().Name, "Object has been disposed and cannot be accessed.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_disposed = true;
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
private readonly object _disposeLock = new object();
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources.
|
||||
/// </summary>
|
||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected virtual void Dispose(bool dispose)
|
||||
{
|
||||
if (dispose)
|
||||
{
|
||||
DisposeConnection();
|
||||
}
|
||||
}
|
||||
|
||||
private void DisposeConnection()
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (_disposeLock)
|
||||
{
|
||||
using (WriteLock.Write())
|
||||
{
|
||||
if (_connection != null)
|
||||
{
|
||||
using (_connection)
|
||||
{
|
||||
_connection.Close();
|
||||
}
|
||||
_connection = null;
|
||||
}
|
||||
|
||||
CloseConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error disposing database");
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CloseConnection()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected List<string> GetColumnNames(IDatabaseConnection connection, string table)
|
||||
{
|
||||
var list = new List<string>();
|
||||
var columnNames = new List<string>();
|
||||
|
||||
foreach (var row in connection.Query("PRAGMA table_info(" + table + ")"))
|
||||
{
|
||||
@@ -303,11 +170,11 @@ namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
var name = row[1].ToString();
|
||||
|
||||
list.Add(name);
|
||||
columnNames.Add(name);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
return columnNames;
|
||||
}
|
||||
|
||||
protected void AddColumn(IDatabaseConnection connection, string table, string columnName, string type, List<string> existingColumnNames)
|
||||
@@ -319,61 +186,103 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
connection.Execute("alter table " + table + " add column " + columnName + " " + type + " NULL");
|
||||
}
|
||||
|
||||
protected void CheckDisposed()
|
||||
{
|
||||
if (_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException(GetType().Name, "Object has been disposed and cannot be accessed.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources.
|
||||
/// </summary>
|
||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected virtual void Dispose(bool dispose)
|
||||
{
|
||||
if (_disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (dispose)
|
||||
{
|
||||
WriteLock.Wait();
|
||||
try
|
||||
{
|
||||
WriteConnection?.Dispose();
|
||||
}
|
||||
finally
|
||||
{
|
||||
WriteLock.Release();
|
||||
}
|
||||
|
||||
WriteLock.Dispose();
|
||||
}
|
||||
|
||||
WriteConnection = null;
|
||||
WriteLock = null;
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ReaderWriterLockSlimExtensions
|
||||
/// <summary>
|
||||
/// The disk synchronization mode, controls how aggressively SQLite will write data
|
||||
/// all the way out to physical storage.
|
||||
/// </summary>
|
||||
public enum SynchronousMode
|
||||
{
|
||||
private sealed class ReadLockToken : IDisposable
|
||||
{
|
||||
private ReaderWriterLockSlim _sync;
|
||||
public ReadLockToken(ReaderWriterLockSlim sync)
|
||||
{
|
||||
_sync = sync;
|
||||
sync.EnterReadLock();
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
if (_sync != null)
|
||||
{
|
||||
_sync.ExitReadLock();
|
||||
_sync = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
private sealed class WriteLockToken : IDisposable
|
||||
{
|
||||
private ReaderWriterLockSlim _sync;
|
||||
public WriteLockToken(ReaderWriterLockSlim sync)
|
||||
{
|
||||
_sync = sync;
|
||||
sync.EnterWriteLock();
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
if (_sync != null)
|
||||
{
|
||||
_sync.ExitWriteLock();
|
||||
_sync = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// SQLite continues without syncing as soon as it has handed data off to the operating system
|
||||
/// </summary>
|
||||
Off = 0,
|
||||
|
||||
public static IDisposable Read(this ReaderWriterLockSlim obj)
|
||||
{
|
||||
//if (BaseSqliteRepository.ThreadSafeMode > 0)
|
||||
//{
|
||||
// return new DummyToken();
|
||||
//}
|
||||
return new WriteLockToken(obj);
|
||||
}
|
||||
/// <summary>
|
||||
/// SQLite database engine will still sync at the most critical moments
|
||||
/// </summary>
|
||||
Normal = 1,
|
||||
|
||||
public static IDisposable Write(this ReaderWriterLockSlim obj)
|
||||
{
|
||||
//if (BaseSqliteRepository.ThreadSafeMode > 0)
|
||||
//{
|
||||
// return new DummyToken();
|
||||
//}
|
||||
return new WriteLockToken(obj);
|
||||
}
|
||||
/// <summary>
|
||||
/// SQLite database engine will use the xSync method of the VFS
|
||||
/// to ensure that all content is safely written to the disk surface prior to continuing.
|
||||
/// </summary>
|
||||
Full = 2,
|
||||
|
||||
/// <summary>
|
||||
/// EXTRA synchronous is like FULL with the addition that the directory containing a rollback journal
|
||||
/// is synced after that journal is unlinked to commit a transaction in DELETE mode.
|
||||
/// </summary>
|
||||
Extra = 3
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Storage mode used by temporary database files.
|
||||
/// </summary>
|
||||
public enum TempStoreMode
|
||||
{
|
||||
/// <summary>
|
||||
/// The compile-time C preprocessor macro SQLITE_TEMP_STORE
|
||||
/// is used to determine where temporary tables and indices are stored.
|
||||
/// </summary>
|
||||
Default = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Temporary tables and indices are stored in a file.
|
||||
/// </summary>
|
||||
File = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Temporary tables and indices are kept in as if they were pure in-memory databases memory.
|
||||
/// </summary>
|
||||
Memory = 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using SQLitePCL.pretty;
|
||||
|
||||
namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
public class ManagedConnection : IDisposable
|
||||
{
|
||||
private SQLiteDatabaseConnection db;
|
||||
private readonly bool _closeOnDispose;
|
||||
private SQLiteDatabaseConnection _db;
|
||||
private readonly SemaphoreSlim _writeLock;
|
||||
private bool _disposed = false;
|
||||
|
||||
public ManagedConnection(SQLiteDatabaseConnection db, bool closeOnDispose)
|
||||
public ManagedConnection(SQLiteDatabaseConnection db, SemaphoreSlim writeLock)
|
||||
{
|
||||
this.db = db;
|
||||
_closeOnDispose = closeOnDispose;
|
||||
_db = db;
|
||||
_writeLock = writeLock;
|
||||
}
|
||||
|
||||
public IStatement PrepareStatement(string sql)
|
||||
{
|
||||
return db.PrepareStatement(sql);
|
||||
return _db.PrepareStatement(sql);
|
||||
}
|
||||
|
||||
public IEnumerable<IStatement> PrepareAll(string sql)
|
||||
{
|
||||
return db.PrepareAll(sql);
|
||||
return _db.PrepareAll(sql);
|
||||
}
|
||||
|
||||
public void ExecuteAll(string sql)
|
||||
{
|
||||
db.ExecuteAll(sql);
|
||||
_db.ExecuteAll(sql);
|
||||
}
|
||||
|
||||
public void Execute(string sql, params object[] values)
|
||||
{
|
||||
db.Execute(sql, values);
|
||||
_db.Execute(sql, values);
|
||||
}
|
||||
|
||||
public void RunQueries(string[] sql)
|
||||
{
|
||||
db.RunQueries(sql);
|
||||
_db.RunQueries(sql);
|
||||
}
|
||||
|
||||
public void RunInTransaction(Action<IDatabaseConnection> action, TransactionMode mode)
|
||||
{
|
||||
db.RunInTransaction(action, mode);
|
||||
_db.RunInTransaction(action, mode);
|
||||
}
|
||||
|
||||
public T RunInTransaction<T>(Func<IDatabaseConnection, T> action, TransactionMode mode)
|
||||
{
|
||||
return db.RunInTransaction(action, mode);
|
||||
return _db.RunInTransaction(action, mode);
|
||||
}
|
||||
|
||||
public IEnumerable<IReadOnlyList<IResultSetValue>> Query(string sql)
|
||||
{
|
||||
return db.Query(sql);
|
||||
return _db.Query(sql);
|
||||
}
|
||||
|
||||
public IEnumerable<IReadOnlyList<IResultSetValue>> Query(string sql, params object[] values)
|
||||
{
|
||||
return db.Query(sql, values);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
using (db)
|
||||
{
|
||||
|
||||
}
|
||||
return _db.Query(sql, values);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_closeOnDispose)
|
||||
if (_disposed)
|
||||
{
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
_writeLock.Release();
|
||||
|
||||
_db = null; // Don't dispose it
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
@@ -18,13 +19,13 @@ namespace Emby.Server.Implementations.Data
|
||||
/// </summary>
|
||||
public class SqliteDisplayPreferencesRepository : BaseSqliteRepository, IDisplayPreferencesRepository
|
||||
{
|
||||
protected IFileSystem FileSystem { get; private set; }
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public SqliteDisplayPreferencesRepository(ILoggerFactory loggerFactory, IJsonSerializer jsonSerializer, IApplicationPaths appPaths, IFileSystem fileSystem)
|
||||
: base(loggerFactory.CreateLogger(nameof(SqliteDisplayPreferencesRepository)))
|
||||
public SqliteDisplayPreferencesRepository(ILogger<SqliteDisplayPreferencesRepository> logger, IJsonSerializer jsonSerializer, IApplicationPaths appPaths, IFileSystem fileSystem)
|
||||
: base(logger)
|
||||
{
|
||||
_jsonSerializer = jsonSerializer;
|
||||
FileSystem = fileSystem;
|
||||
_fileSystem = fileSystem;
|
||||
DbFilePath = Path.Combine(appPaths.DataPath, "displaypreferences.db");
|
||||
}
|
||||
|
||||
@@ -49,7 +50,7 @@ namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
Logger.LogError(ex, "Error loading database file. Will reset and retry.");
|
||||
|
||||
FileSystem.DeleteFile(DbFilePath);
|
||||
_fileSystem.DeleteFile(DbFilePath);
|
||||
|
||||
InitializeInternal();
|
||||
}
|
||||
@@ -61,16 +62,14 @@ namespace Emby.Server.Implementations.Data
|
||||
/// <returns>Task.</returns>
|
||||
private void InitializeInternal()
|
||||
{
|
||||
using (var connection = CreateConnection())
|
||||
string[] queries =
|
||||
{
|
||||
RunDefaultInitialization(connection);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
"create table if not exists userdisplaypreferences (id GUID NOT NULL, userId GUID NOT NULL, client text NOT NULL, data BLOB NOT NULL)",
|
||||
"create unique index if not exists userdisplaypreferencesindex on userdisplaypreferences (id, userId, client)"
|
||||
};
|
||||
"create table if not exists userdisplaypreferences (id GUID NOT NULL, userId GUID NOT NULL, client text NOT NULL, data BLOB NOT NULL)",
|
||||
"create unique index if not exists userdisplaypreferencesindex on userdisplaypreferences (id, userId, client)"
|
||||
};
|
||||
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
connection.RunQueries(queries);
|
||||
}
|
||||
}
|
||||
@@ -82,7 +81,6 @@ namespace Emby.Server.Implementations.Data
|
||||
/// <param name="userId">The user id.</param>
|
||||
/// <param name="client">The client.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
/// <exception cref="ArgumentNullException">item</exception>
|
||||
public void SaveDisplayPreferences(DisplayPreferences displayPreferences, Guid userId, string client, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -98,15 +96,11 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
using (WriteLock.Write())
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
using (var connection = CreateConnection())
|
||||
{
|
||||
connection.RunInTransaction(db =>
|
||||
{
|
||||
SaveDisplayPreferences(displayPreferences, userId, client, db);
|
||||
}, TransactionMode);
|
||||
}
|
||||
connection.RunInTransaction(
|
||||
db => SaveDisplayPreferences(displayPreferences, userId, client, db),
|
||||
TransactionMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +125,6 @@ namespace Emby.Server.Implementations.Data
|
||||
/// <param name="displayPreferences">The display preferences.</param>
|
||||
/// <param name="userId">The user id.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
/// <exception cref="ArgumentNullException">item</exception>
|
||||
public void SaveAllDisplayPreferences(IEnumerable<DisplayPreferences> displayPreferences, Guid userId, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -142,18 +135,17 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
using (WriteLock.Write())
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
using (var connection = CreateConnection())
|
||||
{
|
||||
connection.RunInTransaction(db =>
|
||||
connection.RunInTransaction(
|
||||
db =>
|
||||
{
|
||||
foreach (var displayPreference in displayPreferences)
|
||||
{
|
||||
SaveDisplayPreferences(displayPreference, userId, displayPreference.Client, db);
|
||||
}
|
||||
}, TransactionMode);
|
||||
}
|
||||
},
|
||||
TransactionMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,28 +166,25 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
var guidId = displayPreferencesId.GetMD5();
|
||||
|
||||
using (WriteLock.Read())
|
||||
using (var connection = GetConnection(true))
|
||||
{
|
||||
using (var connection = CreateConnection(true))
|
||||
using (var statement = connection.PrepareStatement("select data from userdisplaypreferences where id = @id and userId=@userId and client=@client"))
|
||||
{
|
||||
using (var statement = connection.PrepareStatement("select data from userdisplaypreferences where id = @id and userId=@userId and client=@client"))
|
||||
{
|
||||
statement.TryBind("@id", guidId.ToGuidBlob());
|
||||
statement.TryBind("@userId", userId.ToGuidBlob());
|
||||
statement.TryBind("@client", client);
|
||||
statement.TryBind("@id", guidId.ToGuidBlob());
|
||||
statement.TryBind("@userId", userId.ToGuidBlob());
|
||||
statement.TryBind("@client", client);
|
||||
|
||||
foreach (var row in statement.ExecuteQuery())
|
||||
{
|
||||
return Get(row);
|
||||
}
|
||||
foreach (var row in statement.ExecuteQuery())
|
||||
{
|
||||
return Get(row);
|
||||
}
|
||||
|
||||
return new DisplayPreferences
|
||||
{
|
||||
Id = guidId.ToString("N")
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return new DisplayPreferences
|
||||
{
|
||||
Id = guidId.ToString("N", CultureInfo.InvariantCulture)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -208,18 +197,15 @@ namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
var list = new List<DisplayPreferences>();
|
||||
|
||||
using (WriteLock.Read())
|
||||
using (var connection = GetConnection(true))
|
||||
{
|
||||
using (var connection = CreateConnection(true))
|
||||
using (var statement = connection.PrepareStatement("select data from userdisplaypreferences where userId=@userId"))
|
||||
{
|
||||
using (var statement = connection.PrepareStatement("select data from userdisplaypreferences where userId=@userId"))
|
||||
{
|
||||
statement.TryBind("@userId", userId.ToGuidBlob());
|
||||
statement.TryBind("@userId", userId.ToGuidBlob());
|
||||
|
||||
foreach (var row in statement.ExecuteQuery())
|
||||
{
|
||||
list.Add(Get(row));
|
||||
}
|
||||
foreach (var row in statement.ExecuteQuery())
|
||||
{
|
||||
list.Add(Get(row));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,22 +214,12 @@ namespace Emby.Server.Implementations.Data
|
||||
}
|
||||
|
||||
private DisplayPreferences Get(IReadOnlyList<IResultSetValue> row)
|
||||
{
|
||||
using (var stream = new MemoryStream(row[0].ToBlob()))
|
||||
{
|
||||
stream.Position = 0;
|
||||
return _jsonSerializer.DeserializeFromStream<DisplayPreferences>(stream);
|
||||
}
|
||||
}
|
||||
=> _jsonSerializer.DeserializeFromString<DisplayPreferences>(row.GetString(0));
|
||||
|
||||
public void SaveDisplayPreferences(DisplayPreferences displayPreferences, string userId, string client, CancellationToken cancellationToken)
|
||||
{
|
||||
SaveDisplayPreferences(displayPreferences, new Guid(userId), client, cancellationToken);
|
||||
}
|
||||
=> SaveDisplayPreferences(displayPreferences, new Guid(userId), client, cancellationToken);
|
||||
|
||||
public DisplayPreferences GetDisplayPreferences(string displayPreferencesId, string userId, string client)
|
||||
{
|
||||
return GetDisplayPreferences(displayPreferencesId, new Guid(userId), client);
|
||||
}
|
||||
=> GetDisplayPreferences(displayPreferencesId, new Guid(userId), client);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,6 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
connection.RunInTransaction(conn =>
|
||||
{
|
||||
//foreach (var query in queries)
|
||||
//{
|
||||
// conn.Execute(query);
|
||||
//}
|
||||
conn.ExecuteAll(string.Join(";", queries));
|
||||
});
|
||||
}
|
||||
@@ -38,7 +34,8 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
public static Guid ReadGuidFromBlob(this IResultSetValue result)
|
||||
{
|
||||
return new Guid(result.ToBlob());
|
||||
// TODO: Remove ToArray when upgrading to netstandard2.1
|
||||
return new Guid(result.ToBlob().ToArray());
|
||||
}
|
||||
|
||||
public static string ToDateTimeParamValue(this DateTime dateValue)
|
||||
@@ -141,7 +138,7 @@ namespace Emby.Server.Implementations.Data
|
||||
}
|
||||
}
|
||||
|
||||
public static void Attach(ManagedConnection db, string path, string alias)
|
||||
public static void Attach(SQLiteDatabaseConnection db, string path, string alias)
|
||||
{
|
||||
var commandText = string.Format("attach @path as {0};", alias);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,6 @@ using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.IO;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SQLitePCL.pretty;
|
||||
|
||||
@@ -33,19 +32,19 @@ namespace Emby.Server.Implementations.Data
|
||||
/// Opens the connection to the database
|
||||
/// </summary>
|
||||
/// <returns>Task.</returns>
|
||||
public void Initialize(ReaderWriterLockSlim writeLock, ManagedConnection managedConnection, IUserManager userManager)
|
||||
public void Initialize(IUserManager userManager, SemaphoreSlim dbLock, SQLiteDatabaseConnection dbConnection)
|
||||
{
|
||||
_connection = managedConnection;
|
||||
|
||||
WriteLock.Dispose();
|
||||
WriteLock = writeLock;
|
||||
WriteLock = dbLock;
|
||||
WriteConnection?.Dispose();
|
||||
WriteConnection = dbConnection;
|
||||
|
||||
using (var connection = CreateConnection())
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
var userDatasTableExists = TableExists(connection, "UserDatas");
|
||||
var userDataTableExists = TableExists(connection, "userdata");
|
||||
|
||||
var users = userDatasTableExists ? null : userManager.Users.ToArray();
|
||||
var users = userDatasTableExists ? null : userManager.Users;
|
||||
|
||||
connection.RunInTransaction(db =>
|
||||
{
|
||||
@@ -85,7 +84,7 @@ namespace Emby.Server.Implementations.Data
|
||||
}
|
||||
}
|
||||
|
||||
private void ImportUserIds(IDatabaseConnection db, User[] users)
|
||||
private void ImportUserIds(IDatabaseConnection db, IEnumerable<User> users)
|
||||
{
|
||||
var userIdsWithUserData = GetAllUserIdsWithUserData(db);
|
||||
|
||||
@@ -129,8 +128,6 @@ namespace Emby.Server.Implementations.Data
|
||||
return list;
|
||||
}
|
||||
|
||||
protected override bool EnableTempStoreMemory => true;
|
||||
|
||||
/// <summary>
|
||||
/// Saves the user data.
|
||||
/// </summary>
|
||||
@@ -178,15 +175,12 @@ namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
using (WriteLock.Write())
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
using (var connection = CreateConnection())
|
||||
connection.RunInTransaction(db =>
|
||||
{
|
||||
connection.RunInTransaction(db =>
|
||||
{
|
||||
SaveUserData(db, internalUserId, key, userData);
|
||||
}, TransactionMode);
|
||||
}
|
||||
SaveUserData(db, internalUserId, key, userData);
|
||||
}, TransactionMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,18 +243,15 @@ namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
using (WriteLock.Write())
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
using (var connection = CreateConnection())
|
||||
connection.RunInTransaction(db =>
|
||||
{
|
||||
connection.RunInTransaction(db =>
|
||||
foreach (var userItemData in userDataList)
|
||||
{
|
||||
foreach (var userItemData in userDataList)
|
||||
{
|
||||
SaveUserData(db, internalUserId, userItemData.Key, userItemData);
|
||||
}
|
||||
}, TransactionMode);
|
||||
}
|
||||
SaveUserData(db, internalUserId, userItemData.Key, userItemData);
|
||||
}
|
||||
}, TransactionMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,28 +272,26 @@ namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
throw new ArgumentNullException(nameof(internalUserId));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
using (WriteLock.Read())
|
||||
using (var connection = GetConnection(true))
|
||||
{
|
||||
using (var connection = CreateConnection(true))
|
||||
using (var statement = connection.PrepareStatement("select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from UserDatas where key =@Key and userId=@UserId"))
|
||||
{
|
||||
using (var statement = connection.PrepareStatement("select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from UserDatas where key =@Key and userId=@UserId"))
|
||||
statement.TryBind("@UserId", internalUserId);
|
||||
statement.TryBind("@Key", key);
|
||||
|
||||
foreach (var row in statement.ExecuteQuery())
|
||||
{
|
||||
statement.TryBind("@UserId", internalUserId);
|
||||
statement.TryBind("@Key", key);
|
||||
|
||||
foreach (var row in statement.ExecuteQuery())
|
||||
{
|
||||
return ReadRow(row);
|
||||
}
|
||||
return ReadRow(row);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,18 +324,15 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
var list = new List<UserItemData>();
|
||||
|
||||
using (WriteLock.Read())
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
using (var connection = CreateConnection())
|
||||
using (var statement = connection.PrepareStatement("select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from UserDatas where userId=@UserId"))
|
||||
{
|
||||
using (var statement = connection.PrepareStatement("select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from UserDatas where userId=@UserId"))
|
||||
{
|
||||
statement.TryBind("@UserId", internalUserId);
|
||||
statement.TryBind("@UserId", internalUserId);
|
||||
|
||||
foreach (var row in statement.ExecuteQuery())
|
||||
{
|
||||
list.Add(ReadRow(row));
|
||||
}
|
||||
foreach (var row in statement.ExecuteQuery())
|
||||
{
|
||||
list.Add(ReadRow(row));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -392,15 +378,5 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
return userData;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool dispose)
|
||||
{
|
||||
// handled by library database
|
||||
}
|
||||
|
||||
protected override void CloseConnection()
|
||||
{
|
||||
// handled by library database
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace Emby.Server.Implementations.Data
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
|
||||
public SqliteUserRepository(
|
||||
ILoggerFactory loggerFactory,
|
||||
ILogger<SqliteUserRepository> logger,
|
||||
IServerApplicationPaths appPaths,
|
||||
IJsonSerializer jsonSerializer)
|
||||
: base(loggerFactory.CreateLogger(nameof(SqliteUserRepository)))
|
||||
: base(logger)
|
||||
{
|
||||
_jsonSerializer = jsonSerializer;
|
||||
|
||||
@@ -35,15 +35,12 @@ namespace Emby.Server.Implementations.Data
|
||||
public string Name => "SQLite";
|
||||
|
||||
/// <summary>
|
||||
/// Opens the connection to the database
|
||||
/// Opens the connection to the database.
|
||||
/// </summary>
|
||||
/// <returns>Task.</returns>
|
||||
public void Initialize()
|
||||
{
|
||||
using (var connection = CreateConnection())
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
RunDefaultInitialization(connection);
|
||||
|
||||
var localUsersTableExists = TableExists(connection, "LocalUsersv2");
|
||||
|
||||
connection.RunQueries(new[] {
|
||||
@@ -56,7 +53,7 @@ namespace Emby.Server.Implementations.Data
|
||||
TryMigrateToLocalUsersTable(connection);
|
||||
}
|
||||
|
||||
RemoveEmptyPasswordHashes();
|
||||
RemoveEmptyPasswordHashes(connection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,9 +72,9 @@ namespace Emby.Server.Implementations.Data
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveEmptyPasswordHashes()
|
||||
private void RemoveEmptyPasswordHashes(ManagedConnection connection)
|
||||
{
|
||||
foreach (var user in RetrieveAllUsers())
|
||||
foreach (var user in RetrieveAllUsers(connection))
|
||||
{
|
||||
// If the user password is the sha1 hash of the empty string, remove it
|
||||
if (!string.Equals(user.Password, "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709", StringComparison.Ordinal)
|
||||
@@ -89,22 +86,16 @@ namespace Emby.Server.Implementations.Data
|
||||
user.Password = null;
|
||||
var serialized = _jsonSerializer.SerializeToBytes(user);
|
||||
|
||||
using (WriteLock.Write())
|
||||
using (var connection = CreateConnection())
|
||||
connection.RunInTransaction(db =>
|
||||
{
|
||||
connection.RunInTransaction(db =>
|
||||
using (var statement = db.PrepareStatement("update LocalUsersv2 set data=@data where Id=@InternalId"))
|
||||
{
|
||||
using (var statement = db.PrepareStatement("update LocalUsersv2 set data=@data where Id=@InternalId"))
|
||||
{
|
||||
statement.TryBind("@InternalId", user.InternalId);
|
||||
statement.TryBind("@data", serialized);
|
||||
statement.MoveNext();
|
||||
}
|
||||
|
||||
}, TransactionMode);
|
||||
}
|
||||
statement.TryBind("@InternalId", user.InternalId);
|
||||
statement.TryBind("@data", serialized);
|
||||
statement.MoveNext();
|
||||
}
|
||||
}, TransactionMode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -119,31 +110,28 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
var serialized = _jsonSerializer.SerializeToBytes(user);
|
||||
|
||||
using (WriteLock.Write())
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
using (var connection = CreateConnection())
|
||||
connection.RunInTransaction(db =>
|
||||
{
|
||||
connection.RunInTransaction(db =>
|
||||
using (var statement = db.PrepareStatement("insert into LocalUsersv2 (guid, data) values (@guid, @data)"))
|
||||
{
|
||||
using (var statement = db.PrepareStatement("insert into LocalUsersv2 (guid, data) values (@guid, @data)"))
|
||||
{
|
||||
statement.TryBind("@guid", user.Id.ToGuidBlob());
|
||||
statement.TryBind("@data", serialized);
|
||||
statement.TryBind("@guid", user.Id.ToGuidBlob());
|
||||
statement.TryBind("@data", serialized);
|
||||
|
||||
statement.MoveNext();
|
||||
}
|
||||
statement.MoveNext();
|
||||
}
|
||||
|
||||
var createdUser = GetUser(user.Id, false);
|
||||
var createdUser = GetUser(user.Id, connection);
|
||||
|
||||
if (createdUser == null)
|
||||
{
|
||||
throw new ApplicationException("created user should never be null");
|
||||
}
|
||||
if (createdUser == null)
|
||||
{
|
||||
throw new ApplicationException("created user should never be null");
|
||||
}
|
||||
|
||||
user.InternalId = createdUser.InternalId;
|
||||
user.InternalId = createdUser.InternalId;
|
||||
|
||||
}, TransactionMode);
|
||||
}
|
||||
}, TransactionMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,39 +144,30 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
var serialized = _jsonSerializer.SerializeToBytes(user);
|
||||
|
||||
using (WriteLock.Write())
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
using (var connection = CreateConnection())
|
||||
connection.RunInTransaction(db =>
|
||||
{
|
||||
connection.RunInTransaction(db =>
|
||||
using (var statement = db.PrepareStatement("update LocalUsersv2 set data=@data where Id=@InternalId"))
|
||||
{
|
||||
using (var statement = db.PrepareStatement("update LocalUsersv2 set data=@data where Id=@InternalId"))
|
||||
{
|
||||
statement.TryBind("@InternalId", user.InternalId);
|
||||
statement.TryBind("@data", serialized);
|
||||
statement.MoveNext();
|
||||
}
|
||||
statement.TryBind("@InternalId", user.InternalId);
|
||||
statement.TryBind("@data", serialized);
|
||||
statement.MoveNext();
|
||||
}
|
||||
|
||||
}, TransactionMode);
|
||||
}
|
||||
}, TransactionMode);
|
||||
}
|
||||
}
|
||||
|
||||
private User GetUser(Guid guid, bool openLock)
|
||||
private User GetUser(Guid guid, ManagedConnection connection)
|
||||
{
|
||||
using (openLock ? WriteLock.Read() : null)
|
||||
using (var statement = connection.PrepareStatement("select id,guid,data from LocalUsersv2 where guid=@guid"))
|
||||
{
|
||||
using (var connection = CreateConnection(true))
|
||||
{
|
||||
using (var statement = connection.PrepareStatement("select id,guid,data from LocalUsersv2 where guid=@guid"))
|
||||
{
|
||||
statement.TryBind("@guid", guid);
|
||||
statement.TryBind("@guid", guid);
|
||||
|
||||
foreach (var row in statement.ExecuteQuery())
|
||||
{
|
||||
return GetUser(row);
|
||||
}
|
||||
}
|
||||
foreach (var row in statement.ExecuteQuery())
|
||||
{
|
||||
return GetUser(row);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,14 +179,10 @@ namespace Emby.Server.Implementations.Data
|
||||
var id = row[0].ToInt64();
|
||||
var guid = row[1].ReadGuidFromBlob();
|
||||
|
||||
using (var stream = new MemoryStream(row[2].ToBlob()))
|
||||
{
|
||||
stream.Position = 0;
|
||||
var user = _jsonSerializer.DeserializeFromStream<User>(stream);
|
||||
user.InternalId = id;
|
||||
user.Id = guid;
|
||||
return user;
|
||||
}
|
||||
var user = _jsonSerializer.DeserializeFromString<User>(row.GetString(2));
|
||||
user.InternalId = id;
|
||||
user.Id = guid;
|
||||
return user;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -216,20 +191,22 @@ namespace Emby.Server.Implementations.Data
|
||||
/// <returns>IEnumerable{User}.</returns>
|
||||
public List<User> RetrieveAllUsers()
|
||||
{
|
||||
var list = new List<User>();
|
||||
|
||||
using (WriteLock.Read())
|
||||
using (var connection = GetConnection(true))
|
||||
{
|
||||
using (var connection = CreateConnection(true))
|
||||
{
|
||||
foreach (var row in connection.Query("select id,guid,data from LocalUsersv2"))
|
||||
{
|
||||
list.Add(GetUser(row));
|
||||
}
|
||||
}
|
||||
return new List<User>(RetrieveAllUsers(connection));
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
/// <summary>
|
||||
/// Retrieve all users from the database
|
||||
/// </summary>
|
||||
/// <returns>IEnumerable{User}.</returns>
|
||||
private IEnumerable<User> RetrieveAllUsers(ManagedConnection connection)
|
||||
{
|
||||
foreach (var row in connection.Query("select id,guid,data from LocalUsersv2"))
|
||||
{
|
||||
yield return GetUser(row);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -245,19 +222,16 @@ namespace Emby.Server.Implementations.Data
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
using (WriteLock.Write())
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
using (var connection = CreateConnection())
|
||||
connection.RunInTransaction(db =>
|
||||
{
|
||||
connection.RunInTransaction(db =>
|
||||
using (var statement = db.PrepareStatement("delete from LocalUsersv2 where Id=@id"))
|
||||
{
|
||||
using (var statement = db.PrepareStatement("delete from LocalUsersv2 where Id=@id"))
|
||||
{
|
||||
statement.TryBind("@id", user.InternalId);
|
||||
statement.MoveNext();
|
||||
}
|
||||
}, TransactionMode);
|
||||
}
|
||||
statement.TryBind("@id", user.InternalId);
|
||||
statement.MoveNext();
|
||||
}
|
||||
}, TransactionMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user