File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 11import json
22
33import requests
4+ from tqdm import tqdm
45
56from src .config import Config
67
1213base_url = f"https://pretalx.com/api/events/{ Config .event } /"
1314
1415resources = [
15- # Questions needs to be passed to include answers in the same endpoint,
16+ # Questions need to be passed to include answers in the same endpoint,
1617 # saving us later time with joining the answers.
1718 "submissions?questions=all" ,
1819 "speakers?questions=all" ,
1920]
2021
2122for resource in resources :
22- print ("Downloading: " , resource )
2323 url = base_url + f"{ resource } "
2424
2525 res0 = []
2626 data = {"next" : url }
2727 n = 0
2828
29+ pbar = tqdm (desc = f"Downloading { resource } " , unit = " page" , dynamic_ncols = True )
30+
2931 while url := data ["next" ]:
3032 n += 1
31- print ( f"Page { n } " )
33+ pbar . update ( 1 )
3234 response = requests .get (url , headers = headers )
3335
3436 if response .status_code != 200 :
3739 data = response .json ()
3840 res0 += data ["results" ]
3941
42+ pbar .close ()
43+
4044 filename = resource .split ("?" )[0 ] # To get rid of "?questions"
4145 filename = f"{ filename } _latest.json"
4246 filepath = Config .raw_path / filename
You can’t perform that action at this time.
0 commit comments