diff --git a/pysonic/__init__.py b/pysonic/__init__.py index f102a9c..3b93d0b 100644 --- a/pysonic/__init__.py +++ b/pysonic/__init__.py @@ -1 +1 @@ -__version__ = "0.0.1" +__version__ = "0.0.2" diff --git a/pysonic/api.py b/pysonic/api.py index 936f9e1..fd33a7f 100644 --- a/pysonic/api.py +++ b/pysonic/api.py @@ -10,12 +10,16 @@ import cherrypy logging = logging.getLogger("api") -class PysonicApi(object): +class PysonicSubsonicApi(object): def __init__(self, db, library, options): self.db = db self.library = library self.options = options + @cherrypy.expose + def index(self): + return str(self.library.db.get_stats()) + @cherrypy.expose @formatresponse def ping_view(self, **kwargs): @@ -61,7 +65,7 @@ class PysonicApi(object): @cherrypy.expose @formatresponse - def getAlbumList_view(self, type, size=50, offset=0, **kwargs): + def getAlbumList_view(self, type, size=250, offset=0, **kwargs): qargs = {} if type == "random": qargs.update(sortby="random") diff --git a/pysonic/daemon.py b/pysonic/daemon.py index c45b7f1..8cab4be 100644 --- a/pysonic/daemon.py +++ b/pysonic/daemon.py @@ -2,7 +2,7 @@ import os import logging import cherrypy from sqlite3 import DatabaseError -from pysonic.api import PysonicApi +from pysonic.api import PysonicSubsonicApi from pysonic.library import PysonicLibrary from pysonic.database import PysonicDatabase, DuplicateRootException @@ -54,7 +54,7 @@ def main(): # logging.warning("Artists: {}".format([i["name"] for i in library.get_artists()])) # logging.warning("Albums: {}".format(len(library.get_albums()))) - api = PysonicApi(db, library, args) + api = PysonicSubsonicApi(db, library, args) api_config = {} if args.disable_auth: logging.warning("starting up with auth disabled") diff --git a/pysonic/database.py b/pysonic/database.py index 4c57ef7..c473033 100644 --- a/pysonic/database.py +++ b/pysonic/database.py @@ -147,6 +147,13 @@ class PysonicDatabase(object): # logging.warning("db schema is version {}".format(version)) pass + @readcursor + def get_stats(self, cursor): + songs = cursor.execute("SELECT COUNT(*) as cnt FROM songs").fetchone()['cnt'] + artists = cursor.execute("SELECT COUNT(*) as cnt FROM artists").fetchone()['cnt'] + albums = cursor.execute("SELECT COUNT(*) as cnt FROM albums").fetchone()['cnt'] + return dict(songs=songs, artists=artists, albums=albums) + # Music related @readcursor def add_root(self, cursor, path, name="Library"):