@@ -12,22 +12,29 @@ def get_tile_urls(
12
12
"""Get tile urls."""
13
13
file_urls = []
14
14
for i in range (len (month_url )):
15
- temp = get_api (month_url [i ]).json ()
15
+ temp = get_api (month_url [i ]).json ()[ 'data' ]
16
16
17
17
if not len (temp ):
18
18
print (f"No files found for site { temp ['data' ]['siteCode' ]} and "
19
19
f"year { temp ['data' ]['month' ]} ." )
20
20
continue
21
21
22
- temp_ = temp ['data' ]['files' ]
23
- # temp_ = json.dumps(temp['data']['files'])
24
- # df = pd.read_json(temp_)
25
- # # get the files for easting and northing
26
-
27
- # if easting is a signle value and northing is a single value
22
+ temp_ = temp ['files' ]
23
+ dataSiteMonth = {
24
+ "data" : {
25
+ "productCode" : temp ['productCode' ],
26
+ "siteCode" : temp ['siteCode' ],
27
+ "month" : temp ['month' ],
28
+ "release" : temp ['release' ],
29
+ "packages" : temp ['packages' ],
30
+ "files" : []
31
+ }
32
+ }
28
33
29
34
if isinstance (easting .astype (str ), str ) and isinstance (northing .astype (str ), str ):
30
- file_urls = [x for x in temp_ if f'_{ easting } _{ northing } ' in x ['name' ]]
35
+ dataSiteMonth ['data' ]['files' ] = [x for x in temp_ if f'_{ easting } _{ northing } ' in x ['name' ]]
36
+ file_urls .append (dataSiteMonth )
37
+
31
38
elif isinstance (easting , np .ndarray ) and isinstance (northing , np .ndarray ):
32
39
for j in range (len (easting )):
33
40
urls = [
@@ -44,6 +51,8 @@ def get_tile_urls(
44
51
45
52
if not len (urls ):
46
53
print (f"no tiles found for { easting [j ]} and { northing [j ]} " )
47
- file_urls .extend (urls )
54
+ dataSiteMonth ['data' ]['files' ].append (urls )
55
+ file_urls .append (dataSiteMonth )
56
+
48
57
print (f'{ len (file_urls )} files found' )
49
58
return file_urls
0 commit comments