Skip to content

Commit

Permalink
update.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe committed Jul 8, 2021
1 parent bc84487 commit b391059
Show file tree
Hide file tree
Showing 29 changed files with 435 additions and 78 deletions.
42 changes: 30 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2020 PublicLeech Authors

# This program is free software: you can redistribute it 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.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# creates a layer from the base Docker image.
FROM python:3.9.2-slim-buster
FROM python:3.9.5-slim-buster

WORKDIR /app

# https://shouldiblamecaching.com/
ENV PIP_NO_CACHE_DIR 1

# http://bugs.python.org/issue19846
# https://github.com/SpEcHiDe/PublicLeech/pull/97
ENV LANG C.UTF-8

# we don't have an interactive xTerm
ENV DEBIAN_FRONTEND noninteractive

# sets the TimeZone, to be used inside the container
ENV TZ Asia/Kolkata

# fix "ephimeral" / "AWS" file-systems
RUN sed -i.bak 's/us-west-2\.ec2\.//' /etc/apt/sources.list

Expand Down Expand Up @@ -34,16 +61,6 @@ RUN sh -c 'echo "deb https://mkvtoolnix.download/debian/ buster main" >> /etc/ap
# to resynchronize the package index files from their sources.
RUN apt -qq update

# http://bugs.python.org/issue19846
# https://github.com/SpEcHiDe/PublicLeech/pull/97
ENV LANG C.UTF-8

# we don't have an interactive xTerm
ENV DEBIAN_FRONTEND noninteractive

# sets the TimeZone, to be used inside the container
ENV TZ Asia/Kolkata

# install required packages
RUN apt -qq install -y --no-install-recommends \
# this package is required to fetch "contents" via "TLS"
Expand Down Expand Up @@ -71,7 +88,8 @@ RUN apt -qq install -y --no-install-recommends \
COPY . .

# install requirements, inside the container
RUN pip3 install --no-cache-dir -r requirements.txt
RUN pip3 install --upgrade pip && \
pip3 install --no-cache-dir -r requirements.txt

# specifies what command to run within the container.
CMD ["python3", "-m", "tobrot"]
9 changes: 9 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@
asyncio==3.4.3
aiohttp==3.7.4

# achG2zZTxbA 12
aria2p==0.9.1

# get metadata from files
hachoir==3.1.1

# process(, and resize) images
Pillow==8.1.1

# required to communicate with Telegram API
Pyrogram==1.2.9
TgCrypto==1.2.2

# required to abup
youtube-dl

# for reading .env files
python-dotenv>=0.10
22 changes: 22 additions & 0 deletions sample_config.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
#
# Copyright (C) 2020 PublicLeech Authors
# This program is free software: you can redistribute it 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.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# All rights reserved.

APP_ID=6
API_HASH=eb06d4abfb49dc3eeb1aeb98ae0f581e
TG_BOT_TOKEN=1234567:tujnbscpnzcqdfkfnchbhithyofczznbgpw
AUTH_CHANNEL=-100123456789 7351948
SUDO_USERS=7351948

30 changes: 17 additions & 13 deletions tobrot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# (c) Shrimadhav U K
# -*- coding: utf-8 -*-
# Copyright (C) 2020 PublicLeech Authors

# This program is free software: you can redistribute it 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.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# the logging things
import logging
from logging.handlers import RotatingFileHandler
import os
import time

# the secret configuration specific things
if os.path.exists(
os.path.join(
__name__,
"config.py"
)
):
from tobrot.config import Config
else:
from tobrot.sample_config import Config
from tobrot.sample_config import Config


# TODO: is there a better way?
Expand Down Expand Up @@ -61,7 +65,7 @@
RotatingFileHandler(
LOG_FILE_ZZGEVC,
maxBytes=FREE_USER_MAX_FILE_SIZE,
backupCount=10
backupCount=1
),
logging.StreamHandler()
]
Expand Down
22 changes: 17 additions & 5 deletions tobrot/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# (c) Shrimadhav U K
# -*- coding: utf-8 -*-
# Copyright (C) 2020 PublicLeech Authors

# This program is free software: you can redistribute it 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.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import os

Expand Down Expand Up @@ -63,11 +75,11 @@
api_id=APP_ID,
api_hash=API_HASH,
workers=343,
workdir=DOWNLOAD_LOCATION
workdir=DOWNLOAD_LOCATION,
parse_mode="html",
sleep_threshold=1800
)
#
app.set_parse_mode("html")
#
# PURGE command
incoming_purge_message_handler = MessageHandler(
incoming_purge_message_f,
Expand Down
16 changes: 15 additions & 1 deletion tobrot/helper_funcs/admin_check.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# Copyright (C) 2020 PublicLeech Authors

# This program is free software: you can redistribute it 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.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.


async def AdminCheck(client, chat_id, user_id):
Expand Down
17 changes: 15 additions & 2 deletions tobrot/helper_funcs/copy_similar_file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# (c) Shrimadhav U K
# -*- coding: utf-8 -*-
# Copyright (C) 2020 PublicLeech Authors

# This program is free software: you can redistribute it 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.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# the logging things
import logging
Expand Down
17 changes: 15 additions & 2 deletions tobrot/helper_funcs/create_compressed_archive.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# (c) Shrimadhav U K
# -*- coding: utf-8 -*-
# Copyright (C) 2020 PublicLeech Authors

# This program is free software: you can redistribute it 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.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# the logging things
import logging
Expand Down
17 changes: 15 additions & 2 deletions tobrot/helper_funcs/create_r_o_m.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# (c) Shrimadhav U K
# -*- coding: utf-8 -*-
# Copyright (C) 2020 PublicLeech Authors

# This program is free software: you can redistribute it 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.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# the logging things
import logging
Expand Down
15 changes: 14 additions & 1 deletion tobrot/helper_funcs/custom_filters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# Copyright (C) 2020 PublicLeech Authors

# This program is free software: you can redistribute it 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.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from pyrogram import (
Client,
Expand Down
17 changes: 15 additions & 2 deletions tobrot/helper_funcs/display_progress.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# (c) Shrimadhav U K
# -*- coding: utf-8 -*-
# Copyright (C) 2020 PublicLeech Authors

# This program is free software: you can redistribute it 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.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# the logging things
import logging
Expand Down
29 changes: 21 additions & 8 deletions tobrot/helper_funcs/download_aria_p_n.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# (c) Shrimadhav U K
# -*- coding: utf-8 -*-
# Copyright (C) 2020 PublicLeech Authors

# This program is free software: you can redistribute it 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.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import aria2p
import asyncio
Expand Down Expand Up @@ -85,14 +98,14 @@ def add_magnet(aria_instance, magnetic_link, c_file_name):
options
)
except Exception as e:
return False, "**FAILED** \n" + str(e) + " \nPlease do not send SLOW links. Read /help"
return False, "<b>FAILED</b> \n" + str(e) + " \nPlease do not send SLOW links. Read /help"
else:
return True, "" + download.gid + ""


def add_torrent(aria_instance, torrent_file_path):
if torrent_file_path is None:
return False, "**FAILED** \n\nsomething wrongings when trying to add <u>TORRENT</u> file"
return False, "<b>FAILED</b> \n\nsomething wrongings when trying to add <u>TORRENT</u> file"
if os.path.exists(torrent_file_path):
# Add Torrent Into Queue
try:
Expand All @@ -103,11 +116,11 @@ def add_torrent(aria_instance, torrent_file_path):
position=None
)
except Exception as e:
return False, "**FAILED** \n" + str(e) + " \nPlease do not send SLOW links. Read /help"
return False, "<b>FAILED</b> \n" + str(e) + " \nPlease do not send SLOW links. Read /help"
else:
return True, "" + download.gid + ""
else:
return False, "**FAILED** \n\nPlease try other sources to get workable link"
return False, "<b>FAILED</b> \n\nPlease try other sources to get workable link"


def add_url(aria_instance, text_url, c_file_name):
Expand All @@ -124,7 +137,7 @@ def add_url(aria_instance, text_url, c_file_name):
options
)
except Exception as e:
return False, "**FAILED** \n" + str(e) + " \nPlease do not send SLOW links. Read /help"
return False, "<b>FAILED</b> \n" + str(e) + " \nPlease do not send SLOW links. Read /help"
else:
return True, "" + download.gid + ""

Expand Down Expand Up @@ -314,7 +327,7 @@ async def check_progress_for_dl(aria2, gid, event, previous_message):
previous_message = msg
else:
msg = file.error_message
await event.edit(f"`{msg}`")
await event.edit(f"<code>{msg}</code>")
return False
await asyncio.sleep(EDIT_SLEEP_TIME_OUT)
return await check_progress_for_dl(
Expand Down
Loading

0 comments on commit b391059

Please sign in to comment.