|
20 | 20 | type=str, |
21 | 21 | ) |
22 | 22 | parser.add_argument( |
23 | | - "--publish", help="Publish the draft.", action="store_true", default=True |
| 23 | + "--publish", help="Publish the draft.", action="store_false", default=False |
24 | 24 | ) |
25 | 25 | parser.add_argument( |
26 | 26 | "--cookies", |
|
38 | 38 |
|
39 | 39 | api = Api( |
40 | 40 | email=os.getenv("EMAIL") if not cookies_path and not cookies_string else None, |
41 | | - password=os.getenv("PASSWORD") if not cookies_path and not cookies_string else None, |
| 41 | + password=os.getenv("PASSWORD") |
| 42 | + if not cookies_path and not cookies_string |
| 43 | + else None, |
42 | 44 | cookies_path=cookies_path, |
43 | 45 | cookies_string=cookies_string, |
44 | 46 | publication_url=os.getenv("PUBLICATION_URL"), |
|
67 | 69 | draft = api.post_draft(post.get_draft()) |
68 | 70 |
|
69 | 71 | # post.set_section(post_data.get("section"), api.get_sections()) |
70 | | - api.put_draft(draft.get("id"), draft_section_id=post.draft_section_id) |
| 72 | + put_draft_kwargs = { |
| 73 | + "draft_section_id": post.draft_section_id, |
| 74 | + "search_engine_title": post_data.get("search_engine_title"), |
| 75 | + "search_engine_description": post_data.get("search_engine_description"), |
| 76 | + "slug": post_data.get("slug"), |
| 77 | + } |
| 78 | + # Remove None values so we only send fields that were explicitly provided |
| 79 | + put_draft_kwargs = {k: v for k, v in put_draft_kwargs.items() if v is not None} |
| 80 | + |
| 81 | + api.put_draft(draft.get("id"), **put_draft_kwargs) |
71 | 82 |
|
72 | 83 | api.add_tags_to_post(draft.get("id"), post_data.get("tags", [])) |
73 | 84 |
|
|
0 commit comments