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

Webradio functions. More...

#include "compile_time.h"
#include "src/lib/webradio.h"
#include "dist/mpack/mpack.h"
#include "src/lib/filehandler.h"
#include "src/lib/log.h"
#include "src/lib/mem.h"
#include "src/lib/mpack.h"
#include "src/lib/sds/sds_extras.h"
#include "src/lib/sds/sds_url.h"
#include "src/lib/utility.h"
#include <pthread.h>
Include dependency graph for webradio.c:

Functions

struct t_webradio_datawebradio_by_uri (struct t_webradios *webradio_favorites, struct t_webradios *webradiodb, const char *uri)
sds webradio_get_extm3u (struct t_webradios *webradio_favorites, struct t_webradios *webradiodb, sds buffer, sds uri)
struct t_webradio_datawebradio_data_new (enum webradio_type type)
void webradio_data_free (struct t_webradio_data *data)
sds webradio_get_cover_uri (struct t_webradio_data *webradio, sds buffer)
void webradio_tags_search (struct t_webradio_tags *tags)
enum webradio_tag_type webradio_tag_name_parse (const char *name)
const char * webradio_type_name (enum webradio_type type)
const char * webradio_get_tag (const struct t_webradio_data *webradio, enum webradio_tag_type tag_type, unsigned int idx)
sds webradio_to_extm3u (const struct t_webradio_data *webradio, sds buffer, const char *uri)
struct t_webradioswebradios_new (void)
void webradios_clear (struct t_webradios *webradios, bool init_rax)
void webradios_free (struct t_webradios *webradios)
void webradios_free_void (void *webradios)
bool webradios_get_read_lock (struct t_webradios *webradios)
bool webradios_get_write_lock (struct t_webradios *webradios)
bool webradios_release_lock (struct t_webradios *webradios)
bool webradios_save_to_disk (struct t_config *config, struct t_webradios *webradios, const char *filename)
bool webradios_read_from_disk (struct t_config *config, struct t_webradios *webradios, const char *filename, enum webradio_type type)

Variables

static const char * webradio_tag_types_names [WEBRADIO_TAG_COUNT]

Detailed Description

Webradio functions.

Function Documentation

◆ webradio_by_uri()

struct t_webradio_data * webradio_by_uri ( struct t_webradios * webradio_favorites,
struct t_webradios * webradiodb,
const char * uri )

Search webradio by uri in favorites and WebradioDB

Parameters
webradio_favoritesPointer to webradio favorites
webradiodbPointer to WebradioDB
uriUri to search for
Returns
pointer to webradio data or NULL on error

◆ webradio_data_free()

void webradio_data_free ( struct t_webradio_data * data)

Frees a webradios data struct

Parameters
datastruct to free

◆ webradio_data_new()

struct t_webradio_data * webradio_data_new ( enum webradio_type type)

Creates a new webradio data struct

Parameters
typeWebradio type
Returns
struct t_webradio_data*

◆ webradio_get_cover_uri()

sds webradio_get_cover_uri ( struct t_webradio_data * webradio,
sds buffer )

Returns the uri for the webradio image

Parameters
webradioWebradio struct
bufferbuffer to append the uri
Returns
pointer to buffer

◆ webradio_get_extm3u()

sds webradio_get_extm3u ( struct t_webradios * webradio_favorites,
struct t_webradios * webradiodb,
sds buffer,
sds uri )

Returns an extm3u for a webradio

Parameters
webradio_favoritesPointer to webradio favorites
webradiodbPointer to WebradioDB
bufferBuffer to append the uri
uriWebradio uri
Returns
Pointer to buffer

◆ webradio_get_tag()

const char * webradio_get_tag ( const struct t_webradio_data * webradio,
enum webradio_tag_type tag_type,
unsigned int idx )

Returns the value of a webradio tag

Parameters
webradioWebdadio
tag_typeWebradio tag
idxIndex of tag
Returns
Tag value or NULL if not exists

◆ webradio_tag_name_parse()

enum webradio_tag_type webradio_tag_name_parse ( const char * name)

Parses a string to a webradio tag type

Parameters
namestring to parse
Returns
enum webradio_tag_type

◆ webradio_tags_search()

void webradio_tags_search ( struct t_webradio_tags * tags)

Sets the webradio tags for search

Parameters
tagsStruct to set

◆ webradio_to_extm3u()

sds webradio_to_extm3u ( const struct t_webradio_data * webradio,
sds buffer,
const char * uri )

Returns an extm3u for a webradio

Parameters
webradioPointer to webradio struct
bufferAlready allocated buffer to append the extm3u
uriOptional uri. If NULL use the first uri from the webradio entry.
Returns
Pointer to buffer

◆ webradio_type_name()

const char * webradio_type_name ( enum webradio_type type)

Returns the webradio type as string literal

Parameters
typewebradio type
Returns
Name of the webradio type

◆ webradios_clear()

void webradios_clear ( struct t_webradios * webradios,
bool init_rax )

Clears the webradios struct

Parameters
webradiosstruct to free
init_raxre-init the rax trees?

◆ webradios_free()

void webradios_free ( struct t_webradios * webradios)

Frees the webradios struct

Parameters
webradiosstruct to free

◆ webradios_free_void()

void webradios_free_void ( void * webradios)

Frees the webradios struct

Parameters
webradiosstruct to free

◆ webradios_get_read_lock()

bool webradios_get_read_lock ( struct t_webradios * webradios)

Acquires a read lock

Parameters
webradiospointer to webradios struct
Returns
true on success, else false

◆ webradios_get_write_lock()

bool webradios_get_write_lock ( struct t_webradios * webradios)

Acquires a write lock

Parameters
webradiospointer to webradios struct
Returns
true on success, else false

◆ webradios_new()

struct t_webradios * webradios_new ( void )

Initializes the webradios struct

Returns
struct t_webradios*

◆ webradios_read_from_disk()

bool webradios_read_from_disk ( struct t_config * config,
struct t_webradios * webradios,
const char * filename,
enum webradio_type type )

Reads the webradios file from disk

Parameters
configpointer to config
webradioswebradios struct to populate
filenamefile to read
typeWebradio type
Returns
true on success, else false

◆ webradios_release_lock()

bool webradios_release_lock ( struct t_webradios * webradios)

Frees the lock

Parameters
webradiospointer to webradios struct
Returns
true on success, else false

◆ webradios_save_to_disk()

bool webradios_save_to_disk ( struct t_config * config,
struct t_webradios * webradios,
const char * filename )

Saves the webradios to disk

Parameters
configpointer to config
webradioswebradios struct to write
filenamefile to write
Returns
true on success, else false

Variable Documentation

◆ webradio_tag_types_names

const char* webradio_tag_types_names[WEBRADIO_TAG_COUNT]
static
Initial value:
= {
[WEBRADIO_TAG_NAME] = "Name",
[WEBRADIO_TAG_IMAGE] = "Image",
[WEBRADIO_TAG_HOMEPAGE] = "Homepage",
[WEBRADIO_TAG_COUNTRY] = "Country",
[WEBRADIO_TAG_REGION] = "Region",
[WEBRADIO_TAG_DESCRIPTION] = "Description",
[WEBRADIO_TAG_URIS] = "Uri",
[WEBRADIO_TAG_BITRATE] = "Bitrate",
[WEBRADIO_TAG_CODEC] = "Codec",
[WEBRADIO_TAG_GENRES] = "Genres",
[WEBRADIO_TAG_LANGUAGES] = "Languages",
[WEBRADIO_TAG_ADDED] = "Added",
[WEBRADIO_TAG_LASTMODIFIED] = "Last-Modified"
}

Mapping for webradio tags to strings