Filename for image is datetime

This commit is contained in:
Stefal 2023-09-10 20:04:26 +02:00
parent a6f38f81e6
commit a02ca67360
1 changed files with 6 additions and 4 deletions

View File

@ -3,6 +3,7 @@ import json
import os import os
import asyncio import asyncio
import argparse import argparse
from datetime import datetime
def parse_args(argv =None): def parse_args(argv =None):
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
@ -57,13 +58,14 @@ if __name__ == '__main__':
print('getting urls') print('getting urls')
for x in range(0, img_num): for x in range(0, img_num):
image_id = image_ids[x]['id'] image_id = image_ids[x]['id']
req_url = 'https://graph.mapillary.com/{}?fields=thumb_original_url'.format(image_id) req_url = 'https://graph.mapillary.com/{}?fields=thumb_original_url,altitude,camera_type,captured_at,compass_angle,geometry,exif_orientation'.format(image_id)
r = requests.get(req_url, headers=header) r = requests.get(req_url, headers=header)
data = r.json() data = r.json()
print('getting url {} of {}'.format(x, img_num)) print('getting url {} of {}'.format(x, img_num))
urls.append(data['thumb_original_url']) urls.append(data)
print('downloading.. this process will take a while. please wait') print('downloading.. this process will take a while. please wait')
for i,url in enumerate(urls): for i,url in enumerate(urls):
path = 'data/{}/{}.jpg'.format(sequence_id, i) path = 'data/{}/{}.jpg'.format(sequence_id, datetime.utcfromtimestamp(int(url['captured_at'])/1000).strftime('%Y-%m-%d_%HH%Mmn%S.%f'))
download(url,path) print(path)
download(url['thumb_original_url'],path)