Skip to content

Commit

Permalink
v0.0.7
Browse files Browse the repository at this point in the history
* Added Separate Anime Channel Upload
* Added Button Upload Support (File Store)
* Added Force Subscriber
* Added 480p Support
* Added Broadcast
* Major Modification In FFMPEG Code.
* Modified Anime Searcher (Formatter)
* Admin Panel Fixed
* Rewritten Whole Program (Fully OOPs Based)
* Optimized Core
* Added Heroku Support
* Added Custom CRF Support
  • Loading branch information
kaif-00z authored May 24, 2024
1 parent 2faf95b commit 7a7f26e
Show file tree
Hide file tree
Showing 17 changed files with 393 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
repository: .
commit_user_name: kaif-00z
commit_user_email: [email protected]
commit_author: kaif-00z <[email protected]>
commit_author: kaif-00z <[email protected]>
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.env
__pycache__/
__pycache__/
test.py
9 changes: 7 additions & 2 deletions .sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ BOT_TOKEN=
MAIN_CHANNEL=-1001111
LOG_CHANNEL=-1001111
CLOUD_CHANNEL=-1001111
REDIS_URI=
REDIS_PASSWORD=
FIREBASE_SERVICE_ACCOUNT_FILE=
FIREBASE_URL=
OWNER=1872074304
BACKUP_CHANNEL=-1001111

# Optional Environment Variable

API_ID=
API_HASH=
FORCESUB_CHANNEL_LINK=
FORCESUB_CHANNEL=
SESSION=
SEND_SCHEDULE=
THUMBNAIL=
CRF=
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@

## Description Of Latest Update

- Added Separate Anime Channel Upload
- <details><summary>Click Here To See How Separate Anime Channel Upload Look.</summary><img src="https://graph.org/file/a0636332545730a4d3d43.jpg" alt="sepul1"/><img src="https://graph.org/file/3eb0b86609469f385f4b5.jpg" alt="sepul2"/></details>
- Added Button Upload Support (File Store)
- <details><summary>Click Here To See How Button Upload Look.</summary><img src="https://graph.org/file/3e9abc9ec7de6a26fd1a1.jpg" alt="btnul"/></details>
- Added ForceSub
- Added 480p Support
- Added Broadcast
- Major Modification In FFMPEG Code.
- Modified Anime Searcher
- Admin Panel Fixed
- ReWritten Whole Program (Fully OOPs Based)
- Optimized Core
- Added Heroku Support
- Added Button Upload Support (File Store)
- <details><summary>Click Here To See How Button Upload Look.</summary><img src="https://graph.org/file/fbe1bf09ad2526f9386e5.jpg" alt="btnul"/></details>
- Added Custom CRF Support

## Contributing
Expand All @@ -40,9 +48,9 @@

- `BOT_TOKEN` - Get This From @Botfather In Telegram.

- `REDIS_URI` - Get This From redis.com
- `FIREBASE_URL` - Get This From Firebase Realtime Database Console.

- `REDIS_PASSWORD` - Get This From redis.com
- `FIREBASE_SERVICE_ACCOUNT_FILE` - Get This From Firebase Realtime Database Console.

- `MAIN_CHANNEL` - ID of Channel Where Anime Will Upload.

Expand All @@ -54,6 +62,8 @@

### OPTIONAL VARIABLES

- `SESSION` - Telethon Session String Of Your Telegram Account.

- `BACKUP_CHANNEL` - ID of Channel Where Anime Will Be Saved As BackUP if You Are Using Button Upload Option Then Make Sure To SET Backup Channel.

- `THUMBNAIL` - JPG/PNG Link of Thumbnail FIle.
Expand All @@ -78,7 +88,7 @@

## Commands

[![Comand](https://graph.org/file/82176674097989fae68d4.png)](https://github.com/kaif-00z/AutoAnimeBot/)
[![Comand](https://graph.org/file/ca8de14ba0b1d3b71af1f.jpg)](https://github.com/kaif-00z/AutoAnimeBot/)

**Uploading of Ongoing Animes Is Automatic**

Expand Down
14 changes: 10 additions & 4 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,24 @@
"value": ""
},

"SESSION": {
"description": "Telethon Session String",
"value": "",
"required": false
},

"OWNER": {
"description": "Get ur Id Of Telegram nd Paste Here.",
"value": ""
},

"REDIS_URI": {
"description": "Redis endpoint URL, from redislabs.com",
"FIREBASE_URL": {
"description": "Firebase endpoint URL, from Firebase Realtime Database",
"value": ""
},

"REDIS_PASSWORD": {
"description": "Redis endpoint password, from redislabs.com",
"FIREBASE_SERVICE_ACCOUNT_FILE": {
"description": "Firebase Service Account File Link, from Firebase Realtime Database",
"value": ""
},

Expand Down
37 changes: 23 additions & 14 deletions auto_env_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@

DATA = {}
ENV = """
API_ID={}
API_HASH={}
BOT_TOKEN={}
SESSION={}
MAIN_CHANNEL={}
LOG_CHANNEL={}
CLOUD_CHANNEL={}
BACKUP_CHANNEL={}
REDIS_URI={}
REDIS_PASSWORD={}
FIREBASE_URL={}
FIREBASE_SERVICE_ACCOUNT_FILE={}
OWNER={}
"""

Expand All @@ -35,21 +38,24 @@ async def generate_session_string():
api_hash = input("Enter your API_HASH: ")
if api_id and api_hash:
async with TelegramClient(StringSession(), api_id, api_hash) as client:
DATA["api_id"] = api_id
DATA["api_hash"] = api_hash
DATA["session"] = str(client.session.save())
return (str(client.session.save()), api_id, api_hash)
print("API_ID and HASH Not Found!")
sys.exit(1)


def get_redis():
redis_uri = input("Enter your Redis URI: ")
redis_pass = input("Enter your Redis Password: ")
if redis_uri and redis_pass:
DATA["redis_uri"] = redis_uri
DATA["redis_pass"] = redis_pass
def get_firebase():
uri = input("Enter your Firebase Realtime Database Url: ")
_pass = input("Enter your Firebase Realtime Database Service Account File Link: ")
if uri and _pass:
DATA["firebase_uri"] = uri
DATA["firebase_pass"] = _pass
return True
else:
DATA["redis_uri"] = ""
DATA["redis_pass"] = ""
DATA["firebase_uri"] = ""
DATA["firebase_pass"] = ""
return False


Expand All @@ -72,13 +78,16 @@ async def create_channel(client, title):

def generate_env():
txt = ENV.format(
DATA["api_id"],
DATA["api_hash"],
DATA["bot_token"],
DATA["session"],
DATA["Ongoing Anime 2024"],
DATA["Ongoing Anime Logs"],
DATA["Ongoing Anime Samples And SS"],
DATA["Ongoing Anime Backup"],
DATA.get("redis_uri") or "",
DATA.get("redis_pass") or "",
DATA.get("firebase_uri") or "",
DATA.get("firebase_pass") or "",
DATA["owner_id"],
)
with open(".env", "w") as f:
Expand Down Expand Up @@ -160,10 +169,10 @@ async def auto_maker():
print(format_exc())
sys.exit(1)
print("Succesfully Created Channel...")
db = get_redis()
db = get_firebase()
if not db:
print(
"Generating .env Without Redis URI and Password. Now You Have To Add it Manually!"
"Generating .env Without Firebase URI and Service Account. Now You Have To Add it Manually!"
)
generate_env()

Expand Down
45 changes: 36 additions & 9 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

tools = Tools()
tools.init_dir()
bot = Bot(None)
bot = Bot()
dB = DataBase()
subsplease = SubsPlease(dB)
torrent = Torrent()
Expand All @@ -48,22 +48,24 @@
)
)
async def _start(event):
msg_id = event.pattern_match.group(1)
xnx = await event.reply("`Please Wait...`")
msg_id = event.pattern_match.group(1)
dB.add_broadcast_user(event.sender_id)
if Var.FORCESUB_CHANNEL and Var.FORCESUB_CHANNEL_LINK:
is_user_joined = await bot.is_joined(Var.FORCESUB_CHANNEL, event.sender_id)
if is_user_joined:
pass
else:
return await xnx.edit(
f"**Please Join {Var.FORCESUB_CHANNEL_LINK} To Use This Bot**",
f"**Please Join The Following Channel To Use This Bot 🫡**",
buttons=[
[Button.url("🚀 JOIN CHANNEL", url=Var.FORCESUB_CHANNEL_LINK)],
[
Button.url(
"♻️ REFRESH",
url=f"https://t.me/{((await bot.get_me()).username)}?start={msg_id}",
)
]
],
],
)
if msg_id:
Expand All @@ -78,8 +80,7 @@ async def _start(event):
await event.reply(file=[i for i in msg])
else:
if event.sender_id == Var.OWNER:
await xnx.delete()
return await event.reply(
return await xnx.edit(
"** < ADMIN PANEL > **",
buttons=admin.admin_panel(),
)
Expand Down Expand Up @@ -123,6 +124,16 @@ async def _(e):
await admin._btn_t(e)


@bot.on(events.callbackquery.CallbackQuery(data="scul"))
async def _(e):
await admin._sep_c_t(e)


@bot.on(events.callbackquery.CallbackQuery(data="cast"))
async def _(e):
await admin.broadcast_bt(e)


@bot.on(events.callbackquery.CallbackQuery(data="bek"))
async def _(e):
await e.edit(buttons=admin.admin_panel())
Expand All @@ -131,8 +142,24 @@ async def _(e):
async def anime(data):
try:
torr = [data.get("480p"), data.get("720p"), data.get("1080p")]
poster = await tools._poster(bot, AnimeInfo(torr[0].title))
anime_info = AnimeInfo(torr[0].title)
poster = await tools._poster(bot, anime_info)
if dB.is_separate_channel_upload():
chat_info = await tools.get_chat_info(bot, anime_info, dB)
await poster.edit(
buttons=[
[
Button.url(
f"EPISODE {anime_info.data.get('episode_number', '')}".strip(),
url=chat_info["invite_link"],
)
]
]
)
poster = await tools._poster(bot, anime_info, chat_info["chat_id"])
btn = [[]]
original_upload = dB.is_original_upload()
button_upload = dB.is_button_upload()
for i in torr:
try:
filename = f"downloads/{i.title}"
Expand All @@ -143,8 +170,8 @@ async def anime(data):
bot,
dB,
{
"original_upload": dB.is_original_upload(),
"button_upload": dB.is_button_upload(),
"original_upload": original_upload,
"button_upload": button_upload,
},
filename,
AnimeInfo(i.title),
Expand Down
Loading

0 comments on commit 7a7f26e

Please sign in to comment.