|
1 |
| -# <img src="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/kinozal-bot-ico-256px.png" width="25" /> Kinozal-Bot |
2 |
| - |
3 |
| -🔈 **[Описание на русском](https://github.com/Lifailon/Kinozal-Bot/blob/rsa/README_RU.md)** |
4 |
| - |
5 |
| -🍿 Project purpose: |
6 |
| - |
7 |
| -- Generation of new posts with sending to Telegram channel based on new publications in tracker **[Kinozal](https://kinozal.tv)** with filtering by rating and year of release. |
8 |
| -- Automation of the process of delivering content to the TV using only the phone. Selection (proposed from the post of the channel or manual search in the bot) and downloading of a suitable torrent-file (using the proposed recommended links to each publication), setting to download in qBittorrent with the ability to manage and track the status, as well as changing the priority of downloading files, and synchronization of content with Plex Media Server, as well as viewing the contents of sections and directories. |
9 |
| - |
10 |
| -## 📚 Stack |
11 |
| - |
12 |
| -- **Kinozal**: read RSS feed, retrieve data from html (no api), search and filter content, download torrent files; |
13 |
| -- *Optional*: any VPN client application and/or proxy server for access to Kinozal; |
14 |
| -- **Telegram api**: sending messages to the channel, reading (commands only) and sending reply messages in menu format (keyboard); |
15 |
| -- **qBittorrent api**: download data from torrent files and manage data (pause, delete, change priority); |
16 |
| -- **Plex Media Server api**: synchronize data and get information about content of sections and child files. |
17 |
| - |
18 |
| -> It is planned to add additional information using third-party api (e.g. tmdb or videocdn) and disk size (e.g. Open Hardware Monitor via web api). |
19 |
| -
|
20 |
| -## 🎉 Example |
21 |
| - |
22 |
| -An active channel with publications: 📢 **[Kinozal-News](https://t.me/kinozal_news)** |
23 |
| - |
24 |
| -<a href="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/status_torrent_and_search_kinozal.jpg"><img src="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/status_torrent_and_search_kinozal.jpg" width="400"/></a> |
25 |
| -<a href="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/info_torrent.jpg"><img src="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/info_torrent.jpg" width="400"/></a> |
26 |
| -<a href="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/find_kinozal.jpg"><img src="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/find_kinozal.jpg" width="400"/></a> |
27 |
| -<a href="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/plex_folder.jpg"><img src="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/plex_folder.jpg" width="400"/></a> |
28 |
| - |
29 |
| - |
30 |
| - |
31 |
| -## 🚀 Install |
32 |
| - |
33 |
| -For the bot to work, you need to prepare your own environment. All settings of connection and filtering of new publications are set in the configuration file: **kinozal-bot.conf** 📑. |
34 |
| - |
35 |
| -1. Register an account in **Kinozal** and fill in the parameters in the configuration: |
36 |
| - |
37 |
| -`KZ_PROFILE="id_you_profile"` - used to get information from the profile \ |
38 |
| -`KZ_USER="LOGIN"` - used at the stage of torrent file downloading and obtaining information in the profile \ |
39 |
| -`KZ_PASS="PASSWORD"` |
40 |
| - |
41 |
| -2. If you do not have direct access to Kinozal, you can use a VPN or proxy server (I use **Handy Cache** in conjunction with **VPN Hotspot Shield** in Split Tunneling mode based on the Windows operating system) through which the bot can proxy its requests. |
42 |
| - |
43 |
| -`PROXY="True"` - enable the use of a proxy server in curl-requests when accessing Kinozal \ |
44 |
| -`PROXY_ADDR="http://192.168.3.100:9090"` \ |
45 |
| -`PROXY_USER="LOGIN"` \ |
46 |
| -`PROXY_PASS="PASSWORD"` |
47 |
| - |
48 |
| -3. Create a bot in **[@botfather](https://t.me/BotFather)** using an intuitive interface and get its API token. Also create your channel for new publications in Kinozal and separately start your chat with the previously created bot to interact with the services. Get the id of the channel (starts with "-") and chat using the bot: **[Get My ID](https://t.me/getmyid_arel_bot)** and fill in the parameters: |
49 |
| - |
50 |
| -`TG_TOKEN="6873341222:AAFnVgfavenjwbKutRwROQQBya_XXXXXXXX"` - used to read and send messages to Telegram chatbot \ |
51 |
| -`TG_CHANNEL="-1002064864175"` - used to send messages to the channel \ |
52 |
| -`TG_CHAT="8888888888,999999999"` - id of all chat rooms for access to the bot (to be filled in with commas), further id can be obtained in the log output from requests of new clients requests \ |
53 |
| -`TG_BOT_NAME="lifailon_ps_bot"` - used to link to the bot from the channel |
54 |
| - |
55 |
| -4. Install torrent client **qBittorrent** and enable **Web interface** in the settings. |
56 |
| - |
57 |
| -`QB_ADDR="http://192.168.3.100:8888"` - specify the final URL, which specifies the IP address of the machine running qBittorrent and port (set in the settings) \ |
58 |
| -`QB_USER="LOGIN"` - is specified in the **Authentication** field in the **Web Interface** settings \ |
59 |
| -`QB_PASS="PASSWORD"` |
60 |
| - |
61 |
| - |
62 |
| - |
63 |
| -5. Install **Plex Media Server** (in my case installed where the qBittorrent client is on my Windows machine) and **get the key/token** to access the REST API. I couldn't find a way to get the key in the web interface, so I captured the token in the network log url request (X-Plex-Token=) during authorization using **Development Tools** (no time limit). |
64 |
| - |
65 |
| -`PLEX_ADDR="http://192.168.3.100:32400"` \ |
66 |
| -`PLEX_TOKEN="TOKEN"` |
67 |
| - |
68 |
| - |
69 |
| - |
70 |
| -## 🐧 Start |
71 |
| - |
72 |
| -To run the bot on a remote machine (I use Ubuntu Server 22.04) place the configuration file **kinozal-bot.conf** next to the script (the paths for storing the log file, cookies and torrent files are set in the configuration) and use the 🐧 interpreter to run it (root privileges are not required): |
73 |
| - |
74 |
| -```bash |
75 |
| -bash ~/bash kinozal-torrent/kinozal-bot-0.4.sh |
76 |
| -``` |
77 |
| - |
78 |
| -On startup, the path to the log will be given. There are 2 main threads (processes) and up to 20 child threads running. |
79 |
| - |
80 |
| -**Stop the service:** |
81 |
| - |
82 |
| -```bash |
83 |
| -bash ~/bash kinozal-torrent/kinozal-bot-0.4.sh stop |
84 |
| -bash ~/bash kinozal-torrent/kinozal-bot-0.4.sh status |
85 |
| -``` |
86 |
| - |
87 |
| -## 📌 Commands |
88 |
| - |
89 |
| -A list of all available commands (except `/search`) are automated through the bot menu. |
90 |
| - |
91 |
| -`/search` - Search in Kinozal by name \ |
92 |
| -`/profile ` - Profile Kinozal (the number of available for download torrent files, download and upload statistics, time sid and peer) \ |
93 |
| -`/torrent_files` - List of downloaded torrent files (with the ability to delete files) \ |
94 |
| -`/status` - qBittorrent manager (list and status of all current torrents added to the torrent client) \ |
95 |
| -`/plex_info` - Plex content (list of available sections for selection) \ |
96 |
| -`/download_torrent` - Download torrent file (pass two parameters: id and file name without spaces) \ |
97 |
| -`/delete_torrent_file_id` - Delete torrent file by id \ |
98 |
| -`/find_kinozal_id` - Search in Kinozal by id \ |
99 |
| -`/download_video_id` - Add to qBittorrent to download from torrent file \ |
100 |
| -`/info` - Download status of the specified torrent (pass parameter: torrent hash) \ |
101 |
| -`/torrent_content` - Contents (files) of the torrent (pass parameter: torrent hash) \ |
102 |
| -`/file_torrent` - Status of selected torrent file (pass parameter: file index) \ |
103 |
| -`/torrent_priority` - Change the priority of the selected file in /file_torrent (pass parameter: priority number) \ |
104 |
| -`/pause` - Set to pause (pass parameter: torrent hash) \ |
105 |
| -`/resume` - Restore download (pass parameter: torrent hash) \ |
106 |
| -`/delete_torrent` - Remove torrent from download (pass parameter: torrent hash) \ |
107 |
| -`/delete_video` - Delete with video data (pass parameter: hash of torrent) \ |
108 |
| -`/plex_status_key` - Information about the selected section in Plex (pass parameter: section key) \ |
109 |
| -`/plex_sync_key` - Synchronize the specified section in Plex (pass parameter: section key) \ |
110 |
| -`/plex_folder_key` - Get the list of directories and files in the selected section \ |
111 |
| -`/find` - Search for content in Plex by path (pass parameter: endpoint) |
112 |
| - |
| 1 | +# <img src="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/kinozal-bot-ico-256px.png" width="25" /> Kinozal-Bot |
| 2 | + |
| 3 | +🔈 **[Описание на русском](https://github.com/Lifailon/Kinozal-Bot/blob/rsa/README_RU.md)** |
| 4 | + |
| 5 | +🍿 Project purpose: |
| 6 | + |
| 7 | +- Generation of new posts with sending to Telegram channel based on new publications in tracker **[Kinozal](https://kinozal.tv)** with filtering by rating and year of release. |
| 8 | +- Automation of the process of delivering content to the TV using only the phone. Selection (proposed from the post of the channel or manual search in the bot) and downloading of a suitable torrent-file (using the proposed recommended links to each publication), setting to download in qBittorrent with the ability to manage and track the status, as well as changing the priority of downloading files, and synchronization of content with Plex Media Server, as well as viewing the contents of sections and directories. |
| 9 | + |
| 10 | +## 📚 Stack |
| 11 | + |
| 12 | +- **Kinozal**: read RSS feed, retrieve data from html (no api), search and filter content, download torrent files; |
| 13 | +- *Optional*: any VPN client application and/or proxy server for access to Kinozal; |
| 14 | +- **Telegram api**: sending messages to the channel, reading (commands only) and sending reply messages in menu format (keyboard); |
| 15 | +- **qBittorrent api**: download data from torrent files and manage data (pause, delete, change priority); |
| 16 | +- **Plex Media Server api**: synchronize data and get information about content of sections and child files. |
| 17 | + |
| 18 | +## 🎉 Example |
| 19 | + |
| 20 | +An active channel with publications: 📢 **[Kinozal-News](https://t.me/kinozal_news)** |
| 21 | + |
| 22 | +<a href="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/status_torrent_and_search_kinozal.jpg"><img src="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/status_torrent_and_search_kinozal.jpg" width="400"/></a> |
| 23 | +<a href="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/info_torrent.jpg"><img src="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/info_torrent.jpg" width="400"/></a> |
| 24 | +<a href="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/find_kinozal.jpg"><img src="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/find_kinozal.jpg" width="400"/></a> |
| 25 | +<a href="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/plex_folder.jpg"><img src="https://github.com/Lifailon/Kinozal-Bot/blob/rsa/image/plex_folder.jpg" width="400"/></a> |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +## 🚀 Install |
| 30 | + |
| 31 | +For the bot to work, you need to prepare your own environment. All settings of connection and filtering of new publications are set in the configuration file: **kinozal-bot.conf** 📑. |
| 32 | + |
| 33 | +1. Register an account in **Kinozal** and fill in the parameters in the configuration: |
| 34 | + |
| 35 | +`KZ_PROFILE="id_you_profile"` - used to get information from the profile \ |
| 36 | +`KZ_USER="LOGIN"` - used at the stage of torrent file downloading and obtaining information in the profile \ |
| 37 | +`KZ_PASS="PASSWORD"` |
| 38 | + |
| 39 | +2. If you do not have direct access to Kinozal, you can use a VPN or proxy server (I use **Handy Cache** in conjunction with **VPN Hotspot Shield** in Split Tunneling mode based on the Windows operating system) through which the bot can proxy its requests. |
| 40 | + |
| 41 | +`PROXY="True"` - enable the use of a proxy server in curl-requests when accessing Kinozal \ |
| 42 | +`PROXY_ADDR="http://192.168.3.100:9090"` \ |
| 43 | +`PROXY_USER="LOGIN"` \ |
| 44 | +`PROXY_PASS="PASSWORD"` |
| 45 | + |
| 46 | +3. Create a bot in **[@botfather](https://t.me/BotFather)** using an intuitive interface and get its API token. Also create your channel for new publications in Kinozal and separately start your chat with the previously created bot to interact with the services. Get the id of the channel (starts with "-") and chat using the bot: **[Get My ID](https://t.me/getmyid_arel_bot)** and fill in the parameters: |
| 47 | + |
| 48 | +`TG_TOKEN="6873341222:AAFnVgfavenjwbKutRwROQQBya_XXXXXXXX"` - used to read and send messages to Telegram chatbot \ |
| 49 | +`TG_CHANNEL="-1002064864175"` - used to send messages to the channel \ |
| 50 | +`TG_CHAT="8888888888,999999999"` - id of all chat rooms for access to the bot (to be filled in with commas), further id can be obtained in the log output from requests of new clients requests \ |
| 51 | +`TG_BOT_NAME="lifailon_ps_bot"` - used to link to the bot from the channel |
| 52 | + |
| 53 | +4. Install torrent client **qBittorrent** and enable **Web interface** in the settings. |
| 54 | + |
| 55 | +`QB_ADDR="http://192.168.3.100:8888"` - specify the final URL, which specifies the IP address of the machine running qBittorrent and port (set in the settings) \ |
| 56 | +`QB_USER="LOGIN"` - is specified in the **Authentication** field in the **Web Interface** settings \ |
| 57 | +`QB_PASS="PASSWORD"` |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | +5. Install **Plex Media Server** (in my case installed where the qBittorrent client is on my Windows machine) and **get the key/token** to access the REST API. I couldn't find a way to get the key in the web interface, so I captured the token in the network log url request (X-Plex-Token=) during authorization using **Development Tools** (no time limit). |
| 62 | + |
| 63 | +`PLEX_ADDR="http://192.168.3.100:32400"` \ |
| 64 | +`PLEX_TOKEN="TOKEN"` |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | +## 🐧 Start |
| 69 | + |
| 70 | +Check that you have **[jq](https://github.com/jqlang/jq)** installed: |
| 71 | + |
| 72 | +```bash |
| 73 | +apt install jq |
| 74 | +jq --version |
| 75 | +jq-1.6 |
| 76 | +``` |
| 77 | + |
| 78 | +To run the bot on a remote machine (I use Ubuntu Server 22.04) place the configuration file **kinozal-bot.conf** next to the script (the paths for storing the log file, cookies and torrent files are set in the configuration) and use the 🐧 interpreter to run it (root privileges are not required): |
| 79 | + |
| 80 | +```bash |
| 81 | +bash ~/bash kinozal-torrent/kinozal-bot-0.4.sh |
| 82 | +``` |
| 83 | + |
| 84 | +On startup, the path to the log will be given. There are 2 main threads (processes) and up to 20 child threads running. |
| 85 | + |
| 86 | +**Stop the service:** |
| 87 | + |
| 88 | +```bash |
| 89 | +bash ~/bash kinozal-torrent/kinozal-bot-0.4.sh stop |
| 90 | +bash ~/bash kinozal-torrent/kinozal-bot-0.4.sh status |
| 91 | +``` |
| 92 | + |
| 93 | +## 📌 Commands |
| 94 | + |
| 95 | +A list of all available commands (except `/search`) are automated through the bot menu. |
| 96 | + |
| 97 | +`/search` - Search in Kinozal by name \ |
| 98 | +`/profile ` - Profile Kinozal (the number of available for download torrent files, download and upload statistics, time sid and peer) \ |
| 99 | +`/torrent_files` - List of downloaded torrent files (with the ability to delete files) \ |
| 100 | +`/status` - qBittorrent manager (list and status of all current torrents added to the torrent client) \ |
| 101 | +`/plex_info` - Plex content (list of available sections for selection) \ |
| 102 | +`/download_torrent` - Download torrent file (pass two parameters: id and file name without spaces) \ |
| 103 | +`/delete_torrent_file_id` - Delete torrent file by id \ |
| 104 | +`/find_kinozal_id` - Search in Kinozal by id \ |
| 105 | +`/download_video_id` - Add to qBittorrent to download from torrent file \ |
| 106 | +`/info` - Download status of the specified torrent (pass parameter: torrent hash) \ |
| 107 | +`/torrent_content` - Contents (files) of the torrent (pass parameter: torrent hash) \ |
| 108 | +`/file_torrent` - Status of selected torrent file (pass parameter: file index) \ |
| 109 | +`/torrent_priority` - Change the priority of the selected file in /file_torrent (pass parameter: priority number) \ |
| 110 | +`/pause` - Set to pause (pass parameter: torrent hash) \ |
| 111 | +`/resume` - Restore download (pass parameter: torrent hash) \ |
| 112 | +`/delete_torrent` - Remove torrent from download (pass parameter: torrent hash) \ |
| 113 | +`/delete_video` - Delete with video data (pass parameter: hash of torrent) \ |
| 114 | +`/plex_status_key` - Information about the selected section in Plex (pass parameter: section key) \ |
| 115 | +`/plex_sync_key` - Synchronize the specified section in Plex (pass parameter: section key) \ |
| 116 | +`/plex_folder_key` - Get the list of directories and files in the selected section \ |
| 117 | +`/find` - Search for content in Plex by path (pass parameter: endpoint) |
| 118 | +`/plex_last_views` - Last views \ |
| 119 | +`/plex_last_added` - Last added files |
0 commit comments