- Go to your Emby interface, open your Movies collection
- The URL will look like this:
http://1.2.3.4/web/index.html#!/movies?serverId=16fe3a5de47f25fb1de848c0a3f435a9&parentId=fc3b74e25d482b4b1bbd0f314e60f776
. Copy theparentId
value (the part afterparentId=
, in this example it'sfc3b74e25d482b4b1bbd0f314e60f776
- Change the
@@MOVIE CATEGORY ID@@
value (between two%22
,parentId%3A%20%22@@MOVIE CATEGORY ID@@%22%7D)
) in the code below with the value you copied in the previous step (eg.parentId%3A%20%22fc3b74e25d482b4b1bbd0f314e60f776%22%7D)
javascript:(async%20function()%7Bwindow.movies%20%3D%20window.movies%20%7C%7C%20(await%20ApiClient.getItems(await%20ApiClient.getCurrentUserId()%2C%20%7Brecursive%3A%20true%2C%20parentId%3A%20%22@@MOVIE CATEGORY ID@@%22%7D)).Items%3B%0A%20%20%20%20const%20unplayedMovies%20%3D%20movies.filter(movie%20%3D%3E%20movie.UserData.Played%20%3D%3D%3D%20false%20%26%26%20movie.IsFolder%20%3D%3D%3D%20false)%3B%0A%20%20%20%20const%20toWatch%20%3D%20unplayedMovies%5BMath.floor(Math.random()%20*%20unplayedMovies.length)%5D%3B%0A%20%20%20%20Emby.Page.showItem(toWatch.Id%2C%20toWatch.ServerId)%3B%7D)()%3B
- Create a bookmark using the modified code as the location
Here is the prettified code if you're interested. The bookmarklet was generated using
https://caiorss.github.io/bookmarklet-maker/, I just added an async%20
at the beginning
because this code uses await
.
(
async function() {
window.movies = window.movies || (await ApiClient.getItems(await ApiClient.getCurrentUserId(), {recursive: true, parentId: "@@MOVIE CATEGORY ID@@"})).Items;
const unplayedMovies = movies.filter(movie => movie.UserData.Played === false && movie.IsFolder === false);
const toWatch = unplayedMovies[Math.floor(Math.random() * unplayedMovies.length)];
Emby.Page.showItem(toWatch.Id, toWatch.ServerId);
}
)();
Inspiration from https://github.com/raben2/embyoracle, thanks 😉