示例#1
0
 def __init__(
     self,
     caption,
     create_date,
     height,
     id,
     image_urls,
     is_bookmarked,
     is_muted,
     meta_pages,
     meta_single_page,
     page_count,
     restrict,
     sanity_level,
     series,
     tags,
     title,
     tools,
     total_bookmarks,
     total_view,
     type,
     user,
     visible,
     width,
     x_restrict,
     client=None,
     total_comments=None,
 ):
     self.caption = caption
     self.create_date = parse_timestamp(create_date)
     self.height = height
     self.id = id
     self.image_urls = {
         **{Size(s): u for s, u in image_urls.items()},
         Size.ORIGINAL: meta_single_page.get("original_image_url", None),
     }
     self.is_bookmarked = is_bookmarked
     self.is_muted = is_muted
     self.meta_pages = [
         {Size(s): u for s, u in p["image_urls"].items()} for p in meta_pages
     ]
     self.page_count = page_count
     self.restrict = restrict
     self.sanity_level = sanity_level
     self.series = series
     self.tags = tags
     self.title = title
     self.tools = tools
     self.total_bookmarks = total_bookmarks
     self.total_view = total_view
     self.type = ContentType(type)
     self.user = User(**user)
     self.visible = visible
     self.width = width
     self.x_restrict = x_restrict
     self.client = client
     self.total_comments = total_comments
示例#2
0
 def __init__(
     self,
     caption,
     create_date,
     id,
     image_urls,
     is_bookmarked,
     is_muted,
     is_mypixiv_only,
     is_x_restricted,
     is_original,
     page_count,
     restrict,
     series,
     tags,
     text_length,
     title,
     total_bookmarks,
     total_comments,
     total_view,
     user,
     visible,
     x_restrict,
     client=None,
 ):
     self.caption = caption
     self.create_date = parse_timestamp(create_date)
     self.id = id
     self.image_urls = {Size(s): u for s, u in image_urls.items()}
     self.is_bookmarked = is_bookmarked
     self.is_muted = is_muted
     self.is_mypixiv_only = is_mypixiv_only
     self.is_x_restricted = is_x_restricted
     self.is_original = is_original
     self.page_count = page_count
     self.restrict = restrict
     self.series = series
     self.tags = tags
     self.text_length = text_length
     self.title = title
     self.total_bookmarks = total_bookmarks
     self.total_comments = total_comments
     self.total_view = total_view
     self.user = User(**user)
     self.visible = visible
     self.x_restrict = x_restrict
     self.client = client
示例#3
0
 def __init__(self, comment, date, id, parent_comment, user, client=None):
     self.comment = comment
     self.date = parse_timestamp(date)
     self.id = id
     self.parent_comment = (
         Comment(
             comment=parent_comment["comment"],
             date=parent_comment["date"],
             id=parent_comment["id"],
             parent_comment={},
             user=parent_comment["user"],
             client=client,
         )
         if parent_comment
         else None
     )
     self.user = User(**user)
     self.client = client
示例#4
0
def test_parse_timestamp_no_colon():
    expected = datetime(2020, 1, 1, 0, 0, tzinfo=timezone(timedelta(seconds=32400)))
    assert parse_timestamp("2020-01-01T00:00:00+0900") == expected