diff --git a/.gitignore b/.gitignore index fbd0668..12a0762 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -nextcloud_auth.json \ No newline at end of file +nextcloud_auth.json +credentials.json diff --git a/__pycache__/app.cpython-36.pyc b/__pycache__/app.cpython-36.pyc deleted file mode 100644 index f56592c..0000000 Binary files a/__pycache__/app.cpython-36.pyc and /dev/null differ diff --git a/app.py b/app.py index 2c370c3..f5e293d 100644 --- a/app.py +++ b/app.py @@ -31,9 +31,7 @@ from googleapiclient.http import MediaIoBaseDownload # If modifying these scopes, delete the file token.json. SCOPES = ['https://www.googleapis.com/auth/photoslibrary'] - - -def main(): +def download(next_page=None): """Shows basic usage of the Docs API. Prints the title of a sample document. """ @@ -63,21 +61,21 @@ def main(): try: service = build('photoslibrary', 'v1', credentials=creds, static_discovery=False) - results = service.mediaItems().list().execute() + results = service.mediaItems().list(pageSize=100, pageToken=next_page).execute() items = results.get('mediaItems', []) + next_page = results.get('nextPageToken') images = [] for item in items: print(f"{item['filename']} {item['mimeType']}") url = "https://homelinuxserver.ddns.net/remote.php/dav/files/arthur/data/Backup/photos/"+item['filename'] - print(url) if "video" in item['mimeType']: requests.put(url, auth=HTTPBasicAuth(nextcloud_user, nextcloud_pass), data=requests.get(item['baseUrl']+'=dv').content) else: requests.put(url, auth=HTTPBasicAuth(nextcloud_user, nextcloud_pass), data=requests.get(item['baseUrl']+'=d').content) - print('done !') + return next_page except HttpError as err: @@ -85,5 +83,8 @@ def main(): if __name__ == '__main__': - main() + next_page = download() + while next_page != 'null': + next_page = download(next_page) + print('done') # [END docs_quickstart] \ No newline at end of file diff --git a/token.json b/token.json index 70bc83a..3961315 100644 --- a/token.json +++ b/token.json @@ -1 +1 @@ -{"token": "ya29.a0AX9GBdUHoUjUGSu4S7_VdbS0kmoHO3rvcJlC2hAOO5gHc8Ha3FDBx6G0zdjtV2SeIaJXPVVHvvMuxDZn37lMTXWQObhVIb3cseSkTE2Lh-HcSd6FhQXuLTApl77mI-2MjIYD49Ld5e6dTCDig9PIHxyaag4HzSIaCgYKAWUSAQASFQHUCsbC6VZE2PWen5SOAsH-58bOrA0166", "refresh_token": "1//0306exYla7apXCgYIARAAGAMSNwF-L9IrDTP2kdneYUP7CBpJ_oqtdWfvtIuuaCDaxySRfADycVywQjJ8C1jjrRCCo_1N16vlxdA", "token_uri": "https://oauth2.googleapis.com/token", "client_id": "114734902818-12qkdhcljn2cjtlffmmag6ahq85ig6bb.apps.googleusercontent.com", "client_secret": "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", "scopes": ["https://www.googleapis.com/auth/photoslibrary"], "expiry": "2023-01-10T22:18:47.449544Z"} \ No newline at end of file +{"token": "ya29.a0AX9GBdU-N2vYtbrra2w9xyrYeDDwIeKkqo0xlISwSwmUpUCtP9bn40dEOEyYJow67UIqPocjkDHFqRINTPCBr28pwFBteTLccPLbp4ZPuVYEugcyO-wixxDy9q0Mp0zk60AFKOFRajos9U5iPmNGGyzCKaGwdpzsaCgYKAf4SAQASFQHUCsbCg9W0B-CJ6giNrNzKtABSIQ0167", "refresh_token": "1//0306exYla7apXCgYIARAAGAMSNwF-L9IrDTP2kdneYUP7CBpJ_oqtdWfvtIuuaCDaxySRfADycVywQjJ8C1jjrRCCo_1N16vlxdA", "token_uri": "https://oauth2.googleapis.com/token", "client_id": "114734902818-12qkdhcljn2cjtlffmmag6ahq85ig6bb.apps.googleusercontent.com", "client_secret": "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", "scopes": ["https://www.googleapis.com/auth/photoslibrary"], "expiry": "2023-01-11T10:29:46.805328Z"} \ No newline at end of file