Browse Source

presque fin

master
BARRAUX Arthur 2 years ago
parent
commit
80d0df2a51
  1. 1
      .gitignore
  2. BIN
      __pycache__/app.cpython-36.pyc
  3. 15
      app.py
  4. 2
      token.json

1
.gitignore

@ -1 +1,2 @@
nextcloud_auth.json
credentials.json

BIN
__pycache__/app.cpython-36.pyc

Binary file not shown.

15
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]

2
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"}
{"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"}
Loading…
Cancel
Save