Package: rclone-python-lp-asset
rclone-python ☁️A python wrapper for rclone that makes rclone's functionality usable in python.
rclone needs to be installed on the system for the wrapper to work.Features ⚒️Copy, move and sync files between remotesDelete and prune files/directoriesList files in a directory including properties of the files.List available remotes.Generate hashes from files or validate them with their hashsum.Create new remotesCheck available remotesCreate and manage public links.Check the currently installed rclone versions and if updates are available.Installation 💾rclone_pythoncan be installed using pippipinstallrclone-pythonor by cloning this repository and running from within the root of the projectpipinstall.How to use 💡All functionally of this wrapper is accessible throughrclone.
The following example checks if rclone is installed.fromrclone_pythonimportrcloneprint(rclone.is_installed())TrueCreate new remoteCreate a new rclone remote connection with rclone's default client-id and client-secret.fromrclone_pythonimportrclonefromrclone_python.remote_typesimportRemoteTypesrclone.create_remote('onedrive',RemoteTypes.onedrive)Additionally, client-id and client-secret can be used with many cloud providers.fromrclone_pythonimportrclonefromrclone_python.remote_typesimportRemoteTypesrclone.create_remote('onedrive',RemoteTypes.onedrive,client_id='YOUR_CLIENT_ID',client_secret='YOUR_CLIENT_SECRET')Copyfromrclone_pythonimportrclone# copy all file in the test_dir on OneDrive to the local data folder.rclone.copy('onedrive:data','data',ignore_existing=True,args=['--create-empty-src-dirs'])Copying onedrive:data to data ⠸ ━━━━━━━━━━━━━━━━━━╸━━━━━━━━━━━━━━━━━━━━━  47% 110.0/236.5 MiB 0:00:04├─video1.webm                ⠸ ━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━  31% 24.4/78.8 MiB   0:00:06├─video2.webm                ⠸ ━━━━━━━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━  45% 35.5/78.8 MiB   0:00:03└─video3.webm                ⠸ ━━━━━━━━━━━━━╸━━━━━━━━━━━━━━━━━━━━━━━━━━  35% 27.6/78.8 MiB   0:00:05DeleteDelete a file or a directory. When deleting a directory, only the files in the directory (and all it's subdirectories)
are deleted, but the folders remain.fromrclone_pythonimportrclone# delete a specific file on onedriverclone.delete('onedrive:data/video1.mp4')Prunefromrclone_pythonimportrclone# remove the entire test_dir folder (and all files contained in it and it's subdirectories) on onedriverclone.purge('onedrive:test_dir')Get Hashfromrclone_pythonimportrclonefromrclone_python.hash_typesimportHashTypesprint(rclone.hash(HashTypes.sha1,"box:data"){'video1.webm': '3ef08d895f25e8b7d84d3a1ac58f8f302e33058b', 'video3.webm': '3ef08d895f25e8b7d84d3a1ac58f8f302e33058b', 'video2.webm': '3ef08d895f25e8b7d84d3a1ac58f8f302e33058b'}Custom ProgressbarYou can use your own rich progressbar with all transfer operations.
This allows you to customize the columns to be displayed.
A list of all rich-progress columns can be foundhere.fromrclone_pythonimportrclonefromrich.progressimport(Progress,TextColumn,BarColumn,TaskProgressColumn,TransferSpeedColumn,)pbar=Progress(TextColumn("[progress.description]{task.description}"),BarColumn(),TaskProgressColumn(),TransferSpeedColumn(),)rclone.copy("data","box:rclone_test/data1",pbar=pbar)Copying data to data1 ━━━━━━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  17% 5.3 MB/s├─video1.mp4         ━━━━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━  38% 4.2 MB/s├─video2.mp4         ━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   5% 1.6 MB/s└─another.mp4        ━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   4% 1.4 MB/sDebugFor debugging progress related functionality, set the DEBUG flag to true:rclone.DEBUG=TrueThis will make the wrapper print the raw rclone progress.