Compare commits

..

6 commits

5 changed files with 61 additions and 76 deletions

View file

@ -171,7 +171,8 @@ namespace Jellyfin.Plugin.SmartPlaylist.ScheduledTasks {
_logger.LogDebug("- {0}", asm); _logger.LogDebug("- {0}", asm);
} }
var i = 0; var i = 0;
foreach (SmartPlaylistDto dto in await _store.GetAllSmartPlaylistsAsync()) { var all_playlists = await _store.GetAllSmartPlaylistsAsync();
foreach (SmartPlaylistDto dto in all_playlists) {
if (!dto.Enabled) { if (!dto.Enabled) {
i += 1; i += 1;
continue; continue;
@ -211,7 +212,7 @@ namespace Jellyfin.Plugin.SmartPlaylist.ScheduledTasks {
await _playlistManager.AddItemToPlaylistAsync(playlist.Id, insertItems, playlistLink.UserId); await _playlistManager.AddItemToPlaylistAsync(playlist.Id, insertItems, playlistLink.UserId);
} }
i += 1; i += 1;
progress.Report(100 * ((double)i)/dto.Playlists.Count()); progress.Report(100 * ((double)i)/all_playlists.Count());
} }
} }

View file

@ -71,17 +71,18 @@
const editEnabled = document.querySelector('#SmartplaylistEditEnabled'); const editEnabled = document.querySelector('#SmartplaylistEditEnabled');
if (id === null) { if (id === null) {
selection.selectedIndex = 0; selection.selectedIndex = 0;
editName.value = ''; editName.value = 'My New Smartplaylist';
editProgram.value = ''; editProgram.value = '(is-favourite)';
editSortProgram.value = ''; editSortProgram.value = '(begin *items*)';
editUsers.innerHTML = ''; editUsers.innerHTML = '';
for (const u of config.Users) { for (const u of config.Users) {
var o = document.createElement('option'); var o = document.createElement('option');
o.value = u[0]; o.value = u[0];
o.innerHTML = u[1]; o.innerHTML = u[1];
o.setAttribute('selected', 'selected');
editUsers.appendChild(o); editUsers.appendChild(o);
} }
editEnabled.checked = false; editEnabled.checked = true;
return; return;
} }
function matchId(p) { function matchId(p) {

View file

@ -10,70 +10,13 @@ The latest version is [v0.4.0.0](https://gitea.redxef.at/redxef/jellyfin-smart-p
## How to use ## How to use
After [installing](#installation) the plugin and restarting Jellyfin After [installing](#installation) the plugin and restarting Jellyfin
create a empty file in `config/data/smartplaylists` like this, maybe go to the plugin settings and below the `Initial Program` configuration
you want to generate a playlist of your favourite rock songs: choose the smart playlist you want to edit, or `Create new playlist ...`
to create a new one.
``` [Go here](examples.md) to see some example configurations.
$ touch config/data/smartplaylists/Rock.yaml
```
Afterwards run the Task `(re)generate Smart Playlists`, this will rename Below are all the configuration values for a smart playlist.
the `yaml` file and populate it with some default values. You can now
adjust the file to your liking. [Go here](examples.md) to see more
examples.
```yaml
Id: Rock
Playlists:
- PlaylistId: 24f12e1e-3278-d6d6-0ca4-066e93296c95
UserId: 6eec632a-ff0d-4d09-aad0-bf9e90b14bc6
Name: Rock
Program: (begin (invoke item "IsFavoriteOrLiked" (list *user*)))
SortProgram: (begin items)
Filename: /config/data/smartplaylists/Rock.yaml
Enabled: true
```
This is the default configuration and will always match all your
favorite songs (and songs which are in favourited albums).
To change the filter you can append a `|` (pipe) to the Program
line and write multiline filters like this:
```yaml
Porgram: |
(begin
(invoke item "IsFavoriteOrLiked" (list *user*)))
```
This is equivalent to the above example (not counting the other
fields obviously).
### Id
Arbitrary Id assigned to this playlist, can usually be left alone.
### Playlists
A list of Playlist/User mappings. By default all users get an entry.
The ids must have the dashes in them as of now. To convert a id
from without dashes to the canonical form run this command:
`echo '<your id here>' | python3 -c 'import uuid; import sys; print(uuid.UUID(sys.stdin.read().strip()))'`
To get your user id navigate to your user profile and copy the part
after `userId` in the address bar.
#### PlaylistId
The id of the playlist that should be managed, must be owned by the
corresponding user.
#### UserId
The user associated with this playlist.
### Name ### Name
@ -121,10 +64,6 @@ the items by name you could use the following program:
*items*) *items*)
``` ```
### Filename
The path to this file, only used internally and updated by the program.
### Enabled ### Enabled
Enable this playlist, currently ignored. Enable this playlist, currently ignored.

View file

@ -10,20 +10,20 @@ resources:
- name: source - name: source
type: git type: git
source: source:
uri: https://gitea.redxef.at/redxef/jellyfin-smart-playlist uri: https://git.redxef.at/redxef/jellyfin-smart-playlist
branch: main branch: main
fetch_tags: true fetch_tags: true
tag_regex: 'v.*' tag_regex: 'v.*'
- name: manifest - name: manifest
type: git type: git
source: source:
uri: ssh://git@gitea.redxef.at:8022/redxef/jellyfin-smart-playlist.git uri: ssh://git@git.redxef.at:8022/redxef/jellyfin-smart-playlist.git
branch: manifest branch: manifest
private_key: ((gitea.id_ed25519)) private_key: ((gitea.id_ed25519))
- name: releases - name: releases
type: http-resource type: http-resource
source: source:
url: https://gitea.redxef.at/api/v1/repos/redxef/jellyfin-smart-playlist/releases url: https://git.redxef.at/api/v1/repos/redxef/jellyfin-smart-playlist/releases
method: get method: get
auth: auth:
basic: basic:
@ -32,7 +32,7 @@ resources:
- name: artifact - name: artifact
type: http-resource type: http-resource
source: source:
url: https://gitea.redxef.at/api/v1/repos/redxef/jellyfin-smart-playlist/releases/((.:release_id))/assets url: https://git.redxef.at/api/v1/repos/redxef/jellyfin-smart-playlist/releases/((.:release_id))/assets
method: get method: get
auth: auth:
basic: basic:

View file

@ -53,3 +53,47 @@
(t (string= (car (getitems parent "Name")) "Seeed")))) (t (string= (car (getitems parent "Name")) "Seeed"))))
``` ```
- `Artists`: A playlist including everything from a list of artists.
```
Id: Artists
Name: Artists
Program: >-
(begin
(define *include-artists* '(
"seeed"
"juli"
"falco"
"peter fox"
"alligatoah"
"kraftklub"
"wanda"
"annennaykantereit"
"feine sahne fischfilet"
"madsen"
"wiener blond"
"die toten hosen"
"die ärzte"
"wir sind helden"
))
(define my-prefilter-only-tracks
(lambda nil
(and
(is-type "Audio")
(not (name-contains "live"))
(not (name-contains "acoustic"))
(not (name-contains "instrumental"))
(not (name-contains "remix")))))
(and
(my-prefilter-only-tracks)
(is-favourite)
(any
(lambda
(i)
;; the `(and (find-artist)` is here to prevent null violations.
(and (find-artist) (string= i (lower (get-name (find-artist))))))
*include-artists*)))
SortProgram: (begin (shuf *items*))
Filename: /config/data/smartplaylists/German.yaml
Enabled: true
```