-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix HDSpace pubdate parsing #5111
Conversation
So it will handle date times like: yesterday at 12:00:00
no need for log.exception here.
Cleanup the log.
calculate_date is not used anymore.
medusa/providers/generic_provider.py
Outdated
return datetime.now(tz.tzlocal()) - timedelta(seconds=seconds) | ||
|
||
if fromtimestamp: | ||
dt = datetime.fromtimestamp(int(pubdate), tz=tz.gettz('UTC')) | ||
else: | ||
dt = parser.parse(pubdate, dayfirst=df, yearfirst=yf, fuzzy=True) | ||
from tzlocal import get_localzone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to remove the import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@p0psicles You marked as resolved but the import is still there
Edit: Marked as unresolved
@@ -574,12 +574,25 @@ def parse_pubdate(pubdate, human_time=False, timezone=None, **kwargs): | |||
matched_time = int(round(float(matched_time.strip()))) | |||
|
|||
seconds = parse('{0} {1}'.format(matched_time, matched_granularity)) | |||
if seconds is None: | |||
log.warning('Failed parsing human time: {0} {1}', matched_time, matched_granularity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the warning is needed since it's already going to cause an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but up until now we often had to guess why
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but now the exception includes the details you added to the warning log, so you don't really need the log?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exeception details are not logged down the stack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see now. Sorry I missed that.
'expected': datetime.now().replace(microsecond=0, tzinfo=tz.gettz('UTC')) - timedelta(days=1, minutes=10, seconds=25), | ||
'human_time': False | ||
}, | ||
{ # p22: hd-space test human date like today at 12:00:00 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be # p23
@@ -127,6 +127,16 @@ | |||
'timezone': 'US/Eastern', | |||
'fromtimestamp': True | |||
}, | |||
{ # p22: hd-space test human date like yesterdat at 12:00:00 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: yesterday
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Just waiting for supers test/go |
fix #5100
@duramato