Add scripts to fetch random items from Jellyfin API with detailed logging [skip ci]
This commit is contained in:
44
test_scripts/fetch_random_item_browser_console.js
Normal file
44
test_scripts/fetch_random_item_browser_console.js
Normal file
@@ -0,0 +1,44 @@
|
||||
(async () => {
|
||||
// 1. Prüfen, ob wir im Jellyfin-Kontext sind
|
||||
if (!window.ApiClient) {
|
||||
console.error("ApiClient nicht gefunden. Bist du sicher, dass Jellyfin im Browser offen ist?");
|
||||
return;
|
||||
}
|
||||
|
||||
const apiClient = window.ApiClient;
|
||||
const userId = apiClient.currentUserId();
|
||||
|
||||
// 2. Alle Items abrufen (Filme und Serien)
|
||||
// Wir fordern extra viele Felder an, um "alle verfügbaren Einträge" zu erhalten
|
||||
const response = await apiClient.getItems(userId, {
|
||||
Recursive: true,
|
||||
IncludeItemTypes: "Movie,Series,Episode",
|
||||
Fields: "Overview,Genres,Path,OfficialRating,Tags,CommunityRating,ExternalUrls,MediaSources,ProductionYear",
|
||||
EnableImageTypes: "Primary,Backdrop,Banner"
|
||||
});
|
||||
|
||||
const items = response.Items;
|
||||
|
||||
if (!items || items.length === 0) {
|
||||
console.warn("Keine Items in deiner Bibliothek gefunden.");
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. Zufälliges Item auswählen
|
||||
const randomItem = items[Math.floor(Math.random() * items.length)];
|
||||
|
||||
// 4. Ausgabe in der Konsole
|
||||
console.log(`%c🎲 Zufälliges Item: ${randomItem.Name}`, "color: #00a4dc; font-weight: bold; font-size: 1.4em;");
|
||||
|
||||
// Gibt alle Metadaten als ausklappbares Objekt aus
|
||||
console.log("Vollständige Metadaten:", randomItem);
|
||||
|
||||
// Erstellt eine übersichtliche Tabelle der wichtigsten Werte
|
||||
console.table({
|
||||
Name: randomItem.Name,
|
||||
Typ: randomItem.Type,
|
||||
Jahr: randomItem.ProductionYear,
|
||||
ID: randomItem.Id,
|
||||
Pfad: randomItem.Path
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user