myMPD
Internal API documentation
Loading...
Searching...
No Matches
smartpls.c File Reference

Smart playlist implementation. More...

#include "compile_time.h"
#include "src/lib/smartpls.h"
#include "src/lib/api.h"
#include "src/lib/filehandler.h"
#include "src/lib/json/json_print.h"
#include "src/lib/json/json_rpc.h"
#include "src/lib/msg_queue.h"
#include "src/lib/sds_extras.h"
#include <string.h>
#include <sys/stat.h>
Include dependency graph for smartpls.c:

Functions

static bool smartpls_save (sds workdir, const char *smartpltype, const char *playlist, const char *fields, const char *sort, bool sortdesc, int max_entries)
 
bool smartpls_save_sticker (sds workdir, const char *playlist, const char *sticker, const char *value, const char *op, const char *sort, bool sortdesc, int max_entries)
 
bool smartpls_save_newest (sds workdir, const char *playlist, unsigned timerange, const char *sort, bool sortdesc, int max_entries)
 
bool smartpls_save_search (sds workdir, const char *playlist, const char *expression, const char *sort, bool sortdesc, int max_entries)
 
bool is_smartpls (sds workdir, const char *playlist)
 
time_t smartpls_get_mtime (sds workdir, const char *playlist)
 
bool smartpls_update (const char *playlist, unsigned long conn_id, unsigned int request_id)
 
bool smartpls_update_all (bool force)
 

Detailed Description

Smart playlist implementation.

Function Documentation

◆ is_smartpls()

bool is_smartpls ( sds  workdir,
const char *  playlist 
)

Checks if playlist is a smart playlist

Parameters
workdirmyMPD working directory
playlistname of the playlist to check
Returns
true if it is a smart playlist else false

◆ smartpls_get_mtime()

time_t smartpls_get_mtime ( sds  workdir,
const char *  playlist 
)

Returns the smart playlist last modification time

Parameters
workdirmyMPD working directory
playlistname of the playlist to check
Returns
last modification time

◆ smartpls_save()

static bool smartpls_save ( sds  workdir,
const char *  smartpltype,
const char *  playlist,
const char *  fields,
const char *  sort,
bool  sortdesc,
int  max_entries 
)
static

Saves the smart playlist to disk.

Parameters
workdirmyMPD working directory
smartpltypetype of the smart playlist: sticker, newest or search
playlistname of the smart playlist
fieldscustom fields
sortmpd tag to sort or the string "shuffle"
sortdescsort descending?
max_entriesmaximum songs
Returns
true on success else false

◆ smartpls_save_newest()

bool smartpls_save_newest ( sds  workdir,
const char *  playlist,
unsigned  timerange,
const char *  sort,
bool  sortdesc,
int  max_entries 
)

Saves a newest smart playlist

Parameters
workdirmyMPD working directory
playlistplaylist name
timerangenumber of second since now
sorttag to sort the playlist: empty = no sorting, shuffle or mpd tag
sortdescsort descending?
max_entriesmaximum number of playlist entries
Returns
true on success else false

◆ smartpls_save_search()

bool smartpls_save_search ( sds  workdir,
const char *  playlist,
const char *  expression,
const char *  sort,
bool  sortdesc,
int  max_entries 
)

Saves a search based smart playlist

Parameters
workdirmyMPD working directory
playlistplaylist name
expressionmpd search expression
sorttag to sort the playlist: empty = no sorting, shuffle or mpd tag
sortdescsort descending?
max_entriesmaximum number of playlist entries
Returns
true on success else false

◆ smartpls_save_sticker()

bool smartpls_save_sticker ( sds  workdir,
const char *  playlist,
const char *  sticker,
const char *  value,
const char *  op,
const char *  sort,
bool  sortdesc,
int  max_entries 
)

Saves a sticker based smart playlist

Parameters
workdirmyMPD working directory
playlistplaylist name
stickersticker name
valueminimum integer value of sticker
opcompare operator
sorttag to sort the playlist: empty = no sorting, shuffle or mpd tag
sortdescsort descending?
max_entriesmaximum number of playlist entries
Returns
true on success else false

◆ smartpls_update()

bool smartpls_update ( const char *  playlist,
unsigned long  conn_id,
unsigned int  request_id 
)

Sends a request to the mympd_api_queue to update a smart playlist

Parameters
playlistsmart playlist to update
conn_idmongoose connection id
request_idjsonrpc request id
Returns
true on success else false

◆ smartpls_update_all()

bool smartpls_update_all ( bool  force)

Sends a request to the mympd_api_queue to update all smart playlists

Parameters
forceForce smart playlist update?
Returns
true on success else false