File tree 1 file changed +10
-4
lines changed
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -59,16 +59,22 @@ def rm(self, path):
59
59
def url (self , path ):
60
60
"""Get server URL for a file key"""
61
61
config = Config ()
62
+ api = API ()
62
63
63
64
if config .config .has_section ("media" ) is False :
64
65
config .config .add_section ("media" )
65
66
66
67
try :
67
68
location = config ["media" ][path ]
68
69
except KeyError :
69
- click .secho (f"Could not locate media '{ path } '" , fg = "red" )
70
+ click .secho (f"Could not locate local media '{ path } '" , fg = "red" )
70
71
return 1
71
72
72
- base_url = config ["config" ]["url" ]
73
- base_url = base_url .rstrip ("/" )
74
- return f"{ base_url } { location } "
73
+ remote_files = api .get ("/api/v1/files?type=page" ).json ()["data" ]
74
+ for remote_file in remote_files :
75
+ if f"/files/{ remote_file ['location' ]} " == location :
76
+ base_url = config ["config" ]["url" ]
77
+ base_url = base_url .rstrip ("/" )
78
+ return f"{ base_url } { location } "
79
+ click .secho (f"Could not locate remote media '{ path } '" , fg = "red" )
80
+ return 1
You can’t perform that action at this time.
0 commit comments