36 lines
1010 B
Python
36 lines
1010 B
Python
from jellyfin_apiclient_python import JellyfinClient
|
|
import json
|
|
import uuid
|
|
import subprocess
|
|
from dotenv import load_dotenv
|
|
import os
|
|
|
|
client = JellyfinClient()
|
|
|
|
load_dotenv()
|
|
|
|
client.config.app('FinPod', '0.0.1', 'FinPod prototype', 'FinPod_prototype_1')
|
|
client.config.data["auth.ssl"] = True
|
|
play_id = str(uuid.uuid4())
|
|
container = "flac"
|
|
client.auth.connect_to_address(os.getenv("host"))
|
|
client.auth.login(os.getenv("URL"), os.getenv("username"), os.getenv("password"))
|
|
|
|
credentials = client.auth.credentials.get_credentials()
|
|
server = credentials["Servers"][0]
|
|
server["username"] = 'username'
|
|
print(json.dumps(server))
|
|
|
|
ffmpeg = subprocess.Popen(
|
|
["ffmpeg", "-i", "pipe:0", "-f", "wav", "pipe:1"],
|
|
stdin=subprocess.PIPE,
|
|
stdout=subprocess.PIPE
|
|
)
|
|
|
|
aplay = subprocess.Popen(
|
|
["aplay"],
|
|
stdin=ffmpeg.stdout
|
|
)
|
|
freebird = client.jellyfin.search_media_items(
|
|
term="Free Bird", media="Music")['Items'][0]
|
|
client.jellyfin.get_audio_stream(ffmpeg.stdin, freebird['Id'], play_id, container) |