Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta #255

Open
wants to merge 91 commits into
base: master
Choose a base branch
from
Open

Beta #255

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift click to select a range
a9b0cc2
Bug Fix All
SilentDemonSD Aug 7, 2023
bdb25a7
Add GoFile Leech
SilentDemonSD Aug 11, 2023
abdc800
Add SendCM, DesiUpload, StreamTape
SilentDemonSD Aug 11, 2023
a90e149
fix up
SilentDemonSD Aug 11, 2023
3ca15a7
Add External GoFile DL
SilentDemonSD Aug 11, 2023
7db5dab
New Setup Starts
SilentDemonSD Aug 12, 2023
4f8f5cb
fix
SilentDemonSD Aug 12, 2023
48c2749
fix
SilentDemonSD Aug 12, 2023
4591e76
fix frame
SilentDemonSD Aug 12, 2023
2667230
Add Multi Aria2c
SilentDemonSD Aug 12, 2023
1f64370
fix up
SilentDemonSD Aug 12, 2023
357f0e4
try debug
SilentDemonSD Aug 12, 2023
0c70db2
fix
SilentDemonSD Aug 12, 2023
e611911
fix Single Aria
SilentDemonSD Aug 12, 2023
5aa37e4
Add Index Folder Support
SilentDemonSD Aug 12, 2023
7b618c5
fix
SilentDemonSD Aug 12, 2023
29ab8b5
refix
SilentDemonSD Aug 12, 2023
b39c7fb
Fix Dir prblm
SilentDemonSD Aug 12, 2023
08dd67f
refix dir prblm
SilentDemonSD Aug 12, 2023
99801a5
fix gd issue
SilentDemonSD Aug 12, 2023
bf80a7d
try debug
SilentDemonSD Aug 12, 2023
1aa5c1e
fix
SilentDemonSD Aug 12, 2023
c3339a7
fix
SilentDemonSD Aug 12, 2023
4954d3a
retry
SilentDemonSD Aug 12, 2023
7bb03ee
retry
SilentDemonSD Aug 12, 2023
9da1498
fix !
SilentDemonSD Aug 12, 2023
8329231
try fix auto delete
SilentDemonSD Aug 12, 2023
159010e
final completion
SilentDemonSD Aug 12, 2023
99bfe22
fix recurring status
SilentDemonSD Aug 12, 2023
48347b6
Add Universal filename
SilentDemonSD Aug 12, 2023
9b370a2
fix
SilentDemonSD Aug 12, 2023
8d6841e
Test New GDFLIX DOMAIN
MajnuRangeela Aug 15, 2023
7536c76
Try New ..
SilentDemonSD Aug 20, 2023
c0b9354
improve
jammesop007aha Apr 29, 2024
be27ec4
improve
jammesop007aha Apr 29, 2024
5329832
improve
jammesop007aha Apr 29, 2024
3612779
improve
jammesop007aha Apr 29, 2024
e4b230d
improve
jammesop007aha Apr 29, 2024
5f6a29a
improve
jammesop007aha Apr 29, 2024
2d4f2c3
improve
jammesop007aha Apr 29, 2024
6e86565
improve
jammesop007aha Apr 29, 2024
5803270
improve
jammesop007aha Apr 29, 2024
3f74cbb
improve
jammesop007aha Apr 29, 2024
da982d0
improve
jammesop007aha Apr 29, 2024
6c7f887
improve
jammesop007aha Apr 29, 2024
ea7b23f
improve
jammesop007aha Apr 29, 2024
528db39
improve
jammesop007aha Apr 29, 2024
d3b9984
improve
jammesop007aha Apr 29, 2024
5142334
improve
jammesop007aha Apr 29, 2024
678c43d
improve
jammesop007aha Apr 29, 2024
224a993
improve
jammesop007aha Apr 29, 2024
eab1116
improve
jammesop007aha Apr 29, 2024
5c004e3
improve
jammesop007aha Apr 29, 2024
1fc6779
improve
jammesop007aha Apr 29, 2024
a4d485f
improve
jammesop007aha Apr 29, 2024
c5cfb79
improve
jammesop007aha Apr 29, 2024
01f17e3
improve
jammesop007aha Apr 29, 2024
89ea537
improve
jammesop007aha Apr 29, 2024
b188f0f
improve
jammesop007aha Apr 29, 2024
d118139
improve
jammesop007aha Apr 29, 2024
15c9a80
improve
jammesop007aha Apr 29, 2024
f51e8d4
improve
jammesop007aha Apr 29, 2024
8f4d917
improve
jammesop007aha Apr 29, 2024
4bd3503
improve
jammesop007aha Apr 29, 2024
27939b1
improve
jammesop007aha Apr 29, 2024
f2f86ec
improve
jammesop007aha Apr 29, 2024
beec95f
improve
jammesop007aha Apr 29, 2024
b69d2a0
improve
jammesop007aha Apr 29, 2024
9e36e9b
improve
jammesop007aha Apr 29, 2024
f9b456d
improve
jammesop007aha Apr 29, 2024
40a0429
improve
jammesop007aha Apr 29, 2024
ba6ca81
improve
jammesop007aha Apr 29, 2024
3c5dd17
improve
jammesop007aha Apr 29, 2024
f7ffcd7
improve
jammesop007aha Apr 29, 2024
dbf5501
improve
jammesop007aha Apr 29, 2024
634bdab
improve
jammesop007aha Apr 29, 2024
fb962aa
improve
jammesop007aha Apr 29, 2024
e51c1f7
improve
jammesop007aha Apr 29, 2024
11cfa5f
improve
jammesop007aha Apr 29, 2024
6d28985
improve
jammesop007aha Apr 29, 2024
d15dd67
improve
jammesop007aha Apr 29, 2024
ade7630
improve
jammesop007aha Apr 29, 2024
9cf7158
improve
jammesop007aha Apr 29, 2024
27e1610
improve
jammesop007aha Apr 29, 2024
7d6af0e
improve
jammesop007aha Apr 29, 2024
ad5bd53
improve
jammesop007aha Apr 29, 2024
ec577b5
improve
jammesop007aha Apr 29, 2024
5ac1aad
improve
jammesop007aha Apr 29, 2024
0736539
improve
jammesop007aha Apr 29, 2024
bfed637
improve
jammesop007aha Apr 29, 2024
ffc7e58
improve
jammesop007aha Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 1,24 @@
config.env
*.pyc
data*
.vscode
.idea
*.json
*.pickle
.netrc
log.txt
accounts/*
Thumbnails/*
MediaInfo/*
Images/*
rclone/*
list_drives.txt
cookies.txt
downloads
bot.session
user.session
terabox.txt
rclone.conf
# A list of files and directories to be ignored by version control systems
.gitignore = [
'config.env',
'*.pyc',
'data*',
'.vscode',
'.idea',
'*.json',
'*.pickle',
'.netrc',
'log.txt',
'accounts/*',
'Thumbnails/*',
'MediaInfo/*',
'Images/*',
'rclone/*',
'list_drives.txt',
'cookies.txt',
'downloads/',
'bot.session',
'user.session',
'terabox.txt',
'rclone.conf'
]
17 changes: 13 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 1,20 @@
FROM mysterysd/wzmlx:latest
# Use an official Python runtime as the base image
FROM python:3.9-slim-buster

WORKDIR /usr/src/app
RUN chmod 777 /usr/src/app
# Set the working directory to /app
WORKDIR /app

# Copy the requirements file to the working directory
COPY requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt

# Install any needed packages specified in requirements.txt
RUN apt-get update && apt-get install -y --no-cache-dir \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Codacy found a medium Error Prone issue: Pin versions in apt get install. Instead of apt-get install <package> use apt-get install <package>=<version>

The issue identified by Hadolint is that the Dockerfile is using the apt-get install command without specifying the exact versions of the packages to be installed. This can lead to non-deterministic builds because the latest version of the packages available at the time of the build will be installed, which might change over time. To ensure a consistent and repeatable build environment, it's recommended to pin specific versions of the packages.

Here's the suggested fix for the Dockerfile line:

Suggested change
RUN apt-get update && apt-get install -y --no-cache-dir \
RUN apt-get update && apt-get install -y --no-install-recommends build-essential=<version> \

Please replace <version> with the specific version of the build-essential package that you want to install. Also, I removed the non-existent --no-cache-dir option from the apt-get install command, which is not valid for apt-get (it's a pip option). Moreover, I included --no-install-recommends to avoid installing unnecessary packages.


This comment was generated by an experimental AI tool.

build-essential \
&& pip install --no-cache-dir -r requirements.txt

# Copy the current directory contents into the container at /app
COPY . .

# Make the script executable and run it
RUN chmod x start.sh
CMD ["bash", "start.sh"]
233 changes: 150 additions & 83 deletions add_to_team_drive.py
Original file line number Diff line number Diff line change
@@ -1,87 1,154 @@
from __future__ import print_function
from google.oauth2.service_account import Credentials
import googleapiclient.discovery
import argparse
import json
from pathlib import Path
import pickle
import progress.bar
import glob
import sys
import argparse
import time
from google_auth_oauthlib.flow import InstalledAppFlow
from typing import Any, Dict, List, Optional

import google.auth
from google.auth.transport.requests import Request
import os
import pickle
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
from googleapiclient.http import BatchHttpRequest

chdrive = build("drive", "v3", credentials=None)

class GoogleDriveTool:
"""A tool to add service accounts to a shared drive from a folder containing credential files."""

def __init__(self, drive_id: str, credential_file: str, service_account_dir: str, yes: bool = False):
self.drive_id = drive_id
self.credential_file = credential_file
self.service_account_dir = service_account_dir
self.yes = yes

def _get_service_account_emails(self) -> List[str]:
"""Get the email addresses of all service accounts in the specified directory."""
service_account_files = list(self.service_account_dir.glob("*.json"))
if not service_account_files:
print(">> No service account files found.")
sys.exit(0)

service_account_emails = []
for file in service_account_files:
with file.open() as f:
data = json.load(f)
service_account_emails.append(data["client_email"])

return service_account_emails

def _authorize(self) -> Credentials:
"""Authorize the user and get credentials."""
creds = None
if Path("token_sa.pickle").exists():
with Path("token_sa.pickle").open("rb") as token:
creds = pickle.load(token)

if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
self.credential_file,
scopes=[
"https://www.googleapis.com/auth/admin.directory.group",
"https://www.googleapis.com/auth/admin.directory.group.member",
],
)
creds = flow.run_console()

with Path("token_sa.pickle").open("wb") as token:
pickle.dump(creds, token)

return creds

def _add_service_accounts_to_drive(self, service_account_emails: List[str]):
"""Add the specified service accounts to the shared drive."""
drive = googleapiclient.discovery.build("drive", "v3", credentials=self._authorize())
batch = drive.new_batch_http_request()

for email in service_account_emails:
batch.add(
drive.permissions().create(
fileId=self.drive_id,
supportsAllDrives=True,
body={
"role": "organizer",
"type": "user",
"emailAddress": email,
},
)
)

try:
batch.execute()
except HttpError as error:
print(f"An error occurred: {error}")
sys.exit(1)

def run(self):
"""Run the tool."""
start_time = time.time()

service_account_emails = self._get_service_account_emails()

if not self.yes:
input(
f">> Make sure the Google account that has generated {self.credential_file} "
"is added into your Team Drive (shared drive) as Manager\n>> (Press any key to continue)"
)

self._add_service_accounts_to_drive(service_account_emails)

print("Complete.")
hours, rem = divmod((time.time() - start_time), 3600)
minutes, sec = divmod(rem, 60)
print(
f"Elapsed Time:\n{int(hours)}:{int(minutes)}:{sec:05.2f}"
)

if __name__ == "__main__":
parse = argparse.ArgumentParser(
description="A tool to add service accounts to a shared drive from a folder containing credential files."
)
parse.add_argument(
"--path",
"-p",
default="accounts",
help="Specify an alternative path to the service accounts folder.",
)
parse.add_argument(
"--credentials",
"-c",
default="./credentials.json",
help="Specify the relative path for the credentials file.",
)
parse.add_argument(
"--yes",
"-y",
default=False,
action="store_true",
help="Skips the sanity prompt.",
)
parsereq = parse.add_argument_group("required arguments")
parsereq.add_argument(
"--drive-id",
"-d",
help="The ID of the Shared Drive.",
required=True,
)

args = parse.parse_args()

tool = GoogleDriveTool(args.drive_id, args.credentials, Path(args.path), args.yes)
tool.run()


pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
pip install argcomplete


stt = time.time()

parse = argparse.ArgumentParser(
description='A tool to add service accounts to a shared drive from a folder containing credential files.')
parse.add_argument('--path', '-p', default='accounts',
help='Specify an alternative path to the service accounts folder.')
parse.add_argument('--credentials', '-c', default='./credentials.json',
help='Specify the relative path for the credentials file.')
parse.add_argument('--yes', '-y', default=False,
action='store_true', help='Skips the sanity prompt.')
parsereq = parse.add_argument_group('required arguments')
parsereq.add_argument('--drive-id', '-d',
help='The ID of the Shared Drive.', required=True)

args = parse.parse_args()
acc_dir = args.path
did = args.drive_id
credentials = glob.glob(args.credentials)

try:
open(credentials[0], 'r')
print('>> Found credentials.')
except IndexError:
print('>> No credentials found.')
sys.exit(0)

if not args.yes:
# input('Make sure the following client id is added to the shared drive as Manager:\n' json.loads((open(
# credentials[0],'r').read()))['installed']['client_id'])
input('>> Make sure the **Google account** that has generated credentials.json\n is added into your Team Drive '
'(shared drive) as Manager\n>> (Press any key to continue)')

creds = None
if os.path.exists('token_sa.pickle'):
with open('token_sa.pickle', 'rb') as token:
creds = pickle.load(token)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(credentials[0], scopes=[
'https://www.googleapis.com/auth/admin.directory.group',
'https://www.googleapis.com/auth/admin.directory.group.member'
])
# creds = flow.run_local_server(port=0)
creds = flow.run_console()
# Save the credentials for the next run
with open('token_sa.pickle', 'wb') as token:
pickle.dump(creds, token)

drive = googleapiclient.discovery.build("drive", "v3", credentials=creds)
batch = drive.new_batch_http_request()

aa = glob.glob('%s/*.json' % acc_dir)
pbar = progress.bar.Bar("Readying accounts", max=len(aa))
for i in aa:
ce = json.loads(open(i, 'r').read())['client_email']
batch.add(drive.permissions().create(fileId=did, supportsAllDrives=True, body={
"role": "organizer",
"type": "user",
"emailAddress": ce
}))
pbar.next()
pbar.finish()
print('Adding...')
batch.execute()

print('Complete.')
hours, rem = divmod((time.time() - stt), 3600)
minutes, sec = divmod(rem, 60)
print("Elapsed Time:\n{:0>2}:{:0>2}:{:05.2f}".format(
int(hours), int(minutes), sec))
import argcomplete
argcomplete.autocomplete(parse)
Loading