Skip to content

Commit 3af6fe0

Browse files
github-actions[bot]SegoCodegithub-actions
authored
Sync from develop to main (#12)
* refactor code and add web panel * Update .gitignore * Update PanelController.java * Update PanelController.java * move views to resource folder * Create demo3.png * Update CommandExecutor.java * Update admin.html * Update admin.html * Update CommandExecutor.java * Update CommandExecutor.java * Update CommandExecutor.java * Update CommandExecutor.java * Update CommandExecutor.java * Update Messages.java * Update CommandExecutor.java * Delete CommandExecutor.java * Delete Utils.java * Update FileUtil.java * Update Webdlbot.java * Update Webdlbot.java * Update Main.java * Update Webdlbot.java * Update Webdlbot.java * Update admin.html * Update admin.html * Update admin.html * Update admin.html * Update admin.html * Update admin.html * Update update-license.yml * Create demoPanel.png * Update README.md * Update LICENSE with repository information * Update demoPanel.png * Delete demo3.png * Simplify html view * Update to latest local state * Update admin.html * update structure * Update pom.xml * Revert "update structure" This reverts commit 99b3936. * refactor * Update pom.xml * Update README.md --------- Co-authored-by: SegoCode <35817798+SegoCode@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com>
1 parent a9bd535 commit 3af6fe0

19 files changed

Lines changed: 652 additions & 418 deletions

File tree

README.md

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# webdl
22

33
<img src="https://raw.githubusercontent.com/SegoCode/webdl_bot/main/media/demo2.gif">
4-
<img src="https://raw.githubusercontent.com/SegoCode/webdl_bot/main/media/demoPanel.png">
54

65
<p align="center">
76
<a href="#about">About</a> •
@@ -15,30 +14,59 @@ Telegram bot in Java for downloading social media videos using yt-dlp
1514

1615
## Features
1716

18-
- Non-blocking message queue processing
17+
- Non-blocking message queue processing with virtual threads
1918

20-
- Dynamic interaction with messages
19+
- Dynamic interaction with Telegram messages (send, delete, edit)
2120

22-
- Panel with usage statistics
21+
- Web panel with usage statistics on port 8080
22+
23+
- Automatic retry on download failures
2324

2425
## Quick Start & Information
2526

2627
Webdl accepts a video URL, downloads it using [yt-dlp](https://github.com/yt-dlp/yt-dlp), and sends it back to the user as a video message.
2728

28-
Clone and run the project from source code.
29+
### From source
30+
2931
```
3032
git clone https://github.com/SegoCode/webdl
31-
cd webdl\code
32-
mvn clean package
33+
cd webdl/code
34+
mvn clean package -DskipTests
3335
java -jar target/webdl.jar
3436
```
3537

36-
For Docker deployment, make sure to set up environment variables.
37-
Use a temp volume for the download, it will delete after send.
38+
### Docker
39+
3840
```
39-
mvn clean package
41+
cd webdl/code
42+
mvn clean package -DskipTests
4043
docker build -t webdl-image .
41-
docker run -e BOT_TOKEN=your-bot-token -p 8080:8080 -v /mnt/drive/data/webdl:/downloads --name webdl webdl-image
44+
docker run -d \
45+
--name webdl \
46+
--restart unless-stopped \
47+
-e BOT_TOKEN=your-bot-token \
48+
-p 8080:8080 \
49+
-v /mnt/drive/data/webdl:/downloads \
50+
webdl-image
51+
```
52+
53+
### Project structure
54+
55+
```
56+
code/src/main/java/org/segocode/webdl/
57+
├── Main.java # Entry point
58+
├── bot/
59+
│ ├── Webdlbot.java # Telegram long-polling bot
60+
│ ├── constants/Messages.java # User-facing message strings
61+
│ ├── model/{User,DataRootContainer}.java # EclipseStore persistence
62+
│ ├── service/{MessageService,VideoService}.java
63+
│ └── util/MessageUtil.java
64+
├── panel/
65+
│ ├── PanelApplication.java # Javalin web server bootstrap
66+
│ └── AdminController.java # Admin panel route handler
67+
└── system/
68+
├── command/CommandExecutor.java # yt-dlp subprocess with retry
69+
└── util/FileUtil.java
4270
```
4371

4472

code/Dockerfile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,11 @@ COPY src ./src
88
RUN mvn package -DskipTests
99

1010
# Runtime stage: Run the application
11-
FROM alpine:latest
11+
FROM eclipse-temurin:21-jre-alpine
1212

13-
RUN apk update && \
14-
apk add --no-cache wget curl ffmpeg && \
13+
RUN apk add --no-cache ffmpeg python3 && \
1514
wget -O /usr/local/bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp && \
16-
chmod a+rx /usr/local/bin/yt-dlp && \
17-
rm -rf /var/cache/apk/*
18-
19-
RUN apk add --no-cache openjdk21 python3 py3-pip
20-
21-
ENV YT_DLP=/usr/bin/yt-dlp PYTHONUNBUFFERED=1
15+
chmod a+rx /usr/local/bin/yt-dlp
2216

2317
WORKDIR /app
2418
COPY --from=build /app/target/webdl.jar /app/webdl.jar

code/pom.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,25 @@
6565
<transformers>
6666
<transformer
6767
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
68-
<mainClass>org.segocode.Main</mainClass>
68+
<mainClass>org.segocode.webdl.Main</mainClass>
6969
</transformer>
7070
</transformers>
7171
</configuration>
7272
</execution>
7373
</executions>
7474
</plugin>
75+
<plugin>
76+
<groupId>com.diffplug.spotless</groupId>
77+
<artifactId>spotless-maven-plugin</artifactId>
78+
<version>3.6.0</version>
79+
<configuration>
80+
<java>
81+
<palantirJavaFormat>
82+
<version>2.92.0</version>
83+
</palantirJavaFormat>
84+
</java>
85+
</configuration>
86+
</plugin>
7587
</plugins>
7688
</build>
7789
</project>

code/src/main/java/org/segocode/bot/service/MessageService.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

code/src/main/java/org/segocode/bot/service/VideoService.java

Lines changed: 0 additions & 62 deletions
This file was deleted.

code/src/main/java/org/segocode/panel/PanelController.java

Lines changed: 0 additions & 60 deletions
This file was deleted.

code/src/main/java/org/segocode/Main.java renamed to code/src/main/java/org/segocode/webdl/Main.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
package org.segocode;
1+
package org.segocode.webdl;
22

3-
import io.javalin.Javalin;
43
import org.eclipse.store.storage.embedded.types.EmbeddedStorage;
54
import org.eclipse.store.storage.embedded.types.EmbeddedStorageManager;
6-
import org.eclipse.store.storage.types.StorageManager;
7-
import org.segocode.bot.Webdlbot;
8-
import org.segocode.panel.PanelController;
5+
import org.segocode.webdl.bot.Webdlbot;
6+
import org.segocode.webdl.panel.PanelApplication;
97
import org.slf4j.Logger;
108
import org.slf4j.LoggerFactory;
119
import org.telegram.telegrambots.meta.TelegramBotsApi;
1210
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession;
1311

14-
import java.util.Date;
15-
1612
public class Main {
1713
private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
1814

@@ -25,7 +21,7 @@ public static void main(String[] args) {
2521
botsApi.registerBot(new Webdlbot(storageManager));
2622
LOGGER.info("Bot started successfully and ready to download videos 🚀");
2723
LOGGER.info("Starting webp anel app...");
28-
PanelController.start(storageManager);
24+
PanelApplication.start(storageManager);
2925
} catch (Exception e) {
3026
LOGGER.error("Error while attempting to start the bot. Error details:", e);
3127
}

0 commit comments

Comments
 (0)