v3.7 (#14)
- Added Uptobox support - Check file in drive before mirror and stop duplicate mirror
This commit is contained in:
parent
def8e7b78b
commit
2ba98ac0de
|
|
@ -32,7 +32,8 @@ Fork this repo, than upload credentials.json and token.pickle to your forks
|
||||||
|
|
||||||
## Features supported:
|
## Features supported:
|
||||||
- Mirroring direct download links to Google Drive
|
- Mirroring direct download links to Google Drive
|
||||||
- Mirroring Mega.nz links to google drive (In development stage)
|
- Mirroring Mega.nz links to Google Drive (In development stage)
|
||||||
|
- Mirroring Uptobox.com links to Google Drive (Uptobox account must be premium)
|
||||||
- Copy files from someone's drive to your drive (Using Autorclone)
|
- Copy files from someone's drive to your drive (Using Autorclone)
|
||||||
- Download/upload progress
|
- Download/upload progress
|
||||||
- Download/upload speeds and ETAs
|
- Download/upload speeds and ETAs
|
||||||
|
|
|
||||||
8
app.json
8
app.json
|
|
@ -66,6 +66,10 @@
|
||||||
"description": "This is to authenticate to your telegram account for downloading Telegram files. You can get this from https://my.telegram.org.",
|
"description": "This is to authenticate to your telegram account for downloading Telegram files. You can get this from https://my.telegram.org.",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
|
"UPTOBOX_TOKEN": {
|
||||||
|
"description": "Uptobox token to mirror uptobox links. Get it from [Uptobox Premium Account](https://uptobox.com/my_account).",
|
||||||
|
"required": false
|
||||||
|
},
|
||||||
"MEGA_API_KEY": {
|
"MEGA_API_KEY": {
|
||||||
"description": "Mega.nz api key to mirror mega.nz links. Get it from https://mega.nz/sdk.",
|
"description": "Mega.nz api key to mirror mega.nz links. Get it from https://mega.nz/sdk.",
|
||||||
"required": false
|
"required": false
|
||||||
|
|
@ -82,6 +86,10 @@
|
||||||
"description": "If you want to remove mega.nz mirror support, set it to True.",
|
"description": "If you want to remove mega.nz mirror support, set it to True.",
|
||||||
"required": false
|
"required": false
|
||||||
},
|
},
|
||||||
|
"STOP_DUPLICATE_MIRROR": {
|
||||||
|
"description": "If this field is set to True, bot will check file in drive, if it is present in drive, downloading will be stopped.",
|
||||||
|
"required": false
|
||||||
|
},
|
||||||
"SHORTENER": {
|
"SHORTENER": {
|
||||||
"description": "If you want to use shortener in Gdrive and index link.",
|
"description": "If you want to use shortener in Gdrive and index link.",
|
||||||
"required": false
|
"required": false
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,16 @@ except KeyError as e:
|
||||||
LOGGER.error("One or more env variables missing! Exiting now")
|
LOGGER.error("One or more env variables missing! Exiting now")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
UPTOBOX_TOKEN = getConfig('UPTOBOX_TOKEN')
|
||||||
|
except KeyError:
|
||||||
|
logging.warning('UPTOBOX_TOKEN not provided!')
|
||||||
|
UPTOBOX_TOKEN = None
|
||||||
|
try:
|
||||||
|
UPTOBOX_TOKEN = getConfig('UPTOBOX_TOKEN')
|
||||||
|
except KeyError:
|
||||||
|
logging.warning('UPTOBOX_TOKEN not provided!')
|
||||||
|
UPTOBOX_TOKEN = None
|
||||||
try:
|
try:
|
||||||
MEGA_API_KEY = getConfig('MEGA_API_KEY')
|
MEGA_API_KEY = getConfig('MEGA_API_KEY')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
@ -160,6 +170,14 @@ try:
|
||||||
except KeyError:
|
except KeyError:
|
||||||
BUTTON_FIVE_NAME = None
|
BUTTON_FIVE_NAME = None
|
||||||
BUTTON_FIVE_URL = None
|
BUTTON_FIVE_URL = None
|
||||||
|
try:
|
||||||
|
STOP_DUPLICATE_MIRROR = getConfig('STOP_DUPLICATE_MIRROR')
|
||||||
|
if STOP_DUPLICATE_MIRROR.lower() == 'true':
|
||||||
|
STOP_DUPLICATE_MIRROR = True
|
||||||
|
else:
|
||||||
|
STOP_DUPLICATE_MIRROR = False
|
||||||
|
except KeyError:
|
||||||
|
STOP_DUPLICATE_MIRROR = False
|
||||||
try:
|
try:
|
||||||
IS_TEAM_DRIVE = getConfig('IS_TEAM_DRIVE')
|
IS_TEAM_DRIVE = getConfig('IS_TEAM_DRIVE')
|
||||||
if IS_TEAM_DRIVE.lower() == 'true':
|
if IS_TEAM_DRIVE.lower() == 'true':
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
from bot import aria2, download_dict_lock
|
from bot import aria2, download_dict_lock, STOP_DUPLICATE_MIRROR
|
||||||
|
from bot.helper.mirror_utils.upload_utils.gdriveTools import GoogleDriveHelper
|
||||||
from bot.helper.ext_utils.bot_utils import *
|
from bot.helper.ext_utils.bot_utils import *
|
||||||
from .download_helper import DownloadHelper
|
from .download_helper import DownloadHelper
|
||||||
from bot.helper.mirror_utils.status_utils.aria_download_status import AriaDownloadStatus
|
from bot.helper.mirror_utils.status_utils.aria_download_status import AriaDownloadStatus
|
||||||
|
|
@ -15,7 +16,25 @@ class AriaDownloadHelper(DownloadHelper):
|
||||||
|
|
||||||
@new_thread
|
@new_thread
|
||||||
def __onDownloadStarted(self, api, gid):
|
def __onDownloadStarted(self, api, gid):
|
||||||
|
sleep(1)
|
||||||
LOGGER.info(f"onDownloadStart: {gid}")
|
LOGGER.info(f"onDownloadStart: {gid}")
|
||||||
|
dl = getDownloadByGid(gid)
|
||||||
|
download = api.get_download(gid)
|
||||||
|
self.name = download.name
|
||||||
|
sname = download.name
|
||||||
|
if STOP_DUPLICATE_MIRROR:
|
||||||
|
if dl.getListener().isTar == True:
|
||||||
|
sname = sname + ".tar"
|
||||||
|
if dl.getListener().extract == True:
|
||||||
|
smsg = None
|
||||||
|
else:
|
||||||
|
gdrive = GoogleDriveHelper(None)
|
||||||
|
smsg, button = gdrive.drive_list(sname)
|
||||||
|
if smsg:
|
||||||
|
dl.getListener().onDownloadError(f'😡 File is already available in drive. You should have search before mirror any file. You might get ban if you do this again. This download has been stopped.\n\n')
|
||||||
|
sendMarkup(" Here are the search results:👇", dl.getListener().bot, dl.getListener().update, button)
|
||||||
|
aria2.remove([download])
|
||||||
|
return
|
||||||
update_all_messages()
|
update_all_messages()
|
||||||
|
|
||||||
def __onDownloadComplete(self, api: API, gid):
|
def __onDownloadComplete(self, api: API, gid):
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ from https://github.com/AvinashReddy3108/PaperplaneExtended . I hereby take no c
|
||||||
than the modifications. See https://github.com/AvinashReddy3108/PaperplaneExtended/commits/master/userbot/modules/direct_links.py
|
than the modifications. See https://github.com/AvinashReddy3108/PaperplaneExtended/commits/master/userbot/modules/direct_links.py
|
||||||
for original authorship. """
|
for original authorship. """
|
||||||
|
|
||||||
|
from bot import UPTOBOX_TOKEN
|
||||||
|
import logging
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
@ -32,6 +34,8 @@ def direct_link_generator(link: str):
|
||||||
return cm_ru(link)
|
return cm_ru(link)
|
||||||
elif 'mediafire.com' in link:
|
elif 'mediafire.com' in link:
|
||||||
return mediafire(link)
|
return mediafire(link)
|
||||||
|
elif 'uptobox.com' in link:
|
||||||
|
return uptobox(link)
|
||||||
elif 'osdn.net' in link:
|
elif 'osdn.net' in link:
|
||||||
return osdn(link)
|
return osdn(link)
|
||||||
elif 'github.com' in link:
|
elif 'github.com' in link:
|
||||||
|
|
@ -100,6 +104,29 @@ def cm_ru(url: str) -> str:
|
||||||
dl_url = data['download']
|
dl_url = data['download']
|
||||||
return dl_url
|
return dl_url
|
||||||
|
|
||||||
|
def uptobox(url: str) -> str:
|
||||||
|
""" Uptobox direct links generator
|
||||||
|
based on https://github.com/jovanzers/WinTenCermin """
|
||||||
|
try:
|
||||||
|
link = re.findall(r'\bhttps?://.*uptobox\.com\S+', url)[0]
|
||||||
|
except IndexError:
|
||||||
|
raise DirectDownloadLinkException("`No Uptobox links found`\n")
|
||||||
|
if UPTOBOX_TOKEN is None:
|
||||||
|
logging.error('UPTOBOX_TOKEN not provided!')
|
||||||
|
dl_url = url
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
link = re.findall(r'\bhttp?://.*uptobox\.com/dl\S+', url)[0]
|
||||||
|
logging.info('Uptobox direct link')
|
||||||
|
dl_url = url
|
||||||
|
except:
|
||||||
|
file_id = re.findall(r'\bhttps?://.*uptobox\.com/(\w+)', url)[0]
|
||||||
|
file_link = 'https://uptobox.com/api/link?token=%s&file_code=%s' % (UPTOBOX_TOKEN, file_id)
|
||||||
|
req = requests.get(file_link)
|
||||||
|
result = req.json()
|
||||||
|
dl_url = result['data']['dlLink']
|
||||||
|
return dl_url
|
||||||
|
|
||||||
|
|
||||||
def mediafire(url: str) -> str:
|
def mediafire(url: str) -> str:
|
||||||
""" MediaFire direct links generator """
|
""" MediaFire direct links generator """
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,13 @@ TELEGRAM_HASH = ""
|
||||||
USE_SERVICE_ACCOUNTS = ""
|
USE_SERVICE_ACCOUNTS = ""
|
||||||
# Optional config
|
# Optional config
|
||||||
AUTHORIZED_CHATS = ""
|
AUTHORIZED_CHATS = ""
|
||||||
INDEX_URL = ""
|
INDEX_URL = ""
|
||||||
|
UPTOBOX_TOKEN = ""
|
||||||
MEGA_API_KEY = ""
|
MEGA_API_KEY = ""
|
||||||
MEGA_EMAIL_ID = ""
|
MEGA_EMAIL_ID = ""
|
||||||
MEGA_PASSWORD = ""
|
MEGA_PASSWORD = ""
|
||||||
BLOCK_MEGA_LINKS = ""
|
BLOCK_MEGA_LINKS = ""
|
||||||
|
STOP_DUPLICATE_MIRROR = ""
|
||||||
SHORTENER = ""
|
SHORTENER = ""
|
||||||
SHORTENER_API = ""
|
SHORTENER_API = ""
|
||||||
# Add more buttons (two buttons are already added of file link and index link, you can add extra buttons too, these are optional)
|
# Add more buttons (two buttons are already added of file link and index link, you can add extra buttons too, these are optional)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue