-
Notifications
You must be signed in to change notification settings - Fork 200
Update Marker class #505
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
Update Marker class #505
Conversation
Addressing #504 remove field attribute as it is no longer available. adding `__repr__` to Marker class resulting in `<Marker:intro:139770:230481>`
plexapi/media.py
Outdated
| name = self._clean(self.firstAttr('type')) | ||
| start = self._clean(self.firstAttr('start')) | ||
| end = self._clean(self.firstAttr('end')) | ||
| return '<%s>' % ':'.join([p for p in [self.__class__.__name__, name, start, end] if p]) |
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.
Since we are adding a repr, lets show the start and end in "human" time in the repr
def sec_to_hh_mm_ss(seconds):
return time.strftime("%H:%M:%S", time.gmtime(seconds))
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.
Seconds: [<Marker:intro:139770:230481>]
Human: [<Marker:intro:0:02:19:0:03:50>]
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.
Looks like it's actually milliseconds. I've adjusted the code to fit.
def mill_sec_to_hh_mm_ss(milliseconds):
if not isinstance(milliseconds, int):
milliseconds = cast(int, milliseconds)
hhmmsssm = timedelta(milliseconds=milliseconds)
return str(hhmmsssm).split(".")[0]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.
Cant you change it to this one, make the format more correct and is more precice
def ms_to_hh_mm_ms(ms):
r = datetime.datetime.utcfromtimestamp(ms/1000)
f = r.strftime("%H:%M:%S.%f")
return f[:-2]
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.
Also Change the repr so its [<Marker:intro: 00:02:19 - 00:03:50>]
Addressing #504
remove field attribute as it is no longer available.
adding
__repr__to Marker class resulting in<Marker:intro:139770:230481>