From 9828dabee15790ab7f9202dc0cc96cc5a70db4b2 Mon Sep 17 00:00:00 2001 From: Oliver Matthews Date: Sun, 12 Jul 2020 22:31:48 +0100 Subject: [PATCH] ensure timestamps are always valid --- README.md | 2 ++ thingy_grabber.py | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ee37b71..e78abff 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,8 @@ python3, beautifulsoup4, requests, lxml - 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.8.7 + - Always, Always generate a valid time stamp. * v0.8.6 - Handle thingiverse returning no files for a thing gracefully. * v0.8.5 diff --git a/thingy_grabber.py b/thingy_grabber.py index 02ea355..6e57a0d 100755 --- a/thingy_grabber.py +++ b/thingy_grabber.py @@ -23,6 +23,7 @@ from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.firefox.options import Options import atexit +import py7zr URL_BASE = "https://www.thingiverse.com" URL_COLLECTION = URL_BASE + "/ajax/thingcollection/list_collected_things" @@ -40,7 +41,7 @@ RETRY_COUNT = 3 MAX_PATH_LENGTH = 250 -VERSION = "0.8.6" +VERSION = "0.8.7" #BROWSER = webdriver.PhantomJS('./phantomjs') @@ -388,6 +389,12 @@ class Thing: # add the .split(' ')[0] to remove the timestamp from the old style timestamps last_bits = [int(x) for x in timestamp_handle.readlines()[0].split(' ')[0].split("-")] logging.warning(last_bits) + if last_bits[0] == 0: + last_bits[0] = 1 + if last_bits[1] == 0: + last_bits[1] = 1 + if last_bits[2] == 0: + last_bits[2] = 1980 try: self.last_time = datetime.datetime(last_bits[0], last_bits[1], last_bits[2]) except ValueError: -- 2.20.1