Skip to content

Commit

Permalink
v4.4.4 (breakdowns#35)
Browse files Browse the repository at this point in the history
- cc after clone finish.
Thanks to anasty17
- Change to yt-dlp
  • Loading branch information
breakdowns authored Mar 24, 2021
1 parent 8610fec commit 1a222a3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 28 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Slam](https://telegra.ph/file/db03910496f06094f1f7a.jpg)](https://youtu.be/Pk_TthHfLeE)

# Slam Mirror Bot
This is a telegram bot writen in python for mirroring files on the internet to our beloved Google Drive. This project is heavily inspired from @out386 's telegram bot which is written in JS.
This is a telegram bot writen in python for mirroring files on the internet to our beloved Google Drive.

## How to deploy?
Deploying is pretty much straight forward and is divided into several steps as follows:
Expand Down Expand Up @@ -170,6 +170,7 @@ where host is the name of extractor (eg. youtube, twitch). Multiple accounts of
## Credits

Thanks to:
- [out386](https://github.com/out386) heavily inspired from telegram bot which is written in JS.
- [Izzy12](https://github.com/lzzy12/) for original repo
- [Dank-del](https://github.com/Dank-del/) for base repo
- [magneto261290](https://github.com/magneto261290/) for some features
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .download_helper import DownloadHelper
import time
from youtube_dl import YoutubeDL, DownloadError
from yt_dlp import YoutubeDL, DownloadError
from bot import download_dict_lock, download_dict
from ..status_utils.youtube_dl_download_status import YoutubeDLDownloadStatus
import logging
Expand Down
13 changes: 5 additions & 8 deletions bot/helper/mirror_utils/upload_utils/gdriveTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,10 @@ def copyFile(self, file_id, dest_id):
if err.resp.get('content-type', '').startswith('application/json'):
reason = json.loads(err.content).get('error').get('errors')[0].get('reason')
if reason == 'userRateLimitExceeded' or reason == 'dailyLimitExceeded':
raise err
if USE_SERVICE_ACCOUNTS:
self.switchServiceAccount()
LOGGER.info(f"Got: {reason}, Trying Again.")
return self.copyFile(file_id,dest_id)
else:
raise err

Expand Down Expand Up @@ -368,13 +371,7 @@ def clone(self, link):
err = err.last_attempt.exception()
err = str(err).replace('>', '').replace('<', '')
LOGGER.error(err)
if "User rate limit exceeded" in str(err):
msg = "User rate limit exceeded."
elif "File not found" in str(err):
msg = "File not found."
else:
msg = f"Error.\n{err}"
return msg, ""
return err, ""
return msg, InlineKeyboardMarkup(buttons.build_menu(2))

def cloneFolder(self, name, local_path, folder_id, parent_id):
Expand Down
29 changes: 12 additions & 17 deletions bot/modules/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,28 @@
from bot.helper.telegram_helper.filters import CustomFilters
from bot.helper.telegram_helper.bot_commands import BotCommands
from bot.helper.ext_utils.bot_utils import new_thread
from bot import dispatcher, LOGGER
from bot import dispatcher


@new_thread
def cloneNode(update,context):
if update.message.from_user.last_name:
last_name = f" {update.message.from_user.last_name}"
else:
last_name = ""
args = update.message.text.split(" ",maxsplit=1)
if update.message.from_user.username:
username = f"@{update.message.from_user.username}"
uname = f"@{update.message.from_user.username}"
else:
username = ""
name = f'<a href="tg://user?id={update.message.from_user.id}">{update.message.from_user.first_name}{last_name}</a>'

args = update.message.text.split(" ",maxsplit=1)
uname = f'<a href="tg://user?id={update.message.from_user.id}">{update.message.from_user.first_name}</a>'
if uname is not None:
cc = f'\n\ncc: {uname}'
if len(args) > 1:
link = args[1]
msg = f'Cloning...\n' \
f'User: {username}\n' \
f'Link: <a href="{link}">{link}</a>'
sendMessage(msg, context.bot, update)
msg = sendMessage(f"Cloning: <code>{link}</code>",context.bot,update)
gd = GoogleDriveHelper()
result, button = gd.clone(link)
LOGGER.info('ID: {} - Username: {} - Message: {}'.format(update.message.chat.id,update.message.chat.username,update.message.text))
# deleteMessage(context.bot,msg)
sendMarkup(result,context.bot,update,button)
deleteMessage(context.bot,msg)
if button == "":
sendMessage(result,context.bot,update)
else:
sendMarkup(result + cc,context.bot,update,button)
else:
sendMessage("Provide G-Drive Shareable Link to Clone.",context.bot,update)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ python-magic
beautifulsoup4>=4.8.2,<4.8.10
pyrogram
TgCrypto
youtube_dl
yt-dlp
feedparser
natsort
heroku3
Expand Down

0 comments on commit 1a222a3

Please sign in to comment.