mirror of
https://github.com/Araon/Meido.git
synced 2025-02-20 11:13:20 +08:00
made some minor changes
This commit is contained in:
parent
c98101f7bf
commit
65f0ba3e2e
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,3 +3,5 @@ botConfig.json
|
|||||||
agentConfig.json
|
agentConfig.json
|
||||||
images
|
images
|
||||||
*.mp4
|
*.mp4
|
||||||
|
dev
|
||||||
|
__pycache__
|
@ -34,7 +34,6 @@ Zoro | 720p, 1080p | ✔️
|
|||||||
- [ ] Add subscription feature
|
- [ ] Add subscription feature
|
||||||
- [ ] Moar Bug fixes
|
- [ ] Moar Bug fixes
|
||||||
- [ ] Add support for linux
|
- [ ] Add support for linux
|
||||||
- [ ] Change file path
|
|
||||||
|
|
||||||
#### Status
|
#### Status
|
||||||
Still under development 🛠️
|
Still under development 🛠️
|
||||||
|
21
bot/bot.py
21
bot/bot.py
@ -1,7 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from turtle import up
|
|
||||||
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
|
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
|
||||||
from telegram.update import Update
|
from telegram.update import Update
|
||||||
from botUtils import showhelp,parse_search_query,getalltsfiles
|
from botUtils import showhelp,parse_search_query,getalltsfiles
|
||||||
@ -9,19 +8,23 @@ from database import getData, postData, updateData
|
|||||||
import subprocess
|
import subprocess
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
BOT_VERSION = 0.1
|
||||||
|
|
||||||
#enabling Logging
|
#enabling Logging
|
||||||
logging.basicConfig(format='%(levelname)s - %(asctime)s - %(name)s - %(message)s', level=logging.INFO)
|
logging.basicConfig(format='%(levelname)s - %(asctime)s - %(name)s - %(message)s', level=logging.INFO)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
with open('bot/config/botConfig.json', 'r') as config:
|
try:
|
||||||
|
with open('bot/config/botConfig.json', 'w+') as config:
|
||||||
configdata = json.load(config)
|
configdata = json.load(config)
|
||||||
|
except:
|
||||||
|
raise Exception('CONFIG FILE NOT FOUND!')
|
||||||
|
|
||||||
API_TOKEN = configdata.get("bot_token")
|
API_TOKEN = configdata.get("bot_token")
|
||||||
|
|
||||||
|
|
||||||
def start(update,context):
|
def start(update,context):
|
||||||
update.message.reply_text("Thanks for using Araon Bot(v:0.01)\nThis is a alpha built so expect delayed response and many bugs\nIf you spot any issue feel free to reach out")
|
update.message.reply_text(f"Thanks for using Araon Bot({BOT_VERSION})\nThis is a alpha built so expect delayed response and many bugs\nIf you spot any issue feel free to reach out")
|
||||||
|
|
||||||
|
|
||||||
def help(update,context):
|
def help(update,context):
|
||||||
@ -30,15 +33,22 @@ def help(update,context):
|
|||||||
|
|
||||||
|
|
||||||
def getanime(update, context):
|
def getanime(update, context):
|
||||||
|
'''
|
||||||
|
Fetches the anime file on the mongo db and then if not found,
|
||||||
|
downloads the anime using animeld
|
||||||
|
'''
|
||||||
logger.info('download function is called!')
|
logger.info('download function is called!')
|
||||||
|
|
||||||
chat_id = update.message.chat_id
|
chat_id = update.message.chat_id
|
||||||
rawUserInput = update.message.text
|
rawUserInput = update.message.text
|
||||||
userInput = rawUserInput[10:]
|
userInput = rawUserInput[10:]
|
||||||
|
|
||||||
if userInput and not userInput == " ":
|
if userInput and not userInput == " ":
|
||||||
userdata = parse_search_query(userInput)
|
userdata = parse_search_query(userInput)
|
||||||
|
|
||||||
update.message.reply_text(f"Checking Internal Db\nAnime: {userdata.get('series_name')}\nSeason: {userdata.get('season_id')}\nEpisode: {userdata.get('episode_id')}")
|
update.message.reply_text(f"Checking Internal Db\nAnime: {userdata.get('series_name')}\nSeason: {userdata.get('season_id')}\nEpisode: {userdata.get('episode_id')}")
|
||||||
logger.info('search_in_mongodb:"%s"', userdata)
|
logger.info('search_in_mongodb:"%s"', userdata)
|
||||||
|
|
||||||
search_in_mongodb = userdata.pop('season_id')
|
search_in_mongodb = userdata.pop('season_id')
|
||||||
anime_name = getData(search_in_mongodb)
|
anime_name = getData(search_in_mongodb)
|
||||||
if not anime_name:
|
if not anime_name:
|
||||||
@ -55,7 +65,7 @@ def getanime(update, context):
|
|||||||
else:
|
else:
|
||||||
update.message.reply_text("Please refer to /help")
|
update.message.reply_text("Please refer to /help")
|
||||||
|
|
||||||
update.message.reply_text(f"{userdata.get('series_name')} - {userdata.get('episode_id')} almost done downloading on the server side!")
|
update.message.reply_text(f"{userdata.get('series_name')} - {userdata.get('episode_id')} is done downloading on the server side!")
|
||||||
filepath = getalltsfiles()
|
filepath = getalltsfiles()
|
||||||
upload_status = subprocess.check_call("python uploaderService/main.py " +'"'+filepath+'"'+ ' ' + str(chat_id) + ' ' + (userdata.get('series_name')+'-'+str(userdata.get('episode_id'))), shell=True)
|
upload_status = subprocess.check_call("python uploaderService/main.py " +'"'+filepath+'"'+ ' ' + str(chat_id) + ' ' + (userdata.get('series_name')+'-'+str(userdata.get('episode_id'))), shell=True)
|
||||||
|
|
||||||
@ -63,7 +73,7 @@ def getanime(update, context):
|
|||||||
def error(update, context):
|
def error(update, context):
|
||||||
"""Log Errors caused by Updates."""
|
"""Log Errors caused by Updates."""
|
||||||
logger.warning('Update "%s" caused error "%s" and "%s"', update, context.error, context )
|
logger.warning('Update "%s" caused error "%s" and "%s"', update, context.error, context )
|
||||||
update.message.reply_text("Something has went wrong!, Please retry :)")
|
update.message.reply_text("Something has went wrong!, Please retry")
|
||||||
|
|
||||||
def check_document(update, context):
|
def check_document(update, context):
|
||||||
'''
|
'''
|
||||||
@ -92,6 +102,7 @@ def check_document(update, context):
|
|||||||
logger.info(data2post)
|
logger.info(data2post)
|
||||||
post_data_to_mongo = postData(data2post)
|
post_data_to_mongo = postData(data2post)
|
||||||
logger.info(post_data_to_mongo)
|
logger.info(post_data_to_mongo)
|
||||||
|
|
||||||
#Keep in mind here i have to parse the chat_id from the caption above
|
#Keep in mind here i have to parse the chat_id from the caption above
|
||||||
context.bot.send_video(end_user_chat_id,file_id,supports_streaming=True,timeout=120)
|
context.bot.send_video(end_user_chat_id,file_id,supports_streaming=True,timeout=120)
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
from pymongo import MongoClient
|
from pymongo import MongoClient
|
||||||
|
|
||||||
client = MongoClient('mongodb://localhost:27017/')
|
|
||||||
|
MONGO_DB_URL = 'mongodb://localhost:27017/'
|
||||||
|
|
||||||
|
client = MongoClient(MONGO_DB_URL)
|
||||||
|
|
||||||
#database
|
#database
|
||||||
db = client["animeDatabase"]
|
db = client["animeDatabase"]
|
||||||
|
@ -1,17 +1,42 @@
|
|||||||
python-telegram-bot
|
Package Version
|
||||||
telethon
|
--------------------- -----------
|
||||||
cachetools
|
animdl 1.4.84
|
||||||
certifi
|
anitopy 2.1.0
|
||||||
pyaes
|
anyio 3.5.0
|
||||||
pyasn1
|
APScheduler 3.6.3
|
||||||
pytz
|
backports.zoneinfo 0.2.1
|
||||||
pytz-deprecation-shim
|
cachetools 4.2.2
|
||||||
rsa
|
certifi 2021.10.8
|
||||||
six
|
charset-normalizer 2.0.12
|
||||||
tornado
|
click 8.0.4
|
||||||
tzdata
|
comtypes 1.1.11
|
||||||
tzlocal
|
cssselect 1.1.0
|
||||||
APScheduler
|
ffmpeg 1.4
|
||||||
ffmpeg
|
h11 0.12.0
|
||||||
Telethon
|
httpcore 0.14.7
|
||||||
backports.zoneinfo
|
httpx 0.22.0
|
||||||
|
idna 3.3
|
||||||
|
lxml 4.8.0
|
||||||
|
multidict 6.0.2
|
||||||
|
pip 20.3.4
|
||||||
|
pkg-resources 0.0.0
|
||||||
|
pyaes 1.6.1
|
||||||
|
pyasn1 0.4.8
|
||||||
|
pycryptodomex 3.14.1
|
||||||
|
pymongo 4.0.2
|
||||||
|
python-telegram-bot 13.11
|
||||||
|
pytz 2021.3
|
||||||
|
pytz-deprecation-shim 0.1.0.post0
|
||||||
|
PyYAML 6.0
|
||||||
|
regex 2021.10.8
|
||||||
|
rfc3986 1.5.0
|
||||||
|
rsa 4.8
|
||||||
|
setuptools 44.1.1
|
||||||
|
six 1.16.0
|
||||||
|
sniffio 1.2.0
|
||||||
|
Telethon 1.24.0
|
||||||
|
tornado 6.1
|
||||||
|
tqdm 4.63.0
|
||||||
|
tzdata 2021.5
|
||||||
|
tzlocal 4.1
|
||||||
|
yarl 1.7.2
|
||||||
|
@ -22,8 +22,12 @@ import logging
|
|||||||
logging.basicConfig(format='%(levelname)s - %(asctime)s - %(name)s - %(message)s', level=logging.INFO)
|
logging.basicConfig(format='%(levelname)s - %(asctime)s - %(name)s - %(message)s', level=logging.INFO)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
with open('uploaderService/config/agentConfig.json', 'r') as config:
|
try:
|
||||||
|
with open('uploaderService/config/agentConfig.json', 'w+') as config:
|
||||||
configdata = json.load(config)
|
configdata = json.load(config)
|
||||||
|
except:
|
||||||
|
raise Exception('CONFIG FILE NOT FOUND!')
|
||||||
|
|
||||||
|
|
||||||
entity = configdata.get('entity') #session name - it doesn't matter what
|
entity = configdata.get('entity') #session name - it doesn't matter what
|
||||||
api_id = configdata.get('api_id')
|
api_id = configdata.get('api_id')
|
||||||
@ -44,11 +48,13 @@ async def callback(current, total):
|
|||||||
'''
|
'''
|
||||||
bot_name = the actual bot name
|
bot_name = the actual bot name
|
||||||
file_path = where the file is downloaded
|
file_path = where the file is downloaded
|
||||||
chat_id = this is the end user chat_id, sent over caption to bot, so it can parse and send it to the correct user
|
chat_id = this is the end user chat_id, sent over caption to bot,
|
||||||
object_id = an internal id used for mapping of file_id and filename stored in the server(for optimization).
|
so it can parse and send it to the correct user
|
||||||
|
object_id = an internal id used for mapping of file_id
|
||||||
|
and filename stored in the server(for optimization).
|
||||||
'''
|
'''
|
||||||
async def uploadVideo(bot_name,file_path,chat_id,object_id):
|
async def uploadVideo(bot_name,file_path,chat_id,object_id):
|
||||||
logger.info('UploadVideo Called')
|
logger.info('video uploading initiated')
|
||||||
async with TelegramClient(entity, api_id, api_hash) as client:
|
async with TelegramClient(entity, api_id, api_hash) as client:
|
||||||
if not await client.is_user_authorized():
|
if not await client.is_user_authorized():
|
||||||
#await client.send_code_request(phone) #at the first start - uncomment, after authorization to avoid FloodWait I advise you to comment
|
#await client.send_code_request(phone) #at the first start - uncomment, after authorization to avoid FloodWait I advise you to comment
|
||||||
|
Loading…
x
Reference in New Issue
Block a user