Got it to run, renamed some template stuff

Now onto the Jellyfin API, yay!
This commit is contained in:
2021-02-05 19:32:27 +01:00
parent ecbf38c005
commit cbee080b54
34 changed files with 80 additions and 76 deletions

4
.gitignore vendored
View File

@@ -273,3 +273,7 @@ $RECYCLE.BIN/
*.lnk *.lnk
# End of https://www.toptal.com/developers/gitignore/api/pycharm+all,python,linux,windows # End of https://www.toptal.com/developers/gitignore/api/pycharm+all,python,linux,windows
/config.ini
/release.lock
/tautulli.db
/version.lock

View File

@@ -1,8 +1,8 @@
<% <%
import plexpy import jellypy
from plexpy import version from jellypy import version
from plexpy.helpers import anon_url from jellypy.helpers import anon_url
from plexpy.notifiers import BROWSER_NOTIFIERS from jellypy.notifiers import BROWSER_NOTIFIERS
%> %>
<!doctype html> <!doctype html>

View File

@@ -13,8 +13,8 @@ DOCUMENTATION :: END
import os import os
import sys import sys
import plexpy import plexpy
from plexpy import common, logger from jellypy import common, logger
from plexpy.helpers import anon_url from jellypy.helpers import anon_url
%> %>
<table class="config-info-table small-muted"> <table class="config-info-table small-muted">

View File

@@ -27,7 +27,7 @@ DOCUMENTATION :: END
</%doc> </%doc>
<%! <%!
from plexpy import helpers from jellypy import helpers
%> %>
% if data != None: % if data != None:

View File

@@ -27,7 +27,7 @@ DOCUMENTATION :: END
</%doc> </%doc>
<%! <%!
from plexpy import helpers from jellypy import helpers
%> %>
% if data != None: % if data != None:

View File

@@ -14,9 +14,9 @@ data :: Usable parameters
DOCUMENTATION :: END DOCUMENTATION :: END
</%doc> </%doc>
<% <%
import plexpy import jellypy
from plexpy import exporter from jellypy import exporter
from plexpy.helpers import anon_url from jellypy.helpers import anon_url
export = exporter.Export() export = exporter.Export()
thumb_media_types = ', '.join([export.PLURAL_MEDIA_TYPES[k] for k, v in export.MEDIA_TYPES.items() if v[0]]) thumb_media_types = ', '.join([export.PLURAL_MEDIA_TYPES[k] for k, v in export.MEDIA_TYPES.items() if v[0]])
art_media_types = ', '.join([export.PLURAL_MEDIA_TYPES[k] for k, v in export.MEDIA_TYPES.items() if v[1]]) art_media_types = ', '.join([export.PLURAL_MEDIA_TYPES[k] for k, v in export.MEDIA_TYPES.items() if v[1]])

View File

@@ -5,7 +5,7 @@
</%def> </%def>
<%def name="body()"> <%def name="body()">
<% from plexpy import PLEX_SERVER_UP %> <% from jellypy import PLEX_SERVER_UP %>
<div class="container-fluid"> <div class="container-fluid">
% for section in config['home_sections']: % for section in config['home_sections']:
% if section == 'current_activity': % if section == 'current_activity':

View File

@@ -39,9 +39,9 @@ DOCUMENTATION :: END
from collections import defaultdict from collections import defaultdict
import re import re
from plexpy import notifiers from jellypy import notifiers
from plexpy.common import MEDIA_TYPE_HEADERS, MEDIA_FLAGS_AUDIO, MEDIA_FLAGS_VIDEO from jellypy.common import MEDIA_TYPE_HEADERS, MEDIA_FLAGS_AUDIO, MEDIA_FLAGS_VIDEO
from plexpy.helpers import page, get_percent, cast_to_int from jellypy.helpers import page, get_percent, cast_to_int
# Get audio codec file # Get audio codec file
def af(codec): def af(codec):

View File

@@ -28,7 +28,7 @@ DOCUMENTATION :: END
% if data != None: % if data != None:
<% <%
from plexpy.helpers import cast_to_int, page from jellypy.helpers import cast_to_int, page
%> %>
% if data['children_count'] > 0: % if data['children_count'] > 0:
<div class="item-children-wrapper"> <div class="item-children-wrapper">

View File

@@ -28,8 +28,8 @@ DOCUMENTATION :: END
% if data != None: % if data != None:
<% <%
from plexpy.common import MEDIA_TYPE_HEADERS from jellypy.common import MEDIA_TYPE_HEADERS
from plexpy.helpers import page from jellypy.helpers import page
types = ('movie', 'show', 'artist', 'album') types = ('movie', 'show', 'artist', 'album')
%> %>
% for media_type in types: % for media_type in types:

View File

@@ -54,7 +54,7 @@ DOCUMENTATION :: END
% if data != None: % if data != None:
<% <%
from plexpy.helpers import page from jellypy.helpers import page
%> %>
% if data['results_count'] > 0: % if data['results_count'] > 0:
% if 'collection' in data['results_list'] and data['results_list']['collection']: % if 'collection' in data['results_list'] and data['results_list']['collection']:

View File

@@ -36,8 +36,8 @@ DOCUMENTATION :: END
<%def name="body()"> <%def name="body()">
% if data: % if data:
<% <%
from plexpy.common import LIVE_TV_SECTION_ID from jellypy.common import LIVE_TV_SECTION_ID
from plexpy.helpers import page from jellypy.helpers import page
%> %>
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">

View File

@@ -32,7 +32,7 @@ DOCUMENTATION :: END
% if data: % if data:
<% <%
from plexpy.helpers import page from jellypy.helpers import page
%> %>
<div class="dashboard-recent-media-row"> <div class="dashboard-recent-media-row">
<div id="recently-added-row-scroller" style="left: 0;"> <div id="recently-added-row-scroller" style="left: 0;">

View File

@@ -25,7 +25,7 @@ DOCUMENTATION :: END
% if data: % if data:
<% <%
from plexpy.helpers import page from jellypy.helpers import page
types = ('movie', 'show', 'artist', 'photo') types = ('movie', 'show', 'artist', 'photo')
headers = {'movie': ('Movie Libraries', ('Movies', '', '')), headers = {'movie': ('Movie Libraries', ('Movies', '', '')),

View File

@@ -19,7 +19,7 @@ DOCUMENTATION :: END
</%doc> </%doc>
% if data: % if data:
<% from plexpy.helpers import page %> <% from jellypy.helpers import page %>
% for a in data: % for a in data:
<ul class="list-unstyled"> <ul class="list-unstyled">
<div class="user-player-instance"> <div class="user-player-instance">

View File

@@ -1,6 +1,6 @@
<% <%
import plexpy import jellypy
plex_login = plexpy.CONFIG.HTTP_PLEX_ADMIN or plexpy.CONFIG.ALLOW_GUEST_ACCESS plex_login = jellypy.CONFIG.HTTP_PLEX_ADMIN or jellypy.CONFIG.ALLOW_GUEST_ACCESS
%> %>
<!doctype html> <!doctype html>

View File

@@ -1,6 +1,6 @@
<%inherit file="base.html"/> <%inherit file="base.html"/>
<%! <%!
from plexpy import helpers from jellypy import helpers
%> %>
<%def name="headIncludes()"> <%def name="headIncludes()">

View File

@@ -1,8 +1,8 @@
% if newsletter: % if newsletter:
<%! <%!
import json import json
from plexpy import notifiers from jellypy import notifiers
from plexpy.helpers import anon_url, checked from jellypy.helpers import anon_url, checked
all_notifiers = sorted(notifiers.get_notifiers(), key=lambda k: (k['agent_label'].lower(), k['friendly_name'], k['id'])) all_notifiers = sorted(notifiers.get_notifiers(), key=lambda k: (k['agent_label'].lower(), k['friendly_name'], k['id']))
email_notifiers = [n for n in all_notifiers if n['agent_name'] == 'email'] email_notifiers = [n for n in all_notifiers if n['agent_name'] == 'email']

View File

@@ -9,7 +9,7 @@ Version: 0.1
DOCUMENTATION :: END DOCUMENTATION :: END
</%doc> </%doc>
<% from plexpy import newsletter_handler %> <% from jellypy import newsletter_handler %>
<ul class="stacked-configs list-unstyled"> <ul class="stacked-configs list-unstyled">
% for newsletter in sorted(newsletters_list, key=lambda k: (k['agent_label'], k['friendly_name'], k['id'])): % for newsletter in sorted(newsletters_list, key=lambda k: (k['agent_label'], k['friendly_name'], k['id'])):
<li class="newsletter-agent pointer" data-id="${newsletter['id']}"> <li class="newsletter-agent pointer" data-id="${newsletter['id']}">

View File

@@ -1,8 +1,8 @@
% if notifier: % if notifier:
<% <%
import json import json
from plexpy import notifiers, users from jellypy import notifiers, users
from plexpy.helpers import checked from jellypy.helpers import checked
available_notification_actions = notifiers.available_notification_actions(agent_id=notifier['agent_id']) available_notification_actions = notifiers.available_notification_actions(agent_id=notifier['agent_id'])
user_emails = [{'user': u['friendly_name'] or u['username'], 'email': u['email']} for u in users.Users().get_users() if u['email']] user_emails = [{'user': u['friendly_name'] or u['username'], 'email': u['email']} for u in users.Users().get_users() if u['email']]

View File

@@ -1,7 +1,7 @@
<% <%
import datetime import datetime
import plexpy import jellypy
from plexpy import activity_handler, helpers from jellypy import activity_handler, helpers
if queue == 'active sessions': if queue == 'active sessions':
filter_key = 'session_key-' filter_key = 'session_key-'

View File

@@ -32,7 +32,7 @@ DOCUMENTATION :: END
% if data != None: % if data != None:
<% <%
from plexpy.helpers import cast_to_int, page from jellypy.helpers import cast_to_int, page
%> %>
% if data: % if data:
<div class="dashboard-recent-media-row"> <div class="dashboard-recent-media-row">

View File

@@ -11,10 +11,10 @@ DOCUMENTATION :: END
<%! <%!
import datetime import datetime
import plexpy import jellypy
from plexpy import common, helpers from jellypy import common, helpers
scheduled_jobs = [j.id for j in plexpy.SCHED.get_jobs()] scheduled_jobs = [j.id for j in jellypy.SCHED.get_jobs()]
%> %>
<table class="config-scheduler-table small-muted"> <table class="config-scheduler-table small-muted">

View File

@@ -3,12 +3,12 @@
import os import os
import sys import sys
import plexpy import jellypy
from plexpy import common, notifiers, newsletters from jellypy import common, notifiers, newsletters
from plexpy.helpers import anon_url, checked from jellypy.helpers import anon_url, checked
docker_setting = 'disabled' if plexpy.DOCKER else '' docker_setting = 'disabled' if jellypy.DOCKER else ''
docker_msg = '<span class="setting-message small">(Controlled by Docker Container)</span>' if plexpy.DOCKER else '' docker_msg = '<span class="setting-message small">(Controlled by Docker Container)</span>' if jellypy.DOCKER else ''
available_notification_agents = sorted(notifiers.available_notification_agents(), key=lambda k: k['label'].lower()) available_notification_agents = sorted(notifiers.available_notification_agents(), key=lambda k: k['label'].lower())
available_newsletter_agents = sorted(newsletters.available_newsletter_agents(), key=lambda k: k['label'].lower()) available_newsletter_agents = sorted(newsletters.available_newsletter_agents(), key=lambda k: k['label'].lower())

View File

@@ -39,7 +39,7 @@ DOCUMENTATION :: END
% if data: % if data:
<% <%
from plexpy.common import VIDEO_RESOLUTION_OVERRIDES, AUDIO_CODEC_OVERRIDES from jellypy.common import VIDEO_RESOLUTION_OVERRIDES, AUDIO_CODEC_OVERRIDES
%> %>
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">

View File

@@ -1,6 +1,6 @@
<%inherit file="base.html"/> <%inherit file="base.html"/>
<%! <%!
from plexpy.helpers import anon_url from jellypy.helpers import anon_url
%> %>
<%def name="headIncludes()"> <%def name="headIncludes()">
</%def> </%def>

View File

@@ -26,7 +26,7 @@ DOCUMENTATION :: END
<%inherit file="base.html"/> <%inherit file="base.html"/>
<%! <%!
from plexpy import helpers from jellypy import helpers
%> %>
<%def name="headIncludes()"> <%def name="headIncludes()">

View File

@@ -28,7 +28,7 @@ DOCUMENTATION :: END
% if data: % if data:
<% <%
from plexpy.helpers import page from jellypy.helpers import page
%> %>
<div class="dashboard-recent-media-row"> <div class="dashboard-recent-media-row">
<div id="recently-watched-row-scroller" style="left: 0;"> <div id="recently-watched-row-scroller" style="left: 0;">

View File

@@ -1,6 +1,6 @@
<% <%
import plexpy import jellypy
from plexpy import common, helpers from jellypy import common, helpers
%> %>
<!doctype html> <!doctype html>

View File

@@ -1,11 +1,11 @@
% if data: % if data:
<% <%
import plexpy import jellypy
from plexpy.helpers import grouper, get_img_service from jellypy.helpers import grouper, get_img_service
recently_added = data['recently_added'] recently_added = data['recently_added']
if plexpy.CONFIG.NEWSLETTER_SELF_HOSTED and plexpy.CONFIG.HTTP_BASE_URL: if jellypy.CONFIG.NEWSLETTER_SELF_HOSTED and plexpy.CONFIG.HTTP_BASE_URL:
base_url = plexpy.CONFIG.HTTP_BASE_URL + plexpy.HTTP_ROOT + 'newsletter/' base_url = jellypy.CONFIG.HTTP_BASE_URL + jellypy.HTTP_ROOT + 'newsletter/'
elif preview: elif preview:
base_url = 'newsletter/' base_url = 'newsletter/'
else: else:
@@ -13,7 +13,7 @@
service = get_img_service(include_self=True) service = get_img_service(include_self=True)
if service == 'self-hosted' and plexpy.CONFIG.HTTP_BASE_URL: if service == 'self-hosted' and plexpy.CONFIG.HTTP_BASE_URL:
base_url_image = plexpy.CONFIG.HTTP_BASE_URL + plexpy.HTTP_ROOT + 'image/' base_url_image = jellypy.CONFIG.HTTP_BASE_URL + jellypy.HTTP_ROOT + 'image/'
elif preview and service and service != 'self-hosted': elif preview and service and service != 'self-hosted':
base_url_image = 'image/' base_url_image = 'image/'
else: else:

View File

@@ -1,19 +1,19 @@
% if data: % if data:
<% <%
import plexpy import jellypy
from plexpy.helpers import grouper, get_img_service from jellypy.helpers import grouper, get_img_service
recently_added = data['recently_added'] recently_added = data['recently_added']
if plexpy.CONFIG.NEWSLETTER_SELF_HOSTED and plexpy.CONFIG.HTTP_BASE_URL: if jellypy.CONFIG.NEWSLETTER_SELF_HOSTED and jellypy.CONFIG.HTTP_BASE_URL:
base_url = plexpy.CONFIG.HTTP_BASE_URL + plexpy.HTTP_ROOT + 'newsletter/' base_url = jellypy.CONFIG.HTTP_BASE_URL + jellypy.HTTP_ROOT + 'newsletter/'
elif preview: elif preview:
base_url = 'newsletter/' base_url = 'newsletter/'
else: else:
base_url = '' base_url = ''
service = get_img_service(include_self=True) service = get_img_service(include_self=True)
if service == 'self-hosted' and plexpy.CONFIG.HTTP_BASE_URL: if service == 'self-hosted' and jellypy.CONFIG.HTTP_BASE_URL:
base_url_image = plexpy.CONFIG.HTTP_BASE_URL + plexpy.HTTP_ROOT + 'image/' base_url_image = jellypy.CONFIG.HTTP_BASE_URL + jellypy.HTTP_ROOT + 'image/'
elif preview and service and service != 'self-hosted': elif preview and service and service != 'self-hosted':
base_url_image = 'image/' base_url_image = 'image/'
else: else:

View File

@@ -31,7 +31,7 @@ from jellypy import datatables
from jellypy import helpers from jellypy import helpers
from jellypy import logger from jellypy import logger
from jellypy import users from jellypy import users
from jellypy.plex import Plex from jellypy.jellyfin import Jellyfin
class Export(object): class Export(object):
@@ -1524,7 +1524,7 @@ class Export(object):
else: else:
plex_token = jellypy.CONFIG.PMS_TOKEN plex_token = jellypy.CONFIG.PMS_TOKEN
plex = Plex(jellypy.CONFIG.PMS_URL, plex_token) jf = Jellyfin(jellypy.CONFIG.PMS_URL, plex_token)
if self.rating_key: if self.rating_key:
logger.debug( logger.debug(
@@ -1534,7 +1534,7 @@ class Export(object):
self.rating_key, self.metadata_level, self.media_info_level, self.rating_key, self.metadata_level, self.media_info_level,
self.thumb_level, self.art_level, self.file_format) self.thumb_level, self.art_level, self.file_format)
self.obj = plex.get_item(self.rating_key) self.obj = jf.get_item(self.rating_key)
self.media_type = self._media_type(self.obj) self.media_type = self._media_type(self.obj)
if self.media_type != 'playlist': if self.media_type != 'playlist':
@@ -1553,7 +1553,7 @@ class Export(object):
self.user_id, self.metadata_level, self.media_info_level, self.user_id, self.metadata_level, self.media_info_level,
self.thumb_level, self.art_level, self.export_type, self.file_format) self.thumb_level, self.art_level, self.export_type, self.file_format)
self.obj = plex.plex self.obj = jf.plex
self.media_type = self.export_type self.media_type = self.export_type
self.obj_title = user_info['username'] self.obj_title = user_info['username']
@@ -1566,7 +1566,7 @@ class Export(object):
self.section_id, self.metadata_level, self.media_info_level, self.section_id, self.metadata_level, self.media_info_level,
self.thumb_level, self.art_level, self.export_type, self.file_format) self.thumb_level, self.art_level, self.export_type, self.file_format)
self.obj = plex.get_library(str(self.section_id)) self.obj = jf.get_library(str(self.section_id))
if self.export_type == 'all': if self.export_type == 'all':
self.media_type = self.obj.type self.media_type = self.obj.type
else: else:

View File

@@ -15,18 +15,18 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Tautulli. If not, see <http://www.gnu.org/licenses/>. # along with Tautulli. If not, see <http://www.gnu.org/licenses/>.
from plexapi.server import PlexServer from jellyfin_apiclient_python import JellyfinClient
class Plex(object): class Jellyfin(object):
def __init__(self, url, token): def __init__(self, url, token):
self.plex = PlexServer(url, token) self.jf = JellyfinClient()
def get_library(self, section_id): def get_library(self, section_id):
return self.plex.library.sectionByID(str(section_id)) return self.jf.library.sectionByID(str(section_id))
def get_library_items(self, section_id): def get_library_items(self, section_id):
return self.get_library(str(section_id)).all() return self.get_library(str(section_id)).all()
def get_item(self, rating_key): def get_item(self, rating_key):
return self.plex.fetchItem(rating_key) return self.jf.fetchItem(rating_key)

View File

@@ -29,7 +29,7 @@ from jellypy import plextv
from jellypy import pmsconnect from jellypy import pmsconnect
from jellypy import session from jellypy import session
from jellypy import users from jellypy import users
from jellypy.plex import Plex from jellypy.jellyfin import Jellyfin
def refresh_libraries(): def refresh_libraries():
@@ -132,8 +132,8 @@ def has_library_type(section_type):
def get_collections(section_id=None): def get_collections(section_id=None):
plex = Plex(jellypy.CONFIG.PMS_URL, session.get_session_user_token()) jf = Jellyfin(jellypy.CONFIG.PMS_URL, session.get_session_user_token())
library = plex.get_library(section_id) library = jf.get_library(section_id)
if library.type not in ('movie', 'show', 'artist'): if library.type not in ('movie', 'show', 'artist'):
return [] return []
@@ -230,12 +230,12 @@ def get_playlists(section_id=None, user_id=None):
if not plex_token: if not plex_token:
return [] return []
plex = Plex(jellypy.CONFIG.PMS_URL, plex_token) jf = Jellyfin(jellypy.CONFIG.PMS_URL, plex_token)
if user_id: if user_id:
playlists = plex.plex.playlists() playlists = jf.plex.playlists()
else: else:
library = plex.get_library(section_id) library = jf.get_library(section_id)
playlists = library.playlist() playlists = library.playlist()
playlists_list = [] playlists_list = []