見出し画像

【OAuth2】Tumblrでフォルダ内の画像をまとめて予約投稿する

指定したローカルフォルダ内の画像を全て、Tumblrのキューに追加するコードです。
PythonでOAuth2で認証してTumblr APIを使用します。

下記リンクの動作を自動化したものです。

https://cohaq.net/cohaq_blog/tumblr-posts-oauth2/



使用方法

操作

(1)標準ブラウザでTumblrにログインします。
(2)実行します。

python tumblr.py

(3)フォルダを選択します。
(4)許可をクリックします。

(5)フォルダ内のすべての画像(png)が予約投稿されます。

初回のみの操作

(1)初回のみTumblr APIにアプリの登録が必要です。
以下のリンクにログインし、"アプリを登録する"をクリックします。

(2)フォームを入力します。

  • アプリケーション名

    • bulk_post_for_queue

  • アプリケーションウェブサイト

    • 何でも良いです。機能には影響しません。自分のブログなりSNSがあればそのアドレスでも良いと思います。

  • アプリケーションの説明

    • add multiple images to the queue all at once (何でも良いです。)

  • 管理用の連絡先メール

    • 自分のメールアドレスを入力します(特に使いません)。

  • デフォルトのコールバックURL

    • http://localhost:8000 (特に使いません)

  • OAuth2リダイレクトURL

    • http://localhost:8000

(3)アプリが登録されます。環境変数にConsumer KeyとSecret keyを設定します。Secret keyは、Show secret keyをクリックすると表示されます。

TUMBLR_CONSUMER_KEY={Consumer Key}
TUMBLR_CONSUMER_SECRET={Secret Key}

環境変数を用いず、コードを書き換えても特に問題ありません。

(4)環境変数にAPIのURLを設定します。

TUMBLR_POSTS_URL=https://api.tumblr.com/v2/blog/{blog-identifier}/post
{blog-identifier}は、Tumblrのユーザー名です。https://www.tumblr.com/{blog-identifier}の部分です。

環境変数を用いず、コードを書き換えても特に問題ありません。

コード

使い方がよくわからない、うまく動かない等ございましたら、ページ最下部の「クリエイターへのお問い合わせ」からお願いします。
pythonの環境構築については分かりやすいサイトが多くありますので、環境に合わせてご参照ください。
APIの仕様変更にはできる限り対応いたしますが、ローカルからのアップロードを禁止するような変更があった場合など、どうしても対応が難しい場合もございますので、ご理解のうえご購入ください。

If you're unsure how to use it or if it's not working properly, please contact the creator through the "Contact the Creator" link at the bottom of the page. There are many sites that provide clear instructions for setting up a Python environment, so please refer to them according to your environment. We will try our best to accommodate any changes in the API specifications. However, please understand that there might be situations where it is difficult to provide support, such as changes that prohibit uploads from local systems, before making your purchase.

ここから先は

7,822字

¥ 2,000

この記事が気に入ったらサポートをしてみませんか?