Last active
April 13, 2017 13:31
-
-
Save arumic/2bb08a04588721f328bafedae73ba3b9 to your computer and use it in GitHub Desktop.
Bansheeで再生中の曲情報を、Mastodonでnowplayingする。
This file contains 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
# coding: utf-8 | |
# インスタンスにログインする | |
from mastodon import Mastodon | |
mastodon = Mastodon( | |
client_id="cred.txt", # register.pyで生成したファイル | |
api_base_url = "https://mastodon.cloud") # インスタンスのエンドポイント | |
mastodon.log_in( | |
"your_login@email.address", # ログインに使うメールアドレス | |
"your_password", # パスワード | |
to_file="auth.txt") # 生成するファイル名 |
This file contains 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
# coding: utf-8 | |
from mastodon import Mastodon | |
import subprocess | |
mastodon = Mastodon( | |
client_id="cred.txt", # register.pyで生成したファイル | |
access_token="auth.txt", # login.pyで生成したファイル | |
api_base_url = "https://mastodon.cloud") # インスタンスのエンドポイント | |
# コマンドラインで曲情報を取得し、いらない部分を取る | |
title = subprocess.check_output("banshee --query-title", shell = True, universal_newlines=True)[7:-1] | |
artist = subprocess.check_output("banshee --query-artist", shell = True, universal_newlines=True)[8:-1] | |
album = subprocess.check_output("banshee --query-album", shell = True, universal_newlines=True)[7:-1] | |
trucknumber = subprocess.check_output("banshee --query-track-number", shell = True, universal_newlines=True)[14:-1] | |
# ハッシュタグを付けたりする | |
msg = "#nowplaying " + title + " - " + artist + " [" + album + " Tr." + trucknumber + "]" | |
# トゥート! | |
mastodon.toot(msg) |
This file contains 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
# coding: utf-8 | |
# インスタンスにアプリケーションを登録 | |
from mastodon import Mastodon | |
Mastodon.create_app("mastodon-banshee-nowplaying", # アプリケーション名 | |
api_base_url = "https://mastodon.cloud", # インスタンスのエンドポイント | |
to_file = "cred.txt" # 生成するファイル名 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment