feat: add Jellyfin link button filter and integrate into playlist info template
This commit is contained in:
@@ -98,6 +98,17 @@ def jellyfin_link(jellyfin_id: str) -> Markup:
|
||||
link = f"{jellyfin_server_url}/web/#/details?id={jellyfin_id}"
|
||||
return Markup(f'<a href="{link}" target="_blank">{jellyfin_id}</a>')
|
||||
|
||||
@template_filter('jellyfin_link_button')
|
||||
def jellyfin_link_btn(jellyfin_id: str) -> Markup:
|
||||
|
||||
jellyfin_server_url = app.config.get('JELLYFIN_SERVER_URL')
|
||||
if not jellyfin_server_url:
|
||||
return Markup(f"<span style='color: red;'>JELLYFIN_SERVER_URL not configured</span>")
|
||||
|
||||
link = f"{jellyfin_server_url}/web/#/details?id={jellyfin_id}"
|
||||
return Markup(f'<a href="{link}" class="btn btn-primary mt-2" target="_blank">Open in Jellyfin</a>')
|
||||
|
||||
|
||||
# A template filter for displaying a datetime in a human-readable format
|
||||
@template_filter('human_datetime')
|
||||
def human_datetime(dt) -> str:
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
<p>{{ item.track_count }} songs, {{ total_duration }}</p>
|
||||
<p>Last Updated: {{ item.last_updated | human_datetime}} | Last Change: {{ item.last_changed | human_datetime}}</p>
|
||||
{% include 'partials/_add_remove_button.html' %}
|
||||
{% if session['is_admin'] and item.jellyfin_id %}
|
||||
<p>
|
||||
{{item.jellyfin_id | jellyfin_link_button}}
|
||||
{% if session['is_admin'] and item.jellyfin_id %}
|
||||
<button id="refresh-playlist-btn" class="btn btn-primary mt-2">Refresh Playlist in Jellyfin</button>
|
||||
<script>
|
||||
document.getElementById('refresh-playlist-btn').addEventListener('click', function() {
|
||||
@@ -29,8 +30,8 @@
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user