def to_json(self): metadata = { "collected_at": timestamp(self.collected_at), "media_type": "digital", "resolution": self.resolution, "hdr": self.hdr, "audio": self.audio_codec, "audio_channels": self.audio_channels, } return {k: v for k, v in metadata.items() if v is not None}
def add_to_history(media, watched_at=None): """Add a :class:`Movie`, :class:`TVShow`, or :class:`TVEpisode` to your watched history :param media: The media object to add to your history :param watched_at: A `datetime.datetime` object indicating the time at which this media item was viewed """ if watched_at is None: watched_at = datetime.now() data = dict(watched_at=timestamp(watched_at)) data.update(media.ids) yield 'sync/history', {media.media_type: [data]}
def rate(media, rating, rated_at=None): """Add a rating from 1 to 10 to a :class:`Movie`, :class:`TVShow`, or :class:`TVEpisode` :param media: The media object to post a rating to :param rating: A rating from 1 to 10 for the media item :param rated_at: A `datetime.datetime` object indicating the time at which this rating was created """ if rated_at is None: rated_at = datetime.now() data = dict(rating=rating, rated_at=timestamp(rated_at)) data.update(media.ids) yield 'sync/ratings', {media.media_type: [data]}
def test_timestamp(): """verify that the trakt timestamp converter works as expected""" meow = datetime.now() result = timestamp(meow) assert result.startswith(str(meow.year)) assert result.endswith('.000Z')
def test_timestamp(): """verify that the trakt timestamp converer works as expected""" meow = datetime.now() result = timestamp(meow) assert result.startswith(str(meow.year)) assert result.endswith('.000Z')