Changes for misskey - using module

This commit is contained in:
Lord Of Nougate 2022-07-18 21:51:01 +02:00
parent 79c5ba4b30
commit 35f91f8f00
2 changed files with 17 additions and 15 deletions

View File

@ -5,29 +5,24 @@
import os
import configparser
import requests
from misskey import Misskey
# Reading config
config = configparser.ConfigParser()
config.read(os.path.dirname(__file__) + '/config.ini')
# Setting login variables
server_token = config['server']['token']
server_url = config['server']['url']
def toot(mastodon_url: str, body: str, mastodon_token: str):
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
)
mk = Misskey(server_url, i=server_token)
if os.getenv('radarr_eventtype'):
if os.getenv('radarr_eventtype') == 'Download':
body = "New content added to Jellyfin: \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'):
@ -41,9 +36,13 @@ if os.getenv('sonarr_eventtype'):
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)
toot(server_url, body, server_token)
mk.notes_create(
text=body
)
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
View File

@ -0,0 +1,3 @@
Misskey.py
configparser
requests