Esempio n. 1
0
async def check_logs():
    log_data = media.read_file("log.txt", filter=True)
    if log_data:
        for message in log_data:
            if "--channel=" in message:
                message = message.split(" --channel=")
                await send(message[0], channel=message[1])
            else:
                await send(message)
        media.write_file("log.txt",
                         "### Beginning of message buffer from server ###\n")
Esempio n. 2
0
async def downloads(ctx, user: discord.User, *flags):
    total_size = 0  # This is in MB
    movies = []
    user_id = user.id
    lines = media.read_file(f"{user_id}.txt", filter=True)
    for line in lines:
        line = line.split("|")
        movies.append(line[0])
        total_size += float(line[2])
    if "--list" in flags:
        await send("{}".format("\n".join(movies)))
    await send(f"{user.display_name} has downloaded \
		{len(movies)} movies/episodes totaling \
		{round(total_size,0)} MB.")
Esempio n. 3
0
def check_for_captcha_solve(timeout=100):
    if __name__ == "__main__":
        media.write_file("captcha.txt", input("Solve the captcha:\n> "))

    filename = "captcha.txt"
    for _ in range(timeout * 2):
        time.sleep(0.5)
        if os.path.isfile(filename):
            solved_captcha = media.read_file(filename)[0]
            media.remove_file(filename)
            return solved_captcha
    log(f"Captcha was not solved withing {timeout} seconds.\nAborting download.",
        silent=False)
    return False
Esempio n. 4
0
async def downloads(ctx, user: discord.User, *flags):
    total_size = 0  # This is in MB
    movies = []
    user_id = user.id
    lines = media.read_file(f"{user_id}.txt", filter=True)
    for line in lines:
        line = line.split("|")
        movies.append(line[0])
        total_size += float(line[2])
    if "--list" in flags:
        await send("{}".format("\n".join(movies)))
    author = user.display_name
    total_size = (f"{int(round(total_size, 0))} MB"
                  if total_size < 2048 else f"{round(total_size/1024, 2)} GB")
    await send(
        f"{author} has downloaded {len(movies)} movies/episodes totaling {total_size}."
    )
Esempio n. 5
0
    def check_captcha(self,
                      xpath="//*[@id=\"checkcapchamodelyii-captcha-image\"]",
                      attr="src"):
        try:
            captcha_element = WebDriverWait(self.driver, 5).until(
                EC.visibility_of_element_located((By.XPATH, xpath)))
            captcha_element = self.driver.find_element_by_xpath(xpath)
            captcha = captcha_element.get_attribute(attr)
            filename = self.screenshot_captcha(captcha_element)
            print(f"DEBUG: Captcha, {captcha}")
        except TimeoutException:
            print("DEBUG: No captcha")
            captcha = False
        if captcha:
            if __name__ != "__main__":
                log("Captcha! Please solve using the command: ```!solve <captcha_solution>```\nREMIND IAN TO FIX THIS --> please don't mess up or the download will fail."
                    )
                log(f"--file={filename}")
                filename = "solved_captcha.txt"
                solved_captcha = False
                while not solved_captcha and (time() - self.start_time) < 60:
                    sleep(1)
                    # print(f"DEBUG: Checking for {filename}")
                    if os.path.isfile(filename):
                        solved_captcha = media.read_file(filename)[0]
                        media.remove_file(filename)
                        print(
                            f"DEBUG: Solved captcha, {solved_captcha}, {not solved_captcha}/{(time() - self.start_time) < 60}"
                        )
            else:
                solved_captcha = input("Enter the solved captcha:\n> ")
            if solved_captcha:
                self.solve_captcha(solved_captcha)
                self.submit_captcha()
                # self.run()

        return captcha
Esempio n. 6
0
async def check_logs(filename="log.txt"):
    log_data = media.read_file(filename, filter=True)
    if log_data:
        media.write_file(filename,
                         "### Beginning of message buffer from server ###\n")

        bulk_message = []
        for message in log_data:
            if "--embed" in message:
                metadata = eval(message.replace("--embed", ""))
                await create_embed(metadata)
            elif "--channel=" in message:
                message = message.split("--channel=")
                await send(message[0], channel=message[1])
            elif "--file" in message:
                await send(message)
            # elif "--res=" in message:
            # 	forced_resolution = message.split("--res=")[1]
            # 	cfg.write_attempts(int(forced_resolution))
            # 	bulk_message.append(message.split("--res=")[0])
            else:
                bulk_message.append(message)

        if bulk_message: await send("\n".join(bulk_message))
Esempio n. 7
0
# notes             :
# license           : MIT
# py version        : 3.8.2 (must run on 3.6 or higher)
#==============================================================================
import time
from threading import Thread
import discord
from requests.exceptions import MissingSchema
from discord.ext import commands, tasks
from scraper import Scraper
from errors import NoResults
# import config as cfg
import media
import download

credentials = media.read_file("credentials.md", filter=True)
scraper = Scraper()
token = credentials[0]
allowed_users = credentials[1:]
channel_id = {
    "commands": 776367990560129066,
    "log": 776354053222826004,
    "spam": 780948981299150888,
}
bot = commands.Bot(command_prefix=[
    "beta ",
    "Beta ",
    "BETA ",
    "please ",
    "Please ",
    "PLEASE ",