Skip to content
forked from Spmart/YTAP-Bot

Telegram bot that downloads audio from YouTube and sends it to the user as an audio file.

License

Notifications You must be signed in to change notification settings

FominVO/YTAP-Bot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YTAP

Telegram bot that downloads audio from YouTube and sends it to the user as an audio file. You can try it now!

Hello, YTAP!

Dependencies and requirements

  • Unix-like OS — Ubuntu, Debian, CentOS or macOS — that's all should work;
  • JDK 11 is minimal (I guess... I actualy using AdoptOpenJDK 14);
  • Maven;
  • Telgrambots library;
  • YouTube-DL installed;
  • FFmpeg installed;

Getting started

0. Install JDK. I use AdoptOpenJDK14 with OpenJ9 VM.

1. Clone repository. If you using an IntelliJ IDEA, you can grab all project directly from GitHub by link.

2. Add telegrambots dependency in your pom.xml:

<dependency>
    <groupId>org.telegram</groupId>
    <artifactId>telegrambots</artifactId>
    <version>4.9</version>
</dependency>

3. Create files name.txt and token.txt in working directory. Add a bot name and token, according to the file names. If you don't have it ask @BotFather at Telegram.

4. Create an empty ./audio directory.

The end result should be something like this: Directory testthings isn't required

5. Install youtube-dl. You can do that from system package manager, but packages may be quite old (except brew on Mac and pacman in Arch). Here is a better way to install a lastest version. Make shure, that you can call youtube-dl from /usr/local/bin/youtube-dl. If not, create a symlink.

6. Install FFmpeg. You can use your system package manager here.

7. Build project with any available method. I use an artifact (JAR) build with IntelliJ IDEA.

8. [Optional] If you deploy your bot to VPS, you probably want to run it in the background. You can use nohup for that, but better way would be a Systemd service.

  1. Create in *.service file in /etc/systemd/system/. For example it would be ytap.service.
  2. Your service may look like that:
    [Unit]
    Description=Manage Java ytap service
    [Service]
    WorkingDirectory=/var/www/telegrambots/ytap/
    ExecStart=/bin/java -jar YTAP.jar
    User=ytap
    Type=simple
    Restart=on-failure
    RestartSec=10
    [Install]
    WantedBy=multi-user.target
    
  3. Save ytap.service file, restart systemd, enable service and start it:
    $ sudo systemctl daemon-reload
    $ sudo systemctl enable ytap.service
    $ sudo systemctl start ytap.service

Now your bot runs in background, automaticly restarts on failure and after server reboot.

About

Telegram bot that downloads audio from YouTube and sends it to the user as an audio file.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%