Compare commits
661 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| de86c861d8 | |||
| af3b8a2a6b | |||
| 47d3d786ca | |||
| 1c755b4bd5 | |||
| 0cece2b194 | |||
| 840fc610f0 | |||
| 6e55fe9f34 | |||
| 1620b8e4c4 | |||
| f798bd3d8b | |||
| 65850f158c | |||
| 8f5991e65f | |||
| 5492e1df35 | |||
| 93fbd8768b | |||
| 246f079905 | |||
| b25285fcc2 | |||
| 7a2b31d328 | |||
| a4ac847f0d | |||
| 6b632b5502 | |||
| 86e1345684 | |||
| b91de0e442 | |||
| 62e47aac4c | |||
| 43fb92ac82 | |||
| de5ecb570f | |||
| 014c851a03 | |||
| eae07b1d3b | |||
| df06736722 | |||
| 25b90a0993 | |||
| ad1b58bf53 | |||
| 259118e48b | |||
| 145ac6bb12 | |||
| 7b581ff917 | |||
| 62423f8156 | |||
| 5fd539445e | |||
| 7c756cccef | |||
| 786826b434 | |||
| 56f41999b5 | |||
| 7423cf89ab | |||
| 8c6ee20b30 | |||
| 17ffa1acc0 | |||
| cec95c9f0a | |||
| eaf3d46e24 | |||
| c30badabbf | |||
| 40cdecc820 | |||
| 3c1088b6d6 | |||
| ac9a4c8f48 | |||
| b79ab2ee3f | |||
| ceef11bca6 | |||
| 5ce80eddb6 | |||
| 8bc3e229d7 | |||
| f939ce138c | |||
| ad89281927 | |||
| c9ae9e6b32 | |||
| ce7dd57d36 | |||
| 43ed1f8e3f | |||
| 9d1e796a20 | |||
| 80bfe5f979 | |||
| 13ee214026 | |||
| 08e38d752a | |||
| aef4d4ffee | |||
| a1b2c70fdd | |||
| c9b4525baf | |||
| 0b0666912e | |||
| 9dbb5681f7 | |||
| eaa7bdd736 | |||
| 0a65bbae5d | |||
| 82cfc1cabb | |||
| f4402ac57b | |||
| f6514f85dc | |||
| 1cf4c0ce39 | |||
| 3ffe7a63e9 | |||
| a532d9d209 | |||
| 9c1f2f6662 | |||
| 0b9ef9ff4c | |||
| 35f25abd8a | |||
| 70bed8c006 | |||
| dcfad6a3c0 | |||
| e7d1540b72 | |||
| 4bc09d74ff | |||
| 7ab45498e6 | |||
| da7ffd9c12 | |||
| b5d7ec111d | |||
| 9077eb836c | |||
| 6f3c2666ca | |||
| eaa3170f01 | |||
| 7e1c425676 | |||
| 7df980f881 | |||
| 7f0259e9cc | |||
| c7b2f99c43 | |||
| 4534238216 | |||
| 2085ef3063 | |||
| 7d3d69eae5 | |||
| 5c129e050b | |||
| 73163de408 | |||
| f18bdc4375 | |||
| 2d9a226378 | |||
| 6cd4094159 | |||
| d4c43ece23 | |||
| 9ac8d5d2bf | |||
| 049ef746f4 | |||
| 83d26211a0 | |||
| 680641707e | |||
| 27d4e092cf | |||
| 5b477b9e9e | |||
| eb332b70e0 | |||
| 824df9cae2 | |||
| 1fc73f324c | |||
| 8dcdb1f8a3 | |||
| 4fe1d1ea66 | |||
| 93b6f8c7b6 | |||
| a33e7c3903 | |||
| 4ea0180781 | |||
| 1d4850d7fb | |||
| cf77e6633e | |||
| c692fdf6c3 | |||
| 1901b177cc | |||
| ce60d77c8d | |||
| fbe1d43488 | |||
| ee8e75513d | |||
| f094fd1e7f | |||
| 14c30e0e58 | |||
| 872f1b9284 | |||
| 5680512573 | |||
| 2f6a43d98a | |||
| 1142c2c501 | |||
| c1502c0230 | |||
| 55cf680b0c | |||
| 6c0d0cdf74 | |||
| 32ad030838 | |||
| 9811c18407 | |||
| a9c6e01294 | |||
| b904d6aaec | |||
| 78958d925a | |||
| afba340028 | |||
| ec4b24149f | |||
| 8e1bd8596f | |||
| f8785f8db8 | |||
| c508c1dd1a | |||
| c78b593afa | |||
| 1b906804de | |||
| 62561e9826 | |||
| cbb9798174 | |||
| 2de6b6a1cc | |||
| 5893d1492e | |||
| 5906f29180 | |||
| 9b838e496e | |||
| 106a1fa9eb | |||
| ecfb2371f4 | |||
| fe3ae95a22 | |||
| 4ae352d5d2 | |||
| 67d56fc5ab | |||
| 039f9eb092 | |||
| df67e52e47 | |||
| e3f7c48f80 | |||
| 57b67ea55c | |||
| 21c3eb475f | |||
| 805f9435f3 | |||
| 213261fbbb | |||
| ceda93a8cf | |||
| 39ec4f863d | |||
| 4d9188221f | |||
| 30c8085964 | |||
| 97206279d8 | |||
| 8d3c8f4ad1 | |||
| bf4075ba1c | |||
| 5f5892242b | |||
| 29602d9fa2 | |||
| f2f1f963d4 | |||
| 56219c8fe4 | |||
| ba211c1360 | |||
| 2870a42cd4 | |||
| f8a2188760 | |||
| 5c4020a52f | |||
| 4c060366b8 | |||
| af219bde11 | |||
| caa279ce36 | |||
| 4651229a0d | |||
| 6c8916a9e6 | |||
| 8d831e2c9d | |||
| 1f3b4f5624 | |||
| 04c8afe616 | |||
| e53aed0910 | |||
| 520b63a8de | |||
| 0e4aa730eb | |||
| 07c7ddccad | |||
| 5ff7252ee9 | |||
| 5461e74539 | |||
| 417484cb6d | |||
| 9aaffd3550 | |||
| 94759d48c7 | |||
| c0e343b696 | |||
| f18ac7c444 | |||
| f637610734 | |||
| 5e1046dd5b | |||
| f25584cb2f | |||
| 03999585d0 | |||
| 772c2b0300 | |||
| 3622e67a56 | |||
| c51630cdd6 | |||
| dab1c55a93 | |||
| 7b966bc988 | |||
| e5e46bee38 | |||
| 3365d96a03 | |||
| fb223cd493 | |||
| 60d49c4773 | |||
| e7aa4ae147 | |||
| c45be41ddc | |||
| 85b37facee | |||
| 90567009ef | |||
| 899afc156e | |||
| 9e33b7e488 | |||
| e7ba60a51f | |||
| 2a3ad325c2 | |||
| 7575b80d31 | |||
| 8bb9d119b5 | |||
| 5da3f2b1c7 | |||
| da6cbcfb75 | |||
| 3d7aff41ee | |||
| 2cc49e8679 | |||
| 0e961c0647 | |||
| 4d5757a6ce | |||
| 62ae0e5075 | |||
| 7513fe2882 | |||
| c945dc8360 | |||
| de7e0da045 | |||
| a706429395 | |||
| f26c9761c3 | |||
| 9424dd4c0e | |||
| 271294a8e7 | |||
| 6b2786292f | |||
| c36247b5e1 | |||
| c182afff2c | |||
| 1129d70dca | |||
| bde71d13f9 | |||
| 67b513d380 | |||
| 8d8d1ee238 | |||
| 7c10715607 | |||
| a939f06fcd | |||
| c50625b0c8 | |||
| bfa2d88935 | |||
| b04ea61e83 | |||
| 2a42a02f3d | |||
| 1e80278a1d | |||
| f38d9156c5 | |||
| 0f32864079 | |||
| f8fbecebc9 | |||
| 40c5656080 | |||
| ddf36a7091 | |||
| 258c67554d | |||
| 007ff31200 | |||
| ff75e3d94b | |||
| aaa18e0048 | |||
| 5c6f89a067 | |||
| c4efc4c293 | |||
| 2d955257e6 | |||
| 3cf84a2992 | |||
| 94a795fe69 | |||
| cc10ae8b2e | |||
| 63ed7cdaca | |||
| 064919e0a2 | |||
| 31b2652c9b | |||
| d080d709d1 | |||
| 0c301c79f2 | |||
| a1dbb6234f | |||
| 30248194af | |||
| 8f54ebeb3a | |||
| d8ef0b9eee | |||
| 6a3bfd071a | |||
| 849df04c05 | |||
| a40ae5ef82 | |||
| 00c535665f | |||
| 8b4a4d8ff8 | |||
| f9fecd541c | |||
| 93b1028498 | |||
| a0a3dba188 | |||
| 92ded00495 | |||
| bcbe258f60 | |||
| 660f9c7c9b | |||
| 8c5ef29894 | |||
| 612fc4c533 | |||
| 635377d227 | |||
| dc86ab8f4c | |||
| 36b63ad916 | |||
| e1b378811d | |||
| 37fb9bba75 | |||
| 848253c678 | |||
| b64e779ed1 | |||
| 046a62cde3 | |||
| 1a9e6efb90 | |||
| fd422c15ba | |||
| c338f76f8d | |||
| 4285b3f4f7 | |||
| d0109869a6 | |||
| d29ad44c54 | |||
| be61b07fea | |||
| e5e171fb6f | |||
| 805d97c3ca | |||
| 040222f259 | |||
| 09ed55eba4 | |||
| a6d4f8cf98 | |||
| d19b2394e8 | |||
| 036a99d84d | |||
| b022335af7 | |||
| a66c20c9d5 | |||
| f9fc135647 | |||
| fbbee9c114 | |||
| a65fbcbaf8 | |||
| 39b68b71d4 | |||
| 4d12a0a937 | |||
| 960973302e | |||
| 1a68b00bdd | |||
| dba73fc473 | |||
| 211f7314ce | |||
| 64d719a63a | |||
| 0304e6b569 | |||
| 190447a0bd | |||
| 497d1265f0 | |||
| 6d459e0692 | |||
| 45cde40cea | |||
| e9deb4c7f7 | |||
| 1abfc763dc | |||
| b84ddcc88d | |||
| 33f7951901 | |||
| d3354f9109 | |||
| d252816cc3 | |||
| 6e31904e95 | |||
| 2825d1f4c7 | |||
| fcb10c6137 | |||
| f564739578 | |||
| 40faf4b383 | |||
| affff353bd | |||
| f410fabff7 | |||
| 7d4b201b6e | |||
| a9ac0aa16b | |||
| 5419970080 | |||
| 506a573180 | |||
| 17b2450b43 | |||
| 2942e65a54 | |||
| 913a7bd9e5 | |||
| c5f2edd9de | |||
| 24d511e6b6 | |||
| 47f3336f9a | |||
| e0e6e5dbed | |||
| aa7f3e7bf7 | |||
| 065a6c45f7 | |||
| b13174dda1 | |||
| 9e6a931a41 | |||
| cdabdfd2f8 | |||
| b4cdbd7547 | |||
| 75fe603919 | |||
| 16ef9ae642 | |||
| 7db3162748 | |||
| 3f0e6d9856 | |||
| d87fc4a400 | |||
| ec6241b79e | |||
| 9b37398e9f | |||
| 3fca8694ee | |||
| 78efffa29b | |||
| 737ecbdadd | |||
| fa6ce22ea7 | |||
| 315c55c844 | |||
| d9ba60e1a5 | |||
| 7503322d01 | |||
| 2e5f2dc687 | |||
| e4afd27908 | |||
| 6fe5d5523e | |||
| 7335946ec2 | |||
| eb4576de9b | |||
| 1e41a9ee99 | |||
| dd5226ab47 | |||
| 989e5535eb | |||
| 65efeed692 | |||
| fcddb2d382 | |||
| bbc892ec81 | |||
| ca1c2821a7 | |||
| c8d4f763fd | |||
| a3d587af44 | |||
| ce2146cc89 | |||
| 8455f17517 | |||
| c075bdd4f9 | |||
| 65d88d0896 | |||
| 1c62640301 | |||
| dd6684c550 | |||
| 2e1a753583 | |||
| cbf6e4ecfb | |||
| 5af471fe1a | |||
| 0deb205faa | |||
| 73eaf0ecaa | |||
| 4791defbdd | |||
| 926249184b | |||
| 659b2755ef | |||
| e9d36edaa4 | |||
| fdcdbf27eb | |||
| 2f5cc2eb80 | |||
| c087fa4956 | |||
| ed33ec6532 | |||
| 2d96c2730c | |||
| 5bcec10be3 | |||
| 207bd15b14 | |||
| 00f0bfc84b | |||
| 7bc3f83c88 | |||
| 1af2803c22 | |||
| fd6a81abfd | |||
| a383093914 | |||
| 13656429af | |||
| bc34881b38 | |||
| e3b11cb087 | |||
| 8df78ca377 | |||
| f12919c6bc | |||
| 00df324ae7 | |||
| f14f9ffc1b | |||
| a388b725bc | |||
| e64eaeefef | |||
| 6830d69b62 | |||
| 8f609a8e93 | |||
| 99c23f47c5 | |||
| 95f9e20f39 | |||
| df1e664bc9 | |||
| fec30a6453 | |||
| a048211486 | |||
| 465e9b2988 | |||
| af1ff19cb2 | |||
| eae470f2ec | |||
| 1933799e32 | |||
| c7977bf7b4 | |||
| ce8407ce46 | |||
| 5d313df190 | |||
| c560a09904 | |||
| df66a92989 | |||
| 52c9611e49 | |||
| 4018112a1d | |||
| 633a257e65 | |||
| 0666d41226 | |||
| c2cfe55e24 | |||
| cb7fbddd7a | |||
| 135d9fed1b | |||
| 267aedc594 | |||
| 325d0da930 | |||
| 615bc74d15 | |||
| 1ca6935d36 | |||
| 3bfb7139d3 | |||
| 14d44765e5 | |||
| 807dd2d920 | |||
| c9a0a7f7c2 | |||
| a3eea6d501 | |||
| 4ce7dcac1b | |||
| 096762f24c | |||
| baf358d223 | |||
| e72973346b | |||
| 41258ecee8 | |||
| b6a5be152a | |||
| d5d45c4935 | |||
| 81eb4ecf09 | |||
| 5a4cc8c449 | |||
| e7ab664310 | |||
| 3cb2fa27b9 | |||
| e29e41aa4c | |||
| cc62613640 | |||
| 2720bcc685 | |||
| c8ac4182fc | |||
| 55b70d3e6d | |||
| a19765b0d3 | |||
| 5c7b65385a | |||
| b6b84269a3 | |||
| e44cb249d0 | |||
| 8bea071865 | |||
| a782652fca | |||
| 3a02803d3c | |||
| 263a08ab4c | |||
| ecdbd985ce | |||
| dd403564cc | |||
| 69d741b39a | |||
| 4c9c2e2d68 | |||
| 8660701340 | |||
| 341c5570af | |||
| ee12753818 | |||
| 055638278c | |||
| bf06ff6482 | |||
| 459a5bc5b7 | |||
| a93f18037c | |||
| 67b5218002 | |||
| d3c745dda4 | |||
| e694818f8f | |||
| 729d7645e1 | |||
| 795e21df9c | |||
| bdc15e6c50 | |||
| c3398ec572 | |||
| 6b38b348fc | |||
| d650529842 | |||
| 2094408f52 | |||
| 89cb8b3a3a | |||
| 7a2d546972 | |||
| 69e801ba2b | |||
| 14edc27ed1 | |||
| 6f7fa7f067 | |||
| a5a1c02e10 | |||
| ce08cbce4b | |||
| e03a5d38bb | |||
| 720db5a476 | |||
| e97783b08e | |||
| 12566f8668 | |||
| d686819417 | |||
| ea7b4a77af | |||
| 6427a06879 | |||
| f2f7a50e95 | |||
| fbc57ebfca | |||
| 26a5681dab | |||
| 4640ff51e8 | |||
| b3b58680e0 | |||
| d1b75df87d | |||
| 4b4e1b9f54 | |||
| 8ebb550270 | |||
| 6b93954246 | |||
| 550d7ebd4b | |||
| 3f331e5d3d | |||
| 020f921af8 | |||
| efa72ce12b | |||
| 38ead633a5 | |||
| 3eb1d0ae99 | |||
| 7bed4ed335 | |||
| b357d41f23 | |||
| 3834603b0a | |||
| f38ba108a3 | |||
| 7ceda3d73f | |||
| aee57b6f98 | |||
| f9d49bd55f | |||
| 3bb082473a | |||
| 31b6726fe5 | |||
| 348b41b0dd | |||
| d4bbfa0516 | |||
| b2af9b3d25 | |||
| ded93a4f0b | |||
| d43f57565b | |||
| 34cf661fb2 | |||
| 91cfb883b6 | |||
| 1cb7deb376 | |||
| 70933c63bb | |||
| 5723b9edd0 | |||
| 65f37a9c66 | |||
| 57516793ab | |||
| afecc5ac12 | |||
| 3331564155 | |||
| 19ce7b9906 | |||
| 40f39340f0 | |||
| f085bcacf7 | |||
| dbd4e73b6e | |||
| b35e6b3315 | |||
| 3c603a67dd | |||
| 8ff5abf5d8 | |||
| 0fdbd39393 | |||
| df93770128 | |||
| b61a935068 | |||
| 95e96b1057 | |||
| 3dd325a280 | |||
| bbe922df74 | |||
| e31eddfd2e | |||
| bbb9f5798b | |||
| b634cf056d | |||
| 2ede22b50a | |||
| a4efd83f7a | |||
| c3ebced763 | |||
| 6cb6621df1 | |||
| 4e5febba8b | |||
| 1fb787d4ea | |||
| f24ddaa55e | |||
| 66542a0003 | |||
| f8a8e1d3e6 | |||
| c1873b8c6d | |||
| 07dceb2704 | |||
| ceec042ffd | |||
| 2a47f255ee | |||
| 1f899e6c6d | |||
| f0686bb18c | |||
| b321dc06e9 | |||
| 5f7c6e846b | |||
| 2d71475a48 | |||
| cfdeb4a1a8 | |||
| 5d3abdefdc | |||
| abcff22f3e | |||
| 7d4ca4d758 | |||
| 9b44b2f31f | |||
| 55bd8da894 | |||
| e8c7abaa2f | |||
| 1702b9beac | |||
| de25052980 | |||
| 03700ed4bb | |||
| e0147a4a6e | |||
| 281fd07e23 | |||
| 1d7a0e62e5 | |||
| e4dcdb9422 | |||
| f035bb09b4 | |||
| 869c6497e9 | |||
| 151ed1ce0d | |||
| bab349da9b | |||
| ac8f9d2955 | |||
| 0f2670069f | |||
| 0af3d32337 | |||
| f5a22f8393 | |||
| 769a82e7ed | |||
| 3985af0042 | |||
| dca0e0a84b | |||
| 233296ba3e | |||
| 2bc4fe0592 | |||
| c22245e296 | |||
| 29de2fc81c | |||
| bd27aefe8a | |||
| 722cabba57 | |||
| 3468c8d5e6 | |||
| b3cc83f8cd | |||
| f6a1ca03ac | |||
| 516ac72c3e | |||
| c068bde0a8 | |||
| ca3ed53a59 | |||
| 04c05ee15e | |||
| 60d27be739 | |||
| 259fe5f447 | |||
| 8d9b7fc9dc | |||
| d5d282147d | |||
| 08f7f66154 | |||
| f702f847e6 | |||
| b9b87cf354 | |||
| a81b9a37ab | |||
| 64174ef374 | |||
| a8b3a9ee1a | |||
| 7be1a7907d | |||
| 05d207f34d | |||
| 26be46b038 | |||
| 47826f1f72 | |||
| f7428f811a | |||
| 3aa8577a38 | |||
| 8b7965dbcb | |||
| 006cb4b13c | |||
| ecb8d6b387 | |||
| b57b05fe1d | |||
| 1e9969857d | |||
| af89dd2694 | |||
| e418e05ab1 | |||
| a8d8a7aca7 | |||
| 4c7226cda1 | |||
| 91b5ee4423 | |||
| f8d7148b9e | |||
| 0f0687b5c9 | |||
| 1384cd4c6e | |||
| 4c5c78d0e4 | |||
| 551abb4496 | |||
| 8af8824c3e | |||
| c01c085ac1 | |||
| 8668acdd6d | |||
| 03567ed36d | |||
| dcfea2cfb3 | |||
| 3c4e6c8240 | |||
| 9e93426c38 | |||
| 5c698e2e9b | |||
| b174e14fbd | |||
| 19e84cd415 | |||
| 73a9b3fd72 | |||
| 64a938879d | |||
| 66b9a9677b | |||
| 39616244d9 | |||
| 990846515f | |||
| 94777aead3 | |||
| 5275d3bfd3 |
@@ -0,0 +1,66 @@
|
||||
acodec
|
||||
adblocker
|
||||
ahooks
|
||||
aliyuncs
|
||||
antd
|
||||
aplus
|
||||
behaviour
|
||||
bili
|
||||
bilibili
|
||||
bodyparser
|
||||
bodys
|
||||
buildx
|
||||
cancle
|
||||
cliqz
|
||||
clsx
|
||||
commitlint
|
||||
compat
|
||||
Conpty
|
||||
consola
|
||||
conventionalcommits
|
||||
datetime
|
||||
DDTHH
|
||||
deeplink
|
||||
esmfile
|
||||
execa
|
||||
ghostery
|
||||
idtype
|
||||
immer
|
||||
inversify
|
||||
KHTML
|
||||
languagedetector
|
||||
localforage
|
||||
lucide
|
||||
mediago
|
||||
metas
|
||||
nocheck
|
||||
optimizelegibility
|
||||
outdir
|
||||
pinia
|
||||
Qrcode
|
||||
redownload
|
||||
Redownload
|
||||
reduxjs
|
||||
remusao
|
||||
rmvb
|
||||
shadcn
|
||||
Sider
|
||||
smaz
|
||||
stylelint
|
||||
svgr
|
||||
svgz
|
||||
tailwindcss
|
||||
TDAPP
|
||||
tiptap
|
||||
tldts
|
||||
tseslint
|
||||
typeorm
|
||||
vaul
|
||||
vitepress
|
||||
vuedraggable
|
||||
vuejs
|
||||
waline
|
||||
watting
|
||||
Watting
|
||||
xgplayer
|
||||
zustand
|
||||
@@ -0,0 +1,15 @@
|
||||
# http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
max_line_length = 80
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
max_line_length = 0
|
||||
trim_trailing_whitespace = false
|
||||
@@ -0,0 +1,5 @@
|
||||
# FIXME: APP_ 开头的会暴漏给前端
|
||||
APP_NAME=mediago
|
||||
APP_ID=mediago.ziying.site
|
||||
APP_COPYRIGHT=caorushizi
|
||||
APP_VERSION=3.0.1
|
||||
+4
-3
@@ -1,4 +1,5 @@
|
||||
VITE_APP_TDID=
|
||||
VITE_APP_SENTRY_DSN=
|
||||
APP_TD_APPID=
|
||||
|
||||
NODE_ENV=development
|
||||
GH_TOKEN=
|
||||
LOAD_DEVTOOLS=
|
||||
DEBUG_PLUGINS=true
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
VITE_APP_TDID=
|
||||
VITE_APP_SENTRY_DSN=
|
||||
APP_TD_APPID=
|
||||
|
||||
NODE_ENV=production
|
||||
GH_TOKEN=
|
||||
DEBUG_PLUGINS=false
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
NODE_ENV=staging
|
||||
@@ -1,6 +0,0 @@
|
||||
.eslintrc.js
|
||||
esbuild.config.js
|
||||
babel.config.js
|
||||
webpack.config.js
|
||||
script/
|
||||
vite.config.ts
|
||||
@@ -1,19 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
browser: true,
|
||||
es6: true,
|
||||
node: true,
|
||||
},
|
||||
parser: "@typescript-eslint/parser",
|
||||
plugins: ["@typescript-eslint", "react"],
|
||||
extends: [
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"react-app",
|
||||
"plugin:prettier/recommended",
|
||||
],
|
||||
rules: {
|
||||
"@typescript-eslint/ban-ts-comment": "warn",
|
||||
"prettier/prettier": "error",
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "npm" # See documentation for possible values
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
@@ -0,0 +1,64 @@
|
||||
# build.yml
|
||||
|
||||
# Workflow's name
|
||||
name: Build Downloader App.
|
||||
|
||||
# Workflow's trigger
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
# Workflow's jobs
|
||||
jobs:
|
||||
# job's id
|
||||
release:
|
||||
# job's name
|
||||
name: build and release electron app
|
||||
|
||||
# the type of machine to run the job on
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
# create a build matrix for jobs
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [windows-latest, macos-latest, macos-13, ubuntu-latest]
|
||||
|
||||
# create steps
|
||||
steps:
|
||||
# step1: check out repository
|
||||
- name: Check out git repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# step2: install node env
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
# step4: install python env
|
||||
- name: Install Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.10"
|
||||
|
||||
# step5: install pnpm env
|
||||
- uses: pnpm/action-setup@v3
|
||||
with:
|
||||
version: latest
|
||||
run_install: true
|
||||
standalone: true
|
||||
|
||||
- name: Build & release app
|
||||
run: pnpm run release
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
APP_TD_APPID: ${{ secrets.APP_TD_APPID }}
|
||||
APP_CLARITY_APPID: ${{ secrets.APP_CLARITY_APPID}}
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mediago-${{ matrix.os }}
|
||||
path: packages/main/release/mediago-*
|
||||
@@ -0,0 +1,51 @@
|
||||
name: Build and Push Multi-arch Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20"
|
||||
|
||||
- uses: pnpm/action-setup@v3
|
||||
with:
|
||||
version: latest
|
||||
run_install: true
|
||||
standalone: true
|
||||
|
||||
- name: Build
|
||||
run: pnpm build:web-release
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Aliyun Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: registry.cn-beijing.aliyuncs.com
|
||||
username: ${{ secrets.ALIYUN_USERNAME }}
|
||||
password: ${{ secrets.ALIYUN_PASSWORD }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
push: true
|
||||
tags: |
|
||||
registry.cn-beijing.aliyuncs.com/caorushizi/mediago:latest
|
||||
registry.cn-beijing.aliyuncs.com/caorushizi/mediago:${{ github.sha }}
|
||||
+3
-10
@@ -1,13 +1,6 @@
|
||||
node_modules
|
||||
.DS_Store
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
.idea
|
||||
.bin
|
||||
.vscode
|
||||
|
||||
yarn.lock
|
||||
yarn-error.log
|
||||
build
|
||||
devtools/*
|
||||
.parcel-cache
|
||||
.vitepress
|
||||
*.tsno.mjs
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"extends": [
|
||||
"development"
|
||||
],
|
||||
"hints": {
|
||||
"axe/text-alternatives": [
|
||||
"default",
|
||||
{
|
||||
"image-alt": "off"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
npx --no -- commitlint --edit ${1}
|
||||
npm run commitlint ${1}
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
npx tsx ./scripts/pre-commit.ts
|
||||
@@ -0,0 +1,3 @@
|
||||
registry=https://registry.npmmirror.com
|
||||
electron_mirror=https://npmmirror.com/mirrors/electron/
|
||||
package-manager=pnpm
|
||||
@@ -0,0 +1,3 @@
|
||||
# Ignore artifacts:
|
||||
build
|
||||
coverage
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch dev",
|
||||
"runtimeExecutable": "npm",
|
||||
"runtimeArgs": ["run-script", "dev"],
|
||||
"skipFiles": ["<node_internals>/**"]
|
||||
},
|
||||
{
|
||||
"name": "Attach to Electron",
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"address": "localhost",
|
||||
"restart": true,
|
||||
"timeout": 10000,
|
||||
"localRoot": "${workspaceFolder}",
|
||||
"remoteRoot": "${workspaceFolder}"
|
||||
}
|
||||
]
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
FROM m.daocloud.io/docker.io/library/node:20 AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./packages/backend/dist /app
|
||||
|
||||
COPY ./packages/backend/package*.json ./
|
||||
|
||||
RUN npm install --omit=dev --registry=https://registry.npmmirror.com
|
||||
|
||||
RUN npm rebuild
|
||||
|
||||
# FROM m.daocloud.io/docker.io/library/debian:11-slim AS deb_extractor
|
||||
|
||||
# RUN cd /tmp && \
|
||||
# apt-get update && apt-get download libicu-dev && \
|
||||
# mkdir /dpkg && \
|
||||
# for deb in *.deb; do dpkg --extract $deb /dpkg || exit 10; done
|
||||
|
||||
# FROM gcr.io/distroless/nodejs20-debian12
|
||||
FROM m.daocloud.io/docker.io/library/node:20-bookworm-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app /app
|
||||
|
||||
# COPY --from=deb_extractor /dpkg /
|
||||
RUN apt-get update && apt-get install -y libicu-dev ffmpeg
|
||||
|
||||
RUN npm install pm2 -g
|
||||
|
||||
EXPOSE 8899
|
||||
|
||||
CMD ["pm2-runtime", "server/index.js"]
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 士子☀️
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
<div align="center">
|
||||
<h1>MediaGo</h1>
|
||||
<a href="https://downloader.caorushizi.cn/en/guides.html?form=github">Quick start</a>
|
||||
<span> • </span>
|
||||
<a href="https://downloader.caorushizi.cn/en?form=github">Website</a>
|
||||
<span> • </span>
|
||||
<a href="https://downloader.caorushizi.cn/en/documents.html?form=github">Docs</a>
|
||||
<span> • </span>
|
||||
<a href="https://github.com/caorushizi/mediago/discussions">Discussions</a>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<img alt="GitHub Downloads (all assets, all releases)" src="https://img.shields.io/github/downloads/caorushizi/mediago/total">
|
||||
<img alt="GitHub Downloads (all assets, latest release)" src="https://img.shields.io/github/downloads/caorushizi/mediago/latest/total">
|
||||
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/caorushizi/mediago">
|
||||
<img alt="GitHub forks" src="https://img.shields.io/github/forks/caorushizi/mediago">
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<a href="https://trendshift.io/repositories/11083" target="_blank">
|
||||
<img src="https://trendshift.io/api/badge/repositories/11083" alt="caorushizi%2Fmediago | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/>
|
||||
</a>
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
## Intro
|
||||
|
||||
This project supports m3u8 video extraction tools, streaming media download, and m3u8 download.
|
||||
|
||||
- **✅ No need to capture packets**: You can easily sniff video resources on web pages using the built-in browser. Choose the resource you want to download from the sniffed resource list—simple and fast.
|
||||
- **📱 Mobile playback**: Easily switch between PC and mobile devices seamlessly. Once downloaded, you can watch the video on your phone.
|
||||
- **⚡️ Batch download**: Supports downloading multiple videos and live streams simultaneously, ensuring high bandwidth is fully utilized.
|
||||
- **🎉 Docker deployment supported**: Supports Docker deployment for the web version, making it convenient and quick.
|
||||
|
||||
## Quickstart
|
||||
|
||||
To run the code, you'll need Node.js and pnpm. Node.js can be downloaded and installed from the official website, and pnpm can be installed via `npm i -g pnpm`.
|
||||
|
||||
## Run the code
|
||||
|
||||
```shell
|
||||
# Code download
|
||||
git clone https://github.com/caorushizi/mediago.git
|
||||
|
||||
# Installation dependency
|
||||
pnpm i
|
||||
|
||||
# Development environment
|
||||
pnpm dev
|
||||
|
||||
# Package run
|
||||
pnpm release
|
||||
|
||||
# Build a docker image
|
||||
docker buildx build -t caorushizi/mediago:latest .
|
||||
|
||||
# docker startup
|
||||
docker run -d --name mediago -p 8899:8899 -v /root/mediago:/root/mediago registry.cn-beijing.aliyuncs.com/caorushizi/mediago
|
||||
|
||||
```
|
||||
|
||||
## Releases
|
||||
|
||||
### v3.0.0 (Released on 2024.10.7)
|
||||
|
||||
#### Software Downloads
|
||||
|
||||
- [【mediago】 Windows (Installer) v3.0.0](https://github.com/caorushizi/mediago/releases/download/v3.0.0/mediago-setup-win32-x64-3.0.0.exe)
|
||||
- [【mediago】 Windows (Portable) v3.0.0](https://github.com/caorushizi/mediago/releases/download/v3.0.0/mediago-portable-win32-x64-3.0.0.exe)
|
||||
- [【mediago】 macOS ARM64 (Apple Silicon) v3.0.0](https://github.com/caorushizi/mediago/releases/download/v3.0.0/mediago-setup-darwin-arm64-3.0.0.dmg)
|
||||
- [【mediago】 macOS x64 (Intel) v3.0.0](https://github.com/caorushizi/mediago/releases/download/v3.0.0/mediago-setup-darwin-x64-3.0.0.dmg)
|
||||
- [【mediago】 Linux v3.0.0](https://github.com/caorushizi/mediago/releases/download/v3.0.0/mediago-setup-linux-amd64-3.0.0.deb)
|
||||
- 【mediago】 Docker v3.0 `docker run -d --name mediago -p 8899:8899 -v /root/mediago:/root/mediago registry.cn-beijing.aliyuncs.com/caorushizi/mediago:v3.0.0`
|
||||
|
||||
#### Domestic Downloads
|
||||
|
||||
- [【mediago】 Windows (Installer) v3.0.0](https://static.ziying.site/mediago/mediago-setup-win32-x64-3.0.0.exe)
|
||||
- [【mediago】 Windows (Portable) v3.0.0](https://static.ziying.site/mediago/mediago-portable-win32-x64-3.0.0.exe)
|
||||
- [【mediago】 macOS ARM64 (Apple Silicon) v3.0.0](https://static.ziying.site/mediago/mediago-setup-darwin-arm64-3.0.0.dmg)
|
||||
- [【mediago】 macOS x64 (Intel) v3.0.0](https://static.ziying.site/mediago/mediago-setup-darwin-x64-3.0.0-beta.5.dmg)
|
||||
- [【mediago】 Linux v3.0.0](https://static.ziying.site/mediago/mediago-setup-linux-amd64-3.0.0.deb)
|
||||
- 【mediago】 Docker v3.0 `docker run -d --name mediago -p 8899:8899 -v /root/mediago:/root/mediago registry.cn-beijing.aliyuncs.com/caorushizi/mediago:v3.0.0`
|
||||
|
||||
### One-click Docker Panel Deployment (Recommended)
|
||||
|
||||
1. Install the BT Panel by visiting [BT Panel](https://www.bt.cn/new/download.html?r=dk_mediago) and downloading the official version script.
|
||||
2. After installation, log into the BT Panel, click on `Docker` in the menu bar. The first time you enter, it will prompt you to install the `Docker` service. Click to install and follow the instructions to complete the installation.
|
||||
3. Once installed, find `MediaGo` in the application store, click install, configure domain names, and other basic information to complete the installation.
|
||||
|
||||
### Software Screenshots
|
||||
|
||||

|
||||
|
||||
### Major Updates
|
||||
|
||||
- Support for Docker deployment on the web version
|
||||
- Updated desktop UI
|
||||
|
||||
### Changelog
|
||||
|
||||
- Updated desktop UI
|
||||
- Support for Docker deployment on the web version
|
||||
- Added video playback, supporting both desktop and mobile playback
|
||||
- Fixed issue where the macOS version couldn't display the interface
|
||||
- Optimized the batch download interaction
|
||||
- Added portable version for Windows (no installation required)
|
||||
- Optimized the download list, supporting sniffing multiple videos on a page
|
||||
- Supported manual import/export of the favorites list
|
||||
- Supported export of the homepage download list
|
||||
- Optimized the interaction logic for the "New Download" form
|
||||
- Supported opening the app via UrlScheme and adding download tasks
|
||||
- Fixed several bugs and enhanced the user experience
|
||||
|
||||
## Software Screenshots
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## Tech Stack
|
||||
|
||||
- React <https://react.dev/>
|
||||
- Electron <https://www.electronjs.org>
|
||||
- Koa <https://koajs.com>
|
||||
- Vite <https://cn.vitejs.dev>
|
||||
- Ant Design <https://ant.design>
|
||||
- Tailwind CSS <https://tailwindcss.com>
|
||||
- Shadcn <https://ui.shadcn.com/>
|
||||
- Inversify <https://inversify.io>
|
||||
- TypeORM <https://typeorm.io>
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
- N_m2u8DL-CLI from <https://github.com/nilaoda/N_m3u8DL-CLI>
|
||||
- N_m3u8DL-RE from <https://github.com/nilaoda/N_m3u8DL-RE>
|
||||
- mediago from <https://github.com/caorushizi/hls-downloader>
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
<div align="center">
|
||||
<h1>MediaGo</h1>
|
||||
<a href="https://downloader.caorushizi.cn/jp/guides.html?form=github">早く始めます</a>
|
||||
<span> • </span>
|
||||
<a href="https://downloader.caorushizi.cn/jp?form=github">公式サイトです</a>
|
||||
<span> • </span>
|
||||
<a href="https://downloader.caorushizi.cn/jp/documents.html?form=github">にやすりをかける</a>
|
||||
<span> • </span>
|
||||
<a href="https://github.com/caorushizi/mediago/discussions">Discussions</a>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<img alt="GitHub Downloads (all assets, all releases)" src="https://img.shields.io/github/downloads/caorushizi/mediago/total">
|
||||
<img alt="GitHub Downloads (all assets, latest release)" src="https://img.shields.io/github/downloads/caorushizi/mediago/latest/total">
|
||||
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/caorushizi/mediago">
|
||||
<img alt="GitHub forks" src="https://img.shields.io/github/forks/caorushizi/mediago">
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<a href="https://trendshift.io/repositories/11083" target="_blank">
|
||||
<img src="https://trendshift.io/api/badge/repositories/11083" alt="caorushizi%2Fmediago | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/>
|
||||
</a>
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
## Intro
|
||||
|
||||
本プロジェクトはm3u8ビデオ抽出ツール、ストリーミングダウンロード、m3u8ダウンロードをサポートしています。
|
||||
|
||||
- **✅ パケットキャプチャ不要**: ソフトウェアに内蔵されたブラウザを使用して、ウェブページ内のビデオリソースを簡単に検出し、検出したリソースリストからダウンロードしたいリソースを選択することで、シンプルかつ迅速にダウンロードできます。
|
||||
- **📱 モバイル再生**: PCとモバイルデバイス間で簡単にシームレスに切り替えが可能で、ダウンロードが完了した後はスマートフォンでビデオを視聴できます。
|
||||
- **⚡️ バッチダウンロード**: 複数のビデオやライブストリームリソースを同時にダウンロードでき、高速帯域幅を無駄にしません。
|
||||
- **🎉 Dockerデプロイメントサポート**: WebエンドをDockerでデプロイすることができ、簡単かつ便利です。
|
||||
|
||||
## Quickstart
|
||||
|
||||
コードを実行するには、Node.jsとpnpmが必要です。Node.jsは公式ウェブサイトからダウンロードしてインストールし、pnpmは`npm i -g pnpm`コマンドでインストールできます。
|
||||
|
||||
## コードの実行
|
||||
|
||||
```shell
|
||||
# コードのダウンロードです
|
||||
git clone https://github.com/caorushizi/mediago.git
|
||||
|
||||
# インストール依存症です
|
||||
pnpm i
|
||||
|
||||
# 開発環境です
|
||||
pnpm dev
|
||||
|
||||
# 梱包して運行します
|
||||
pnpm release
|
||||
|
||||
# dockerミラーリングを構築します
|
||||
docker buildx build -t caorushizi/mediago:latest .
|
||||
|
||||
# docker启动
|
||||
docker run -d --name mediago -p 8899:8899 -v /root/mediago:/root/mediago registry.cn-beijing.aliyuncs.com/caorushizi/mediago
|
||||
|
||||
```
|
||||
|
||||
## Releases
|
||||
|
||||
### v3.0.0 (2024.10.7 発売)
|
||||
|
||||
#### ソフトウェアダウンロード
|
||||
|
||||
- [【mediago】 windows(インストーラー版) v3.0.0](https://github.com/caorushizi/mediago/releases/download/v3.0.0/mediago-setup-win32-x64-3.0.0.exe)
|
||||
- [【mediago】 windows(ポータブル版) v3.0.0](https://github.com/caorushizi/mediago/releases/download/v3.0.0/mediago-portable-win32-x64-3.0.0.exe)
|
||||
- [【mediago】 macos arm64(Appleチップ) v3.0.0](https://github.com/caorushizi/mediago/releases/download/v3.0.0/mediago-setup-darwin-arm64-3.0.0.dmg)
|
||||
- [【mediago】 macos x64(Intelチップ) v3.0.0](https://github.com/caorushizi/mediago/releases/download/v3.0.0/mediago-setup-darwin-x64-3.0.0.dmg)
|
||||
- [【mediago】 linux v3.0.0](https://github.com/caorushizi/mediago/releases/download/v3.0.0/mediago-setup-linux-amd64-3.0.0.deb)
|
||||
- 【mediago】 docker v3.0 `docker run -d --name mediago -p 8899:8899 -v /root/mediago:/root/mediago registry.cn-beijing.aliyuncs.com/caorushizi/mediago:v3.0.0`
|
||||
|
||||
#### 国内ダウンロード
|
||||
|
||||
- [【mediago】 windows(インストーラー版) v3.0.0](https://static.ziying.site/mediago/mediago-setup-win32-x64-3.0.0.exe)
|
||||
- [【mediago】 windows(ポータブル版) v3.0.0](https://static.ziying.site/mediago/mediago-portable-win32-x64-3.0.0.exe)
|
||||
- [【mediago】 macos arm64(Appleチップ) v3.0.0](https://static.ziying.site/mediago/mediago-setup-darwin-arm64-3.0.0.dmg)
|
||||
- [【mediago】 macos x64(Intelチップ) v3.0.0](https://static.ziying.site/mediago/mediago-setup-darwin-x64-3.0.0-beta.5.dmg)
|
||||
- [【mediago】 linux v3.0.0](https://static.ziying.site/mediago/mediago-setup-linux-amd64-3.0.0.deb)
|
||||
- 【mediago】 docker v3.0 `docker run -d --name mediago -p 8899:8899 -v /root/mediago:/root/mediago registry.cn-beijing.aliyuncs.com/caorushizi/mediago:v3.0.0`
|
||||
|
||||
### docker 宝塔パネルワンクリックデプロイ(推奨)
|
||||
|
||||
1. 宝塔パネルをインストールし、[宝塔パネル](https://www.bt.cn/new/download.html?r=dk_mediago) の公式サイトから正式版のスクリプトを選択してインストールします。
|
||||
|
||||
2. インストール後、宝塔パネルにログインし、メニューから `Docker` をクリックします。初めてアクセスすると、`Docker` サービスをインストールするように指示されるので、「今すぐインストール」をクリックし、指示に従ってインストールを完了します。
|
||||
|
||||
3. インストールが完了したら、アプリストアで「MediaGo」を見つけ、インストールをクリックし、ドメイン名などの基本情報を設定してインストールを完了します。
|
||||
|
||||
### ソフトウェアスクリーンショット
|
||||
|
||||

|
||||
|
||||
### 重要な更新
|
||||
|
||||
- Web端のdockerデプロイをサポート
|
||||
- デスクトップ端のUIを更新
|
||||
|
||||
### 更新ログ
|
||||
|
||||
- デスクトップ端のUIを更新
|
||||
- Web端のdockerデプロイをサポート
|
||||
- 新たにビデオ再生機能を追加、デスクトップとモバイル端両方で再生可能
|
||||
- Macでの画面表示ができない問題を修正
|
||||
- バッチダウンロードのインタラクションを最適化
|
||||
- Windowsのポータブル版(インストール不要)を追加
|
||||
- ダウンロードリストの最適化、ページ内の複数のビデオリソースを嗅ぎ取る機能を追加
|
||||
- 手動でお気に入りリストのインポートとエクスポートをサポート
|
||||
- ホームページのダウンロードリストエクスポートをサポート
|
||||
- 「新規ダウンロード」フォームのインタラクションロジックを最適化
|
||||
- UrlSchemeでアプリを開き、ダウンロードタスクを追加する機能をサポート
|
||||
- バグの修正とユーザー体験の向上
|
||||
|
||||
## ソフトウェアスクリーンショット
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## 技術スタック
|
||||
|
||||
- react <https://react.dev/>
|
||||
- electron <https://www.electronjs.org>
|
||||
- koa <https://koajs.com>
|
||||
- vite <https://cn.vitejs.dev>
|
||||
- antd <https://ant.design>
|
||||
- tailwindcss <https://tailwindcss.com>
|
||||
- shadcn <https://ui.shadcn.com/>
|
||||
- inversify <https://inversify.io>
|
||||
- typeorm <https://typeorm.io>
|
||||
|
||||
## 感謝
|
||||
|
||||
- N_m2u8DL-CLI は <https://github.com/nilaoda/N_m3u8DL-CLI> から来ています
|
||||
- N_m3u8DL-RE は <https://github.com/nilaoda/N_m3u8DL-RE> から来ています
|
||||
- mediago は <https://github.com/caorushizi/hls-downloader> から来ています
|
||||
@@ -1,39 +1,137 @@
|
||||
# media-downloader
|
||||
m3u8 视频在线提取工具 流媒体下载 m3u8下载 桌面客户端 windows mac。
|
||||
可以直接在线获取 m3u8 链接地址,无需使用使用网络抓包,无需安装浏览器插件,可以直接带出请求标头……
|
||||
<div align="center">
|
||||
<h1>MediaGo</h1>
|
||||
<a href="https://downloader.caorushizi.cn/guides.html?form=github">快速开始</a>
|
||||
<span> • </span>
|
||||
<a href="https://downloader.caorushizi.cn?form=github">官网</a>
|
||||
<span> • </span>
|
||||
<a href="https://downloader.caorushizi.cn/documents.html?form=github">文档</a>
|
||||
<span> • </span>
|
||||
<a href="https://github.com/caorushizi/mediago/discussions">Discussions</a>
|
||||
<br>
|
||||
|
||||
# 上手指南
|
||||
以下指南将帮助你在本地机器上安装和运行该项目,进行开发和测试。关于如何将该项目部署到在线环境,请参考部署小节。
|
||||
<a href="https://github.com/caorushizi/mediago/blob/master/README.en.md">English</a>
|
||||
<span> • </span>
|
||||
<a href="https://github.com/caorushizi/mediago/blob/master/README.jp.md">日本語</a>
|
||||
<br>
|
||||
|
||||
# 安装要求
|
||||
运行代码需要 node 和 yarn,node需要在官网下载安装,yarn可以通过`npm i -g yarn`安装。
|
||||
<img alt="GitHub Downloads (all assets, all releases)" src="https://img.shields.io/github/downloads/caorushizi/mediago/total">
|
||||
<img alt="GitHub Downloads (all assets, latest release)" src="https://img.shields.io/github/downloads/caorushizi/mediago/latest/total">
|
||||
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/caorushizi/mediago">
|
||||
<img alt="GitHub forks" src="https://img.shields.io/github/forks/caorushizi/mediago">
|
||||
<br>
|
||||
|
||||
# 运行代码
|
||||
<a href="https://trendshift.io/repositories/11083" target="_blank">
|
||||
<img src="https://trendshift.io/api/badge/repositories/11083" alt="caorushizi%2Fmediago | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/>
|
||||
</a>
|
||||
|
||||
开发环境 `yarn run watch`
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
打包运行 `yarn run publish`
|
||||
## Intro
|
||||
|
||||
# 下载链接
|
||||
- [v1.1.3 windows](https://github.com/caorushizi/m3u8-downloader/releases/download/1.1.3/media-downloader-setup-1.1.3.exe)
|
||||
- [v1.0.3 windows](http://static.ziying.site/media-downloader-1.0.3%20Setup.exe)
|
||||
- [v1.0.2 windows](http://static.ziying.site/media-downloader-1.0.2%20Setup.exe)
|
||||
- [v1.0.1 windows](http://static.ziying.site/media-downloader-1.0.1%20Setup.exe)
|
||||
- [v1.0.0 windows](http://static.ziying.site/media-downloader-1.0.0%20Setup.exe)
|
||||
本项目支持 m3u8 视频在线提取工具 流媒体下载 m3u8 下载。
|
||||
|
||||
# 软件截图
|
||||
- **✅ 无需抓包**: 使用软件自带浏览器可以轻松嗅探网页中的视频资源,通过嗅探到的资源列表选择自己想要下载的资源,简单快速。
|
||||
- **📱 移动播放**: 可以轻松无缝的在 PC 和移动设备之前切换,下载完成后即可使用手机观看视频。
|
||||
- **⚡️ 批量下载**: 支持同时下载多个视频和直播资源,高速带宽不闲置。
|
||||
- **🎉 支持 docker 部署**: 支持 docker 部署 web 端,方便快捷。
|
||||
|
||||

|
||||
## Quickstart
|
||||
|
||||

|
||||
运行代码需要 node 和 pnpm,node 需要在官网下载安装,pnpm 可以通过`npm i -g pnpm`安装。
|
||||
|
||||
# 技术栈
|
||||
- vite https://cn.vitejs.dev
|
||||
- antd https://ant.design
|
||||
- electron https://www.electronjs.org
|
||||
## 运行代码
|
||||
|
||||
# 鸣谢
|
||||
N_m3u8DL-CLI 来自于 https://github.com/nilaoda/N_m3u8DL-CLI
|
||||
```shell
|
||||
# 代码下载
|
||||
git clone https://github.com/caorushizi/mediago.git
|
||||
|
||||
mediago 来自于 https://github.com/caorushizi/mediago
|
||||
# 安装依赖
|
||||
pnpm i
|
||||
|
||||
# 开发环境
|
||||
pnpm dev
|
||||
|
||||
# 打包运行
|
||||
pnpm release
|
||||
|
||||
# 构建 docker 镜像
|
||||
docker buildx build -t caorushizi/mediago:latest .
|
||||
|
||||
# docker 启动
|
||||
docker run -d --name mediago -p 8899:8899 -v /root/mediago:/root/mediago registry.cn-beijing.aliyuncs.com/caorushizi/mediago
|
||||
|
||||
```
|
||||
|
||||
## Releases
|
||||
|
||||
### v3.0.0 (2024.10.7 发布)
|
||||
|
||||
#### 软件下载
|
||||
|
||||
- [【mediago】 windows(安装版) v3.0.0](https://github.com/caorushizi/mediago/releases/download/v3.0.0/mediago-setup-win32-x64-3.0.0.exe)
|
||||
- [【mediago】 windows(便携版) v3.0.0](https://github.com/caorushizi/mediago/releases/download/v3.0.0/mediago-portable-win32-x64-3.0.0.exe)
|
||||
- [【mediago】 macos arm64(apple 芯片) v3.0.0](https://github.com/caorushizi/mediago/releases/download/v3.0.0/mediago-setup-darwin-arm64-3.0.0.dmg)
|
||||
- [【mediago】 macos x64(intel 芯片) v3.0.0](https://github.com/caorushizi/mediago/releases/download/v3.0.0/mediago-setup-darwin-x64-3.0.0.dmg)
|
||||
- [【mediago】 linux v3.0.0](https://github.com/caorushizi/mediago/releases/download/v3.0.0/mediago-setup-linux-amd64-3.0.0.deb)
|
||||
- 【mediago】 docker v3.0 `docker run -d --name mediago -p 8899:8899 -v /root/mediago:/root/mediago registry.cn-beijing.aliyuncs.com/caorushizi/mediago:v3.0.0`
|
||||
|
||||
### docker 宝塔面板一键部署(推荐)
|
||||
|
||||
1. 安装宝塔面板,前往 [宝塔面板](https://www.bt.cn/new/download.html?r=dk_mediago) 官网,选择正式版的脚本下载安装
|
||||
|
||||
2. 安装后登录宝塔面板,在菜单栏中点击 `Docker`,首次进入会提示安装`Docker`服务,点击立即安装,按提示完成安装
|
||||
|
||||
3. 安装完成后在应用商店中找到`MediaGo`,点击安装,配置域名等基本信息即可完成安装
|
||||
|
||||
### 软件截图
|
||||
|
||||

|
||||
|
||||
### 重要更新
|
||||
|
||||
- 支持 docker 部署 web 端
|
||||
- 更新桌面端 UI
|
||||
|
||||
### 更新日志
|
||||
|
||||
- 更新桌面端 UI
|
||||
- 支持 docker 部署 web 端
|
||||
- 新增视频播放,支持桌面端和移动端播放
|
||||
- 修复 mac 打开无法展示界面的问题
|
||||
- 优化了批量下载的交互
|
||||
- 添加了 windows 的便携版(免安装哦)
|
||||
- 优化了下载列表,支持页面中多个视频的嗅探
|
||||
- 支持收藏列表手动导入导出
|
||||
- 支持首页下载列表导出
|
||||
- 优化了【新建下载】表单的交互逻辑
|
||||
- 支持 UrlScheme 打开应用,并添加下载任务
|
||||
- 修复了一些 bug 并提升用户体验
|
||||
|
||||
## 软件截图
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## 技术栈
|
||||
|
||||
- react <https://react.dev/>
|
||||
- electron <https://www.electronjs.org>
|
||||
- koa <https://koajs.com>
|
||||
- vite <https://cn.vitejs.dev>
|
||||
- antd <https://ant.design>
|
||||
- tailwindcss <https://tailwindcss.com>
|
||||
- shadcn <https://ui.shadcn.com/>
|
||||
- inversify <https://inversify.io>
|
||||
- typeorm <https://typeorm.io>
|
||||
|
||||
## 鸣谢
|
||||
|
||||
- N_m2u8DL-CLI 来自于 <https://github.com/nilaoda/N_m3u8DL-CLI>
|
||||
- N_m3u8DL-RE 来自于 <https://github.com/nilaoda/N_m3u8DL-RE>
|
||||
- mediago 来自于 <https://github.com/caorushizi/hls-downloader>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 44 KiB |
@@ -0,0 +1,100 @@
|
||||
export default {
|
||||
extends: ["@commitlint/config-conventional"], // extends can be nested
|
||||
parserPreset: "conventional-changelog-conventionalcommits",
|
||||
prompt: {
|
||||
settings: {},
|
||||
messages: {
|
||||
skip: ":skip",
|
||||
max: "upper %d chars",
|
||||
min: "%d chars at least",
|
||||
emptyWarning: "can not be empty",
|
||||
upperLimitWarning: "over limit",
|
||||
lowerLimitWarning: "below limit",
|
||||
},
|
||||
types: [
|
||||
{ value: "feat", name: "feat: ✨ A new feature", emoji: "✨ " },
|
||||
{ value: "fix", name: "fix: 🐛 A bug fix", emoji: "🐛 " },
|
||||
{
|
||||
value: "docs",
|
||||
name: "docs: 📝 Documentation only changes",
|
||||
emoji: "📝 ",
|
||||
},
|
||||
{
|
||||
value: "style",
|
||||
name: "style: 💄 Changes that do not affect the meaning of the code",
|
||||
emoji: "💄 ",
|
||||
},
|
||||
{
|
||||
value: "refactor",
|
||||
name: "refactor: 📦️ A code change that neither fixes a bug nor adds a feature",
|
||||
emoji: "📦️ ",
|
||||
},
|
||||
{
|
||||
value: "perf",
|
||||
name: "perf: 🚀 A code change that improves performance",
|
||||
emoji: "🚀 ",
|
||||
},
|
||||
{
|
||||
value: "test",
|
||||
name: "test: 🚨 Adding missing tests or correcting existing tests",
|
||||
emoji: "🚨 ",
|
||||
},
|
||||
{
|
||||
value: "build",
|
||||
name: "build: 🛠 Changes that affect the build system or external dependencies",
|
||||
emoji: "🛠 ",
|
||||
},
|
||||
{
|
||||
value: "ci",
|
||||
name: "ci: 🎡 Changes to our CI configuration files and scripts",
|
||||
emoji: "🎡 ",
|
||||
},
|
||||
{
|
||||
value: "chore",
|
||||
name: "chore: 🔨 Other changes that don't modify src or test files",
|
||||
emoji: "🔨 ",
|
||||
},
|
||||
{
|
||||
value: "revert",
|
||||
name: "revert: ⏪️ Reverts a previous commit",
|
||||
emoji: ":rewind:",
|
||||
},
|
||||
],
|
||||
useEmoji: true,
|
||||
confirmColorize: true,
|
||||
emojiAlign: "center",
|
||||
questions: {
|
||||
scope: {
|
||||
description:
|
||||
"What is the scope of this change (e.g. component or file name)",
|
||||
},
|
||||
subject: {
|
||||
description:
|
||||
"Write a short, imperative tense description of the change",
|
||||
},
|
||||
body: {
|
||||
description: "Provide a longer description of the change",
|
||||
},
|
||||
isBreaking: {
|
||||
description: "Are there any breaking changes?",
|
||||
},
|
||||
breakingBody: {
|
||||
description:
|
||||
"A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself",
|
||||
},
|
||||
breaking: {
|
||||
description: "Describe the breaking changes",
|
||||
},
|
||||
isIssueAffected: {
|
||||
description: "Does this change affect any open issues?",
|
||||
},
|
||||
issuesBody: {
|
||||
description:
|
||||
"If issues are closed, the commit requires a body. Please enter a longer description of the commit itself",
|
||||
},
|
||||
issues: {
|
||||
description: 'Add issue references (e.g. "fix #123", "re #123".)',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"import": [
|
||||
"@cspell/dict-lorem-ipsum/cspell-ext.json"
|
||||
],
|
||||
"caseSensitive": false,
|
||||
"dictionaries": [
|
||||
"custom-words"
|
||||
],
|
||||
"dictionaryDefinitions": [
|
||||
{
|
||||
"name": "custom-words",
|
||||
"path": "./.cspell/custom-words.txt",
|
||||
"addWords": true
|
||||
}
|
||||
],
|
||||
"ignorePaths": [
|
||||
"**/node_modules/**",
|
||||
"**/dist/**",
|
||||
"**/lib/**",
|
||||
"**/docs/**",
|
||||
"**/stats.html"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import globals from "globals";
|
||||
import pluginJs from "@eslint/js";
|
||||
import tseslint from "typescript-eslint";
|
||||
|
||||
export default [
|
||||
{ languageOptions: { globals: globals.browser } },
|
||||
pluginJs.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
{
|
||||
rules: {
|
||||
"@typescript-eslint/no-explicit-any": "warn",
|
||||
},
|
||||
},
|
||||
];
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="referrer" content="never">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>在线视频下载</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/renderer/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
+52
-133
@@ -1,144 +1,63 @@
|
||||
{
|
||||
"name": "media-downloader",
|
||||
"version": "1.1.4",
|
||||
"description": "在线视频下载",
|
||||
"name": "mediago",
|
||||
"version": "0.1.0",
|
||||
"description": "mediago",
|
||||
"author": "caorushizi",
|
||||
"main": "dist/main/index.js",
|
||||
"license": "MIT",
|
||||
"homepage": "./",
|
||||
"homepage": "https://downloader.caorushizi.cn/",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dist": "cross-env NODE_ENV=production node script/build.js",
|
||||
"watch": "cross-env NODE_ENV=development node script/watch.js",
|
||||
"electron": "cross-env NODE_ENV=production electron .",
|
||||
"pack": "electron-builder --dir",
|
||||
"build": "electron-builder",
|
||||
"publish": "npm run dist && npm run build",
|
||||
"build-debug": "npm run dist && npm run pack && ./build/win-unpacked/在线视频下载.exe"
|
||||
"dev": "tsx scripts/dev.ts && pnpm --parallel -F \"./packages/*\" run dev",
|
||||
"dev:web": "pnpm --parallel -F \"./packages/*\" run dev:web",
|
||||
"build": "tsx scripts/build.ts",
|
||||
"build:plugin": "pnpm -F plugin run build",
|
||||
"build:main": "pnpm -F main run build",
|
||||
"build:web": "pnpm -F renderer run build:web",
|
||||
"build:backend": "pnpm -F backend run build",
|
||||
"build:renderer": "pnpm -F renderer run build",
|
||||
"build:mobile": "pnpm -F mobile run build",
|
||||
"build:web-release": "tsx scripts/web.ts",
|
||||
"rebuild:web": "pnpm -F backend rebuild",
|
||||
"rebuild:electron": "pnpm -F main run rebuild",
|
||||
"beta": "pnpm run build && pnpm -F mediago run pack",
|
||||
"release": "pnpm run build && pnpm -F main run release",
|
||||
"types": "pnpm -F main run types",
|
||||
"types:renderer": "pnpm -F renderer run types",
|
||||
"types:watch": "pnpm -F main run types:watch",
|
||||
"prepare": "husky",
|
||||
"commit": "git-cz",
|
||||
"commitlint": "commitlint --edit",
|
||||
"spellcheck": "cspell \"packages/**/src/**/*.{ts,tsx}\"",
|
||||
"lint-staged": "pnpm --recursive -F \"./packages/*\" run lint-staged"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^4.6.2",
|
||||
"@ant-design/pro-form": "^1.49.6",
|
||||
"@ant-design/pro-table": "^2.59.2",
|
||||
"@chakra-ui/react": "^1.7.2",
|
||||
"@emotion/react": "^11",
|
||||
"@emotion/styled": "^11",
|
||||
"@sentry/electron": "^2.5.4",
|
||||
"@sentry/react": "^6.16.1",
|
||||
"@sentry/tracing": "^6.16.1",
|
||||
"antd": "^4.17.2",
|
||||
"classnames": "^2.3.1",
|
||||
"connected-react-router": "^6.9.1",
|
||||
"electron-devtools-installer": "^3.2.0",
|
||||
"electron-log": "^4.3.2",
|
||||
"electron-squirrel-startup": "^1.0.0",
|
||||
"electron-store": "^7.0.2",
|
||||
"framer-motion": "^4",
|
||||
"glob": "^7.1.6",
|
||||
"localforage": "^1.9.0",
|
||||
"m3u8-parser": "^4.7.0",
|
||||
"moment": "^2.29.1",
|
||||
"nanoid": "^3.1.30",
|
||||
"prop-types": "^15.7.2",
|
||||
"qs": "^6.10.1",
|
||||
"re-resizable": "^6.9.1",
|
||||
"react": "^17.0.0",
|
||||
"react-dom": "^17.0.0",
|
||||
"react-file-drop": "^3.1.2",
|
||||
"react-redux": "^7.2.4",
|
||||
"react-router": "^5.2.0",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"react-virtualized-auto-sizer": "^1.0.6",
|
||||
"react-window": "^1.8.6",
|
||||
"redux": "^4.1.1",
|
||||
"redux-devtools-extension": "^2.13.9",
|
||||
"redux-saga": "^1.1.3",
|
||||
"semver": "^7.3.4"
|
||||
"keywords": [],
|
||||
"license": "MIT",
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "node_modules/cz-git"
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-eslint": "^8.0.1",
|
||||
"@types/glob": "^7.1.3",
|
||||
"@types/node": "^14.14.35",
|
||||
"@types/qs": "^6.9.7",
|
||||
"@types/react": "^17.0.0",
|
||||
"@types/react-dom": "^17.0.0",
|
||||
"@types/react-router": "^5.1.16",
|
||||
"@types/react-router-dom": "^5.1.8",
|
||||
"@types/react-virtualized-auto-sizer": "^1.0.1",
|
||||
"@types/react-window": "^1.8.5",
|
||||
"@types/semver": "^7.3.4",
|
||||
"@typescript-eslint/eslint-plugin": "^4.0.0",
|
||||
"@typescript-eslint/parser": "^4.0.0",
|
||||
"@vitejs/plugin-react-refresh": "^1.3.1",
|
||||
"babel-eslint": "^10.0.0",
|
||||
"chalk": "^4.1.2",
|
||||
"concurrently": "^6.0.0",
|
||||
"@commitlint/cli": "^19.3.0",
|
||||
"@commitlint/config-conventional": "^19.2.2",
|
||||
"@commitlint/core": "^19.3.0",
|
||||
"@commitlint/cz-commitlint": "^19.2.0",
|
||||
"@commitlint/format": "^19.3.0",
|
||||
"@eslint/js": "^8.57.0",
|
||||
"commitizen": "^4.3.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"dotenv": "^8.2.0",
|
||||
"electron": "16.0.4",
|
||||
"electron-builder": "^22.14.2",
|
||||
"electron-updater": "^4.6.1",
|
||||
"esbuild": "^0.9.5",
|
||||
"eslint": "^7.5.0",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
"eslint-config-react-app": "^6.0.0",
|
||||
"eslint-plugin-flowtype": "^5.2.0",
|
||||
"eslint-plugin-import": "^2.22.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.3.1",
|
||||
"eslint-plugin-prettier": "^3.3.1",
|
||||
"eslint-plugin-react": "^7.20.3",
|
||||
"eslint-plugin-react-hooks": "^4.0.8",
|
||||
"less": "^4.1.1",
|
||||
"prettier": "2.2.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"sass": "^1.32.8",
|
||||
"typescript": "^4.2.4",
|
||||
"vite": "^2.5.0"
|
||||
"cspell": "^8.8.3",
|
||||
"cz-git": "^1.9.2",
|
||||
"eslint": "^8.57.0",
|
||||
"globals": "^15.3.0",
|
||||
"husky": "^9.0.11",
|
||||
"tsx": "^4.11.0",
|
||||
"typescript-eslint": "^7.10.0",
|
||||
"zx": "^8.1.1"
|
||||
},
|
||||
"build": {
|
||||
"productName": "在线视频下载",
|
||||
"appId": "mediago.ziying.site",
|
||||
"copyright": "caorushizi",
|
||||
"artifactName": "media-downloader-setup-${version}.${ext}",
|
||||
"directories": {
|
||||
"output": "build"
|
||||
},
|
||||
"files": [
|
||||
"dist/**/*",
|
||||
"package.json"
|
||||
],
|
||||
"extraResources": [
|
||||
".bin/**"
|
||||
],
|
||||
"win": {
|
||||
"icon": "assets/icon.ico",
|
||||
"requestedExecutionLevel": "requireAdministrator",
|
||||
"target": [
|
||||
{
|
||||
"target": "nsis"
|
||||
}
|
||||
]
|
||||
},
|
||||
"dmg": {
|
||||
"contents": []
|
||||
},
|
||||
"mac": {
|
||||
"icon": "build/icons/icon.icns"
|
||||
},
|
||||
"linux": {
|
||||
"icon": "build/icons"
|
||||
},
|
||||
"nsis": {
|
||||
"oneClick": false,
|
||||
"allowElevation": true,
|
||||
"allowToChangeInstallationDirectory": true,
|
||||
"installerIcon": "",
|
||||
"uninstallerIcon": "",
|
||||
"installerHeaderIcon": "",
|
||||
"createDesktopShortcut": true,
|
||||
"createStartMenuShortcut": true,
|
||||
"shortcutName": "",
|
||||
"include": "",
|
||||
"script": ""
|
||||
"pnpm": {
|
||||
"patchedDependencies": {
|
||||
"@ghostery/adblocker@2.3.1": "patches/@ghostery__adblocker@2.3.1.patch"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
npm-debug.log
|
||||
@@ -0,0 +1,9 @@
|
||||
.bin
|
||||
node_modules
|
||||
build
|
||||
dist
|
||||
bin/Logs
|
||||
release
|
||||
types
|
||||
log
|
||||
bin
|
||||
@@ -0,0 +1 @@
|
||||
types/
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1 @@
|
||||
# backend
|
||||
@@ -0,0 +1,16 @@
|
||||
import globals from "globals";
|
||||
import pluginJs from "@eslint/js";
|
||||
import tseslint from "typescript-eslint";
|
||||
|
||||
export default [
|
||||
{
|
||||
languageOptions: { globals: globals.node },
|
||||
},
|
||||
pluginJs.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
{
|
||||
rules: {
|
||||
"@typescript-eslint/no-explicit-any": "warn",
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1 @@
|
||||
export { dev, build } from "./scripts";
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"watch": ["dist"],
|
||||
"ext": "js",
|
||||
"exec": "npx cross-env NODE_ENV=development node dist/server/index.js"
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"name": "backend",
|
||||
"version": "0.1.0",
|
||||
"description": "在线视频下载器",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"start": "nodemon",
|
||||
"dev:web": "cross-env NODE_ENV=development gulp dev",
|
||||
"build": "cross-env NODE_ENV=production gulp build",
|
||||
"types": "tsc",
|
||||
"types:watch": "tsc -w",
|
||||
"lint-staged": "lint-staged"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,jsx,ts,tsx}": "eslint"
|
||||
},
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^8.57.0",
|
||||
"@types/cors": "^2.8.17",
|
||||
"@types/cross-spawn": "^6.0.6",
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/glob": "^8.1.0",
|
||||
"@types/gulp": "^4.0.17",
|
||||
"@types/koa": "^2.15.0",
|
||||
"@types/koa-bodyparser": "^4.3.12",
|
||||
"@types/koa-send": "^4.1.6",
|
||||
"@types/koa-static": "^4.0.4",
|
||||
"@types/koa__cors": "^5.0.0",
|
||||
"@types/koa__router": "^12.0.4",
|
||||
"@types/lodash": "^4.17.4",
|
||||
"@types/mime-types": "^2.1.4",
|
||||
"@types/node": "^20.12.12",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@types/serve-handler": "^6.1.4",
|
||||
"@types/undertaker": "^1.2.11",
|
||||
"consola": "^3.2.3",
|
||||
"cross-env": "^7.0.3",
|
||||
"cross-spawn": "^7.0.3",
|
||||
"del": "^7.1.0",
|
||||
"dotenv": "^16.4.5",
|
||||
"esbuild": "0.21.4",
|
||||
"esbuild-register": "^3.5.0",
|
||||
"eslint": "^8.57.0",
|
||||
"glob": "^10.4.1",
|
||||
"globals": "^15.3.0",
|
||||
"gulp": "^5.0.0",
|
||||
"lint-staged": "^15.2.5",
|
||||
"nodemon": "^3.1.4",
|
||||
"semver": "^7.6.2",
|
||||
"typescript": "^5.4.5",
|
||||
"typescript-eslint": "^7.10.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@koa/cors": "^5.0.0",
|
||||
"@koa/router": "^12.0.1",
|
||||
"axios": "^1.7.2",
|
||||
"better-sqlite3": "^9.3.0",
|
||||
"cheerio": "1.0.0-rc.12",
|
||||
"dayjs": "^1.11.11",
|
||||
"execa": "^9.1.0",
|
||||
"fs-extra": "^11.2.0",
|
||||
"i18next": "^23.11.5",
|
||||
"inversify": "^6.0.2",
|
||||
"koa": "^2.15.3",
|
||||
"koa-bodyparser": "^4.4.1",
|
||||
"koa-send": "^5.0.1",
|
||||
"koa-static": "^5.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"mime-types": "^2.1.35",
|
||||
"nanoid": "^5.0.7",
|
||||
"node-pty": "^1.0.0",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"socket.io": "^4.8.0",
|
||||
"strip-ansi": "^7.1.0",
|
||||
"typeorm": "0.3.20",
|
||||
"winston": "^3.14.2"
|
||||
},
|
||||
"keywords": []
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Env, isDev, mainResolve } from "./utils";
|
||||
import esbuild from "esbuild";
|
||||
|
||||
export function buildOptions(): esbuild.BuildOptions {
|
||||
const getDefine = (): Record<string, string> => {
|
||||
const vars: Record<string, string> = {
|
||||
"process.env.NODE_ENV": isDev ? '"development"' : '"production"',
|
||||
};
|
||||
if (isDev) {
|
||||
vars.__bin__ = `"${mainResolve("bin").replace(/\\/g, "\\\\")}"`;
|
||||
Object.assign(vars, Env.getInstance().loadDotEnvDefined());
|
||||
}
|
||||
|
||||
return vars;
|
||||
};
|
||||
|
||||
return {
|
||||
entryPoints: [mainResolve("src/index.ts")],
|
||||
bundle: true,
|
||||
sourcemap: process.env.NODE_ENV === "development",
|
||||
define: getDefine(),
|
||||
outdir: mainResolve("dist/server"),
|
||||
loader: { ".png": "file" },
|
||||
minify: process.env.NODE_ENV === "production",
|
||||
packages: "external",
|
||||
format: "esm",
|
||||
target: ["node20"],
|
||||
platform: "node",
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import { deleteSync } from "del";
|
||||
import { mainResolve, Env, isDev } from "./utils";
|
||||
import gulp from "gulp";
|
||||
import * as esbuild from "esbuild";
|
||||
import consola from "consola";
|
||||
import { buildOptions } from "./config";
|
||||
import fs from "fs";
|
||||
import spawn from "cross-spawn";
|
||||
|
||||
const env = Env.getInstance();
|
||||
env.loadDotEnvRuntime();
|
||||
|
||||
async function clean() {
|
||||
return deleteSync([mainResolve("dist/server")]);
|
||||
}
|
||||
|
||||
async function buildClean() {
|
||||
return deleteSync([mainResolve("dist")]);
|
||||
}
|
||||
|
||||
async function copyBin() {
|
||||
const source = mainResolve(
|
||||
"../main/bin",
|
||||
isDev ? process.platform : "linux",
|
||||
process.arch,
|
||||
);
|
||||
const target = mainResolve("dist/server/bin");
|
||||
fs.cpSync(source, target, {
|
||||
recursive: true,
|
||||
filter: (src) => {
|
||||
if (!isDev && src.endsWith("ffmpeg")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const copy = gulp.parallel(copyBin);
|
||||
|
||||
async function watchTask() {
|
||||
const main = await esbuild.context(buildOptions());
|
||||
await main.rebuild();
|
||||
|
||||
const watcher = gulp.watch(["./src"]);
|
||||
watcher
|
||||
.on("change", async () => {
|
||||
await main.rebuild();
|
||||
})
|
||||
.on("error", (error: any) => {
|
||||
consola.error(error);
|
||||
});
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
async function startNodemon() {
|
||||
const nodemon = spawn("npm", ["start"], {
|
||||
stdio: "pipe",
|
||||
});
|
||||
|
||||
nodemon.stdout?.on("data", (data) => {
|
||||
consola.log(data.toString());
|
||||
});
|
||||
|
||||
// Listen for stderr data events
|
||||
nodemon.stderr?.on("data", (data) => {
|
||||
consola.error(`stderr: ${data.toString()}`);
|
||||
});
|
||||
|
||||
// Listens for closing events of the child process
|
||||
nodemon.on("close", (code) => {
|
||||
consola.log(`子进程退出,退出码 ${code}`);
|
||||
});
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
async function buildTask() {
|
||||
await esbuild.build(buildOptions());
|
||||
}
|
||||
|
||||
// Development environment
|
||||
export const dev = gulp.series(clean, copy, watchTask, startNodemon);
|
||||
// Build packaging
|
||||
export const build = gulp.series(buildClean, copy, buildTask);
|
||||
@@ -0,0 +1,70 @@
|
||||
import dotenv from "dotenv";
|
||||
import { resolve } from "path";
|
||||
import fs from "fs-extra";
|
||||
|
||||
const baseResolve = (...r: any[]) => resolve(__dirname, ...r);
|
||||
export const mainResolve = (...r: string[]) => baseResolve("..", ...r);
|
||||
export const rootResolve = (...r: string[]) => baseResolve("../../..", ...r);
|
||||
|
||||
export const isDev = process.env.NODE_ENV === "development";
|
||||
|
||||
export const isLinux = process.platform === "linux";
|
||||
export const isMac = process.platform === "darwin";
|
||||
export const isWin = process.platform === "win32";
|
||||
|
||||
export class Env {
|
||||
env: Record<string, string> = {};
|
||||
nodeEnv = "";
|
||||
static instance: Env;
|
||||
|
||||
private constructor(nodeEnv = process.env.NODE_ENV) {
|
||||
const env = this.parseEnv(rootResolve(".env"));
|
||||
const modeEnv = this.parseEnv(rootResolve(`.env.${nodeEnv}`));
|
||||
const localEnv = this.parseEnv(rootResolve(`.env.${nodeEnv}.local`));
|
||||
|
||||
this.nodeEnv = nodeEnv || "development";
|
||||
this.env = { ...env, ...modeEnv, ...localEnv };
|
||||
}
|
||||
|
||||
static getInstance() {
|
||||
if (!Env.instance) {
|
||||
Env.instance = new Env();
|
||||
}
|
||||
|
||||
return Env.instance;
|
||||
}
|
||||
|
||||
private parseEnv(path: string) {
|
||||
if (!fs.existsSync(path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const parsed = dotenv.parse(fs.readFileSync(path));
|
||||
if (!parsed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Object.keys(parsed).reduce((prev: any, curr) => {
|
||||
prev[curr] = parsed[curr];
|
||||
return prev;
|
||||
}, {});
|
||||
}
|
||||
|
||||
loadDotEnvRuntime() {
|
||||
Object.keys(this.env).forEach((key) => {
|
||||
if (process.env[key] != null || !this.env[key]) return;
|
||||
process.env[key] = this.env[key];
|
||||
});
|
||||
}
|
||||
|
||||
loadDotEnvDefined() {
|
||||
return Object.keys(this.env).reduce<Record<string, string>>((prev, cur) => {
|
||||
prev[`process.env.${[cur]}`] = JSON.stringify(this.env[cur]);
|
||||
return prev;
|
||||
}, {});
|
||||
}
|
||||
|
||||
get isDev() {
|
||||
return this.nodeEnv === "development";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import { inject, injectable } from "inversify";
|
||||
import { TYPES } from "./types.ts";
|
||||
import TypeORM from "./vendor/TypeORM.ts";
|
||||
import RouterHandlerService from "./core/router.ts";
|
||||
import Koa from "koa";
|
||||
import cors from "@koa/cors";
|
||||
import bodyParser from "koa-bodyparser";
|
||||
import Logger from "./vendor/Logger.ts";
|
||||
import http from "http";
|
||||
import SocketIO from "./vendor/SocketIO.ts";
|
||||
import VideoRepository from "./repository/VideoRepository.ts";
|
||||
import { DownloadStatus } from "./interfaces.ts";
|
||||
import serve from "koa-static";
|
||||
import { STATIC_DIR } from "./const.ts";
|
||||
import send from "koa-send";
|
||||
|
||||
@injectable()
|
||||
export default class ElectronApp extends Koa {
|
||||
constructor(
|
||||
@inject(TYPES.RouterHandlerService)
|
||||
private readonly router: RouterHandlerService,
|
||||
@inject(TYPES.TypeORM)
|
||||
private readonly db: TypeORM,
|
||||
@inject(TYPES.Logger)
|
||||
private readonly logger: Logger,
|
||||
@inject(TYPES.SocketIO)
|
||||
private readonly socket: SocketIO,
|
||||
@inject(TYPES.VideoRepository)
|
||||
private readonly videoRepository: VideoRepository,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
private async vendorInit() {
|
||||
await this.db.init();
|
||||
}
|
||||
|
||||
async init(): Promise<void> {
|
||||
this.router.init();
|
||||
|
||||
// vendor
|
||||
await this.vendorInit();
|
||||
|
||||
this.use(cors())
|
||||
.use(bodyParser())
|
||||
.use(this.router.routes())
|
||||
.use(this.router.allowedMethods());
|
||||
this.use(serve(STATIC_DIR));
|
||||
|
||||
// Middleware that handles static files and front-end routing
|
||||
this.use(async (ctx, next) => {
|
||||
if (!ctx.path.startsWith("/api")) {
|
||||
try {
|
||||
await send(ctx, ctx.path, { root: STATIC_DIR });
|
||||
} catch (err: any) {
|
||||
if (err.status === 404) {
|
||||
await send(ctx, "index.html", { root: STATIC_DIR });
|
||||
}
|
||||
}
|
||||
}
|
||||
await next();
|
||||
});
|
||||
|
||||
const server = http.createServer(this.callback());
|
||||
|
||||
this.socket.initSocketIO(server);
|
||||
|
||||
server.listen(8899, () => {
|
||||
this.logger.info("Server running on port 8899");
|
||||
});
|
||||
}
|
||||
|
||||
// If there are still videos being downloaded after the restart, change the status to download failed
|
||||
async resetDownloadStatus(): Promise<void> {
|
||||
// If data in the downloading state still fails after the restart, all downloads fail
|
||||
const videos = await this.videoRepository.findWattingAndDownloadingVideos();
|
||||
const videoIds = videos.map((video) => video.id);
|
||||
await this.videoRepository.changeVideoStatus(
|
||||
videoIds,
|
||||
DownloadStatus.Failed,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import os from "os";
|
||||
import { dirname, resolve } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
export const API_PREFIX = "/api";
|
||||
export const HOME_DIR = os.homedir();
|
||||
export const DOWNLOAD_DIR = `${HOME_DIR}/mediago`;
|
||||
export const STATIC_DIR = resolve(__dirname, "../app");
|
||||
export const BIN_DIR = resolve(__dirname, "./bin");
|
||||
export const DB_PATH = `${__dirname}/../mediago.db`;
|
||||
@@ -0,0 +1,107 @@
|
||||
import { inject, injectable } from "inversify";
|
||||
import {
|
||||
DownloadItem,
|
||||
DownloadItemPagination,
|
||||
type Controller,
|
||||
} from "../interfaces.ts";
|
||||
import { TYPES } from "../types.ts";
|
||||
import { get, post } from "../helper/index.ts";
|
||||
import VideoRepository from "../repository/VideoRepository.ts";
|
||||
import { Context } from "koa";
|
||||
import DownloaderService from "../services/DownloaderService.ts";
|
||||
import DownloadService from "../services/DownloadService.ts";
|
||||
import Logger from "../vendor/Logger.ts";
|
||||
|
||||
@injectable()
|
||||
export default class DownloadController implements Controller {
|
||||
constructor(
|
||||
@inject(TYPES.VideoRepository)
|
||||
private readonly videoRepository: VideoRepository,
|
||||
@inject(TYPES.DownloaderService)
|
||||
private readonly downloaderService: DownloaderService,
|
||||
@inject(TYPES.DownloadService)
|
||||
private readonly downloadService: DownloadService,
|
||||
@inject(TYPES.Logger)
|
||||
private readonly logger: Logger,
|
||||
) {}
|
||||
|
||||
@get("/")
|
||||
async getFavorites() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@post("add-download-item")
|
||||
async addDownloadItem(ctx: Context) {
|
||||
const video = ctx.request.body as DownloadItem;
|
||||
const item = await this.videoRepository.addVideo(video);
|
||||
return item;
|
||||
}
|
||||
|
||||
@post("add-download-items")
|
||||
async addDownloadItems(ctx: Context) {
|
||||
const videos = ctx.request.body as DownloadItem[];
|
||||
return this.downloaderService.addDownloadItems(videos);
|
||||
}
|
||||
|
||||
@post("get-download-items")
|
||||
async getDownloadItems(ctx: Context) {
|
||||
const pagination = ctx.request.body as DownloadItemPagination;
|
||||
const videos = await this.videoRepository.findVideos(pagination);
|
||||
return videos;
|
||||
}
|
||||
|
||||
@post("start-download")
|
||||
async startDownload(ctx: Context) {
|
||||
const { vid } = ctx.request.body as { vid: number };
|
||||
await this.downloaderService.startDownload(vid);
|
||||
}
|
||||
|
||||
@post("delete-download-item")
|
||||
async deleteDownloadItem(ctx: Context) {
|
||||
const { id } = ctx.request.body as { id: number };
|
||||
await this.videoRepository.deleteDownloadItem(id);
|
||||
}
|
||||
|
||||
@post("download-now")
|
||||
async downloadNow(ctx: Context) {
|
||||
const video = ctx.request.body as Omit<DownloadItem, "id">;
|
||||
await this.downloaderService.downloadNow(video);
|
||||
}
|
||||
|
||||
@post("download-items-now")
|
||||
async downloadItemsNow(ctx: Context) {
|
||||
const videos = ctx.request.body as Omit<DownloadItem, "id">[];
|
||||
// Add download
|
||||
const items = await this.downloaderService.addDownloadItems(videos);
|
||||
// Start downloading
|
||||
items.forEach((item) => this.downloaderService.startDownload(item.id));
|
||||
return items;
|
||||
}
|
||||
|
||||
@post("edit-download-now")
|
||||
async editDownloadNow(ctx: Context) {
|
||||
const video = ctx.request.body as DownloadItem;
|
||||
const item = await this.downloaderService.editDownloadItem(video);
|
||||
await this.downloaderService.startDownload(item.id);
|
||||
return item;
|
||||
}
|
||||
|
||||
@post("edit-download-item")
|
||||
async editDownloadItem(ctx: Context) {
|
||||
const video = ctx.request.body as DownloadItem;
|
||||
this.logger.info("editDownloadItem", video);
|
||||
return this.downloaderService.editDownloadItem(video);
|
||||
}
|
||||
|
||||
@post("stop-download")
|
||||
async stopDownload(ctx: Context) {
|
||||
const { id } = ctx.request.body as { id: number };
|
||||
|
||||
this.downloadService.stopTask(id);
|
||||
}
|
||||
|
||||
@post("get-video-folders")
|
||||
async getVideoFolders() {
|
||||
return this.downloaderService.getVideoFolders();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { inject, injectable } from "inversify";
|
||||
import { type Controller } from "../interfaces.ts";
|
||||
import { ConfigParams, TYPES } from "../types.ts";
|
||||
import FavoriteRepository from "../repository/FavoriteRepository.ts";
|
||||
import { get, post } from "../helper/index.ts";
|
||||
import Logger from "../vendor/Logger.ts";
|
||||
import ConfigService from "../services/ConfigService.ts";
|
||||
import { Context } from "koa";
|
||||
import SocketIO from "../vendor/SocketIO.ts";
|
||||
|
||||
@injectable()
|
||||
export default class HomeController implements Controller {
|
||||
constructor(
|
||||
@inject(TYPES.FavoriteRepository)
|
||||
private readonly favoriteRepository: FavoriteRepository,
|
||||
@inject(TYPES.Logger)
|
||||
private readonly logger: Logger,
|
||||
@inject(TYPES.ConfigService)
|
||||
private readonly config: ConfigService,
|
||||
@inject(TYPES.SocketIO)
|
||||
private readonly socket: SocketIO,
|
||||
) {}
|
||||
|
||||
@get("/")
|
||||
async getFavorites() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@post("get-app-store")
|
||||
async getAppStore() {
|
||||
const store = await this.config.getConfig();
|
||||
return store;
|
||||
}
|
||||
|
||||
@post("set-app-store")
|
||||
async setAppStore(ctx: Context) {
|
||||
const params = ctx.request.body as ConfigParams;
|
||||
this.config.setConfig(params);
|
||||
this.logger.info("set app store");
|
||||
return false;
|
||||
}
|
||||
|
||||
@post("socket-test")
|
||||
async socketTest(ctx: Context) {
|
||||
const { message } = ctx.request.body as { message: string };
|
||||
this.logger.info(message);
|
||||
|
||||
this.socket.emit("socket-test", message);
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import { inject, injectable, multiInject } from "inversify";
|
||||
import { Controller } from "../interfaces.ts";
|
||||
import { TYPES } from "../types.ts";
|
||||
import Router from "@koa/router";
|
||||
import { error, success } from "../helper/utils.ts";
|
||||
import { API_PREFIX } from "../const.ts";
|
||||
import path from "path";
|
||||
import Logger from "../vendor/Logger.ts";
|
||||
|
||||
@injectable()
|
||||
export default class RouterHandlerService extends Router {
|
||||
constructor(
|
||||
@multiInject(TYPES.Controller)
|
||||
private readonly controllers: Controller[],
|
||||
@inject(TYPES.Logger)
|
||||
private readonly logger: Logger,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
private registerIpc(
|
||||
controller: Controller,
|
||||
propertyKey: string | symbol,
|
||||
): void {
|
||||
const property = controller[propertyKey];
|
||||
if (typeof property !== "function") return;
|
||||
|
||||
const httpMethod: "get" | "post" = Reflect.getMetadata(
|
||||
"http-method",
|
||||
controller,
|
||||
propertyKey,
|
||||
);
|
||||
if (!httpMethod) return;
|
||||
|
||||
const routerPath = Reflect.getMetadata(
|
||||
"router-path",
|
||||
controller,
|
||||
propertyKey,
|
||||
);
|
||||
if (!routerPath) return;
|
||||
|
||||
const finalPath = path
|
||||
.join(API_PREFIX, routerPath)
|
||||
.replace(/\\/g, "/")
|
||||
.replace(/\/$/, "");
|
||||
this[httpMethod](finalPath, async (context, next) => {
|
||||
try {
|
||||
let res = property.call(controller, context, next);
|
||||
if (res.then) {
|
||||
res = await res;
|
||||
}
|
||||
context.body = success(res);
|
||||
} catch (e: unknown) {
|
||||
this.logger.error(e);
|
||||
if (e instanceof Error) {
|
||||
context.body = error(e.message);
|
||||
} else {
|
||||
context.body = error(String(e));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
init(): void {
|
||||
for (const controller of this.controllers) {
|
||||
const Class = Object.getPrototypeOf(controller);
|
||||
Object.getOwnPropertyNames(Class).forEach((propertyKey) =>
|
||||
this.registerIpc(controller, propertyKey),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export interface Vendor {
|
||||
init(): Promise<void>;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm";
|
||||
import { AppLanguage, AppTheme } from "../types.ts";
|
||||
import { DOWNLOAD_DIR } from "../const.ts";
|
||||
|
||||
@Entity({
|
||||
name: "config",
|
||||
})
|
||||
export class Config {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
nullable: false,
|
||||
default: DOWNLOAD_DIR,
|
||||
})
|
||||
local: string;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
enum: AppTheme,
|
||||
nullable: false,
|
||||
default: AppTheme.System,
|
||||
})
|
||||
theme: AppTheme;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
enum: AppLanguage,
|
||||
nullable: false,
|
||||
default: AppLanguage.System,
|
||||
})
|
||||
language: AppLanguage;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
nullable: false,
|
||||
default: "",
|
||||
})
|
||||
proxy: string;
|
||||
|
||||
@Column({
|
||||
type: "boolean",
|
||||
default: false,
|
||||
nullable: false,
|
||||
})
|
||||
isLive: boolean;
|
||||
|
||||
@Column({
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
default: false,
|
||||
})
|
||||
downloadProxySwitch: boolean;
|
||||
|
||||
@Column({
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
default: true,
|
||||
})
|
||||
deleteSegments: boolean;
|
||||
|
||||
@Column({
|
||||
type: "int",
|
||||
nullable: false,
|
||||
default: 2,
|
||||
})
|
||||
maxRunner: number;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdDate: Date;
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedDate: Date;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm";
|
||||
|
||||
@Entity({
|
||||
name: "favorite",
|
||||
})
|
||||
export class Favorite {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
nullable: false,
|
||||
})
|
||||
title: string;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
nullable: false,
|
||||
})
|
||||
url: string;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
nullable: true,
|
||||
})
|
||||
icon?: string;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdDate: Date;
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedDate: Date;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import { DownloadStatus, DownloadType } from "../interfaces.ts";
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm";
|
||||
|
||||
@Entity({
|
||||
name: "video",
|
||||
})
|
||||
export class Video {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
nullable: false,
|
||||
})
|
||||
name: string;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
nullable: true,
|
||||
})
|
||||
folder?: string;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
nullable: false,
|
||||
default: DownloadType.m3u8,
|
||||
})
|
||||
type: DownloadType;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
nullable: false,
|
||||
})
|
||||
url: string;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
nullable: true,
|
||||
})
|
||||
headers?: string;
|
||||
|
||||
@Column({
|
||||
type: "boolean",
|
||||
default: false,
|
||||
nullable: false,
|
||||
})
|
||||
isLive: boolean;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
nullable: false,
|
||||
default: DownloadStatus.Ready,
|
||||
})
|
||||
status: DownloadStatus;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
nullable: false,
|
||||
default: "",
|
||||
})
|
||||
log: string;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdDate: Date;
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedDate: Date;
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
/* eslint-disable no-var */
|
||||
declare global {
|
||||
var __bin__: string;
|
||||
}
|
||||
|
||||
export {};
|
||||
@@ -0,0 +1,13 @@
|
||||
export const get = (route: string) => {
|
||||
return (target: any, propertyKey: string): void => {
|
||||
Reflect.defineMetadata("http-method", "get", target, propertyKey);
|
||||
Reflect.defineMetadata("router-path", route, target, propertyKey);
|
||||
};
|
||||
};
|
||||
|
||||
export const post = (route: string) => {
|
||||
return (target: any, propertyName: string): void => {
|
||||
Reflect.defineMetadata("http-method", "post", target, propertyName);
|
||||
Reflect.defineMetadata("router-path", route, target, propertyName);
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
import { spawn } from "child_process";
|
||||
import { ffmpegPath } from "./variables.ts";
|
||||
|
||||
export const convertToAudio = async (
|
||||
input: string,
|
||||
output: string,
|
||||
): Promise<void> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const ffmpeg = spawn(ffmpegPath, [
|
||||
"-y",
|
||||
"-v",
|
||||
"error",
|
||||
"-i",
|
||||
input,
|
||||
"-acodec",
|
||||
"mp3",
|
||||
"-format",
|
||||
"mp3",
|
||||
output,
|
||||
]);
|
||||
let errData = "";
|
||||
|
||||
ffmpeg.stderr.on("data", (data) => {
|
||||
errData += String(data);
|
||||
});
|
||||
|
||||
ffmpeg.on("error", (err) => {
|
||||
reject(err);
|
||||
});
|
||||
|
||||
ffmpeg.on("close", (code) => {
|
||||
if (code === 0) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(new Error(errData));
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
import os from "os";
|
||||
|
||||
export function getLocalIP() {
|
||||
const interfaces = os.networkInterfaces();
|
||||
let localIP = "";
|
||||
|
||||
// Traverse the network interface
|
||||
for (const key in interfaces) {
|
||||
const iface = interfaces[key];
|
||||
if (!iface) continue;
|
||||
|
||||
// IPv4 addresses that are not loopback addresses are filtered out
|
||||
const filteredIface = iface.filter(
|
||||
(details) => details.family === "IPv4" && !details.internal,
|
||||
);
|
||||
|
||||
if (filteredIface.length > 0) {
|
||||
localIP = filteredIface[0].address;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return localIP;
|
||||
}
|
||||
|
||||
export { sleep, formatHeaders } from "./utils.ts";
|
||||
export * from "./variables.ts";
|
||||
export { get, post } from "./decorator.ts";
|
||||
export { convertToAudio } from "./ffmpeg.ts";
|
||||
@@ -0,0 +1,37 @@
|
||||
import EventEmitter from "events";
|
||||
|
||||
export async function sleep(second = 1): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, second * 1000));
|
||||
}
|
||||
|
||||
export function formatHeaders(headers: Record<string, string>): string {
|
||||
if (!headers) return "";
|
||||
const formatted = Object.entries(headers)
|
||||
.map(([key, value]) => `${key}:${value}`)
|
||||
.join("\n");
|
||||
return formatted;
|
||||
}
|
||||
|
||||
export const event = new EventEmitter();
|
||||
|
||||
export interface IpcResponse {
|
||||
code: number;
|
||||
message: string;
|
||||
data: Record<string, any> | null;
|
||||
}
|
||||
|
||||
export function success(data: Record<string, any>): IpcResponse {
|
||||
return {
|
||||
code: 0,
|
||||
message: "success",
|
||||
data,
|
||||
};
|
||||
}
|
||||
|
||||
export function error(message = "fail"): IpcResponse {
|
||||
return {
|
||||
code: -1,
|
||||
message,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { resolve } from "path";
|
||||
import { BIN_DIR } from "../const.ts";
|
||||
|
||||
export enum Platform {
|
||||
Windows = "win32",
|
||||
MacOS = "darwin",
|
||||
Linux = "linux",
|
||||
}
|
||||
|
||||
export const isMac = process.platform === Platform.MacOS;
|
||||
export const isWin = process.platform === Platform.Windows;
|
||||
export const isLinux = process.platform === Platform.Linux;
|
||||
|
||||
export function resolveBin(path: string) {
|
||||
if (isWin) {
|
||||
path += ".exe";
|
||||
}
|
||||
return resolve(BIN_DIR, path);
|
||||
}
|
||||
|
||||
export const appName = process.env.APP_NAME || "mediago";
|
||||
export const defaultScheme = "mediago";
|
||||
export const PERSIST_MEDIAGO = "persist:mediago";
|
||||
export const PERSIST_WEBVIEW = "persist:webview";
|
||||
export const PRIVACY_WEBVIEW = "webview";
|
||||
|
||||
// bin path
|
||||
export const ffmpegPath = resolveBin("ffmpeg");
|
||||
export const biliDownloaderBin = resolveBin("BBDown");
|
||||
export const m3u8DownloaderBin = resolveBin("N_m3u8DL-RE");
|
||||
|
||||
// user agent
|
||||
export const pcUA = "";
|
||||
export const mobileUA =
|
||||
"Mozilla/5.0 (Linux; Android 11; SAMSUNG SM-G973U) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/14.2 Chrome/87.0.4280.141 Mobile Safari/537.36";
|
||||
@@ -0,0 +1,114 @@
|
||||
import i18n from "i18next";
|
||||
|
||||
i18n.init({
|
||||
debug: process.env.NODE_ENV === "development",
|
||||
fallbackLng: "zh",
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
},
|
||||
resources: {
|
||||
en: {
|
||||
translation: {
|
||||
processIPC: "Processing ipc [{{channel}}] event exception: ",
|
||||
open: "Open",
|
||||
delete: "Delete",
|
||||
noMainWindow: "No main window found",
|
||||
copyLinkAddress: "Copy Link Address",
|
||||
select: "Select",
|
||||
download: "Download",
|
||||
refresh: "Refresh",
|
||||
openFolder: "Download Folder",
|
||||
openFile: "Open File",
|
||||
noFileFound: "No file found",
|
||||
exportFavorites: "Export Favorites",
|
||||
copy: "Copy",
|
||||
paste: "Paste",
|
||||
noTaskFound: "No task found",
|
||||
urlExist: "Url already exists",
|
||||
videoExistsPleaseChangeName:
|
||||
"Video name already exists, please change the video name",
|
||||
videoNotExists: "Video does not exist",
|
||||
unknownError: "Unknown error",
|
||||
unsupportedDownloadType: "Unsupported download type",
|
||||
captureVideoLinkInWindow: "Capture video link in window: {{url}}",
|
||||
browserViewNotFound: "Browser view not found",
|
||||
currentWindowNotFound: "Current window not found",
|
||||
proxyNotAllowEmpty: "[Proxy] Proxy cannot be empty",
|
||||
enableProxy: "[Proxy] Enable Proxy({{proxy}})",
|
||||
disableProxy: "[Proxy] Disable Proxy",
|
||||
adBlockerEnableFailed: "[AdBlocker] AdBlocker enable failed",
|
||||
enableADBlocker: "[AdBlocker] Enable AD Blocker",
|
||||
adBlockerDisableFailed: "[AdBlocker] AdBlocker disable failed",
|
||||
disableADBlocker: "[AdBlocker] Disable AD Blocker",
|
||||
ua: '[UA] User-Agent: "{{ua}}"',
|
||||
session: "[Session] {{mode}} Mode",
|
||||
currentEnvironmentIsDevelopment:
|
||||
"Current environment is development, start loading developer tools",
|
||||
loadDevToolsSuccess: "Load developer tools successfully",
|
||||
loadDevToolsFailed: "Failed to load developer tools",
|
||||
autoUpdateSuccess: "Auto update success",
|
||||
nextTimeWillAutoInstall: "Will be automatically installed next time",
|
||||
downloadSuccess: "Download success",
|
||||
videoDownloadSuccess: "{{name}} download success",
|
||||
downloadFailed: "Download failed",
|
||||
videoDownloadFailed: "{{name}} download failed",
|
||||
showMainWindow: "Show main window",
|
||||
exitApp: "Exit app",
|
||||
updateAvailable: "Update available.",
|
||||
updateNotAvailable: "No updates available.",
|
||||
},
|
||||
},
|
||||
zh: {
|
||||
translation: {
|
||||
processIPC: "处理 ipc [{{channel}}] 事件时异常: ",
|
||||
open: "打开",
|
||||
delete: "删除",
|
||||
noMainWindow: "未找到主窗口",
|
||||
copyLinkAddress: "复制链接地址",
|
||||
select: "选择",
|
||||
download: "下载",
|
||||
refresh: "刷新",
|
||||
openFolder: "下载目录",
|
||||
openFile: "打开文件",
|
||||
noFileFound: "未找到文件",
|
||||
exportFavorites: "导出收藏",
|
||||
copy: "复制",
|
||||
paste: "粘贴",
|
||||
noTaskFound: "未找到任务",
|
||||
urlExist: "链接已存在",
|
||||
videoExistsPleaseChangeName: "视频名称已存在,请更改视频名称",
|
||||
videoNotExists: "视频不存在",
|
||||
unknownError: "未知错误",
|
||||
unsupportedDownloadType: "不支持的下载类型",
|
||||
captureVideoLinkInWindow: "在窗口中捕获视频链接: {{url}}",
|
||||
browserViewNotFound: "未找到 BrowserView",
|
||||
currentWindowNotFound: "未找到当前窗口",
|
||||
proxyNotAllowEmpty: "[Proxy] 代理不能为空",
|
||||
enableProxy: "[Proxy] 启用代理({{proxy}})",
|
||||
disableProxy: "[Proxy] 关闭代理",
|
||||
adBlockerEnableFailed: "[AdBlocker] AdBlocker 启用失败",
|
||||
enableADBlocker: "[AdBlocker] 启用 AD Blocker",
|
||||
adBlockerDisableFailed: "[AdBlocker] AdBlocker 关闭失败",
|
||||
disableADBlocker: "[AdBlocker] 关闭 AD Blocker",
|
||||
ua: '[UA] User-Agent: "{{ua}}"',
|
||||
session: "[Session] {{mode}} 模式",
|
||||
currentEnvironmentIsDevelopment:
|
||||
"当前环境为开发环境,开始加载开发者工具",
|
||||
loadDevToolsSuccess: "加载开发者工具成功",
|
||||
loadDevToolsFailed: "加载开发者工具失败",
|
||||
autoUpdateSuccess: "自动更新成功",
|
||||
nextTimeWillAutoInstall: "下次将自动安装",
|
||||
downloadSuccess: "下载成功",
|
||||
videoDownloadSuccess: "{{name}} 下载成功",
|
||||
downloadFailed: "下载失败",
|
||||
videoDownloadFailed: "{{name}} 下载失败",
|
||||
showMainWindow: "显示主窗口",
|
||||
exitApp: "退出应用",
|
||||
updateAvailable: "有可用更新。",
|
||||
updateNotAvailable: "没有可用更新。",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default i18n;
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
declare module "*.svg";
|
||||
declare module "*.png";
|
||||
declare module "*.jpg";
|
||||
declare module "*.jpeg";
|
||||
declare module "*.gif";
|
||||
declare module "*.bmp";
|
||||
declare module "*.tiff";
|
||||
@@ -0,0 +1,7 @@
|
||||
import "reflect-metadata";
|
||||
import { container } from "./inversify.config.ts";
|
||||
import { TYPES } from "./types.ts";
|
||||
import ElectronApp from "./app.ts";
|
||||
|
||||
const mediago = container.get<ElectronApp>(TYPES.ElectronApp);
|
||||
mediago.init();
|
||||
@@ -0,0 +1,73 @@
|
||||
export type Controller = Record<string | symbol, any>;
|
||||
|
||||
export interface DownloadItem {
|
||||
id: number;
|
||||
type: DownloadType;
|
||||
name: string;
|
||||
url: string;
|
||||
headers?: string;
|
||||
status?: DownloadStatus;
|
||||
isLive?: boolean;
|
||||
folder?: string;
|
||||
}
|
||||
|
||||
export enum DownloadFilter {
|
||||
list = "list",
|
||||
done = "done",
|
||||
}
|
||||
|
||||
export interface DownloadItemPagination {
|
||||
current?: number;
|
||||
pageSize?: number;
|
||||
filter?: DownloadFilter;
|
||||
}
|
||||
|
||||
export interface ConversionPagination {
|
||||
current?: number;
|
||||
pageSize?: number;
|
||||
}
|
||||
|
||||
export interface VideoResponse {
|
||||
total: number;
|
||||
list: DownloadItem[];
|
||||
}
|
||||
|
||||
export enum DownloadStatus {
|
||||
Ready = "ready",
|
||||
Watting = "watting",
|
||||
Downloading = "downloading",
|
||||
Stopped = "stopped",
|
||||
Success = "success",
|
||||
Failed = "failed",
|
||||
}
|
||||
|
||||
export type Task = {
|
||||
id: number;
|
||||
params: Omit<DownloadParams, "id" | "abortSignal" | "callback">;
|
||||
};
|
||||
|
||||
export interface DownloadProgress {
|
||||
id: number;
|
||||
type: string;
|
||||
percent: string;
|
||||
speed: string;
|
||||
isLive: boolean;
|
||||
}
|
||||
|
||||
export enum DownloadType {
|
||||
m3u8 = "m3u8",
|
||||
bilibili = "bilibili",
|
||||
}
|
||||
export interface DownloadParams {
|
||||
id: number;
|
||||
type: DownloadType;
|
||||
url: string;
|
||||
local: string;
|
||||
name: string;
|
||||
headers?: string;
|
||||
abortSignal: AbortController;
|
||||
proxy?: string;
|
||||
deleteSegments?: boolean;
|
||||
callback: (progress: DownloadProgress) => void;
|
||||
folder?: string;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import HomeController from "./controller/HomeController.ts";
|
||||
import { Container } from "inversify";
|
||||
import FavoriteRepository from "./repository/FavoriteRepository.ts";
|
||||
import ElectronApp from "./app.ts";
|
||||
import { Controller } from "./interfaces.ts";
|
||||
import { TYPES } from "./types.ts";
|
||||
import TypeORM from "./vendor/TypeORM.ts";
|
||||
import RouterHandler from "./core/router.ts";
|
||||
import HomeService from "./services/HomeService.ts";
|
||||
import Logger from "./vendor/Logger.ts";
|
||||
import DownloadController from "./controller/DownloadController.ts";
|
||||
import VideoRepository from "./repository/VideoRepository.ts";
|
||||
import ConfigRepository from "./repository/ConfigRepository.ts";
|
||||
import ConfigService from "./services/ConfigService.ts";
|
||||
import DownloadService from "./services/DownloadService.ts";
|
||||
import SocketIO from "./vendor/SocketIO.ts";
|
||||
import DownloaderService from "./services/DownloaderService.ts";
|
||||
|
||||
const container = new Container({
|
||||
skipBaseClassChecks: true,
|
||||
defaultScope: "Singleton",
|
||||
autoBindInjectable: true,
|
||||
});
|
||||
|
||||
container
|
||||
.bind<ElectronApp>(TYPES.ElectronApp)
|
||||
.to(ElectronApp)
|
||||
.inSingletonScope();
|
||||
|
||||
// services
|
||||
container.bind<HomeService>(TYPES.HomeService).to(HomeService);
|
||||
container.bind<ConfigService>(TYPES.ConfigService).to(ConfigService);
|
||||
container.bind<DownloadService>(TYPES.DownloadService).to(DownloadService);
|
||||
container
|
||||
.bind<DownloaderService>(TYPES.DownloaderService)
|
||||
.to(DownloaderService);
|
||||
|
||||
// controller
|
||||
container.bind<Controller>(TYPES.Controller).to(HomeController);
|
||||
container.bind<Controller>(TYPES.Controller).to(DownloadController);
|
||||
|
||||
// repository
|
||||
container
|
||||
.bind<FavoriteRepository>(TYPES.FavoriteRepository)
|
||||
.to(FavoriteRepository);
|
||||
container.bind<VideoRepository>(TYPES.VideoRepository).to(VideoRepository);
|
||||
container.bind<ConfigRepository>(TYPES.ConfigRepository).to(ConfigRepository);
|
||||
|
||||
// vendor
|
||||
container.bind<TypeORM>(TYPES.TypeORM).to(TypeORM);
|
||||
container.bind<Logger>(TYPES.Logger).to(Logger);
|
||||
container.bind<SocketIO>(TYPES.SocketIO).to(SocketIO);
|
||||
|
||||
// core
|
||||
container
|
||||
.bind<RouterHandler>(TYPES.RouterHandlerService)
|
||||
.to(RouterHandler)
|
||||
.inSingletonScope();
|
||||
|
||||
export { container };
|
||||
Vendored
+66
@@ -0,0 +1,66 @@
|
||||
import { Rectangle } from "electron";
|
||||
import { type DownloadType } from "interfaces";
|
||||
import { AppLanguage, AppTheme } from "./types";
|
||||
|
||||
declare interface EnvPath {
|
||||
binPath: string;
|
||||
dbPath: string;
|
||||
workspace: string;
|
||||
platform: string;
|
||||
local: string;
|
||||
}
|
||||
|
||||
declare interface BrowserWindowInitialVal {
|
||||
url?: string;
|
||||
sourceList?: WebSource[];
|
||||
}
|
||||
|
||||
declare interface WebSource {
|
||||
url: string;
|
||||
type: DownloadType;
|
||||
name: string;
|
||||
headers?: string;
|
||||
}
|
||||
|
||||
declare interface AppStore {
|
||||
// Local storage address
|
||||
local: string;
|
||||
// Download completion tone
|
||||
promptTone: boolean;
|
||||
// Proxy address
|
||||
proxy: string;
|
||||
// Whether to enable agent
|
||||
useProxy: boolean;
|
||||
// Delete the original file after downloading
|
||||
deleteSegments: boolean;
|
||||
// A new window opens the browser
|
||||
openInNewWindow: boolean;
|
||||
mainBounds?: Rectangle;
|
||||
browserBounds?: Rectangle;
|
||||
blockAds: boolean;
|
||||
// theme
|
||||
theme: AppTheme;
|
||||
// Using browser plugins
|
||||
useExtension: boolean;
|
||||
// Whether to use mobile UA
|
||||
isMobile: boolean;
|
||||
// Maximum number of simultaneous downloads
|
||||
maxRunner: number;
|
||||
// Language
|
||||
language: AppLanguage;
|
||||
// Show terminal or not
|
||||
showTerminal: boolean;
|
||||
// Privacy mode
|
||||
privacy: boolean;
|
||||
// Machine id
|
||||
machineId: string;
|
||||
// Download proxy Settings
|
||||
downloadProxySwitch: boolean;
|
||||
// Automatic update
|
||||
autoUpgrade: boolean;
|
||||
}
|
||||
|
||||
declare interface BrowserStore {
|
||||
url: string;
|
||||
sourceList: WebSource[];
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { inject, injectable } from "inversify";
|
||||
import { ConfigParams, TYPES } from "../types.ts";
|
||||
import TypeORM from "../vendor/TypeORM.ts";
|
||||
import { Repository } from "typeorm";
|
||||
import { Config } from "../entity/Config.ts";
|
||||
|
||||
@injectable()
|
||||
export default class ConfigRepository {
|
||||
repository: Repository<Config>;
|
||||
|
||||
constructor(
|
||||
@inject(TYPES.TypeORM)
|
||||
private readonly db: TypeORM,
|
||||
) {
|
||||
this.repository = this.db.manager.getRepository(Config);
|
||||
}
|
||||
|
||||
async getConfig(): Promise<Config> {
|
||||
const config = await this.repository.findOneBy({ id: 1 });
|
||||
if (!config) {
|
||||
return await this.repository.save(new Config());
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
async setConfig({ key, val }: ConfigParams) {
|
||||
const config = await this.getConfig();
|
||||
this.repository.update(config.id, { [key]: val });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { inject, injectable } from "inversify";
|
||||
import { TYPES } from "../types.ts";
|
||||
import { Favorite } from "../entity/Favorite.ts";
|
||||
import TypeORM from "../vendor/TypeORM.ts";
|
||||
|
||||
@injectable()
|
||||
export default class FavoriteRepository {
|
||||
constructor(
|
||||
@inject(TYPES.TypeORM)
|
||||
private readonly db: TypeORM,
|
||||
) {}
|
||||
|
||||
async findFavorites(): Promise<Favorite[]> {
|
||||
return await this.db.manager.find(Favorite, {
|
||||
order: {
|
||||
createdDate: "desc",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async addFavorite(favorite: Favorite): Promise<Favorite> {
|
||||
const exist = await this.db.manager.findOne(Favorite, {
|
||||
where: {
|
||||
url: favorite.url,
|
||||
},
|
||||
});
|
||||
|
||||
if (exist) {
|
||||
throw new Error("网址已经存在");
|
||||
}
|
||||
|
||||
const item = new Favorite();
|
||||
item.title = favorite.title;
|
||||
item.url = favorite.url;
|
||||
item.icon = favorite.icon;
|
||||
return await this.db.manager.save(item);
|
||||
}
|
||||
|
||||
async removeFavorite(id: number): Promise<void> {
|
||||
await this.db.manager.getRepository(Favorite).delete(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
import { Video } from "../entity/Video.ts";
|
||||
import { inject, injectable } from "inversify";
|
||||
import {
|
||||
DownloadFilter,
|
||||
DownloadItem,
|
||||
DownloadItemPagination,
|
||||
DownloadStatus,
|
||||
} from "../interfaces.ts";
|
||||
import { TYPES } from "../types.ts";
|
||||
import { In, Not } from "typeorm";
|
||||
import TypeORM from "../vendor/TypeORM.ts";
|
||||
import i18n from "../i18n/index.ts";
|
||||
|
||||
@injectable()
|
||||
export default class VideoRepository {
|
||||
constructor(
|
||||
@inject(TYPES.TypeORM)
|
||||
private readonly db: TypeORM,
|
||||
) {}
|
||||
|
||||
async addVideo(video: Omit<DownloadItem, "id">) {
|
||||
// Let's see if there's a video with the same name
|
||||
const exist = await this.findVideoByName(video.name);
|
||||
if (exist) {
|
||||
throw new Error(i18n.t("videoExistsPleaseChangeName"));
|
||||
}
|
||||
const item = new Video();
|
||||
item.name = video.name;
|
||||
item.url = video.url;
|
||||
item.type = video.type;
|
||||
video.headers && (item.headers = video.headers);
|
||||
video.folder && (item.folder = video.folder);
|
||||
return await this.db.manager.save(item);
|
||||
}
|
||||
|
||||
async addVideos(videos: Omit<DownloadItem, "id">[]) {
|
||||
// Check for videos with the same name
|
||||
const names = videos.map((item) => item.name);
|
||||
const existItems = await this.db.appDataSource
|
||||
.getRepository(Video)
|
||||
.findBy({ name: In(names) });
|
||||
if (existItems.length) {
|
||||
const existNames = existItems.map((item) => item.name);
|
||||
throw new Error(
|
||||
i18n.t("videoExistsPleaseChangeName") +
|
||||
"[" +
|
||||
existNames.join(", ") +
|
||||
"]",
|
||||
);
|
||||
}
|
||||
|
||||
const items = videos.map((video) => {
|
||||
const item = new Video();
|
||||
item.name = video.name;
|
||||
item.url = video.url;
|
||||
item.type = video.type;
|
||||
video.headers && (item.headers = video.headers);
|
||||
video.folder && (item.folder = video.folder);
|
||||
return item;
|
||||
});
|
||||
return await this.db.manager.save(items);
|
||||
}
|
||||
|
||||
// Edit video
|
||||
async editVideo(video: DownloadItem) {
|
||||
const item = await this.db.appDataSource
|
||||
.getRepository(Video)
|
||||
.findOneBy({ id: video.id });
|
||||
if (!item) {
|
||||
throw new Error(i18n.t("videoNotExists"));
|
||||
}
|
||||
item.name = video.name;
|
||||
item.url = video.url;
|
||||
video.headers && (item.headers = video.headers);
|
||||
video.folder && (item.folder = video.folder);
|
||||
return await this.db.manager.save(item);
|
||||
}
|
||||
|
||||
// Find all Videos
|
||||
async findAllVideos() {
|
||||
return await this.db.appDataSource.getRepository(Video).find({
|
||||
order: {
|
||||
createdDate: "DESC",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async findVideos(pagination: DownloadItemPagination) {
|
||||
const {
|
||||
current = 0,
|
||||
pageSize = 50,
|
||||
filter = DownloadFilter.list,
|
||||
} = pagination;
|
||||
const filterCondition =
|
||||
filter === DownloadFilter.done
|
||||
? DownloadStatus.Success
|
||||
: Not(DownloadStatus.Success);
|
||||
|
||||
const [items, count] = await this.db.appDataSource
|
||||
.getRepository(Video)
|
||||
.findAndCount({
|
||||
where: {
|
||||
status: filterCondition,
|
||||
},
|
||||
order: {
|
||||
createdDate: "ASC",
|
||||
},
|
||||
skip: (current - 1) * pageSize,
|
||||
take: pageSize,
|
||||
});
|
||||
return {
|
||||
total: count,
|
||||
list: items,
|
||||
};
|
||||
}
|
||||
|
||||
async findVideo(id: number) {
|
||||
const repository = this.db.appDataSource.getRepository(Video);
|
||||
const video = await repository.findOneBy({ id });
|
||||
|
||||
if (!video) {
|
||||
throw new Error(i18n.t("videoNotExists"));
|
||||
}
|
||||
|
||||
return video;
|
||||
}
|
||||
|
||||
async findVideoByName(name: string) {
|
||||
return this.db.appDataSource.getRepository(Video).findOneBy({
|
||||
name,
|
||||
});
|
||||
}
|
||||
|
||||
async changeVideoStatus(id: number | number[], status: DownloadStatus) {
|
||||
const ids = !Array.isArray(id) ? [id] : id;
|
||||
const videoRepository = this.db.appDataSource.getRepository(Video);
|
||||
const videos = await videoRepository.findBy({ id: In(ids) });
|
||||
for (const video of videos) {
|
||||
video.status = status;
|
||||
}
|
||||
await videoRepository.save(videos);
|
||||
}
|
||||
|
||||
async changeVideoIsLive(id: number) {
|
||||
const video = await this.findVideo(id);
|
||||
video.isLive = true;
|
||||
return this.db.manager.save(video);
|
||||
}
|
||||
|
||||
async findWattingAndDownloadingVideos() {
|
||||
return await this.db.appDataSource.getRepository(Video).find({
|
||||
where: {
|
||||
status: In([DownloadStatus.Downloading, DownloadStatus.Watting]),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async deleteDownloadItem(id: number) {
|
||||
return await this.db.appDataSource.getRepository(Video).delete(id);
|
||||
}
|
||||
|
||||
async findVideoByUrl(url: string) {
|
||||
return this.db.appDataSource.getRepository(Video).findOneBy({
|
||||
url,
|
||||
});
|
||||
}
|
||||
|
||||
async appendDownloadLog(id: number, message: string) {
|
||||
const video = await this.findVideo(id);
|
||||
video.log = video.log ? `${video.log}\n${message}` : message;
|
||||
return await this.db.manager.save(video);
|
||||
}
|
||||
|
||||
async getDownloadLog(id: number) {
|
||||
const video = await this.findVideo(id);
|
||||
return video.log;
|
||||
}
|
||||
|
||||
async getVideoFolders() {
|
||||
const videos = await this.db.appDataSource.getRepository(Video).find();
|
||||
const folders = new Set<string>();
|
||||
for (const video of videos) {
|
||||
if (video.folder) {
|
||||
folders.add(video.folder);
|
||||
}
|
||||
}
|
||||
return Array.from(folders);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { inject, injectable } from "inversify";
|
||||
import { ConfigParams, TYPES } from "../types.ts";
|
||||
import ConfigRepository from "../repository/ConfigRepository.ts";
|
||||
|
||||
@injectable()
|
||||
export default class ConfigService {
|
||||
constructor(
|
||||
@inject(TYPES.ConfigRepository)
|
||||
private readonly configRepository: ConfigRepository,
|
||||
) {}
|
||||
|
||||
async getConfig() {
|
||||
return await this.configRepository.getConfig();
|
||||
}
|
||||
|
||||
async setConfig({ key, val }: ConfigParams) {
|
||||
return await this.configRepository.setConfig({ key, val });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,422 @@
|
||||
import EventEmitter from "events";
|
||||
import { inject, injectable } from "inversify";
|
||||
import {
|
||||
DownloadParams,
|
||||
DownloadProgress,
|
||||
DownloadStatus,
|
||||
Task,
|
||||
} from "../interfaces.ts";
|
||||
import { TYPES } from "../types.ts";
|
||||
import Logger from "../vendor/Logger.ts";
|
||||
import VideoRepository from "../repository/VideoRepository.ts";
|
||||
import {
|
||||
Platform,
|
||||
biliDownloaderBin,
|
||||
m3u8DownloaderBin,
|
||||
} from "../helper/index.ts";
|
||||
import * as pty from "node-pty";
|
||||
import stripAnsi from "strip-ansi";
|
||||
import i18n from "../i18n/index.ts";
|
||||
import ConfigService from "./ConfigService.ts";
|
||||
import path from "path";
|
||||
|
||||
interface DownloadContext {
|
||||
// Whether it is live
|
||||
isLive: boolean;
|
||||
// Download progress
|
||||
percent: string;
|
||||
// Download speed
|
||||
speed: string;
|
||||
// Ready
|
||||
ready: boolean;
|
||||
}
|
||||
|
||||
export interface DownloadOptions {
|
||||
abortSignal: AbortController;
|
||||
encoding?: string;
|
||||
onMessage?: (ctx: DownloadContext, message: string) => void;
|
||||
id: number;
|
||||
}
|
||||
|
||||
interface Schema {
|
||||
args: Record<string, { argsName: string[] | null }>;
|
||||
consoleReg: {
|
||||
percent: string;
|
||||
speed: string;
|
||||
error: string;
|
||||
start: string;
|
||||
isLive: string;
|
||||
};
|
||||
bin: string;
|
||||
platform: string[];
|
||||
type: string;
|
||||
}
|
||||
|
||||
// FIXME: Multilingual regular expressions
|
||||
const processList: Schema[] = [
|
||||
{
|
||||
type: "m3u8",
|
||||
platform: [Platform.MacOS, Platform.Linux, Platform.Windows],
|
||||
bin: m3u8DownloaderBin,
|
||||
args: {
|
||||
url: {
|
||||
argsName: null,
|
||||
},
|
||||
localDir: {
|
||||
argsName: ["--tmp-dir", "--save-dir"],
|
||||
},
|
||||
name: {
|
||||
argsName: ["--save-name"],
|
||||
},
|
||||
headers: {
|
||||
argsName: ["--header"],
|
||||
},
|
||||
deleteSegments: {
|
||||
argsName: ["--del-after-done"],
|
||||
},
|
||||
proxy: {
|
||||
argsName: ["--custom-proxy"],
|
||||
},
|
||||
__common__: {
|
||||
argsName: [
|
||||
"--no-log",
|
||||
"--auto-select",
|
||||
"--ui-language",
|
||||
"zh-CN",
|
||||
"--live-real-time-merge",
|
||||
],
|
||||
},
|
||||
},
|
||||
consoleReg: {
|
||||
percent: "([\\d.]+)%",
|
||||
speed: "([\\d.]+[GMK]Bps)",
|
||||
error: "ERROR",
|
||||
start: "保存文件名:",
|
||||
isLive: "检测到直播流",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "bilibili",
|
||||
platform: [Platform.Linux, Platform.MacOS, Platform.Windows],
|
||||
bin: biliDownloaderBin,
|
||||
args: {
|
||||
url: {
|
||||
argsName: null,
|
||||
},
|
||||
localDir: {
|
||||
argsName: ["--work-dir"],
|
||||
},
|
||||
name: {
|
||||
argsName: ["--file-pattern"],
|
||||
},
|
||||
},
|
||||
consoleReg: {
|
||||
speed: "([\\d.]+\\s[GMK]B/s)",
|
||||
percent: "([\\d.]+)%",
|
||||
error: "ERROR",
|
||||
start: "开始下载",
|
||||
isLive: "检测到直播流",
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@injectable()
|
||||
export default class DownloadService extends EventEmitter {
|
||||
private queue: Task[] = [];
|
||||
|
||||
private active: Task[] = [];
|
||||
|
||||
private limit: number = 2;
|
||||
|
||||
private signal: Record<number, AbortController> = {};
|
||||
|
||||
constructor(
|
||||
@inject(TYPES.Logger)
|
||||
private readonly logger: Logger,
|
||||
@inject(TYPES.VideoRepository)
|
||||
private readonly videoRepository: VideoRepository,
|
||||
@inject(TYPES.ConfigService)
|
||||
private readonly storeService: ConfigService,
|
||||
) {
|
||||
super();
|
||||
|
||||
// this.storeService.getConfig().then(({ maxRunner }) => {
|
||||
// this.limit = maxRunner;
|
||||
// });
|
||||
}
|
||||
|
||||
async addTask(task: Task) {
|
||||
this.queue.push(task);
|
||||
this.runTask();
|
||||
}
|
||||
|
||||
async stopTask(id: number) {
|
||||
if (this.signal[id]) {
|
||||
this.signal[id].abort();
|
||||
}
|
||||
}
|
||||
|
||||
async execute(task: Task) {
|
||||
try {
|
||||
await this.videoRepository.changeVideoStatus(
|
||||
task.id,
|
||||
DownloadStatus.Downloading,
|
||||
);
|
||||
this.emit("download-start", task.id);
|
||||
|
||||
this.logger.info(`taskId: ${task.id} start`);
|
||||
const controller = new AbortController();
|
||||
this.signal[task.id] = controller;
|
||||
|
||||
const callback = (progress: DownloadProgress) => {
|
||||
if (progress.type === "progress") {
|
||||
this.emit("download-progress", progress);
|
||||
} else if (progress.type === "ready") {
|
||||
this.emit("download-ready-start", progress);
|
||||
if (progress.isLive) {
|
||||
this.removeTask(progress.id);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const params: DownloadParams = {
|
||||
...task.params,
|
||||
id: task.id,
|
||||
abortSignal: controller,
|
||||
callback,
|
||||
};
|
||||
|
||||
const { proxy, downloadProxySwitch } =
|
||||
await this.storeService.getConfig();
|
||||
if (downloadProxySwitch && proxy) {
|
||||
params.proxy = proxy;
|
||||
}
|
||||
|
||||
await this.process(params);
|
||||
delete this.signal[task.id];
|
||||
this.logger.info(`taskId: ${task.id} success`);
|
||||
|
||||
await this.videoRepository.changeVideoStatus(
|
||||
task.id,
|
||||
DownloadStatus.Success,
|
||||
);
|
||||
this.emit("download-success", task.id);
|
||||
} catch (err: any) {
|
||||
if (err.message === "AbortError") {
|
||||
this.logger.info(`taskId: ${task.id} stopped`);
|
||||
// Download pause
|
||||
await this.videoRepository.changeVideoStatus(
|
||||
task.id,
|
||||
DownloadStatus.Stopped,
|
||||
);
|
||||
this.emit("download-stop", task.id);
|
||||
} else {
|
||||
this.logger.error(`taskId: ${task.id} failed`, err);
|
||||
// Download failure
|
||||
await this.videoRepository.changeVideoStatus(
|
||||
task.id,
|
||||
DownloadStatus.Failed,
|
||||
);
|
||||
this.emit("download-failed", task.id, err);
|
||||
}
|
||||
} finally {
|
||||
this.removeTask(task.id);
|
||||
|
||||
// Transmission complete
|
||||
if (this.queue.length === 0 && this.active.length === 0) {
|
||||
// this.emit("download-finish");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
removeTask(id: number) {
|
||||
// Process the currently active task
|
||||
const doneId = this.active.findIndex((i) => i.id === id);
|
||||
this.active.splice(doneId, 1);
|
||||
// Process completed tasks
|
||||
if (this.active.length < this.limit) {
|
||||
this.runTask();
|
||||
}
|
||||
}
|
||||
|
||||
runTask() {
|
||||
while (this.active.length < this.limit && this.queue.length > 0) {
|
||||
const task = this.queue.shift();
|
||||
if (task) {
|
||||
this.active.push(task);
|
||||
this.execute(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private _execa(
|
||||
binPath: string,
|
||||
args: string[],
|
||||
params: DownloadOptions,
|
||||
): Promise<void> {
|
||||
const { abortSignal, onMessage, id } = params;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const ptyProcess = pty.spawn(binPath, args, {
|
||||
name: "xterm-color",
|
||||
cols: 500,
|
||||
rows: 500,
|
||||
useConpty: false,
|
||||
});
|
||||
|
||||
if (onMessage) {
|
||||
const ctx: DownloadContext = {
|
||||
ready: false,
|
||||
isLive: false,
|
||||
percent: "",
|
||||
speed: "",
|
||||
};
|
||||
ptyProcess.onData((data) => {
|
||||
try {
|
||||
const txt = stripAnsi(data);
|
||||
this.emit("download-message", id, data);
|
||||
onMessage(ctx, txt);
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
abortSignal.signal.addEventListener("abort", () => {
|
||||
ptyProcess.kill();
|
||||
reject(new Error("AbortError"));
|
||||
});
|
||||
|
||||
ptyProcess.onExit(({ exitCode }) => {
|
||||
if (exitCode === 0) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(new Error(i18n.t("unknownError")));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async downloader(params: DownloadParams, schema: Schema): Promise<void> {
|
||||
const {
|
||||
id,
|
||||
abortSignal,
|
||||
url,
|
||||
local,
|
||||
name,
|
||||
deleteSegments,
|
||||
headers,
|
||||
callback,
|
||||
proxy,
|
||||
folder,
|
||||
} = params;
|
||||
|
||||
const spawnParams = [];
|
||||
for (const key of Object.keys(schema.args)) {
|
||||
const { argsName } = schema.args[key];
|
||||
if (key === "url") {
|
||||
argsName && spawnParams.push(...argsName);
|
||||
spawnParams.push(url);
|
||||
}
|
||||
if (key === "localDir") {
|
||||
let finalLocal = local;
|
||||
if (folder) {
|
||||
finalLocal = path.join(local, folder);
|
||||
}
|
||||
argsName && argsName.forEach((i) => spawnParams.push(i, finalLocal));
|
||||
}
|
||||
if (key === "name") {
|
||||
argsName && argsName.forEach((i) => spawnParams.push(i, name));
|
||||
}
|
||||
|
||||
if (key === "headers" && headers) {
|
||||
const headerArr: string[] = headers?.split("\n") || [];
|
||||
headerArr.forEach((headerStr) => {
|
||||
spawnParams.push("--header", headerStr);
|
||||
});
|
||||
}
|
||||
|
||||
if (key === "deleteSegments" && deleteSegments) {
|
||||
argsName && spawnParams.push(...argsName);
|
||||
}
|
||||
|
||||
if (key === "proxy" && proxy) {
|
||||
argsName && argsName.forEach((i) => spawnParams.push(i, proxy));
|
||||
}
|
||||
|
||||
if (key === "__common__") {
|
||||
argsName && spawnParams.push(...argsName);
|
||||
}
|
||||
}
|
||||
|
||||
const { consoleReg } = schema;
|
||||
const isLiveReg = RegExp(consoleReg.isLive, "g");
|
||||
const startDownloadReg = RegExp(consoleReg.start, "g");
|
||||
const errorReg = RegExp(consoleReg.error, "g");
|
||||
const speedReg = RegExp(consoleReg.speed, "g");
|
||||
const percentReg = RegExp(consoleReg.percent, "g");
|
||||
|
||||
const onMessage = (ctx: DownloadContext, message: string) => {
|
||||
// Resolve whether it is a live resource
|
||||
if (isLiveReg.test(message)) {
|
||||
ctx.isLive = true;
|
||||
}
|
||||
// Parse download progress
|
||||
const [, percent] = percentReg.exec(message) || [];
|
||||
if (percent && Number(ctx.percent || 0) < Number(percent)) {
|
||||
ctx.percent = percent;
|
||||
}
|
||||
// Parsing download speed
|
||||
const [, speed] = speedReg.exec(message) || [];
|
||||
if (speed) {
|
||||
ctx.speed = speed;
|
||||
}
|
||||
|
||||
if (startDownloadReg.test(message)) {
|
||||
callback({
|
||||
id,
|
||||
type: "ready",
|
||||
isLive: ctx.isLive,
|
||||
speed: "",
|
||||
percent: "",
|
||||
});
|
||||
ctx.ready = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (errorReg.test(message)) {
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
if (ctx.ready && (ctx.percent || ctx.speed)) {
|
||||
callback({
|
||||
id,
|
||||
type: "progress",
|
||||
percent: ctx.percent || "",
|
||||
speed: ctx.speed || "",
|
||||
isLive: ctx.isLive,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
this.logger.debug("download params: ", spawnParams.join(" "));
|
||||
await this._execa(schema.bin, spawnParams, {
|
||||
id,
|
||||
abortSignal,
|
||||
onMessage,
|
||||
});
|
||||
}
|
||||
|
||||
async process(params: DownloadParams): Promise<void> {
|
||||
const program = processList
|
||||
.filter((i) => i.platform.includes(process.platform))
|
||||
.filter((i) => i.type === params.type);
|
||||
|
||||
if (program.length === 0) {
|
||||
return Promise.reject(new Error(i18n.t("unsupportedDownloadType")));
|
||||
}
|
||||
|
||||
const schema = program[0];
|
||||
await this.downloader(params, schema);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import { inject, injectable } from "inversify";
|
||||
import VideoRepository from "../repository/VideoRepository.ts";
|
||||
import { TYPES } from "../types.ts";
|
||||
import ConfigRepository from "../repository/ConfigRepository.ts";
|
||||
import { DownloadItem, DownloadStatus, Task } from "../interfaces.ts";
|
||||
import DownloadService from "./DownloadService.ts";
|
||||
|
||||
@injectable()
|
||||
export default class DownloaderService {
|
||||
constructor(
|
||||
@inject(TYPES.VideoRepository)
|
||||
private readonly videoRepository: VideoRepository,
|
||||
@inject(TYPES.ConfigRepository)
|
||||
private readonly store: ConfigRepository,
|
||||
@inject(TYPES.DownloadService)
|
||||
private readonly downloadService: DownloadService,
|
||||
) {}
|
||||
|
||||
async startDownload(vid: number) {
|
||||
// Find the video you want to download
|
||||
const video = await this.videoRepository.findVideo(vid);
|
||||
const { name, url, headers, type, folder } = video;
|
||||
const { local, deleteSegments } = await this.store.getConfig();
|
||||
|
||||
const task: Task = {
|
||||
id: vid,
|
||||
params: {
|
||||
url,
|
||||
type,
|
||||
local,
|
||||
name,
|
||||
headers,
|
||||
deleteSegments,
|
||||
folder,
|
||||
},
|
||||
};
|
||||
await this.videoRepository.changeVideoStatus(vid, DownloadStatus.Watting);
|
||||
this.downloadService.addTask(task);
|
||||
}
|
||||
|
||||
async downloadNow(video: Omit<DownloadItem, "id">) {
|
||||
// Add download
|
||||
const item = await this.addDownloadItem(video);
|
||||
// Start downloading
|
||||
await this.startDownload(item.id);
|
||||
return item;
|
||||
}
|
||||
|
||||
async addDownloadItem(video: Omit<DownloadItem, "id">) {
|
||||
const item = await this.videoRepository.addVideo(video);
|
||||
return item;
|
||||
}
|
||||
|
||||
async addDownloadItems(videos: Omit<DownloadItem, "id">[]) {
|
||||
const items = await this.videoRepository.addVideos(videos);
|
||||
return items;
|
||||
}
|
||||
|
||||
async editDownloadItem(video: DownloadItem) {
|
||||
return this.videoRepository.editVideo(video);
|
||||
}
|
||||
|
||||
async getVideoFolders() {
|
||||
return this.videoRepository.getVideoFolders();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import EventEmitter from "events";
|
||||
import { injectable } from "inversify";
|
||||
|
||||
@injectable()
|
||||
export default class HomeService extends EventEmitter {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import { Config } from "./entity/Config.ts";
|
||||
|
||||
export const TYPES = {
|
||||
ElectronApp: Symbol.for("ElectronApp"),
|
||||
RouterHandlerService: Symbol.for("RouterHandlerService"),
|
||||
Controller: Symbol.for("Controller"),
|
||||
// repository
|
||||
VideoRepository: Symbol.for("VideoRepository"),
|
||||
FavoriteRepository: Symbol.for("FavoriteRepository"),
|
||||
ConversionRepository: Symbol.for("ConversionRepository"),
|
||||
ConfigRepository: Symbol.for("ConfigRepository"),
|
||||
// windows
|
||||
BrowserWindow: Symbol.for("BrowserWindow"),
|
||||
MainWindow: Symbol.for("MainWindow"),
|
||||
PlayerWindow: Symbol.for("PlayerWindow"),
|
||||
// services
|
||||
HomeService: Symbol.for("HomeService"),
|
||||
DownloadService: Symbol.for("DownloadService"),
|
||||
SessionService: Symbol.for("SessionService"),
|
||||
ProtocolService: Symbol.for("ProtocolService"),
|
||||
VideoService: Symbol.for("VideoService"),
|
||||
SniffingHelper: Symbol.for("SniffingHelper"),
|
||||
ConfigService: Symbol.for("ConfigService"),
|
||||
DownloaderService: Symbol.for("DownloaderService"),
|
||||
// vendor
|
||||
TypeORM: Symbol.for("TypeORM"),
|
||||
Logger: Symbol.for("Logger"),
|
||||
SocketIO: Symbol.for("SocketIO"),
|
||||
};
|
||||
|
||||
export enum AppTheme {
|
||||
System = "system",
|
||||
Light = "light",
|
||||
Dark = "dark",
|
||||
}
|
||||
|
||||
export enum AppLanguage {
|
||||
System = "system",
|
||||
ZH = "zh",
|
||||
EN = "en",
|
||||
}
|
||||
|
||||
export interface ConfigParams {
|
||||
key: keyof Config;
|
||||
val: Config[keyof Config];
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
import { injectable } from "inversify";
|
||||
import { Vendor } from "../core/vendor.ts";
|
||||
import winston from "winston";
|
||||
|
||||
@injectable()
|
||||
export default class Logger implements Vendor {
|
||||
logger: winston.Logger;
|
||||
|
||||
constructor() {
|
||||
this.logger = winston.createLogger({
|
||||
level: "info",
|
||||
format: winston.format.json(),
|
||||
defaultMeta: { service: "user-service" },
|
||||
transports: [
|
||||
//
|
||||
// - Write all logs with importance level of `error` or less to `error.log`
|
||||
// - Write all logs with importance level of `info` or less to `combined.log`
|
||||
//
|
||||
new winston.transports.File({
|
||||
filename: "./log/error.log",
|
||||
level: "error",
|
||||
}),
|
||||
new winston.transports.File({ filename: "./log/combined.log" }),
|
||||
],
|
||||
});
|
||||
|
||||
//
|
||||
// If we're not in production then log to the `console` with the format:
|
||||
// `${info.level}: ${info.message} JSON.stringify({ ...rest }) `
|
||||
//
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
this.logger.add(
|
||||
new winston.transports.Console({
|
||||
format: winston.format.simple(),
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
info(...args: unknown[]) {
|
||||
return this.logger.info(args);
|
||||
}
|
||||
|
||||
warn(...args: unknown[]) {
|
||||
return this.logger.warn(args);
|
||||
}
|
||||
|
||||
error(...args: unknown[]) {
|
||||
return this.logger.error(args);
|
||||
}
|
||||
|
||||
debug(...args: unknown[]) {
|
||||
return this.logger.debug(args);
|
||||
}
|
||||
|
||||
async init() {}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
import { inject, injectable } from "inversify";
|
||||
import { Vendor } from "../core/vendor.ts";
|
||||
import http from "http";
|
||||
import { Server } from "socket.io";
|
||||
import { TYPES } from "../types.ts";
|
||||
import DownloadService from "../services/DownloadService.ts";
|
||||
import { DownloadProgress } from "../interfaces.ts";
|
||||
import VideoRepository from "../repository/VideoRepository.ts";
|
||||
import Logger from "./Logger.ts";
|
||||
import ConfigService from "../services/ConfigService.ts";
|
||||
|
||||
@injectable()
|
||||
export default class SocketIO implements Vendor {
|
||||
io: Server;
|
||||
|
||||
constructor(
|
||||
@inject(TYPES.DownloadService)
|
||||
private readonly downloadService: DownloadService,
|
||||
@inject(TYPES.VideoRepository)
|
||||
private readonly videoRepository: VideoRepository,
|
||||
@inject(TYPES.Logger)
|
||||
private readonly logger: Logger,
|
||||
@inject(TYPES.ConfigService)
|
||||
private readonly store: ConfigService,
|
||||
) {}
|
||||
|
||||
async init() {}
|
||||
|
||||
async initSocketIO(server: http.Server) {
|
||||
this.io = new Server(server, {
|
||||
/* options */
|
||||
cors: {
|
||||
origin: "*",
|
||||
},
|
||||
});
|
||||
|
||||
this.io.engine.on("headers", (headers) => {
|
||||
headers["Access-Control-Allow-Private-Network"] = true;
|
||||
});
|
||||
|
||||
this.io.on("connection", () => {});
|
||||
|
||||
this.downloadService.on("download-ready-start", this.onDownloadReadyStart);
|
||||
this.downloadService.on("download-progress", this.onDownloadProgress);
|
||||
this.downloadService.on("download-success", this.onDownloadSuccess);
|
||||
this.downloadService.on("download-failed", this.onDownloadFailed);
|
||||
this.downloadService.on("download-start", this.onDownloadStart);
|
||||
this.downloadService.on("download-stop", this.onDownloadStop);
|
||||
this.downloadService.on("download-message", this.receiveMessage);
|
||||
}
|
||||
|
||||
async emit(event: string, ...data: any[]) {
|
||||
this.io.emit(event, {}, ...data);
|
||||
}
|
||||
|
||||
onDownloadReadyStart = async ({ id, isLive }: DownloadProgress) => {
|
||||
if (isLive) {
|
||||
await this.videoRepository.changeVideoIsLive(id);
|
||||
this.emit("change-video-is-live", { id });
|
||||
}
|
||||
};
|
||||
|
||||
onDownloadProgress = (progress: DownloadProgress) => {
|
||||
this.emit("download-progress", progress);
|
||||
};
|
||||
|
||||
onDownloadSuccess = async (id: number) => {
|
||||
this.emit("download-success", id);
|
||||
};
|
||||
|
||||
onDownloadFailed = async (id: number, err: unknown) => {
|
||||
this.logger.error("download failed: ", err);
|
||||
this.emit("download-failed", id);
|
||||
};
|
||||
|
||||
onDownloadStart = async (id: number) => {
|
||||
this.emit("download-start", id);
|
||||
};
|
||||
|
||||
onDownloadStop = async (id: number) => {
|
||||
this.emit("download-stop", id);
|
||||
};
|
||||
|
||||
receiveMessage = async (id: number, message: string) => {
|
||||
// Write the log to the database
|
||||
await this.videoRepository.appendDownloadLog(id, message);
|
||||
};
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
import { injectable } from "inversify";
|
||||
import { DataSource, EntityManager } from "typeorm";
|
||||
import { Favorite } from "../entity/Favorite.ts";
|
||||
import { Vendor } from "../core/vendor.ts";
|
||||
import { Video } from "../entity/Video.ts";
|
||||
import { Config } from "../entity/Config.ts";
|
||||
import { DB_PATH } from "../const.ts";
|
||||
|
||||
@injectable()
|
||||
export default class DatabaseService implements Vendor {
|
||||
appDataSource: DataSource;
|
||||
|
||||
constructor() {
|
||||
this.appDataSource = new DataSource({
|
||||
type: "better-sqlite3",
|
||||
database: DB_PATH,
|
||||
synchronize: true,
|
||||
logging: false,
|
||||
entities: [Favorite, Video, Config],
|
||||
migrations: [],
|
||||
subscribers: [],
|
||||
});
|
||||
}
|
||||
|
||||
async init() {
|
||||
await this.appDataSource.initialize();
|
||||
}
|
||||
|
||||
get manager(): EntityManager {
|
||||
return this.appDataSource.manager;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2015",
|
||||
"module": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"resolveJsonModule": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"moduleResolution": "NodeNext",
|
||||
"strictPropertyInitialization": false,
|
||||
"typeRoots": ["node_modules/@types"],
|
||||
"declaration": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"declarationDir": "./types",
|
||||
"outDir": "app/output/build/main",
|
||||
"allowImportingTsExtensions": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.node.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"composite": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "ES2015",
|
||||
"lib": ["ES2015"],
|
||||
"moduleResolution": "Node",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true,
|
||||
"typeRoots": ["node_modules/@types"]
|
||||
},
|
||||
"include": ["gulpfile.ts", "scripts"]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
.bin
|
||||
node_modules
|
||||
build
|
||||
dist
|
||||
bin/Logs
|
||||
release
|
||||
types
|
||||
@@ -0,0 +1 @@
|
||||
types/
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1 @@
|
||||
# Main Process
|
||||
@@ -0,0 +1,5 @@
|
||||
node_modules
|
||||
output
|
||||
bin
|
||||
mobile
|
||||
plugin
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "mediago",
|
||||
"version": "3.0.1",
|
||||
"description": "在线视频下载器",
|
||||
"main": "main/index.js",
|
||||
"author": "caorushizi",
|
||||
"homepage": "https://downloader.caorushizi.cn/",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@ghostery/adblocker": "^2.3.1",
|
||||
"@ghostery/adblocker-content": "^2.3.1",
|
||||
"@ghostery/adblocker-electron": "^2.3.1",
|
||||
"@ghostery/adblocker-electron-preload": "^2.3.1",
|
||||
"@ghostery/adblocker-extended-selectors": "^2.3.1",
|
||||
"@remusao/guess-url-type": "^1.3.0",
|
||||
"@remusao/small": "^1.3.0",
|
||||
"@remusao/smaz": "^1.10.0",
|
||||
"@remusao/smaz-compress": "^1.10.0",
|
||||
"@remusao/smaz-decompress": "^1.10.0",
|
||||
"@remusao/trie": "^1.5.0",
|
||||
"node-pty": "^1.0.0",
|
||||
"tldts-experimental": "^6.1.70"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "30.0.8"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
@@ -0,0 +1,3 @@
|
||||
provider: generic
|
||||
updaterCacheDirName: mediago-updater
|
||||
url: "http://127.0.0.1:9000/release"
|
||||
@@ -0,0 +1,16 @@
|
||||
import globals from "globals";
|
||||
import pluginJs from "@eslint/js";
|
||||
import tseslint from "typescript-eslint";
|
||||
|
||||
export default [
|
||||
{
|
||||
languageOptions: { globals: globals.node },
|
||||
},
|
||||
pluginJs.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
{
|
||||
rules: {
|
||||
"@typescript-eslint/no-explicit-any": "warn",
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1 @@
|
||||
export { dev, build, release } from "./scripts";
|
||||
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"name": "main",
|
||||
"version": "0.1.0",
|
||||
"description": "在线视频下载器",
|
||||
"type": "module",
|
||||
"main": "main/index.js",
|
||||
"scripts": {
|
||||
"postinstall": "electron-rebuild -f -w",
|
||||
"dev": "cross-env NODE_ENV=development gulp dev",
|
||||
"pack": "cross-env NODE_ENV=development gulp release",
|
||||
"build": "cross-env NODE_ENV=production gulp build",
|
||||
"release": "cross-env NODE_ENV=production gulp release",
|
||||
"rebuild": "electron-rebuild -f -w",
|
||||
"types": "tsc",
|
||||
"types:watch": "tsc -w",
|
||||
"lint-staged": "lint-staged"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,jsx,ts,tsx}": "eslint"
|
||||
},
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@electron/rebuild": "^3.6.0",
|
||||
"@eslint/js": "^8.57.0",
|
||||
"@types/cors": "^2.8.17",
|
||||
"@types/electron-devtools-installer": "^2.2.5",
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/glob": "^8.1.0",
|
||||
"@types/gulp": "^4.0.17",
|
||||
"@types/lodash": "^4.17.4",
|
||||
"@types/mime-types": "^2.1.4",
|
||||
"@types/node": "^20.12.12",
|
||||
"@types/node-fetch": "^2.6.11",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@types/serve-handler": "^6.1.4",
|
||||
"@types/undertaker": "^1.2.11",
|
||||
"consola": "^3.2.3",
|
||||
"cross-env": "^7.0.3",
|
||||
"del": "^7.1.0",
|
||||
"dotenv": "^16.4.5",
|
||||
"electron": "30.0.8",
|
||||
"electron-builder": "^24.13.3",
|
||||
"electron-updater": "^6.1.8",
|
||||
"esbuild": "^0.21.4",
|
||||
"esbuild-register": "^3.5.0",
|
||||
"eslint": "^8.57.0",
|
||||
"glob": "^10.4.1",
|
||||
"globals": "^15.3.0",
|
||||
"gulp": "^5.0.0",
|
||||
"prebuild-install": "^7.1.2",
|
||||
"semver": "^7.6.2",
|
||||
"typescript": "^5.4.5",
|
||||
"typescript-eslint": "^7.10.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ghostery/adblocker-electron": "^2.3.1",
|
||||
"axios": "^1.7.2",
|
||||
"better-sqlite3": "^9.6.0",
|
||||
"cheerio": "1.0.0-rc.12",
|
||||
"cors": "^2.8.5",
|
||||
"dayjs": "^1.11.11",
|
||||
"electron-devtools-installer": "^3.2.0",
|
||||
"electron-is-dev": "^3.0.1",
|
||||
"electron-log": "^5.1.5",
|
||||
"electron-store": "^9.0.0",
|
||||
"execa": "^9.1.0",
|
||||
"express": "^4.19.2",
|
||||
"fs-extra": "^11.2.0",
|
||||
"i18next": "^23.11.5",
|
||||
"inversify": "^6.0.2",
|
||||
"lint-staged": "^15.2.5",
|
||||
"lodash": "^4.17.21",
|
||||
"lru-cache": "^11.0.1",
|
||||
"mime-types": "^2.1.35",
|
||||
"nanoid": "^5.0.7",
|
||||
"node-fetch": "^3.3.2",
|
||||
"node-machine-id": "^1.1.12",
|
||||
"node-pty": "^1.0.0",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"serve-handler": "^6.1.5",
|
||||
"strip-ansi": "^7.1.0",
|
||||
"typeorm": "0.3.20"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
import { Configuration } from "electron-builder";
|
||||
import { Env, isDev, mainResolve } from "./utils";
|
||||
import esbuild from "esbuild";
|
||||
|
||||
const external = [
|
||||
"electron",
|
||||
"nock",
|
||||
"aws-sdk",
|
||||
"mock-aws-s3",
|
||||
"@ghostery/adblocker-electron",
|
||||
"tldts-experimental",
|
||||
"node-pty",
|
||||
];
|
||||
|
||||
function getConfig(): esbuild.BuildOptions {
|
||||
const getDefine = (): Record<string, string> => {
|
||||
if (isDev) {
|
||||
return {
|
||||
__bin__: `"${mainResolve("app/bin").replace(/\\/g, "\\\\")}"`,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
...Env.getInstance().loadDotEnvDefined(),
|
||||
"process.env.NODE_ENV": '"production"',
|
||||
};
|
||||
};
|
||||
|
||||
return {
|
||||
bundle: true,
|
||||
sourcemap: process.env.NODE_ENV === "development",
|
||||
external,
|
||||
define: getDefine(),
|
||||
outdir: mainResolve("app/build/main"),
|
||||
loader: { ".png": "file" },
|
||||
minify: process.env.NODE_ENV === "production",
|
||||
};
|
||||
}
|
||||
|
||||
function buildOptions(
|
||||
entry: string,
|
||||
platform: esbuild.Platform,
|
||||
target: string,
|
||||
): esbuild.BuildOptions {
|
||||
return {
|
||||
...getConfig(),
|
||||
entryPoints: [mainResolve(entry)],
|
||||
platform: platform,
|
||||
target: [target],
|
||||
};
|
||||
}
|
||||
|
||||
export function browserOptions(entry: string): esbuild.BuildOptions {
|
||||
return buildOptions(entry, "browser", "chrome89");
|
||||
}
|
||||
|
||||
export function nodeOptions(entry: string): esbuild.BuildOptions {
|
||||
return buildOptions(entry, "node", "node16.13");
|
||||
}
|
||||
|
||||
export function getReleaseConfig(): Configuration {
|
||||
return {
|
||||
productName: process.env.APP_NAME,
|
||||
buildVersion: process.env.APP_VERSION,
|
||||
appId: process.env.APP_ID,
|
||||
copyright: process.env.APP_COPYRIGHT,
|
||||
artifactName:
|
||||
"${productName}-setup-${platform}-${arch}-${buildVersion}.${ext}",
|
||||
npmRebuild: true,
|
||||
directories: {
|
||||
output: "./release",
|
||||
},
|
||||
files: [
|
||||
{
|
||||
from: "./build",
|
||||
to: "./",
|
||||
},
|
||||
"./package.json",
|
||||
],
|
||||
extraResources: [
|
||||
{
|
||||
from: "./app/plugin",
|
||||
to: "plugin",
|
||||
},
|
||||
{
|
||||
from: "./app/mobile",
|
||||
to: "mobile",
|
||||
},
|
||||
{
|
||||
from: "./bin/${platform}/${arch}",
|
||||
to: "bin",
|
||||
},
|
||||
],
|
||||
win: {
|
||||
icon: "../assets/icon.ico",
|
||||
target: [
|
||||
{
|
||||
target: "nsis",
|
||||
arch: ["x64"],
|
||||
},
|
||||
"portable",
|
||||
],
|
||||
},
|
||||
portable: {
|
||||
artifactName:
|
||||
"${productName}-portable-${platform}-${arch}-${buildVersion}.${ext}",
|
||||
},
|
||||
dmg: {
|
||||
contents: [
|
||||
{
|
||||
x: 410,
|
||||
y: 150,
|
||||
type: "link",
|
||||
path: "/Applications",
|
||||
},
|
||||
{
|
||||
x: 130,
|
||||
y: 150,
|
||||
type: "file",
|
||||
},
|
||||
],
|
||||
},
|
||||
mac: {
|
||||
icon: "../assets/icon.icns",
|
||||
target: [
|
||||
{
|
||||
target: "dmg",
|
||||
arch: [process.arch === "arm64" ? "arm64" : "x64"],
|
||||
},
|
||||
],
|
||||
},
|
||||
linux: {
|
||||
category: "Utility",
|
||||
icon: "../assets/icon.icns",
|
||||
maintainer: "caorushizi <84996057@qq.com>",
|
||||
target: {
|
||||
target: "deb",
|
||||
arch: ["x64"],
|
||||
},
|
||||
},
|
||||
nsis: {
|
||||
oneClick: false,
|
||||
allowElevation: true,
|
||||
allowToChangeInstallationDirectory: true,
|
||||
createDesktopShortcut: true,
|
||||
createStartMenuShortcut: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
import { deleteSync } from "del";
|
||||
import { ElectronApp, mainResolve, Env, isWin } from "./utils";
|
||||
import gulp from "gulp";
|
||||
import * as esbuild from "esbuild";
|
||||
import consola from "consola";
|
||||
import { browserOptions, nodeOptions, getReleaseConfig } from "./config";
|
||||
import semver from "semver";
|
||||
import pkg from "../app/package.json";
|
||||
import * as builder from "electron-builder";
|
||||
import { globSync } from "glob";
|
||||
import fs from "fs";
|
||||
import { exec } from "child_process";
|
||||
|
||||
const env = Env.getInstance();
|
||||
env.loadDotEnvRuntime();
|
||||
|
||||
async function clean() {
|
||||
return deleteSync([
|
||||
mainResolve("app/build"),
|
||||
mainResolve("app/bin"),
|
||||
mainResolve("app/mobile"),
|
||||
mainResolve("app/plugin"),
|
||||
mainResolve("release"),
|
||||
]);
|
||||
}
|
||||
|
||||
function compileTypescript() {
|
||||
exec("npx tsc", (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.error(`Error: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
if (stderr) {
|
||||
console.error(`Stderr: ${stderr}`);
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function copySqlite() {
|
||||
const path = "build/Release/better_sqlite3.node";
|
||||
const source = mainResolve("node_modules/better-sqlite3", path);
|
||||
const target = mainResolve("app", path);
|
||||
fs.cpSync(source, target, { recursive: true });
|
||||
}
|
||||
|
||||
async function copyBin() {
|
||||
const source = mainResolve("bin", process.platform, process.arch);
|
||||
const target = mainResolve("app/bin");
|
||||
fs.cpSync(source, target, { recursive: true });
|
||||
}
|
||||
|
||||
async function chmodBin() {
|
||||
// Go through all the files in the folder and set the permissions on the files to 777
|
||||
if (isWin) return;
|
||||
|
||||
const files = globSync(mainResolve("app/bin/*"));
|
||||
for (const file of files) {
|
||||
fs.chmodSync(file, 0o777);
|
||||
}
|
||||
}
|
||||
|
||||
async function copyUpdateConfig() {
|
||||
const source = mainResolve("dev-app-update.yml");
|
||||
const target = mainResolve("app/build/main/dev-app-update.yml");
|
||||
fs.cpSync(source, target, { recursive: true });
|
||||
}
|
||||
|
||||
const devCopy = gulp.parallel(copyBin, copySqlite, copyUpdateConfig);
|
||||
const buildCopy = gulp.parallel(copySqlite);
|
||||
|
||||
async function watchTask() {
|
||||
const app = new ElectronApp();
|
||||
const main = await esbuild.context(nodeOptions("src/index.ts"));
|
||||
const preload = await esbuild.context(browserOptions("src/preload.ts"));
|
||||
|
||||
const watcher = gulp.watch(["./src"]);
|
||||
watcher
|
||||
.on("ready", async () => {
|
||||
await main.rebuild();
|
||||
await preload.rebuild();
|
||||
app.start();
|
||||
})
|
||||
.on("change", async () => {
|
||||
compileTypescript();
|
||||
|
||||
await main.rebuild();
|
||||
await preload.rebuild();
|
||||
app.restart();
|
||||
})
|
||||
.on("error", (error) => {
|
||||
consola.error(error);
|
||||
});
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
async function buildTask() {
|
||||
await esbuild.build(nodeOptions("src/index.ts"));
|
||||
await esbuild.build(browserOptions("src/preload.ts"));
|
||||
}
|
||||
|
||||
async function pack() {
|
||||
if (semver.neq(process.env.APP_VERSION || "", pkg.version)) {
|
||||
throw new Error("请先同步构建版本和发布版本");
|
||||
}
|
||||
const config = getReleaseConfig();
|
||||
if (process.env.GH_TOKEN) {
|
||||
config.publish = {
|
||||
provider: "github",
|
||||
repo: "mediago",
|
||||
owner: "caorushizi",
|
||||
releaseType: "draft",
|
||||
};
|
||||
}
|
||||
await builder.build({ config });
|
||||
}
|
||||
|
||||
// Development environment
|
||||
export const dev = gulp.series(devCopy, chmodBin, watchTask);
|
||||
// Build packaging
|
||||
export const build = gulp.series(clean, buildCopy, chmodBin, buildTask);
|
||||
// release
|
||||
export const release = gulp.series(pack);
|
||||
@@ -0,0 +1,108 @@
|
||||
import { ChildProcessWithoutNullStreams, spawn } from "child_process";
|
||||
import dotenv from "dotenv";
|
||||
import { resolve } from "path";
|
||||
import consola from "consola";
|
||||
import fs from "fs-extra";
|
||||
import electron from "electron";
|
||||
|
||||
const baseResolve = (...r: any[]) => resolve(__dirname, ...r);
|
||||
export const mainResolve = (...r: string[]) => baseResolve("..", ...r);
|
||||
export const rootResolve = (...r: string[]) => baseResolve("../../..", ...r);
|
||||
|
||||
export const isDev = process.env.NODE_ENV === "development";
|
||||
|
||||
export const isLinux = process.platform === "linux";
|
||||
export const isMac = process.platform === "darwin";
|
||||
export const isWin = process.platform === "win32";
|
||||
|
||||
export class ElectronApp {
|
||||
process: ChildProcessWithoutNullStreams | null = null;
|
||||
|
||||
start() {
|
||||
const args = ["--inspect=5858", mainResolve("app/build/main/index.js")];
|
||||
|
||||
this.process = spawn(String(electron), args);
|
||||
|
||||
this.process.stdout.on("data", (data) => {
|
||||
consola.log(String(data));
|
||||
});
|
||||
|
||||
this.process.stderr.on("data", (data) => {
|
||||
consola.log(String(data));
|
||||
});
|
||||
}
|
||||
|
||||
restart() {
|
||||
this.kill();
|
||||
this.start();
|
||||
}
|
||||
|
||||
kill() {
|
||||
if (this.process && this.process.pid) {
|
||||
if (isMac) {
|
||||
spawn("kill", ["-9", String(this.process.pid)]);
|
||||
} else {
|
||||
process.kill(this.process.pid);
|
||||
}
|
||||
this.process = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class Env {
|
||||
env: Record<string, string> = {};
|
||||
nodeEnv = "";
|
||||
static instance: Env;
|
||||
|
||||
private constructor(nodeEnv = process.env.NODE_ENV) {
|
||||
const env = this.parseEnv(rootResolve(".env"));
|
||||
const modeEnv = this.parseEnv(rootResolve(`.env.${nodeEnv}`));
|
||||
const localEnv = this.parseEnv(rootResolve(`.env.${nodeEnv}.local`));
|
||||
|
||||
this.nodeEnv = nodeEnv || "development";
|
||||
this.env = { ...env, ...modeEnv, ...localEnv };
|
||||
}
|
||||
|
||||
static getInstance() {
|
||||
if (!Env.instance) {
|
||||
Env.instance = new Env();
|
||||
}
|
||||
|
||||
return Env.instance;
|
||||
}
|
||||
|
||||
private parseEnv(path: string) {
|
||||
if (!fs.existsSync(path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const parsed = dotenv.parse(fs.readFileSync(path));
|
||||
if (!parsed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Object.keys(parsed).reduce((prev: any, curr) => {
|
||||
prev[curr] = parsed[curr];
|
||||
return prev;
|
||||
}, {});
|
||||
}
|
||||
|
||||
loadDotEnvRuntime() {
|
||||
Object.keys(this.env).forEach((key) => {
|
||||
if (process.env[key] != null || !this.env[key]) return;
|
||||
process.env[key] = this.env[key];
|
||||
});
|
||||
}
|
||||
|
||||
loadDotEnvDefined() {
|
||||
return Object.keys(this.env).reduce<Record<string, string>>((prev, cur) => {
|
||||
if (!cur.startsWith("APP_")) return prev;
|
||||
prev[`process.env.${[cur]}`] = JSON.stringify(this.env[cur]);
|
||||
return prev;
|
||||
}, {});
|
||||
}
|
||||
|
||||
get isDev() {
|
||||
return this.nodeEnv === "development";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
import { inject, injectable } from "inversify";
|
||||
import { DownloadStatus } from "./interfaces.ts";
|
||||
import { TYPES } from "./types.ts";
|
||||
import { Menu, Tray, app, nativeImage, nativeTheme, Event } from "electron";
|
||||
import TrayIcon from "./tray-icon.png";
|
||||
import TrayIconLight from "./tray-icon-light.png";
|
||||
import path from "path";
|
||||
import MainWindow from "./windows/MainWindow.ts";
|
||||
import WebviewService from "./services/WebviewService.ts";
|
||||
import VideoRepository from "./repository/VideoRepository.ts";
|
||||
import ElectronDevtools from "./vendor/ElectronDevtools.ts";
|
||||
import ElectronStore from "./vendor/ElectronStore.ts";
|
||||
import ElectronUpdater from "./vendor/ElectronUpdater.ts";
|
||||
import TypeORM from "./vendor/TypeORM.ts";
|
||||
import ProtocolService from "./core/protocol.ts";
|
||||
import IpcHandlerService from "./core/ipc.ts";
|
||||
import { VideoService } from "./services/VideoService.ts";
|
||||
import i18n from "./i18n/index.ts";
|
||||
import { isMac } from "./helper/variables.ts";
|
||||
|
||||
@injectable()
|
||||
export default class ElectronApp {
|
||||
constructor(
|
||||
@inject(TYPES.MainWindow)
|
||||
private readonly mainWindow: MainWindow,
|
||||
@inject(TYPES.ProtocolService)
|
||||
private readonly protocol: ProtocolService,
|
||||
@inject(TYPES.ElectronUpdater)
|
||||
private readonly updater: ElectronUpdater,
|
||||
@inject(TYPES.IpcHandlerService)
|
||||
private readonly ipc: IpcHandlerService,
|
||||
@inject(TYPES.TypeORM)
|
||||
private readonly db: TypeORM,
|
||||
@inject(TYPES.WebviewService)
|
||||
private readonly webview: WebviewService,
|
||||
@inject(TYPES.VideoRepository)
|
||||
private readonly videoRepository: VideoRepository,
|
||||
@inject(TYPES.ElectronDevtools)
|
||||
private readonly devTools: ElectronDevtools,
|
||||
@inject(TYPES.ElectronStore)
|
||||
private readonly store: ElectronStore,
|
||||
@inject(TYPES.VideoService)
|
||||
private readonly videoService: VideoService,
|
||||
) {}
|
||||
|
||||
private async serviceInit(): Promise<void> {
|
||||
this.mainWindow.init();
|
||||
this.videoService.init();
|
||||
}
|
||||
|
||||
private async vendorInit() {
|
||||
await this.db.init();
|
||||
this.updater.init();
|
||||
this.devTools.init();
|
||||
}
|
||||
|
||||
async init(): Promise<void> {
|
||||
this.protocol.create();
|
||||
this.ipc.init();
|
||||
|
||||
// vendor
|
||||
await this.vendorInit();
|
||||
// service
|
||||
await this.serviceInit();
|
||||
|
||||
app.on("activate", () => {
|
||||
this.mainWindow.init();
|
||||
});
|
||||
|
||||
this.initAppTheme();
|
||||
this.initLanguage();
|
||||
this.resetDownloadStatus();
|
||||
|
||||
this.initTray();
|
||||
}
|
||||
|
||||
initAppTheme(): void {
|
||||
const theme = this.store.get("theme");
|
||||
nativeTheme.themeSource = theme;
|
||||
}
|
||||
|
||||
initLanguage(): void {
|
||||
const language = this.store.get("language");
|
||||
i18n.changeLanguage(language);
|
||||
}
|
||||
|
||||
initTray() {
|
||||
const iconPath = path.resolve(__dirname, isMac ? TrayIconLight : TrayIcon);
|
||||
const icon = nativeImage.createFromPath(iconPath);
|
||||
const tray = new Tray(icon);
|
||||
tray.setToolTip("Media Go");
|
||||
tray.addListener("click", () => {
|
||||
this.mainWindow.init();
|
||||
});
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: i18n.t("showMainWindow"),
|
||||
click: () => this.mainWindow.init(),
|
||||
},
|
||||
{
|
||||
label: i18n.t("exitApp"),
|
||||
role: "quit",
|
||||
},
|
||||
]);
|
||||
tray.setContextMenu(contextMenu);
|
||||
}
|
||||
|
||||
// If there are still videos being downloaded after the restart, change the status to download failed
|
||||
async resetDownloadStatus(): Promise<void> {
|
||||
// If data in the downloading state still fails after the restart, all downloads fail
|
||||
const videos = await this.videoRepository.findWattingAndDownloadingVideos();
|
||||
const videoIds = videos.map((video) => video.id);
|
||||
await this.videoRepository.changeVideoStatus(
|
||||
videoIds,
|
||||
DownloadStatus.Failed,
|
||||
);
|
||||
}
|
||||
|
||||
secondInstance = (event: Event, commandLine: string[]) => {
|
||||
const url = commandLine.pop() || "";
|
||||
this.mainWindow.showWindow(url);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { inject, injectable } from "inversify";
|
||||
import { ConversionPagination, type Controller } from "../interfaces.ts";
|
||||
import { TYPES } from "../types.ts";
|
||||
import ConversionRepository from "../repository/ConversionRepository.ts";
|
||||
import { handle } from "../helper/decorator.ts";
|
||||
import { Conversion } from "../entity/Conversion.ts";
|
||||
import { IpcMainEvent } from "electron/main";
|
||||
|
||||
@injectable()
|
||||
export default class ConversionController implements Controller {
|
||||
constructor(
|
||||
@inject(TYPES.ConversionRepository)
|
||||
private readonly conversionRepository: ConversionRepository
|
||||
) {}
|
||||
|
||||
@handle("get-conversions")
|
||||
async getConversions(e: IpcMainEvent, pagination: ConversionPagination) {
|
||||
return await this.conversionRepository.getConversions(pagination);
|
||||
}
|
||||
|
||||
@handle("add-conversion")
|
||||
async addConversion(e: IpcMainEvent, conversion: Conversion) {
|
||||
return await this.conversionRepository.addConversion(conversion);
|
||||
}
|
||||
|
||||
@handle("delete-conversion")
|
||||
async deleteConversion(e: IpcMainEvent, id: number) {
|
||||
return await this.conversionRepository.deleteConversion(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
import { IpcMainEvent } from "electron/main";
|
||||
import { inject, injectable } from "inversify";
|
||||
import { handle, videoPattern } from "../helper/index.ts";
|
||||
import {
|
||||
type Controller,
|
||||
DownloadItem,
|
||||
DownloadItemPagination,
|
||||
Task,
|
||||
DownloadStatus,
|
||||
VideoStat,
|
||||
ListPagination,
|
||||
} from "../interfaces.ts";
|
||||
import { TYPES } from "../types.ts";
|
||||
import MainWindow from "../windows/MainWindow.ts";
|
||||
import ElectronStore from "../vendor/ElectronStore.ts";
|
||||
import DownloadService from "../services/DownloadService.ts";
|
||||
import VideoRepository from "../repository/VideoRepository.ts";
|
||||
import WebviewService from "../services/WebviewService.ts";
|
||||
import path from "path";
|
||||
import { glob } from "glob";
|
||||
|
||||
@injectable()
|
||||
export default class DownloadController implements Controller {
|
||||
constructor(
|
||||
@inject(TYPES.ElectronStore)
|
||||
private readonly store: ElectronStore,
|
||||
@inject(TYPES.VideoRepository)
|
||||
private readonly videoRepository: VideoRepository,
|
||||
@inject(TYPES.DownloadService)
|
||||
private readonly downloadService: DownloadService,
|
||||
@inject(TYPES.MainWindow)
|
||||
private readonly mainWindow: MainWindow,
|
||||
@inject(TYPES.WebviewService)
|
||||
private readonly webviewService: WebviewService,
|
||||
) {}
|
||||
|
||||
@handle("show-download-dialog")
|
||||
async showDownloadDialog(e: IpcMainEvent, data: DownloadItem) {
|
||||
const image = await this.webviewService.captureView();
|
||||
this.webviewService.sendToWindow(
|
||||
"show-download-dialog",
|
||||
data,
|
||||
image?.toDataURL(),
|
||||
);
|
||||
}
|
||||
|
||||
@handle("add-download-item")
|
||||
async addDownloadItem(e: IpcMainEvent, video: Omit<DownloadItem, "id">) {
|
||||
const item = await this.videoRepository.addVideo(video);
|
||||
// This sends a message to the page notifying it of the update
|
||||
this.mainWindow.send("download-item-notifier", item);
|
||||
return item;
|
||||
}
|
||||
|
||||
@handle("add-download-items")
|
||||
async addDownloadItems(e: IpcMainEvent, videos: Omit<DownloadItem, "id">[]) {
|
||||
const items = await this.videoRepository.addVideos(videos);
|
||||
// This sends a message to the page notifying it of the update
|
||||
this.mainWindow.send("download-item-notifier", items);
|
||||
return items;
|
||||
}
|
||||
|
||||
@handle("edit-download-item")
|
||||
async editDownloadItem(e: IpcMainEvent, video: DownloadItem) {
|
||||
const item = await this.videoRepository.editVideo(video);
|
||||
return item;
|
||||
}
|
||||
|
||||
@handle("edit-download-now")
|
||||
async editDownloadNow(e: IpcMainEvent, video: DownloadItem) {
|
||||
const item = await this.editDownloadItem(e, video);
|
||||
await this.startDownload(e, item.id);
|
||||
return item;
|
||||
}
|
||||
|
||||
@handle("download-now")
|
||||
async downloadNow(e: IpcMainEvent, video: Omit<DownloadItem, "id">) {
|
||||
// Add download
|
||||
const item = await this.addDownloadItem(e, video);
|
||||
// Start downloading
|
||||
await this.startDownload(e, item.id);
|
||||
return item;
|
||||
}
|
||||
|
||||
@handle("download-items-now")
|
||||
async downloadItemsNow(e: IpcMainEvent, videos: Omit<DownloadItem, "id">[]) {
|
||||
// Add download
|
||||
const items = await this.addDownloadItems(e, videos);
|
||||
// Start downloading
|
||||
items.forEach((item) => this.startDownload(e, item.id));
|
||||
return items;
|
||||
}
|
||||
|
||||
@handle("get-download-items")
|
||||
async getDownloadItems(
|
||||
e: IpcMainEvent,
|
||||
pagination: DownloadItemPagination,
|
||||
): Promise<ListPagination> {
|
||||
const videos = await this.videoRepository.findVideos(pagination);
|
||||
|
||||
const result: ListPagination = {
|
||||
total: videos.total,
|
||||
list: [],
|
||||
};
|
||||
|
||||
const local = this.store.get("local");
|
||||
for (const video of videos.list) {
|
||||
const final: VideoStat = { ...video };
|
||||
if (video.status === DownloadStatus.Success) {
|
||||
const pattern = path.join(local, `${video.name}.{${videoPattern}}`);
|
||||
const files = await glob(pattern);
|
||||
final.exists = files.length > 0;
|
||||
final.file = files[0];
|
||||
}
|
||||
result.list.push(final);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@handle("start-download")
|
||||
async startDownload(e: IpcMainEvent, vid: number) {
|
||||
// Find the video you want to download
|
||||
const video = await this.videoRepository.findVideo(vid);
|
||||
const { name, url, headers, type, folder } = video;
|
||||
const local = this.store.get("local");
|
||||
|
||||
// Add parameters from the configuration
|
||||
const deleteSegments = this.store.get("deleteSegments");
|
||||
|
||||
const task: Task = {
|
||||
id: vid,
|
||||
params: {
|
||||
url,
|
||||
type,
|
||||
local,
|
||||
name,
|
||||
headers,
|
||||
deleteSegments,
|
||||
folder,
|
||||
},
|
||||
};
|
||||
await this.videoRepository.changeVideoStatus(vid, DownloadStatus.Watting);
|
||||
this.downloadService.addTask(task);
|
||||
}
|
||||
|
||||
@handle("stop-download")
|
||||
async stopDownload(e: IpcMainEvent, id: number) {
|
||||
this.downloadService.stopTask(id);
|
||||
}
|
||||
|
||||
@handle("delete-download-item")
|
||||
async deleteDownloadItem(e: IpcMainEvent, id: number) {
|
||||
return await this.videoRepository.deleteDownloadItem(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,429 @@
|
||||
import {
|
||||
dialog,
|
||||
IpcMainEvent,
|
||||
Menu,
|
||||
MenuItem,
|
||||
MenuItemConstructorOptions,
|
||||
nativeTheme,
|
||||
shell,
|
||||
clipboard,
|
||||
} from "electron";
|
||||
import { Favorite } from "../entity/Favorite.ts";
|
||||
import {
|
||||
convertToAudio,
|
||||
db,
|
||||
videoPattern,
|
||||
workspace,
|
||||
} from "../helper/index.ts";
|
||||
import { inject, injectable } from "inversify";
|
||||
import { AppStore, EnvPath } from "../main.ts";
|
||||
import path from "path";
|
||||
import { handle, getLocalIP } from "../helper/index.ts";
|
||||
import { DownloadStatus, type Controller } from "../interfaces.ts";
|
||||
import { TYPES } from "../types.ts";
|
||||
import fs from "fs-extra";
|
||||
import MainWindow from "../windows/MainWindow.ts";
|
||||
import BrowserWindow from "../windows/BrowserWindow.ts";
|
||||
import ElectronStore from "../vendor/ElectronStore.ts";
|
||||
import WebviewService from "../services/WebviewService.ts";
|
||||
import FavoriteRepository from "../repository/FavoriteRepository.ts";
|
||||
import VideoRepository from "../repository/VideoRepository.ts";
|
||||
import ConversionRepository from "../repository/ConversionRepository.ts";
|
||||
import { machineId } from "node-machine-id";
|
||||
import { nanoid } from "nanoid";
|
||||
import { glob } from "glob";
|
||||
import i18n from "../i18n/index.ts";
|
||||
import ElectronLogger from "../vendor/ElectronLogger.ts";
|
||||
import ElectronUpdater from "../vendor/ElectronUpdater.ts";
|
||||
|
||||
@injectable()
|
||||
export default class HomeController implements Controller {
|
||||
private sharedState: Record<string, unknown> = {};
|
||||
|
||||
constructor(
|
||||
@inject(TYPES.ElectronStore)
|
||||
private readonly store: ElectronStore,
|
||||
@inject(TYPES.FavoriteRepository)
|
||||
private readonly favoriteRepository: FavoriteRepository,
|
||||
@inject(TYPES.MainWindow)
|
||||
private readonly mainWindow: MainWindow,
|
||||
@inject(TYPES.VideoRepository)
|
||||
private readonly videoRepository: VideoRepository,
|
||||
@inject(TYPES.BrowserWindow)
|
||||
private readonly browserWindow: BrowserWindow,
|
||||
@inject(TYPES.WebviewService)
|
||||
private readonly webviewService: WebviewService,
|
||||
@inject(TYPES.ConversionRepository)
|
||||
private readonly conversionRepository: ConversionRepository,
|
||||
@inject(TYPES.ElectronLogger)
|
||||
private readonly logger: ElectronLogger,
|
||||
@inject(TYPES.ElectronUpdater)
|
||||
private readonly updater: ElectronUpdater,
|
||||
) {}
|
||||
|
||||
@handle("get-env-path")
|
||||
async getEnvPath(): Promise<EnvPath> {
|
||||
return {
|
||||
binPath: __bin__,
|
||||
dbPath: db,
|
||||
workspace: workspace,
|
||||
platform: process.platform,
|
||||
local: this.store.get("local"),
|
||||
};
|
||||
}
|
||||
|
||||
@handle("get-favorites")
|
||||
getFavorites() {
|
||||
return this.favoriteRepository.findFavorites();
|
||||
}
|
||||
|
||||
@handle("add-favorite")
|
||||
addFavorite(e: IpcMainEvent, favorite: Favorite) {
|
||||
return this.favoriteRepository.addFavorite(favorite);
|
||||
}
|
||||
|
||||
@handle("remove-favorite")
|
||||
removeFavorite(e: IpcMainEvent, id: number): Promise<void> {
|
||||
return this.favoriteRepository.removeFavorite(id);
|
||||
}
|
||||
|
||||
@handle("get-app-store")
|
||||
getAppStore() {
|
||||
return this.store.store;
|
||||
}
|
||||
|
||||
@handle("on-favorite-item-context-menu")
|
||||
async onFavoriteItemContextMenu(e: IpcMainEvent, id: number) {
|
||||
const send = (action: string) => {
|
||||
this.mainWindow.send("favorite-item-event", {
|
||||
action,
|
||||
payload: id,
|
||||
});
|
||||
};
|
||||
const template: Array<MenuItemConstructorOptions | MenuItem> = [
|
||||
{
|
||||
label: i18n.t("open"),
|
||||
click: () => {
|
||||
send("open");
|
||||
},
|
||||
},
|
||||
{ type: "separator" },
|
||||
{
|
||||
label: i18n.t("delete"),
|
||||
click: () => {
|
||||
send("delete");
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const menu = Menu.buildFromTemplate(template);
|
||||
menu.popup();
|
||||
}
|
||||
|
||||
@handle("select-download-dir")
|
||||
async selectDownloadDir(): Promise<string> {
|
||||
const window = this.mainWindow.window;
|
||||
if (!window) return Promise.reject(i18n.t("noMainWindow"));
|
||||
|
||||
const result = await dialog.showOpenDialog(window, {
|
||||
properties: ["openDirectory"],
|
||||
});
|
||||
|
||||
if (!result.canceled) {
|
||||
const dir = result.filePaths[0];
|
||||
this.store.set("local", dir);
|
||||
return dir;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@handle("set-app-store")
|
||||
async setAppStore(e: IpcMainEvent, key: keyof AppStore, val: any) {
|
||||
// useProxy
|
||||
if (key === "useProxy") {
|
||||
const proxy = this.store.get("proxy");
|
||||
this.webviewService.setProxy(val, proxy);
|
||||
}
|
||||
// proxy
|
||||
if (key === "proxy") {
|
||||
const useProxy = this.store.get("useProxy");
|
||||
useProxy && this.webviewService.setProxy(true, val);
|
||||
}
|
||||
// block
|
||||
if (key === "blockAds") {
|
||||
this.webviewService.setBlocking(val);
|
||||
}
|
||||
// theme
|
||||
if (key === "theme") {
|
||||
nativeTheme.themeSource = val;
|
||||
}
|
||||
// isMobile
|
||||
if (key === "isMobile") {
|
||||
this.webviewService.setUserAgent(val);
|
||||
}
|
||||
// privacy
|
||||
if (key === "privacy") {
|
||||
this.webviewService.setDefaultSession(val);
|
||||
}
|
||||
// language
|
||||
if (key === "language") {
|
||||
i18n.changeLanguage(val);
|
||||
}
|
||||
// allowBeta
|
||||
if (key === "allowBeta") {
|
||||
this.updater.changeAllowBeta(val);
|
||||
}
|
||||
// audio muted mode
|
||||
if (key === "audioMuted") {
|
||||
this.webviewService.setAudioMuted(val);
|
||||
}
|
||||
|
||||
this.store.set(key, val);
|
||||
}
|
||||
|
||||
@handle("open-dir")
|
||||
async openDir(e: IpcMainEvent, dir: string) {
|
||||
await shell.openPath(dir);
|
||||
}
|
||||
|
||||
@handle("open-url")
|
||||
async openUrl(e: IpcMainEvent, url: string) {
|
||||
await shell.openExternal(url);
|
||||
}
|
||||
|
||||
@handle("on-download-list-context-menu")
|
||||
async downloadListContextMenu(e: IpcMainEvent, id: number) {
|
||||
const send = (action: string) => {
|
||||
this.mainWindow.send("download-item-event", {
|
||||
action,
|
||||
payload: id,
|
||||
});
|
||||
};
|
||||
const item = await this.videoRepository.findVideo(id);
|
||||
const template: Array<MenuItemConstructorOptions | MenuItem> = [
|
||||
{
|
||||
label: i18n.t("copyLinkAddress"),
|
||||
click: () => {
|
||||
clipboard.writeText(item.url || "");
|
||||
},
|
||||
},
|
||||
{
|
||||
label: i18n.t("select"),
|
||||
click: () => {
|
||||
send("select");
|
||||
},
|
||||
},
|
||||
{
|
||||
label: i18n.t("download"),
|
||||
click: () => {
|
||||
send("download");
|
||||
},
|
||||
},
|
||||
{
|
||||
label: i18n.t("refresh"),
|
||||
click: () => {
|
||||
send("refresh");
|
||||
},
|
||||
},
|
||||
{ type: "separator" },
|
||||
{
|
||||
label: i18n.t("delete"),
|
||||
click: () => {
|
||||
send("delete");
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
if (item.status === DownloadStatus.Success) {
|
||||
const local = this.store.get("local");
|
||||
const pattern = path.join(local, `${item.name}.{${videoPattern}}`);
|
||||
const files = await glob(pattern);
|
||||
const exists = files.length > 0;
|
||||
if (exists) {
|
||||
const file = files[0];
|
||||
template.unshift(
|
||||
{
|
||||
label: i18n.t("openFolder"),
|
||||
click: () => {
|
||||
shell.showItemInFolder(file);
|
||||
},
|
||||
},
|
||||
{
|
||||
label: i18n.t("openFile"),
|
||||
click: () => {
|
||||
shell.openPath(file);
|
||||
},
|
||||
},
|
||||
{ type: "separator" },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const menu = Menu.buildFromTemplate(template);
|
||||
menu.popup();
|
||||
}
|
||||
|
||||
@handle("convert-to-audio")
|
||||
async convertToAudio(e: IpcMainEvent, id: number) {
|
||||
const conversion = await this.conversionRepository.findConversion(id);
|
||||
const local = this.store.get("local");
|
||||
const input = conversion.path;
|
||||
const outName = `${path.basename(input, path.extname(input))}.mp3`;
|
||||
const output = path.join(local, outName);
|
||||
|
||||
const exist = await fs.exists(input);
|
||||
if (exist) {
|
||||
return await convertToAudio(input, output);
|
||||
} else {
|
||||
return Promise.reject(i18n.t("noFileFound"));
|
||||
}
|
||||
}
|
||||
|
||||
@handle("show-browser-window")
|
||||
async showBrowserWindow() {
|
||||
this.browserWindow.showWindow();
|
||||
}
|
||||
|
||||
@handle("combine-to-home-page")
|
||||
async combineToHomePage() {
|
||||
// Close browser window
|
||||
this.browserWindow.hideWindow();
|
||||
// Modify the properties in the Settings
|
||||
this.store.set("openInNewWindow", false);
|
||||
}
|
||||
|
||||
@handle("get-local-ip")
|
||||
async getLocalIp() {
|
||||
return getLocalIP();
|
||||
}
|
||||
|
||||
@handle("get-shared-state")
|
||||
async getSharedState() {
|
||||
return this.sharedState;
|
||||
}
|
||||
|
||||
@handle("set-shared-state")
|
||||
async setSharedState(event: IpcMainEvent, state: any) {
|
||||
this.sharedState = state;
|
||||
}
|
||||
|
||||
@handle("get-download-log")
|
||||
async getDownloadLog(event: IpcMainEvent, id: number) {
|
||||
const video = await this.videoRepository.findVideo(id);
|
||||
return video.log || "";
|
||||
}
|
||||
|
||||
@handle("select-file")
|
||||
async selectFile() {
|
||||
const window = this.mainWindow.window;
|
||||
if (!window) return Promise.reject(i18n.t("noMainWindow"));
|
||||
|
||||
const result = await dialog.showOpenDialog(window, {
|
||||
properties: ["openFile"],
|
||||
});
|
||||
|
||||
if (!result.canceled) {
|
||||
return result.filePaths[0];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@handle("get-machine-id")
|
||||
async getMachineId() {
|
||||
try {
|
||||
const id = this.store.get("machineId");
|
||||
if (id) return id;
|
||||
const newId = await machineId();
|
||||
this.store.set("machineId", newId);
|
||||
return newId;
|
||||
} catch (e) {
|
||||
const id = this.store.get("machineId");
|
||||
if (id) return id;
|
||||
const newId = nanoid();
|
||||
this.store.set("machineId", newId);
|
||||
return newId;
|
||||
}
|
||||
}
|
||||
|
||||
@handle("export-favorites")
|
||||
async exportFavorites() {
|
||||
const favorites = await this.favoriteRepository.findFavorites();
|
||||
const json = JSON.stringify(
|
||||
favorites.map((i) => ({
|
||||
title: i.title,
|
||||
url: i.url,
|
||||
icon: i.icon,
|
||||
})),
|
||||
null,
|
||||
2,
|
||||
);
|
||||
const window = this.mainWindow.window;
|
||||
if (!window) return Promise.reject(i18n.t("noMainWindow"));
|
||||
|
||||
const result = await dialog.showSaveDialog(window, {
|
||||
title: i18n.t("exportFavorites"),
|
||||
defaultPath: "favorites.json",
|
||||
filters: [{ name: "JSON", extensions: ["json"] }],
|
||||
});
|
||||
|
||||
if (!result.canceled) {
|
||||
await fs.writeFile(result.filePath, json);
|
||||
}
|
||||
}
|
||||
|
||||
@handle("import-favorites")
|
||||
async importFavorites() {
|
||||
const window = this.mainWindow.window;
|
||||
if (!window) return Promise.reject(i18n.t("noMainWindow"));
|
||||
|
||||
const result = await dialog.showOpenDialog(window, {
|
||||
properties: ["openFile"],
|
||||
filters: [{ name: "JSON", extensions: ["json"] }],
|
||||
});
|
||||
|
||||
if (!result.canceled) {
|
||||
const filePath = result.filePaths[0];
|
||||
const json = await fs.readJSON(filePath);
|
||||
await this.favoriteRepository.importFavorites(json);
|
||||
}
|
||||
}
|
||||
|
||||
@handle("check-update")
|
||||
async checkUpdate() {
|
||||
this.updater.manualUpdate();
|
||||
}
|
||||
|
||||
@handle("start-update")
|
||||
async startUpdate() {
|
||||
this.updater.startDownload();
|
||||
}
|
||||
|
||||
@handle("install-update")
|
||||
async installUpdate() {
|
||||
this.updater.install();
|
||||
}
|
||||
|
||||
@handle("export-download-list")
|
||||
async exportDownloadList() {
|
||||
const videos = await this.videoRepository.findAllVideos();
|
||||
|
||||
const txt = videos.map((video) => `${video.url} ${video.name}`).join("\n");
|
||||
const window = this.mainWindow.window;
|
||||
if (!window) return Promise.reject(i18n.t("noMainWindow"));
|
||||
|
||||
const result = await dialog.showSaveDialog(window, {
|
||||
title: i18n.t("exportDownloadList"),
|
||||
defaultPath: "download-list.txt",
|
||||
filters: [{ name: "Text", extensions: ["txt"] }],
|
||||
});
|
||||
|
||||
if (!result.canceled) {
|
||||
await fs.writeFile(result.filePath, txt);
|
||||
}
|
||||
}
|
||||
|
||||
@handle("get-video-folders")
|
||||
async getVideoFolders() {
|
||||
return this.videoRepository.getVideoFolders();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { inject, injectable } from "inversify";
|
||||
import { handle } from "../helper/index.ts";
|
||||
import { type Controller } from "../interfaces.ts";
|
||||
import { TYPES } from "../types.ts";
|
||||
import PlayerWindow from "../windows/PlayerWindow.ts";
|
||||
|
||||
@injectable()
|
||||
export default class PlayerController implements Controller {
|
||||
constructor(
|
||||
@inject(TYPES.PlayerWindow)
|
||||
private readonly playerWindow: PlayerWindow,
|
||||
) {}
|
||||
|
||||
@handle("open-player-window")
|
||||
async openPlayerWindow() {
|
||||
this.playerWindow.showWindow();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import {
|
||||
IpcMainEvent,
|
||||
Menu,
|
||||
MenuItem,
|
||||
MenuItemConstructorOptions,
|
||||
} from "electron";
|
||||
import { inject, injectable } from "inversify";
|
||||
import { handle } from "../helper/index.ts";
|
||||
import { type Controller } from "../interfaces.ts";
|
||||
import { TYPES } from "../types.ts";
|
||||
import WebviewService from "../services/WebviewService.ts";
|
||||
import ElectronStore from "../vendor/ElectronStore.ts";
|
||||
import { SniffingHelper } from "../services/SniffingHelperService.ts";
|
||||
import i18n from "../i18n/index.ts";
|
||||
|
||||
@injectable()
|
||||
export default class WebviewController implements Controller {
|
||||
constructor(
|
||||
@inject(TYPES.WebviewService)
|
||||
private readonly webview: WebviewService,
|
||||
@inject(TYPES.ElectronStore)
|
||||
private readonly store: ElectronStore,
|
||||
@inject(TYPES.SniffingHelper)
|
||||
private readonly sniffingHelper: SniffingHelper,
|
||||
) {}
|
||||
|
||||
@handle("set-webview-bounds")
|
||||
async setWebviewBounds(e: IpcMainEvent, bounds: Electron.Rectangle) {
|
||||
this.webview.setBounds(bounds);
|
||||
}
|
||||
|
||||
@handle("webview-load-url")
|
||||
async browserViewLoadUrl(e: IpcMainEvent, url: string): Promise<void> {
|
||||
await this.webview.loadURL(url);
|
||||
}
|
||||
|
||||
@handle("webview-url-contextmenu")
|
||||
async webviewUrlContextMenu() {
|
||||
const template: Array<MenuItemConstructorOptions | MenuItem> = [
|
||||
{
|
||||
label: i18n.t("copy"),
|
||||
role: "copy",
|
||||
},
|
||||
{
|
||||
label: i18n.t("paste"),
|
||||
role: "paste",
|
||||
},
|
||||
];
|
||||
|
||||
const menu = Menu.buildFromTemplate(template);
|
||||
menu.popup();
|
||||
}
|
||||
|
||||
@handle("webview-go-back")
|
||||
async webviewGoBack(): Promise<boolean> {
|
||||
return this.webview.goBack();
|
||||
}
|
||||
|
||||
@handle("webview-reload")
|
||||
async webviewReload() {
|
||||
await this.webview.reload();
|
||||
}
|
||||
|
||||
@handle("webview-show")
|
||||
async webviewShow() {
|
||||
this.webview.show();
|
||||
}
|
||||
|
||||
@handle("webview-hide")
|
||||
async webviewHide() {
|
||||
this.webview.hide();
|
||||
}
|
||||
|
||||
@handle("webview-go-home")
|
||||
async webviewGoHome() {
|
||||
await this.webview.goHome();
|
||||
}
|
||||
|
||||
@handle("webview-change-user-agent")
|
||||
async webviewChangeUserAgent(e: IpcMainEvent, isMobile: boolean) {
|
||||
this.webview.setUserAgent(isMobile);
|
||||
this.store.set("isMobile", isMobile);
|
||||
}
|
||||
|
||||
@handle("plugin-ready")
|
||||
async pluginReady() {
|
||||
this.sniffingHelper.pluginReady();
|
||||
}
|
||||
|
||||
@handle("clear-webview-cache")
|
||||
async clearWebviewCache() {
|
||||
return this.webview.clearCache();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import { ipcMain } from "electron";
|
||||
import { inject, injectable, multiInject } from "inversify";
|
||||
import { Controller } from "../interfaces.ts";
|
||||
import { TYPES } from "../types.ts";
|
||||
import ElectronLogger from "../vendor/ElectronLogger.ts";
|
||||
import { error, success } from "../helper/utils.ts";
|
||||
|
||||
@injectable()
|
||||
export default class IpcHandlerService {
|
||||
constructor(
|
||||
@multiInject(TYPES.Controller)
|
||||
private readonly controllers: Controller[],
|
||||
@inject(TYPES.ElectronLogger)
|
||||
private readonly logger: ElectronLogger,
|
||||
) {}
|
||||
|
||||
private registerIpc(
|
||||
controller: Controller,
|
||||
propertyKey: string | symbol,
|
||||
): void {
|
||||
const property = controller[propertyKey];
|
||||
if (typeof property !== "function") return;
|
||||
|
||||
const channel: string = Reflect.getMetadata(
|
||||
"ipc-channel",
|
||||
controller,
|
||||
propertyKey,
|
||||
);
|
||||
if (!channel) return;
|
||||
|
||||
const ipcMethod: "on" | "handle" = Reflect.getMetadata(
|
||||
"ipc-method",
|
||||
controller,
|
||||
propertyKey,
|
||||
);
|
||||
if (!ipcMethod) return;
|
||||
|
||||
ipcMain[ipcMethod](channel, async (...args: unknown[]) => {
|
||||
try {
|
||||
let res = property.call(controller, ...args);
|
||||
if (res.then) {
|
||||
res = await res;
|
||||
}
|
||||
return success(res);
|
||||
} catch (e: unknown) {
|
||||
this.logger.error(`process ipc [${channel}] failed: `, e);
|
||||
if (e instanceof Error) {
|
||||
return error(e.message);
|
||||
} else {
|
||||
return error(String(e));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
init(): void {
|
||||
for (const controller of this.controllers) {
|
||||
const Class = Object.getPrototypeOf(controller);
|
||||
Object.getOwnPropertyNames(Class).forEach((propertyKey) =>
|
||||
this.registerIpc(controller, propertyKey),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user