Skip to content

Commit 716a5ec

Browse files
authored
use res['title'] to as a new filename (#82)
1 parent 23dd102 commit 716a5ec

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

hvpy/facade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def getJP2Header(
6666
--------
6767
>>> from hvpy import getJP2Header
6868
>>> getJP2Header(id=7654321,callback="xml_header")
69-
'xml_header(\\\'<?xml version="1.0" encoding="utf-8"?><meta><fits><SIMPLE>1</SIMPLE><BITPIX>16</BITPIX>...')'
69+
'xml_header(\\\'<?xml version="1.0" encoding="utf-8"?><meta><fits>...')'
7070
"""
7171
params = getJP2HeaderInputParameters(id=id, callback=callback)
7272
return execute_api_call(input_parameters=params)

hvpy/helpers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def createMovie(
5959
Default is `False`.
6060
filename
6161
The path to save the file to.
62-
Optional, will default to ``f"{res['id']}_{startTime.date()}_{endTime.date()}.{format}"``.
62+
Optional, will default to ``f"{res['title']}.{format}"``.
6363
hq
6464
Download a higher-quality movie file (valid for "mp4" movies only, ignored otherwise).
6565
Default is `False`, optional.
@@ -97,6 +97,7 @@ def createMovie(
9797
if res.get("error"):
9898
raise RuntimeError(res["error"])
9999
timeout_counter = time.time() + 60 * timeout # Default 5 minutes
100+
title = ""
100101
while True:
101102
status = getMovieStatus(
102103
id=res["id"],
@@ -106,6 +107,7 @@ def createMovie(
106107
if status["status"] in [0, 1]:
107108
time.sleep(3)
108109
if status["status"] == 2:
110+
title = status["title"]
109111
break
110112
if time.time() > timeout_counter:
111113
raise RuntimeError(f"Exceeded timeout of {timeout} minutes.")
@@ -117,7 +119,7 @@ def createMovie(
117119
hq=hq,
118120
)
119121
if filename is None:
120-
filename = f"{res['id']}_{startTime.date()}_{endTime.date()}.{format}"
122+
filename = f"{title}.{format}"
121123
else:
122124
filename = f"{filename}.{format}"
123125
save_file(

0 commit comments

Comments
 (0)