Created
August 11, 2023 04:21
-
-
Save mrsipan/381b5e535b07a09c21b9a75a4270530c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from oauth2client import client | |
from googleapiclient import sample_tools | |
import sys | |
import argparse | |
def main(argv=sys.argv): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-d', '--draft', dest='isDraft', action='store_true', | |
help='Is draft') | |
parser.add_argument('-b', '--blog-id', dest='blogId', help='Blog id') | |
settings = parser.parse_args() | |
svc, flags = sample_tools.init( | |
[''], | |
'blogger', | |
'v3', | |
__doc__, | |
__file__, | |
scope="https://www.googleapis.com/auth/blogger", | |
) | |
return svc.posts().insert( | |
blogId=settings.blogId, | |
# The first line of the input is the title | |
# The rest is the content | |
body=dict(title=sys.stdin.readline(), content=sys.stdin.read()), | |
isDraft=settings.isDraft, | |
fetchImages=True, | |
).execute() | |
if __name__ == '__main__': | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment