Exemplo n.º 1
0
    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}
Exemplo n.º 2
0
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]}
Exemplo n.º 3
0
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]}
Exemplo n.º 4
0
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]}
Exemplo n.º 5
0
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]}
Exemplo n.º 6
0
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')
Exemplo n.º 7
0
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')