Skip to content

Conversation

@blacktwin
Copy link
Collaborator

Addressing #504

remove field attribute as it is no longer available.
adding __repr__ to Marker class resulting in <Marker:intro:139770:230481>

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])
Copy link
Collaborator

@Hellowlol Hellowlol Jun 13, 2020

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))

Copy link
Collaborator Author

@blacktwin blacktwin Jun 13, 2020

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>]

Copy link
Collaborator Author

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]

Copy link
Collaborator

@Hellowlol Hellowlol Jun 14, 2020

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]

Copy link
Collaborator

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>]

@Hellowlol Hellowlol merged commit 37c8575 into master Jun 14, 2020
@Hellowlol Hellowlol deleted the intro_update branch June 14, 2020 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants