Skip to content

Commit

Permalink
HUGE REFRACTOR (now added scalable suport for various databases in th…
Browse files Browse the repository at this point in the history
…e future)
  • Loading branch information
Kyamel committed Jun 6, 2024
1 parent e995856 commit e21fde1
Show file tree
Hide file tree
Showing 14 changed files with 783 additions and 371 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*.pyc
src/shared_components/api/bot_api/sensitive/*
src/client/bot_api/sensitive/*
venv/
19 changes: 17 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
{
"python.linting.enabled": true,
"python.linting.mypyEnabled": true,
"python.linting.enabled": true
}
"python.linting.pylintEnabled": true,
"python.linting.flake8Enabled": false, // Desabilite o flake8 se não estiver usando
"python.linting.lintOnSave": true,
"python.linting.mypyArgs": [
"--ignore-missing-imports"
],
"python.linting.pylintArgs": [
"--disable=C0111" // Exemplo de desabilitar uma verificação específica do pylint
],
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--line-length",
"88"
],
"editor.formatOnSave": true
}
Binary file modified data/animestele.db
Binary file not shown.
Empty file added error_log.txt
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import httpx
from telegram import Bot, InputMediaVideo, KeyboardButton, ReplyKeyboardMarkup, Message
from telegram.error import TimedOut
from src.shared_components import values
from src.local import db_sqlite3_acess
from src.shared_components.api.bot_api.sensitive import token
from shared_components import values
from interface import db_acess
from client.bot_api.sensitive import token

class Telena:

def __init__(self, token=token.TOKEN_TELENA):
self.token = token
self.bot = Bot(token=token)
platform, channel = db_sqlite3_acess.init_animestele()
platform, channel = db_acess.init_animestele()
self.platform = platform
self.chaneel = channel

Expand Down Expand Up @@ -107,11 +107,11 @@ async def edit_message(self, chat_id, message_id, new_text):
print(f"Error editing message {message_id} in chat {chat_id}: {e}")


async def add_anime_to_telegram(self, chat_id, mal_id: int, database_path=values.DATABASE_PATH, print_log=False):
async def add_anime_to_telegram(self, chat_id, mal_id: int, database_path=values.SQLITE_DATABASE_PATH, print_log=False):
try:
if print_log:
print(f"Trying to send anime {mal_id} to telegram channel {chat_id}")
anime, episodes = db_sqlite3_acess.get_anime_from_database(mal_id=mal_id, database_path=database_path)
anime, episodes = db_acess.get_anime_from_database(mal_id=mal_id, database_path=database_path)

# Verify if anime is not in telegram yet
if '#telegram' not in anime.added_to:
Expand Down Expand Up @@ -151,7 +151,7 @@ async def add_anime_to_telegram(self, chat_id, mal_id: int, database_path=values
else:
anime.added_to = f"{anime.added_to},{new_added_to}"
# save into database
db_sqlite3_acess.save_msg_an(anime)
db_acess.save_msg_an(anime)
if print_log:
print(anime)
except Exception as e:
Expand Down Expand Up @@ -189,7 +189,7 @@ async def add_anime_to_telegram(self, chat_id, mal_id: int, database_path=values
episode.added_to = new_added_to
else:
episode.added_to = f"{episode.added_to},{new_added_to}"
db_sqlite3_acess.save_msg_ep(episode)
db_acess.save_msg_ep(episode)
if print_log:
print(episode)
except Exception as e:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from tokenize import String
from bs4 import BeautifulSoup
import requests
from src.shared_components import values
from shared_components import values

def get_title_and_hyperlinks_from_af(url_af=values.URL_AF_RELEASES, headers=values.HEADERS, extract_amount=10, start_page=1, extract_dub=False, print_log=False):
"""
Expand Down
File renamed without changes.
Loading

0 comments on commit e21fde1

Please # to comment.