Skip to content

Commit

Permalink
lua: expose genre thumbnail from medialibrary
Browse files Browse the repository at this point in the history
  • Loading branch information
mohak2003 authored and robUx4 committed Aug 23, 2024
1 parent 72a5ad4 commit 5cd6ec2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions modules/lua/libs/medialibrary.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,25 @@ static int vlclua_ml_get_album_thumbnail( lua_State *L )
return 1;
}

static int vlclua_ml_get_genre_thumbnail( lua_State *L )
{
if( lua_gettop( L ) < 1 ) return vlclua_error( L );

lua_Integer genreId = luaL_checkinteger( L, 1 );
vlc_object_t *p_this = vlclua_get_this( L );
vlc_medialibrary_t *ml = vlc_ml_instance_get( p_this );
vlc_ml_genre_t *genre = vlc_ml_get_genre( ml, genreId );
if ( genre == NULL ||
genre->thumbnails[VLC_ML_THUMBNAIL_SMALL].psz_mrl == NULL )
{
vlc_ml_release( genre );
return 0;
}
lua_pushstring( L, genre->thumbnails[VLC_ML_THUMBNAIL_SMALL].psz_mrl );
vlc_ml_release( genre );
return 1;
}

static int vlclua_ml_list_album_tracks( lua_State *L )
{
vlc_object_t *p_this = vlclua_get_this( L );
Expand Down Expand Up @@ -836,6 +855,7 @@ static const luaL_Reg vlclua_ml_reg[] = {
{ "genre_artists", vlclua_ml_list_genre_artists },
{ "artist_thumbnail", vlclua_ml_get_artist_thumbnail },
{ "album_thumbnail", vlclua_ml_get_album_thumbnail },
{ "genre_thumbnail", vlclua_ml_get_genre_thumbnail },
{ "reload", vlclua_ml_reload },
{ "history", vlclua_ml_history },
{ "video_history",vlclua_ml_video_history },
Expand Down

0 comments on commit 5cd6ec2

Please sign in to comment.