{"id":24270689,"url":"https://github.com/raghur/easyblogger","last_synced_at":"2025-04-05T14:04:06.635Z","repository":{"id":16458104,"uuid":"79981521","full_name":"raghur/easyblogger","owner":"raghur","description":"Python client for Blogger platform. Write blog posts in Markdown or asciidoc and publish them on Blogger.","archived":false,"fork":false,"pushed_at":"2025-03-28T01:17:05.000Z","size":238,"stargazers_count":51,"open_issues_count":16,"forks_count":19,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T13:05:02.634Z","etag":null,"topics":["asciidoc","blogger","blogger-api","cli-utilities","markdown","pandoc","vim"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raghur.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-25T04:02:21.000Z","updated_at":"2025-03-16T17:10:22.000Z","dependencies_parsed_at":"2023-10-10T20:35:08.600Z","dependency_job_id":"9fd68c7c-a59f-45c9-a093-d51742ad87c4","html_url":"https://github.com/raghur/easyblogger","commit_stats":{"total_commits":294,"total_committers":4,"mean_commits":73.5,"dds":0.3945578231292517,"last_synced_commit":"19b322d5a77996142de822ea6bc020fe02dc5270"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raghur%2Feasyblogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raghur%2Feasyblogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raghur%2Feasyblogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raghur%2Feasyblogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raghur","download_url":"https://codeload.github.com/raghur/easyblogger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345850,"owners_count":20924102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asciidoc","blogger","blogger-api","cli-utilities","markdown","pandoc","vim"],"created_at":"2025-01-15T16:54:30.798Z","updated_at":"2025-04-05T14:04:06.607Z","avatar_url":"https://github.com/raghur.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"EasyBlogger\n===========\n\n[![Build Status](https://travis-ci.org/raghur/easyblogger.svg?branch=master)](https://travis-ci.org/raghur/easyblogger)\n[![Coverage Status](https://coveralls.io/repos/github/raghur/easyblogger/badge.svg?branch=master)](https://coveralls.io/github/raghur/easyblogger?branch=master)\n[![PyPI](https://img.shields.io/pypi/v/easyblogger.svg)](https://pypi.python.org/pypi/easyblogger)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/Easyblogger.svg)](https://pypi.python.org/pypi/easyblogger)\n[![Updates](https://pyup.io/repos/github/raghur/easyblogger/shield.svg)](https://pyup.io/account/repos/github/raghur/easyblogger/)\n\nBlog to blogger from the command line.\n\nWhy not googlecl?\n-----------------\n\nI tried. Didn't work. `googlecl` is just too rough and isn't easy to\nscript. For ex:\n\n1.  No way to update a post\n2.  Doesn't work with blog and post ids.\n3.  and others...\n\nSo what does this do?\n---------------------\n\n1.  Provides a command line tool and create, update or delete posts on\n    Blogger hosted blogs.\n2.  Post content can be piped in - so you can use your favourite way to\n    generate html markup\n3.  Pandoc goodness - so that you can write your doc in any of the input\n    formats that Pandoc supports\n3.  More Pandoc goodness - supports pandoc filters so you can do nice things like\n    create diagrams with [`mermaid-filter`](https://github.com/raghur/mermaid-filter)\n4.  AsciiDoc support - Supports asciidoc as a source format as well using\n    `asciidoctor` \u0026 `asciidoctor-diagram`\n4.  You can also export your existing posts to your favourite\n    lightweight markup format like markdown etc as individual files.\n    Then edit them in a real editor, and publish them back! All pandoc\n    output formats!\n5.  Understands specially marked comments - so you can just hand it a\n    file and it'll figure out what to do - great for posting from vim\n    etc.\n\nInstallation, Configuration and Usage\n=====================================\n\nInstallation\n------------\n\n``` {.sourceCode .bash}\n# Now live on PyPI\nsudo pip install EasyBlogger\n```\n\nThis installs EasyBlogger and its dependencies. It also installs the\n`easyblogger` script\n\n### Pandoc\n\nInstall [pandoc](http://johnmacfarlane.net/pandoc/installing.html) If\nyou're on cygwin, you can just install the windows dl and put\n`pandoc.exe` somewhere on path\n\nOAuth2 API Authentication and Authorization\n-------------------------------------------\n\nThe tool needs to be granted access to manage the blog. Google APIs use\nOAuth2.\n\n1.  First, get your blog id. You can find the blog id by viewing the\n    source. For ex. on my blog, I have the following lines near the top:\n\n    ``` {.sourceCode .html}\n    \u003clink rel=\"alternate\" type=\"application/atom+xml\" title=\"Nifty Tidbits - Atom\" href=\"http://blog.rraghur.in/feeds/posts/default\" /\u003e\n    \u003clink rel=\"alternate\" type=\"application/rss+xml\" title=\"Nifty Tidbits - RSS\" href=\"http://blog.rraghur.in/feeds/posts/default?alt=rss\" /\u003e\n    \u003clink rel=\"service.post\" type=\"application/atom+xml\" title=\"Nifty Tidbits - Atom\" href=\"http://www.blogger.com/feeds/7642453/posts/default\" /\u003e\n    ```\n\n    On the last link, the number `7642453` is the blogId\n\n2.  Authorize\n\n    **On Linux**\n\n    ``` {.sourceCode .bash}\n    # run through OAuth2 hoops... following needs to be run as root\n    # First find your blog Id\n\n    easyblogger --blogid \u003cyourblogid\u003e get\n\n    # This will first open a browser and ask you to sign in and\n    # approve access to your blog\n    ```\n\n    This will open a browser. You may see a chrome warning that it can't\n    be run as root - but you can ignore that. Once you authorize,\n    `~/.easyblogger.credentials` is created with your OAuth2 token\n\n\n    **On Windows**\n\n    If your `PATH` variable has the python Scripts folder, then you\n    should just be able to run `easyblogger --blogid \u003cid\u003e get` in a\n    command window. If not, then open a `cmd` window and navigate to\n    `\u003cpython install folder\u003e\\Scripts` and run\n    `python easyblogger --blogid \u003cyourblogid\u003e get`\n\n3.  All set!\n\n    That's it - you're all set!\n\n    You will need to repeat the OAuth2 authorization process if you ever\n    change the blog, or revoke permissions or if the auth token expires.\n\nVIM Configuration\n-------------------\n\n1. Stick the following in your `~/.vimrc`\n```vim\nfunc! s:systemwrapper(cmd)\n    echom a:cmd\n    let output=system(a:cmd)\n    return output\nendfunction\nfunc! BlogSave(file)\n    \" to debug, replace with\n    \" exec \"!easyblogger file \" . a:file\n    let output=s:systemwrapper(\"easyblogger file \". a:file)\n    echom output\nendfunction\ncommand! BlogSave call BlogSave(expand(\"%:p\"))\n```\n\n1. Start writing a post - create a markdown file (.md) with frontmatter in a comment\n```markdown\n\u003c!--\nid:\ntitle    : title\ntags   : [any, comma, separated, labels]\nformat\t : markdown\npublished: true\nfilters: \u003cpath to your filter\u003e\n--\u003e\n```\nNote that as of Easyblogger 3.0, the preferred frontmatter format is borrowed from Hugo.\nThe original frontmatter header in earlier versions is deprecated. However, if `easyblogger`\nfinds header using the older keys, then it will use them.\nWhile there should be no reason to prefer the old format, if you need that for whatever\nreason, you must specify `--legacy-frontmatter` flag in the `get` subcommand. For more\ndetails, refer to the Frontmatter section\n\n*LEGACY FRONTMATTER FORMAT*\n__still supported but you're encouraged to use the new format__\n```\n\u003c!--\nPostId:\nTitle    : title\nLabels   : any, comma, separated, labels\nFormat\t : markdown\nPublished: true\nfilters: \u003cpath to your filter\u003e\n--\u003e\n```\n\n2. If you prefer using `asciidoc`, then use the following comment header:\n```asciidoc\n+++\nid:\ntitle    : title\ntags   : [any, comma, separated, labels]\nformat\t : asciidoc\npublished: true\n+++\n```\n\n*LEGACY FRONTMATTER FORMAT*\n__still supported but you're encouraged to use the new format__\n```asciidoc\n////\nPostId:\nTitle    : title\nLabels   : any, comma, separated, labels\nFormat\t : asciidoc\nPublished: true\n////\n```\n\nAsciidoc does not require filters - it has a better system of plugins. Just\nensure that you have installed `asciidoctor` and `asciidoctor-diagram` gems\n\n1. When done, call `:BlogSave` and your blog will be published\n\nUsage\n-----\n\n### Getting posts\n\n1.  Get a list of posts post Id, title and url are output by default.\n\n    ``` {.sourceCode .bash}\n    # get a list of posts\n    # param : Blog Id - look at your blog's atom pub url - its the number in the url.\n    easyblogger --blogid 7642453 get\n\n    4424091495287409038,Moving from Wordpress.com to Blogger,http://blog.rraghur.in/2013/08/moving-from-wordpresscom-to-blogger.html\n    ...\n    ...\n    # 10 rows shown\n    ```\n\n2.  Filter by labels or search; specify `max` results to be returned.\n\n    ``` {.sourceCode .bash}\n    # get only the last 5 with tag 'vim'\n    # you can specify multiple tags - separate them with commas\n    easyblogger --blogid 7642453 get -l vim -c 5\n\n    # search for all posts with 'vim'\n    easyblogger --blogid 7642453 get -q vim -c 5\n    ```\n\n3.  Get a specific post by its id\n\n    ``` {.sourceCode .bash}\n    # get a specific post by id\n    easyblogger --blogid 7642453 get -p 3728334747597998671\n    ```\n\n4.  Get a specific post by its url\n\n    ``` {.sourceCode .bash}\n    # get a specific post by url\n    easyblogger --blogid 7642453 get -u https://blog.rraghur.in/2015/06/js-development-2015.html\n    ```\n\n5.  Control which fields are printed out.\n\n    ``` {.sourceCode .bash}\n    # output field control\n    easyblogger  get -p 3728334747597998671 -f \"id,title,url,labels\"\n    3728334747597998671,Rewriting history with Git,http://blog.rraghur.in/2012/12/rewriting-history-with-git.html,[u'git', u'HOWTO', u'Tips']\n    ```\n\n5.  Output in (lightweight) markup - very good for updates.\n    -   If its a single post, then its printed to console.\n\n        ``` {.sourceCode .bash}\n        easyblogger --blogid 7642453 get -p 3728334747597998671 -d markdown\n        ```\n\n        It also includes a header that will allow you to edit the file\n        and update the post back with the file subcommand below\n\n    -   if more than one post, then each post is written to a file (name\n        derived from the title)\n\n        ``` {.sourceCode .bash}\n        easyblogger --blogid 7642453 get -l vim -d markdown\n        ```\n\n    -   If you'd like to get a single post as a file, specific `-w` or\n        `--write-files`\n\n        ``` {.sourceCode .bash}\n        easyblogger --blogid 7642453 get -p 3728334747597998671 -d markdown --write-files\n        ```\n\n    -   Supports all mark up formats supported by `pandoc`\n\n        ``` {.sourceCode .bash}\n        # Output formats: native, json, docx, odt, epub, epub3, fb2, html, html5, s5,\n                 slidy, slideous, dzslides, docbook, opendocument, latex, beamer,\n                 context, texinfo, man, markdown, markdown_strict,\n                 markdown_phpextra, markdown_github, markdown_mmd, plain, rst,\n                 mediawiki, textile, rtf, org, asciidoc\n        ```\n\n### Default Args file\n\nSpecifying --blogid each time is just painful. You can set a default\nblogId by creating a default args file `~/.easyblogger` as follows:\n\n``` {.sourceCode .bash}\ncat \u003e ~/.easyblogger\n--blogid\n234567\n```\n\nAnd now you can type the command as:\n\n``` {.sourceCode .bash}\neasyblogger get\n```\n\nYou can override the args from file by providing the argument on the\ncommand line\n\n### Create a new blog post\n\nNote: ~~Blogger API v3 does not support/expose API for creating posts as drafts. Please ask for this feature on Google's blogger dev group - I'll add that capability once/if it becomes available.~~\n\nBlogs are created as drafts by default now. You can override this with the `--publish` flag\nwhich will post the blog directly (current behavior)\n\n``` {.sourceCode .bash}\n# create a post from stdin with title and labels\n\n\neasyblogger post -t \"Hello World\" -l \"python,hello\" -c \"Hello world!!!\" --date 2018-01-01T10:00:00\n```\n\nPipe out from any HTML generation mechanism\n\n``` {.sourceCode .bash}\npandoc -f markdown -  | easyblogger   --blogid 6136696198547817747 post -t 'Hello from Pandoc' -f -\n # Hello from Pandoc\nthis is a nice long post\n\n3295765957555899963\n```\n\nOr just tell easyblogger to convert from `markdown` with the --format\narg\n\n``` {.sourceCode .bash}\n# --format supports\n#                native,json,markdown,\n#                markdown_strict,markdown_phpextra,\n#                markdown_mmd,rst,mediawiki,\n#                docbook,textile,html,latex\n\neasyblogger post -t 'Hello from Pandoc' --format markdown -c \"##heading2\"\n\n2342323423423423423\n```\n\n### Update posts\n\nUpdate works with a patch request - only specify what you need changed\nBlogger API does not allow the blog permalink to be updated - so in case\nyou want to change that you'll need to delete and create another post\n(though you will probably lose comments etc - so only viable if you've\njust published it)\n\n``` {.sourceCode .bash}\neasyblogger update -t 'A new title' -l \"new,labels\" 3295765957555899963 --date 2018-01-01T10:00:00\n```\n\nYou can also update the contents by passing in the `--file` argument.\nPiping it in works too - use `--file -`; like so\n\n``` {.sourceCode .bash}\npandoc -f markdown -  | easyblogger  update -t 'Hello from Pandoc' --file - 3295765957555899963\n# This is h1\n## this is h2\n\nSome para text\n[EOF]\n```\n\n### Posting or Updating from a file\n\nI wrote `easyblogger` script primarily so I can blog from Vim. If your\nfile has properly formatted comments, then `EasyBlogger` will figure out\nwhat to do (insert or update) based on the metadata.\n\nSo, you can author a post like so:\n\n``` {.sourceCode .bash}\ncat MyBlogPost.md\n\u003c!--\nTitle: This is your title\nPostId:\nLabels: a,b,c\nformat: markdown\npublished: false\nPublishDate: 2018-01-01T10:00:00\nfilters: \u003cpath to your installed filter\u003e\n--\u003e\n# This is my content\n```\nThe example above uses legacy frontmatter format. You're encouraged to use the new\nformat which allows for additional metadata.\n\nAnd post it to your blog like so:\n\n``` {.sourceCode .bash}\neasyblogger file MyBlogPost.md\n```\n\nAnd `easyblogger` will update your post doc back with the `postId` of\nthe generated post. Now, if you edit the doc and publish again with the\nsame command, your post will be updated.\n\n### Deleting posts\n\nTo delete posts, you need to specify the post id\n\n``` {.sourceCode .bash}\neasyblogger delete 234546720561632959\n```\n\nFrontmatter\n==============\n\nAs you've seen, easyblogger relies on a comment header with specific keys for\nmetadata about the post as well as to drive the behavior of the program.\nWhen `EasyBlogger` started, I had come up with my own set of (minimal) keys.\nSomewhere in the 2.x days, I built support for the frontmatter format as defined\nin Hugo project(along with some specific keys used for Blogger) - this is especially\nuseful if you want to migrate off Blogger to Hugo.\n\nThe header format can be either TOML or YAML. The new frontmatter keys are the default both for input and output.\n\nOutput Rules\n--------------\nWhen writing to output files with `get`, easyblogger will write the header in\n1. Document format - asciidoc: Header in TOML enclosed by `+++`\n2. Legacy header keys - only if the command line specifies the `--legacy-frontmatter` flag\n\nInput Rules\n-------------\n1. Header enclosed with `+++` - parse as TOML\n2. Header encosed with HTML comment or `////` - parse as YAML\n3. If doc is TOML, then default format is supposed to be 'asciidoc' if not specified.\n4. If doc is YAML, then default format is supposed to be 'markdown' if not specified.\n\nIf any of the legacy frontmatter keys (`Title`, `PostId` etc) are present, then the legacy keys\nare expected. Otherwise the new style Hugo compliant headers are expected.\n\n### Frontmatter keys\n\n* New style (Hugo)\n    ```toml\n    +++\n    title = \"Proxy PAC file for work\"\n    id = \"293493242234\"\n    tags = [ \"Rants\", \"Tips\", \"Utilities\",]\n    aliases = [ \"http://niftybytes.blogspot.com/2018/04/proxy-pac-file-for-work_30.html\",]\n    publishdate = 2018-04-30T12:42:00+05:30\n    draft = false\n    date = 2018-04-30T12:42:00+05:30\n    lastmod = 2018-04-30T12:47:37+05:30\n    +++\n    ```\n* Old style (Easyblogger)\n    ```\n    \u003c!--\n    Labels: [Rants, Tips, Utilities]\n    PostId: '8010087245053438499'\n    Published: true\n    PublishDate: 2018-04-30T12:42:00\n    Title: Proxy PAC file for work\n    --\u003e\n    ```\n\nUsing EasyBlogger as a library\n==============================\n\nUsing EasyBlogger class\n-----------------------\n\nFeel free to use the EasyBlogger class in your own tool/utility whatever\nelse. Just remember:\n\n1.  Use your own API client id (see below)\n2.  Include an attribution and a link to EasyBlogger - not mandatory\n    -but just be nice:)\n\n### Client API ids\n\nIf you're using EasyBlogger class in your tool/utility, please then\nregister for API access at [Google's API\nconsole](https://code.google.com/apis/console). Create a client id and\nsecret key at the API access page and request for Blogger API access.\nOnce you have API access authorized, you're good to get started. Just\ncreate the `EasyBlogger` constructor with your client id and secret\n\nIf you're integrating by shelling out, then stick the API key and client\nid in the command line with `--clientid` and `--secret` args. You can\nalso stick them in the `~/.easyblogger` file to avoid specifying them\neach time\n\nDev Guide\n=========\n\n1.  Clone the repo\n2.  Start a virtualenv - `virtualenv .dev`\n3.  Activate it - `.dev\\Scripts\\activate`\n4.  Install dependencies - `pip install -r requirements.txt`\n5.  `pip install -e .`\n\n### Running tests\n\n1.  Exit out of any virtualenvs\n2.  Run `tox`\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraghur%2Feasyblogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraghur%2Feasyblogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraghur%2Feasyblogger/lists"}