forked from NussNougate/arr-mastodon
Changes for misskey - using module
This commit is contained in:
parent
79c5ba4b30
commit
35f91f8f00
@ -5,29 +5,24 @@
|
|||||||
import os
|
import os
|
||||||
import configparser
|
import configparser
|
||||||
import requests
|
import requests
|
||||||
|
from misskey import Misskey
|
||||||
|
|
||||||
|
# Reading config
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(os.path.dirname(__file__) + '/config.ini')
|
config.read(os.path.dirname(__file__) + '/config.ini')
|
||||||
|
# Setting login variables
|
||||||
server_token = config['server']['token']
|
server_token = config['server']['token']
|
||||||
server_url = config['server']['url']
|
server_url = config['server']['url']
|
||||||
|
|
||||||
def toot(mastodon_url: str, body: str, mastodon_token: str):
|
mk = Misskey(server_url, i=server_token)
|
||||||
headers = {}
|
|
||||||
headers["Authorization"] = f"Bearer {mastodon_token}"
|
|
||||||
|
|
||||||
data = {}
|
|
||||||
data["status"] = body
|
|
||||||
|
|
||||||
response = requests.post(
|
|
||||||
url=f"{mastodon_url}/api/v1/statuses", data=data, headers=headers
|
|
||||||
)
|
|
||||||
|
|
||||||
if os.getenv('radarr_eventtype'):
|
if os.getenv('radarr_eventtype'):
|
||||||
if os.getenv('radarr_eventtype') == 'Download':
|
if os.getenv('radarr_eventtype') == 'Download':
|
||||||
body = "New content added to Jellyfin: \n"
|
body = "New content added to Jellyfin: \n"
|
||||||
body += "Movie: " + os.getenv('radarr_movie_title') + '\n'
|
body += "Movie: " + os.getenv('radarr_movie_title') + '\n'
|
||||||
toot(server_url, body, server_token)
|
mk.notes_create(
|
||||||
|
text=body
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if os.getenv('sonarr_eventtype'):
|
if os.getenv('sonarr_eventtype'):
|
||||||
@ -41,9 +36,13 @@ if os.getenv('sonarr_eventtype'):
|
|||||||
release_quality = os.getenv('sonarr_episodefile_quality')
|
release_quality = os.getenv('sonarr_episodefile_quality')
|
||||||
body += "%s - S%sE%s - %s [%s]\n" % (series_title, season_number, episode_number, episode_title, release_quality)
|
body += "%s - S%sE%s - %s [%s]\n" % (series_title, season_number, episode_number, episode_title, release_quality)
|
||||||
|
|
||||||
toot(server_url, body, server_token)
|
mk.notes_create(
|
||||||
|
text=body
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if os.getenv('sonarr_eventtype') == 'Test':
|
if os.getenv('sonarr_eventtype') == 'Test':
|
||||||
toot(server_url, "Test message", server_token)
|
mk.notes_create(
|
||||||
|
text="Test message from jellybot"
|
||||||
|
)
|
||||||
|
|
||||||
|
3
requirements.txt
Executable file
3
requirements.txt
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
Misskey.py
|
||||||
|
configparser
|
||||||
|
requests
|
Reference in New Issue
Block a user