2024-10-25 23:19:29 +02:00
|
|
|
import os, requests, json
|
2024-07-24 19:13:42 +02:00
|
|
|
import argparse
|
|
|
|
from urllib.parse import quote
|
|
|
|
|
2024-10-25 23:19:29 +02:00
|
|
|
|
|
|
|
def parse_args(argv=None):
|
2024-07-24 19:13:42 +02:00
|
|
|
parser = argparse.ArgumentParser()
|
2024-10-25 23:19:29 +02:00
|
|
|
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",
|
|
|
|
)
|
2024-07-24 19:13:42 +02:00
|
|
|
|
|
|
|
global args
|
|
|
|
args = parser.parse_args(argv)
|
|
|
|
|
|
|
|
|
2024-10-25 23:19:29 +02:00
|
|
|
if __name__ == "__main__":
|
2024-07-24 19:13:42 +02:00
|
|
|
parse_args()
|
|
|
|
|
|
|
|
mly_key = args.access_token
|
|
|
|
creator_username = args.username
|
2024-10-25 23:19:29 +02:00
|
|
|
max_img = args.pictures
|
2024-07-24 19:13:42 +02:00
|
|
|
|
2024-10-25 23:19:29 +02:00
|
|
|
url = f"https://graph.mapillary.com/images?access_token={mly_key}&creator_username={creator_username}&limit={max_img}&fields=id,sequence"
|
|
|
|
print(url)
|
2024-07-24 19:13:42 +02:00
|
|
|
|
|
|
|
response = requests.get(url)
|
|
|
|
|
|
|
|
if response.status_code == 200:
|
2024-10-25 23:19:29 +02:00
|
|
|
json = response.json()
|
2024-07-24 19:13:42 +02:00
|
|
|
|
2024-10-25 23:19:29 +02:00
|
|
|
# tri des séquences uniques
|
|
|
|
sequences_ids = [obj["sequence"] for obj in json["data"]]
|
|
|
|
unique_ids = list(set(sequences_ids))
|
|
|
|
print(unique_ids)
|
2024-07-24 19:13:42 +02:00
|
|
|
else:
|
2024-10-25 23:19:29 +02:00
|
|
|
print(response)
|