@@ -1762,6 +1762,100 @@ def playlist_generate(self, mode='random',
17621762 data .pop ('flag' )
17631763 return self .get_request (ampache_url , data , api_method )
17641764
1765+ def smartlists (self , filter_str = False , exact = False , offset = 0 , limit = 0 , include = False , sort = False , cond = False ):
1766+ """ smartlists
1767+ MINIMUM_API_VERSION=380001
1768+
1769+ This returns smartlists based on the specified filter
1770+
1771+ INPUTS
1772+ * filter_str = (string) search the name of a smartlist //optional
1773+ * exact = (integer) 0,1, if true filter is exact rather then fuzzy //optional
1774+ * offset = (integer) //optional
1775+ * limit = (integer) //optional
1776+ * include = (integer) 0,1, if true include the objects in the smartlist //optional
1777+ * cond = (string) Filter the browse using ';' separated comma string pairs (e.g. 'filter1,value1;filter2,value2') //optional
1778+ * sort = (string) sort name / comma separated key pair. Default 'ASC' (e.g. 'name,ASC' and 'name' are the same) //optional
1779+ """
1780+ ampache_url = self .AMPACHE_URL + '/server/' + self .AMPACHE_API + '.server.php'
1781+ api_method = 'smartlists'
1782+ data = {'action' : api_method ,
1783+ 'auth' : self .AMPACHE_SESSION ,
1784+ 'filter' : filter_str ,
1785+ 'exact' : exact ,
1786+ 'offset' : str (offset ),
1787+ 'limit' : str (limit ),
1788+ 'include' : include ,
1789+ 'sort' : sort ,
1790+ 'cond' : cond }
1791+ if not filter_str :
1792+ data .pop ('filter' )
1793+ if not exact :
1794+ data .pop ('exact' )
1795+ if not include :
1796+ data .pop ('include' )
1797+ if not sort :
1798+ data .pop ('sort' )
1799+ if not cond :
1800+ data .pop ('cond' )
1801+ return self .get_request (ampache_url , data , api_method )
1802+
1803+ def smartlist (self , filter_id : int ):
1804+ """ smartlist
1805+ MINIMUM_API_VERSION=380001
1806+
1807+ This returns a single smartlist
1808+
1809+ INPUTS
1810+ * filter_id = (integer) $smartlist_id
1811+ """
1812+ ampache_url = self .AMPACHE_URL + '/server/' + self .AMPACHE_API + '.server.php'
1813+ api_method = 'smartlist'
1814+ data = {'action' : api_method ,
1815+ 'auth' : self .AMPACHE_SESSION ,
1816+ 'filter' : filter_id }
1817+ return self .get_request (ampache_url , data , api_method )
1818+
1819+ def smartlist_songs (self , filter_id : int , random = False , offset = 0 , limit = 0 ):
1820+ """ smartlist_songs
1821+ MINIMUM_API_VERSION=380001
1822+
1823+ This returns the songs for a smartlist
1824+
1825+ INPUTS
1826+ * filter_id = (integer) $smartlist_id
1827+ * random = (integer) 0,1, if true get random songs using limit //optional
1828+ * offset = (integer) //optional
1829+ * limit = (integer) //optional
1830+ """
1831+ ampache_url = self .AMPACHE_URL + '/server/' + self .AMPACHE_API + '.server.php'
1832+ api_method = 'smartlist_songs'
1833+ data = {'action' : api_method ,
1834+ 'auth' : self .AMPACHE_SESSION ,
1835+ 'filter' : filter_id ,
1836+ 'random' : random ,
1837+ 'offset' : str (offset ),
1838+ 'limit' : str (limit )}
1839+ if not random :
1840+ data .pop ('random' )
1841+ return self .get_request (ampache_url , data , api_method )
1842+
1843+ def smartlist_delete (self , filter_id : int ):
1844+ """ smartlist_delete
1845+ MINIMUM_API_VERSION=380001
1846+
1847+ This deletes a smartlist
1848+
1849+ INPUTS
1850+ * filter_id = (integer) $smartlist_id
1851+ """
1852+ ampache_url = self .AMPACHE_URL + '/server/' + self .AMPACHE_API + '.server.php'
1853+ api_method = 'smartlist_delete'
1854+ data = {'action' : api_method ,
1855+ 'auth' : self .AMPACHE_SESSION ,
1856+ 'filter' : filter_id }
1857+ return self .get_request (ampache_url , data , api_method )
1858+
17651859 def shares (self , filter_str = False ,
17661860 exact = False , offset = 0 , limit = 0 , sort = False , cond = False ):
17671861 """ shares
@@ -4558,10 +4652,40 @@ def execute(self, method: str, params=None):
45584652 params ["client" ] = CLIENT_NAME
45594653 return self .player (params ["filter_str" ], params ["object_type" ], params ["state" ],
45604654 params ["play_time" ], params ["client" ])
4655+ case 'playlists' :
4656+ if not "filter_str" in params :
4657+ params ["filter_str" ] = False
4658+ if not "exact" in params :
4659+ params ["exact" ] = False
4660+ if not "offset" in params :
4661+ params ["offset" ] = 0
4662+ if not "limit" in params :
4663+ params ["limit" ] = 0
4664+ if not "hide_search" in params :
4665+ params ["hide_search" ] = False
4666+ if not "show_dupes" in params :
4667+ params ["show_dupes" ] = False
4668+ if not "include" in params :
4669+ params ["include" ] = False
4670+ if not "sort" in params :
4671+ params ["sort" ] = False
4672+ if not "cond" in params :
4673+ params ["cond" ] = False
4674+ return self .playlists (params ["filter_str" ], params ["exact" ], params ["offset" ], params ["limit" ],
4675+ params ["hide_search" ], params ["show_dupes" ], params ["include" ],
4676+ params ["sort" ], params ["cond" ])
45614677 case 'playlist' :
45624678 if not "filter_id" in params :
45634679 return False
45644680 return self .playlist (params ["filter_id" ])
4681+ case 'playlist_songs' :
4682+ if not "random" in params :
4683+ params ["random" ] = False
4684+ if not "offset" in params :
4685+ params ["offset" ] = 0
4686+ if not "limit" in params :
4687+ params ["limit" ] = 0
4688+ return self .playlist_songs (params ["filter_id" ], params ["random" ], params ["offset" ], params ["limit" ])
45654689 case 'playlist_add' :
45664690 if not "filter_id" in params or not "object_id" in params or not "object_type" in params :
45674691 return False
@@ -4621,36 +4745,6 @@ def execute(self, method: str, params=None):
46214745 if not "track" in params :
46224746 params ["track" ] = False
46234747 return self .playlist_remove_song (params ["filter_id" ])
4624- case 'playlists' :
4625- if not "filter_str" in params :
4626- params ["filter_str" ] = False
4627- if not "exact" in params :
4628- params ["exact" ] = False
4629- if not "offset" in params :
4630- params ["offset" ] = 0
4631- if not "limit" in params :
4632- params ["limit" ] = 0
4633- if not "hide_search" in params :
4634- params ["hide_search" ] = False
4635- if not "show_dupes" in params :
4636- params ["show_dupes" ] = False
4637- if not "include" in params :
4638- params ["include" ] = False
4639- if not "sort" in params :
4640- params ["sort" ] = False
4641- if not "cond" in params :
4642- params ["cond" ] = False
4643- return self .playlists (params ["filter_str" ], params ["exact" ], params ["offset" ], params ["limit" ],
4644- params ["hide_search" ], params ["show_dupes" ], params ["include" ],
4645- params ["sort" ], params ["cond" ])
4646- case 'playlist_songs' :
4647- if not "random" in params :
4648- params ["random" ] = False
4649- if not "offset" in params :
4650- params ["offset" ] = 0
4651- if not "limit" in params :
4652- params ["limit" ] = 0
4653- return self .playlist_songs (params ["filter_id" ], params ["random" ], params ["offset" ], params ["limit" ])
46544748 case 'podcast' :
46554749 if not "include" in params :
46564750 params ["include" ] = False
@@ -4804,6 +4898,43 @@ def execute(self, method: str, params=None):
48044898 params ["cond" ] = False
48054899 return self .shares (params ["filter_str" ], params ["exact" ], params ["offset" ], params ["limit" ],
48064900 params ["sort" ], params ["cond" ])
4901+ case 'smartlists' :
4902+ if not "filter_str" in params :
4903+ params ["filter_str" ] = False
4904+ if not "exact" in params :
4905+ params ["exact" ] = False
4906+ if not "offset" in params :
4907+ params ["offset" ] = 0
4908+ if not "limit" in params :
4909+ params ["limit" ] = 0
4910+ if not "hide_search" in params :
4911+ params ["hide_search" ] = False
4912+ if not "show_dupes" in params :
4913+ params ["show_dupes" ] = False
4914+ if not "include" in params :
4915+ params ["include" ] = False
4916+ if not "sort" in params :
4917+ params ["sort" ] = False
4918+ if not "cond" in params :
4919+ params ["cond" ] = False
4920+ return self .smartlists (params ["filter_str" ], params ["exact" ], params ["offset" ], params ["limit" ],
4921+ params ["include" ], params ["sort" ], params ["cond" ])
4922+ case 'smartlist' :
4923+ if not "filter_id" in params :
4924+ return False
4925+ return self .smartlist (params ["filter_id" ])
4926+ case 'smartlist_songs' :
4927+ if not "random" in params :
4928+ params ["random" ] = False
4929+ if not "offset" in params :
4930+ params ["offset" ] = 0
4931+ if not "limit" in params :
4932+ params ["limit" ] = 0
4933+ return self .smartlist_songs (params ["filter_id" ], params ["random" ], params ["offset" ], params ["limit" ])
4934+ case 'smartlist_delete' :
4935+ if not "filter_id" in params :
4936+ return False
4937+ return self .smartlist_delete (params ["filter_id" ])
48074938 case 'song' :
48084939 if not "filter_id" in params :
48094940 return False
0 commit comments