From 5099f0f3687bd382e82c4050e8d0c99fbfd9065e Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 22 Oct 2024 23:05:29 +0200 Subject: [PATCH 1/3] correct typos, adapt chmod of bash scripts Signed-off-by: Matthias --- README.md | 13 ++++++++----- batch_get_username.sh | 4 +++- get_sequences_of_username.py | 2 +- get_user.sh | 1 + secrets_variables_example.sh | 4 +++- 5 files changed, 16 insertions(+), 8 deletions(-) mode change 100644 => 100755 batch_get_username.sh mode change 100644 => 100755 get_user.sh diff --git a/README.md b/README.md index 0b6bde9..f6a92a8 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ Simple code to download images in one or several mapillary sequences. The images ## How to use ### Setup env variables -copy the secret variables files to setup your maipllary dev token, and your panoramax OpenStreetMap token. +copy the secret variables files to setup your mapillary dev token, and your panoramax OpenStreetMap token. ```Shell -cp secrets_variables_examples.sh secrets_variables.sh +cp secrets_variables_example.sh secrets_variables.sh editor secrets_variables.sh ``` @@ -13,10 +13,13 @@ editor secrets_variables.sh To avoid to download everything at once, this is a 2 steps process: - 1/ We set a list of users for which we want to get the list of sequences to download, and get a bash script for each user. Change the list of users in the batch file `batch_get_username.sh`. - change the access token with your access token and the sequence ids with the ids of the sequences you want to download ```bash usernames=( "someone_having_nice_pictures" "someone_else" "oh_look_a_these_usernames" ) # use real accounts, it might work better ``` + then, execute: + ```bash + ./batch_get_username.sh + ``` This will give you a few files that the other scripts will use to generate a script to download all sequences of each user. One user, one bash script generated. @@ -25,7 +28,7 @@ To avoid to download everything at once, this is a 2 steps process: bash script_bash_get_sequences_for_user_SOMEONE.sh ``` **Or all of the generated batch scripts at once.** - + ```bash bash script_bash_get_sequences_for_user_* ``` @@ -101,7 +104,7 @@ python3 -m venv mly_venv source mly_venv/bin/activate python -m pip install -r requirements.txt ``` -Then you can run `python mapillary_download "MLY|xxxx|xxxxxxx" --sequence_ids xxxxxxxxxxx` +Then you can run `python mapillary_download.py "MLY|xxxx|xxxxxxx" --sequence_ids xxxxxxxxxxx` When you're done with the script, simply run `deactivate` to exit the virtual environnement. On windows you can create a virtual environnement too, or use the prebuilt `mapillary_download.exe` available on the release page. diff --git a/batch_get_username.sh b/batch_get_username.sh old mode 100644 new mode 100755 index da8cab1..e67e769 --- a/batch_get_username.sh +++ b/batch_get_username.sh @@ -28,6 +28,8 @@ echo "---------- utilisateur: $username" if [ ! -f "out_$username.json" ]; then bash find_user_id.sh $username + #FIXME: find_user_id.sh is not part of this repo. maybe get_user.sh? + #FIXME: also check if file is empty? fi # Vérifier si le fichier sequences_$username.txt existe if [ ! -f "sequences_$username.txt" ]; then @@ -41,4 +43,4 @@ echo "---------- utilisateur: $username" fi done -echo "---------- finished getting users ------------" \ No newline at end of file +echo "---------- finished getting users ------------" diff --git a/get_sequences_of_username.py b/get_sequences_of_username.py index 4184112..251445f 100644 --- a/get_sequences_of_username.py +++ b/get_sequences_of_username.py @@ -7,7 +7,7 @@ import argparse def parse_args(argv =None): parser = argparse.ArgumentParser() - parser.add_argument('--username', type=str, help='Username to get the sequences id of') + parser.add_argument('--username', type=str, help='Username to get the sequences id of', required=True) parser.add_argument('--dev_token', type=str, help='Your mapillary developer token') parser.add_argument('--max_sequence', type=str, help='Username to get the sequences id of') diff --git a/get_user.sh b/get_user.sh old mode 100644 new mode 100755 index 53187ae..9af963e --- a/get_user.sh +++ b/get_user.sh @@ -9,6 +9,7 @@ export username=$1 export num_user=$2 echo "télécharger la séquence pour l'utilisateur $username, $num_user" bash curl_land.sh "$username" "$num_user" > "out_${username}.json" +#FIXME curl_land script not included in this repo echo "séquences récupérées:" num_sequences=$(grep -o -w 'image_id' "out_${username}.json" | wc -l) diff --git a/secrets_variables_example.sh b/secrets_variables_example.sh index 80d88d8..d3f9e23 100644 --- a/secrets_variables_example.sh +++ b/secrets_variables_example.sh @@ -1,5 +1,7 @@ # scripts common shared variables # this is to copy as a file named "secrets_variables.sh" which is ignored in this git repo - +# Mapillary: +# register an application at https://www.mapillary.com/dashboard/developers +# read permissions needed, all other fields can be random. copy the client token export MAPILLARY_DEV_TOKEN="MLY|blahblah_replace_it" -- 2.39.5 From c8404cdd545eaa53f4a59b78963d054ff257ad8f Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 24 Oct 2024 00:01:05 +0200 Subject: [PATCH 2/3] add panormax cli Signed-off-by: Matthias --- README.md | 7 +++++-- requirements.txt | 3 ++- secrets_variables_example.sh | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f6a92a8..e151368 100644 --- a/README.md +++ b/README.md @@ -102,9 +102,10 @@ git clone https://github.com/Stefal/mapillary_download.git cd mapillary_download python3 -m venv mly_venv source mly_venv/bin/activate +source secrets_variables.sh python -m pip install -r requirements.txt ``` -Then you can run `python mapillary_download.py "MLY|xxxx|xxxxxxx" --sequence_ids xxxxxxxxxxx` +Then you can run `python mapillary_download.py $MAPILLARY_DEV_TOKEN --sequence_ids xxxxxxxxxxx` When you're done with the script, simply run `deactivate` to exit the virtual environnement. On windows you can create a virtual environnement too, or use the prebuilt `mapillary_download.exe` available on the release page. @@ -117,8 +118,10 @@ go in your `data` folder, and to the user subfolder, and assuming you have alrea ```Shell +source mly_venv/bin/activate +source secrets_variables.sh cd data/some_user -for dir in */; do dir=${dir%?} ; geovisio upload --api-url https://panoramax.openstreetmap.fr "$dir" --token=BLAH_BLAH ; done +for dir in */; do dir=${dir%?} ; panoramax_cli upload --api-url https://panoramax.openstreetmap.fr "$dir" --token=$PANORAMAX_DEV_TOKEN ; done ``` Have fun! diff --git a/requirements.txt b/requirements.txt index 934cbed..4db3c20 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ requests >= 2.28.2 pytz >= 2023.3 timezonefinder >=6.2.0 -pyexiv2 >= 2.8.2 \ No newline at end of file +pyexiv2 >= 2.8.2 +panoramax_cli >= 1.1.1 diff --git a/secrets_variables_example.sh b/secrets_variables_example.sh index d3f9e23..68ff40a 100644 --- a/secrets_variables_example.sh +++ b/secrets_variables_example.sh @@ -5,3 +5,7 @@ # register an application at https://www.mapillary.com/dashboard/developers # read permissions needed, all other fields can be random. copy the client token export MAPILLARY_DEV_TOKEN="MLY|blahblah_replace_it" + +# Panoramax +# copy the token from your profile settings at https://panoramax.openstreetmap.fr/settings +export PANORAMAX_DEV_TOKEN="yourtokenhere" -- 2.39.5 From 7d297ed80564bf618fffc78d0f45e5c356195cbe Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 24 Oct 2024 01:10:06 +0200 Subject: [PATCH 3/3] fixup! correct typos, adapt chmod of bash scripts Signed-off-by: Matthias --- batch_get_username.sh | 4 +--- get_sequences_of_username.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) mode change 100755 => 100644 batch_get_username.sh diff --git a/batch_get_username.sh b/batch_get_username.sh old mode 100755 new mode 100644 index e67e769..da8cab1 --- a/batch_get_username.sh +++ b/batch_get_username.sh @@ -28,8 +28,6 @@ echo "---------- utilisateur: $username" if [ ! -f "out_$username.json" ]; then bash find_user_id.sh $username - #FIXME: find_user_id.sh is not part of this repo. maybe get_user.sh? - #FIXME: also check if file is empty? fi # Vérifier si le fichier sequences_$username.txt existe if [ ! -f "sequences_$username.txt" ]; then @@ -43,4 +41,4 @@ echo "---------- utilisateur: $username" fi done -echo "---------- finished getting users ------------" +echo "---------- finished getting users ------------" \ No newline at end of file diff --git a/get_sequences_of_username.py b/get_sequences_of_username.py index 251445f..3fe8f1c 100644 --- a/get_sequences_of_username.py +++ b/get_sequences_of_username.py @@ -9,7 +9,7 @@ def parse_args(argv =None): parser = argparse.ArgumentParser() parser.add_argument('--username', type=str, help='Username to get the sequences id of', required=True) parser.add_argument('--dev_token', type=str, help='Your mapillary developer token') - parser.add_argument('--max_sequence', type=str, help='Username to get the sequences id of') + parser.add_argument('--max_sequence', type=str, help='Limit the amount of retrieved sequence ids') global args args = parser.parse_args(argv) -- 2.39.5