fix file get v0.10.2
authorOliver Matthews <oliver@codersoffortune.net>
Fri, 7 Aug 2020 00:12:48 +0000 (01:12 +0100)
committerOliver Matthews <oliver@codersoffortune.net>
Fri, 7 Aug 2020 00:13:01 +0000 (01:13 +0100)
README.md
thingy_grabber.py

index 89ede2c..07520c2 100644 (file)
--- a/README.md
+++ b/README.md
@@ -101,7 +101,9 @@ python3, requests, py7xr (>=0.8.2)
 - If there is an updated file, the old directory will be moved to `name_timestamp` where `timestamp` is the last upload time of the old files. The code will then copy unchanged files across and download any new ones.
 
 ## Changelog
-* V0.10.1
+* v0.10.2
+  - Fixed regression in rest API
+* v0.10.1
   - A couple of minor bug fixes on exception handling.
 * v0.10.0
   - API access! new -a option to provide an API key for more stable access.
index 16f84db..59b5ff5 100755 (executable)
@@ -40,6 +40,7 @@ API_COLLECTION_THINGS = API_BASE + "/collections/{}/things/?" + ACCESS_QP
 API_THING_DETAILS = API_BASE + "/things/{}/?" + ACCESS_QP
 API_THING_FILES = API_BASE + "/things/{}/files/?" + ACCESS_QP
 API_THING_IMAGES = API_BASE + "/things/{}/images/?" + ACCESS_QP
+API_THING_DOWNLOAD = "/download/?" + ACCESS_QP
 
 API_KEY = None
 
@@ -48,7 +49,7 @@ RETRY_COUNT = 3
 
 MAX_PATH_LENGTH = 250
 
-VERSION = "0.10.1"
+VERSION = "0.10.2"
 
 TIMESTAMP_FILE = "timestamp.txt"
 
@@ -401,7 +402,7 @@ class Thing:
             logging.debug("Parsing link: {}".format(sanitise_url(link['url'])))
             try:
                 datestamp = datetime.datetime.strptime(link['date'], DEFAULT_DATETIME_FORMAT)
-                self._file_links.append(FileLink(link['name'], datestamp, link['url']))
+                self._file_links.append(FileLink(link['name'], datestamp, link['url'] + API_THING_DOWNLOAD.format(API_KEY)))
             except ValueError:
                 logging.error(link['date'])
 
@@ -599,7 +600,6 @@ class Thing:
         logging.debug("Generating download_dir")
         os.mkdir(self.download_dir)
         filelist_file = os.path.join(self.download_dir, "filelist.txt")
-        url_suffix = "/?" + ACCESS_QP.format(API_KEY)
         with open(filelist_file, 'w', encoding="utf-8") as fl_handle:
             for fl in self._file_links:
               fl_handle.write("{},{},{}\n".format(fl.link, fl.name, fl.last_update))
@@ -633,7 +633,7 @@ class Thing:
                 file_name = truncate_name(os.path.join(self.download_dir, file_link.name))
                 logging.debug("Downloading {} from {} to {}".format(
                     file_link.name, file_link.link, file_name))
-                data_req = SESSION.get(file_link.link + url_suffix)
+                data_req = SESSION.get(file_link.link)
                 if data_req.status_code != 200:
                     logging.error("Unexpected status code {} for {}: {}".format(data_req.status_code, sanitise_url(file_link.link), data_req.text))
                     fail_dir(self.download_dir)