{"id":13594381,"url":"https://github.com/lzzy12/python-aria-mirror-bot","last_synced_at":"2025-04-09T07:31:52.197Z","repository":{"id":38009226,"uuid":"209987323","full_name":"lzzy12/python-aria-mirror-bot","owner":"lzzy12","description":"A telegram bot for all your mirror needs | OG Repo","archived":false,"fork":false,"pushed_at":"2022-09-14T15:35:43.000Z","size":460,"stargazers_count":738,"open_issues_count":30,"forks_count":1307,"subscribers_count":44,"default_branch":"main","last_synced_at":"2024-08-02T16:52:01.931Z","etag":null,"topics":["google-drive","mirror","mirror-bot","python-mirror-bot","team-drive","telegram-bot","telegram-mirror-bot"],"latest_commit_sha":null,"homepage":"https://t.me/pythonmirrorsupport","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lzzy12.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"lzzy12"}},"created_at":"2019-09-21T13:11:12.000Z","updated_at":"2024-07-21T19:09:14.000Z","dependencies_parsed_at":"2022-07-09T04:46:01.298Z","dependency_job_id":null,"html_url":"https://github.com/lzzy12/python-aria-mirror-bot","commit_stats":null,"previous_names":[],"tags_count":6,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzzy12%2Fpython-aria-mirror-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzzy12%2Fpython-aria-mirror-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzzy12%2Fpython-aria-mirror-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzzy12%2Fpython-aria-mirror-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lzzy12","download_url":"https://codeload.github.com/lzzy12/python-aria-mirror-bot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223375313,"owners_count":17135347,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google-drive","mirror","mirror-bot","python-mirror-bot","team-drive","telegram-bot","telegram-mirror-bot"],"created_at":"2024-08-01T16:01:32.619Z","updated_at":"2024-11-06T16:31:14.664Z","avatar_url":"https://github.com/lzzy12.png","language":"Python","funding_links":["https://github.com/sponsors/lzzy12"],"categories":["Python"],"sub_categories":[],"readme":"# What is this repo about?\nThis is a telegram bot writen in python for mirroring files on the internet to our beloved Google Drive.\n\n# Inspiration \nThis project is heavily inspired from @out386 's telegram bot which is written in JS.\n\n# Features supported:\n- Mirroring direct download links to google drive\n- Download progress\n- Upload progress\n- Download/upload speeds and ETAs\n- Docker support\n- Uploading To Team Drives.\n- Index Link support\n- Service account support\n- Mirror all youtube-dl supported links\n- Mirror telegram files\n- Stable Mega.nz support\n- Unzip downloads\n- Persistent authorised chat storage\n\n# How to deploy?\nDeploying is pretty much straight forward and is divided into several steps as follows:\n## Installing requirements\n\n- Clone this repo:\n```\ngit clone https://github.com/lzzy12/python-aria-mirror-bot mirror-bot/\ncd mirror-bot\n```\n\n- Install requirements\nFor Debian based distros\n```\nsudo apt install python3\n```\nInstall Docker by following the [official docker docs](https://docs.docker.com/engine/install/debian/)\n\n\n- For Arch and it's derivatives:\n```\nsudo pacman -S docker python\n```\n\n- Install dependencies for running setup scripts:\n```shell script\npip3 install -r requirements-cli.txt\n```\n\n## Setting up config file\nNOTE: Starting from 953113269e4424ecb956d0b9b093b846301efffb we are moving away from storing authroized chat ids in txt files. We will be using a light weight redis db. So, going forword, a redis db is a must.\n```\ncp config_sample.env config.env\n```\n- Remove the first line saying:\n```\n_____REMOVE_THIS_LINE_____=True\n```\nFill up rest of the fields. Meaning of each fields are discussed below:\n- **BOT_TOKEN** : The telegram bot token that you get from @BotFather\n- **GDRIVE_FOLDER_ID** : This is the folder ID of the Google Drive Folder to which you want to upload all the mirrors.\n- **DOWNLOAD_DIR** : The path to the local folder where the downloads should be downloaded to\n- **DOWNLOAD_STATUS_UPDATE_INTERVAL** : A short interval of time in seconds after which the Mirror progress message is updated. (I recommend to keep it 5 seconds at least)  \n- **OWNER_ID** : The Telegram user ID (not username) of the owner of the bot\n- **AUTO_DELETE_MESSAGE_DURATION** : Interval of time (in seconds), after which the bot deletes it's message (and command message) which is expected to be viewed instantly. Note: Set to -1 to never automatically delete messages\n- **IS_TEAM_DRIVE** : (Optional field) Set to \"True\" if GDRIVE_FOLDER_ID is from a Team Drive else False or Leave it empty.\n- **USE_SERVICE_ACCOUNTS**: (Optional field) (Leave empty if unsure) Whether to use service accounts or not. For this to work see  \"Using service accounts\" section below.\n- **INDEX_URL** : (Optional field) Refer to https://github.com/maple3142/GDIndex/ The URL should not have any trailing '/'\n- **TELEGRAM_API** : This is to authenticate to your telegram account for downloading Telegram files. You can get this from https://my.telegram.org DO NOT put this in quotes.\n- **TELEGRAM_HASH** : This is to authenticate to your telegram account for downloading Telegram files. You can get this from https://my.telegram.org\n- **USER_SESSION_STRING** : Session string generated by running:\n- **MEGA_KEY**: Mega.nz api key to mirror mega.nz links. Get it from [Mega SDK Page](https://mega.nz/sdk)\n- **MEGA_USERNAME**: Your mega email id (You can leave it empty, it will start megasdkrest server in anonymous mode)\n- **MEGA_PASSWORD**: Your password for your mega.nz account. (**NOTE**: You must deactivate 2FA to use the account with the bot otherwise bot will not be able to sign in)\n- **REDIS_HOST**: Redis DB Host URL. Redis DB is used to store the authorised chats informations (you can get it at https://redis.com -\u003e Login -\u003e Select Free subscription -\u003e Create Database -\u003e Enter a name -\u003e Select a location(if you want) -\u003e keep everything else default. You will get a public endpoint(refered to as REDIS_HOST in this repo), port (most probably 6397) and a password)\n- **REDIS_PORT**: Redis DB Port number.\n- **REDIS_PASSWORD**: Password of your redis DB\n```\npython3 generate_string_session.py\n```\nNote: You can limit maximum concurrent downloads by changing the value of MAX_CONCURRENT_DOWNLOADS in aria.sh. By default, it's set to 2\n \n## Getting Google OAuth API credential file\n\n- Visit the [Google Cloud Console](https://console.developers.google.com/apis/credentials)\n- Go to the OAuth Consent tab, fill it, and save.\n- Go to the Credentials tab and click Create Credentials -\u003e OAuth Client ID\n- Choose Other and Create.\n- Use the download button to download your credentials.\n- Move that file to the root of mirror-bot, and rename it to credentials.json\n- Visit [Google API page](https://console.developers.google.com/apis/library)\n- Search for Drive and enable it if it is disabled\n- Finally, run the script to generate token file (token.pickle) for Google Drive:\n```\npip install google-api-python-client google-auth-httplib2 google-auth-oauthlib\npython3 generate_drive_token.py\n```\n## Deploying\n\n- Start docker daemon (skip if already running):\n```\nsudo dockerd\n```\n- Build Docker image:\n```\nsudo docker build . -t mirror-bot\n```\n- Run the image:\n```\nsudo docker run mirror-bot\n```\n\n# Using service accounts for uploading to avoid user rate limit\nFor Service Account to work, you must set USE_SERVICE_ACCOUNTS=\"True\" in config file or environment variables\nMany thanks to [AutoRClone](https://github.com/xyou365/AutoRclone) for the scripts\n**NOTE:** Using service accounts is only recommended while uploading to a team drive.\n## Generating service accounts\nStep 1. Generate service accounts [What is service account](https://cloud.google.com/iam/docs/service-accounts)\n---------------------------------\nLet us create only the service accounts that we need. \n**Warning:** abuse of this feature is not the aim of this project and we do **NOT** recommend that you make a lot of projects, just one project and 100 sa allow you plenty of use, its also possible that over abuse might get your projects banned by google. \n\n```\nNote: 1 service account can copy around 750gb a day, 1 project can make 100 service accounts so that's 75tb a day, for most users this should easily suffice. \n```\n\n`python3 gen_sa_accounts.py --quick-setup 1 --new-only`\n\nA folder named accounts will be created which will contain keys for the service accounts\n\nNOTE: If you have created SAs in past from this script, you can also just re download the keys by running:\n```\npython3 gen_sa_accounts.py --download-keys project_id\n```\n\n### Add all the service accounts to the Team Drive\n- Run:\n```\npython3 add_to_team_drive.py -d SharedTeamDriveSrcID\n```\n\n# Youtube-dl authentication using .netrc file\nFor using your premium accounts in youtube-dl, edit the netrc file (in the root directory of this repository) according to following format:\n```\nmachine host login username password my_youtube_password\n```\nwhere host is the name of extractor (eg. youtube, twitch). Multiple accounts of different hosts can be added each separated by a new line\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flzzy12%2Fpython-aria-mirror-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flzzy12%2Fpython-aria-mirror-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flzzy12%2Fpython-aria-mirror-bot/lists"}