mirror of
https://forge.chapril.org/tykayn/mapillary_download
synced 2025-06-20 01:34:43 +02:00
correct text-array to download script, ask for usernames if empty, improve argparse, linting to black
Signed-off-by: Matthias <matthias@pebble>
This commit is contained in:
parent
ff90b70d5d
commit
795fd20030
8 changed files with 398 additions and 189 deletions
|
@ -1,38 +1,51 @@
|
|||
import requests, json
|
||||
import os, requests, json
|
||||
import argparse
|
||||
from urllib.parse import quote
|
||||
|
||||
def parse_args(argv =None):
|
||||
|
||||
def parse_args(argv=None):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--access_token', type=str, help='Your mapillary access token')
|
||||
parser.add_argument('--username', type=str, help='Username to get the sequences id of')
|
||||
parser.add_argument('--pictures', type=str, help='Limit of pictures to fetch')
|
||||
parser.add_argument(
|
||||
"--access_token",
|
||||
type=str,
|
||||
default=os.environ["MAPILLARY_DEV_TOKEN"],
|
||||
help="Your mapillary access token",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--username",
|
||||
type=str,
|
||||
required=True,
|
||||
help="Username to get the sequences id of",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--pictures",
|
||||
type=str,
|
||||
default=500,
|
||||
help="Limit of pictures to fetch, max=5000",
|
||||
)
|
||||
|
||||
global args
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
parse_args()
|
||||
|
||||
if args.access_token == None:
|
||||
print('please provide the access_token')
|
||||
exit()
|
||||
|
||||
mly_key = args.access_token
|
||||
creator_username = args.username
|
||||
max_img= args.pictures
|
||||
max_img = args.pictures
|
||||
|
||||
url = f'https://graph.mapillary.com/images?access_token={mly_key}&creator_username={creator_username}&limit={max_img}&fields=id,sequence'
|
||||
url = f"https://graph.mapillary.com/images?access_token={mly_key}&creator_username={creator_username}&limit={max_img}&fields=id,sequence"
|
||||
print(url)
|
||||
|
||||
response = requests.get(url)
|
||||
|
||||
if response.status_code == 200:
|
||||
json = response.json()
|
||||
json = response.json()
|
||||
|
||||
# tri des séquences uniques
|
||||
sequences_ids = [obj['sequence'] for obj in json['data']]
|
||||
unique_ids = list(set(sequences_ids))
|
||||
print(unique_ids)
|
||||
# tri des séquences uniques
|
||||
sequences_ids = [obj["sequence"] for obj in json["data"]]
|
||||
unique_ids = list(set(sequences_ids))
|
||||
print(unique_ids)
|
||||
else:
|
||||
print(response)
|
||||
print(response)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue