Skip to content

Python Web App which Indexes a Your Telegram Channel and Serves its Files for Download and Stream.

License

Notifications You must be signed in to change notification settings

babupakkakivellu/Surf-TG

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Surf_TG
Python Web App which Indexes a Your Telegram Channel and Serves its Files for Download and Stream.

Features πŸ“‘

  • Multi Channel Index πŸ“‘
  • Thumbnail Support (Channel Profile) πŸ–ΌοΈ
  • Search Support πŸ”
  • Login support πŸ”
  • Faster Resumeable Download Link ⏩
  • Stream Video Support πŸ“Ί
  • 25 Website Themes (Bootswatch) 🎨
  • Playlist Creator Support πŸ“€
  • Database Support πŸ’Ύ

To-Do πŸ“¦

  • API Support πŸ› οΈ
  • Admin Pannel Support πŸ‘‘

Website Screenshots 🌐

Environment Variables πŸͺ§

To run this Surf-TG, you will need to add the following environment variables to your config.env file.

Note

First, rename the sample_config.env to config.env.

Variable Name Value
API_ID (required) Telegram api_id obtained from https://my.telegram.org/apps. int
API_HASH (required) Telegram api_hash obtained from https://my.telegram.org/apps. str
BOT_TOKEN (required) The Telegram Bot Token that you got from @BotFather str
AUTH_CHANNEL (required) Chat_ID of the Channel you are using for index (Seperate Multiple Channel By , eg- -100726731829, -10022121832). int
DATABASE_URL (required) Your Mongo Database URL (Connection string). Follow this Guide to generate database. str
BASE_URL (required) Valid BASE URL where the bot is deployed. Format of URL should be http://myip, where myip is the IP/Domain(public) of your bot. For Heroku use App Url. str
PORT Port on which app should listen to, defaults to 8080. int
USERNAME default username is admin. str
PASSWORD default password is admin. str
ADMIN_USERNAME Set the admin username so that the admin can log in to Playlist Creator. Make it different from USERNAME. The default admin username is surfTG. str
ADMIN_PASSWORD Set the admin password so that the admin can log in to Playlist Creator. Make it different from PASSWORD. The default admin password is surfTG. str
SLEEP_THRESHOLD Set a sleep threshold for flood wait exceptions, defaut is 60. int
WORKERS Number of maximum concurrent workers for handling incoming updates, default is 10. int
MULTI_TOKEN Multi bot token for handing incoming updates. (*)asterisk represents any interger starting from 1. str
THEME Choose any Bootswatch theme for UI, Default is flatly. str

Themes 🎨

  • There are 25 Themes from bootswatch official Bootstrap Themes.
  • You can check Theme from bootswatch.com before selecting.
  • To Change theme, Set Appropriate Theme name in Theme Variable.
Themes
cerulean cosmo cyborg darkly flatly journal
litera lumen lux materia minty pulse
sandstone simplex sketchy slate solar spacelab
superhero united yeti vapor morph quartz
zephyr

Multiple Bots πŸš€ (Speed Booster)

Note

What it multi-client feature and what it does?

This feature shares the Telegram API requests between worker bots to speed up download speed when many users are using the server and to avoid the flood limits that are set by Telegram.

Note

You can add up to 50 bots since 50 is the max amount of bot admins you can set in a Telegram Channel.

To enable multi-client, generate new bot tokens and add it as your config.env with the following key names.

MULTI_TOKEN1: Add your first bot token here. MULTI_TOKEN2: Add your second bot token here.

you may also add as many as bots you want. (max limit is 50) MULTI_TOKEN3, MULTI_TOKEN4, etc.

Warning

Don't forget to add all these worker bots to the AUTH_CHANNEL for the proper functioning

Generate Database πŸ’Ύ

Note

Why Database is Required

In Playlist Creator, the folder and file data are stored. As of now, the session string is not required in Surf-TG, so to store these files, the database is necessary.

  1. Go to https://mongodb.com/ and sign-up.
  2. Create Shared Cluster.
  3. Press on Database under Deployment Header, your created cluster will be there.
  4. Press on connect, choose Allow Access From Anywhere and press on Add IP Address without editing the ip, then create user.
  5. After creating user press on Choose a connection, then press on Connect your application. Choose Driver python and version 3.6 or later.
  6. Copy your connection string and replace <password> with the password of your user, then press close.

Playlist Creator πŸ“€

Note

Login With ADMIN_USERNAME and ADMIN_PASSWORD

  • πŸ“ Create Folder/Subfolder
  • ✏️ Edit the Folder Name
  • πŸ–ΌοΈ Edit the Folder Thumbnail
  • πŸ“₯ Directly Store File in folder from AUTH_CHANNEL
  • πŸ” Search Support of file in Playlist folder (limited to the folder which is open in the browser)
  • ✏️ Edit Filename of File
  • πŸ–ΌοΈ Edit Thumbnail of File

Deployment

Either you could locally host, VPS, or deploy on Heroku

Deploy Locally:

git clone https://github.com/weebzone/Surf-TG
cd Surf-TG
python3 -m venv ./venv
. ./venv/bin/activate
pip install -r requirements.txt
python3 -m bot
  • To stop the whole server, do CTRL+C

  • If you want to run this server 24/7 on the VPS, follow these steps.

sudo apt install tmux -y
tmux
python3 -m bot
  • now you can close the VPS and the server will run on it.

Deploy using Docker

  • Clone the Repository:
git clone https://github.com/weebzone/Surf-TG
cd Surf-TG
  • Start Docker daemon (SKIP if already running, mostly you don't need to do this):
sudo dockerd
  • Build own Docker image:
sudo docker build -t Surf-TG .
  • Start Container:
sudo docker run -p 8080:8080 Surf-TG
  • To stop the running image:
sudo docker ps
sudo docker stop id

Deploy on Heroku :

Easily Deploy to Heroku use this Colab Tool

FAQ πŸ€”

Question 1: Is a session string required in Surf-TG?

Answer: No, it is not required.

Question 2: Why is the initial indexing slow?

Answer: The initial indexing process might be slow because the bot retrieves and stores file data in the MongoDB database without needing the session string. This optimization ensures that subsequent indexing processes are faster.

Question 3: Can anyone create or edit folders/files in Playlist Creator?

Answer: No, only admins with ADMIN_USERNAME and ADMIN_PASSWORD can log in to Playlist Creator.

Question 4: If i delete the mongoDb database then my playlist also deleted?

Answer: Yes, Your all the playlist will be deleted.

Question 5: If i delete the file from AUTH_CHANNEL still then it will be played in Surf-TG?

Answer: No, Once the file is deleted it will be no more playable.

Contributing

Feel free to contribute to this project if you have any further ideas

Credits

Contact Info

Telegram Username

Copyright ©️

Copyright (C) 2024-present Weebzone under GNU Affero General Public License.

Surf-TG is Free Software: You can use, study share and improve it at your will. Specifically you can redistribute and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Also keep in mind that all the forks of this repository MUST BE OPEN-SOURCE and MUST BE UNDER THE SAME LICENSE.

About

Python Web App which Indexes a Your Telegram Channel and Serves its Files for Download and Stream.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 55.4%
  • HTML 44.4%
  • Other 0.2%