'Get the homepage watch statistics.
Required parameters:
None
Optional parameters:
grouping (int):         0 or 1
time_range (str):       The time range to calculate statistics, \'30\'
stats_type (int):       0 for plays, 1 for duration
stats_count (str):      The number of top items to list, \'5\'
Returns:
json:
[{"stat_id": "top_movies",
"stat_type": "total_plays",
"rows": [{...}]
{"stat_id": "popular_movies",
"rows": [{...}]
{"stat_id": "top_tv",
"stat_type": "total_plays",
"rows":
[{"content_rating": "TV-MA",
"friendly_name": "",
"grandparent_thumb": "/library/metadata/1219/thumb/1462175063",
"labels": [],
"last_play": 1462380698,
"media_type": "episode",
"platform": "",
"platform_type": "",
"rating_key": 1219,
"row_id": 1116,
"section_id": 2,
"thumb": "",
"title": "Game of Thrones",
"total_duration": 213302,
"total_plays": 69,
"user": "",
"users_watched": ""
{"stat_id": "popular_tv",
"rows": [{...}]
{"stat_id": "top_music",
"stat_type": "total_plays",
"rows": [{...}]
{"stat_id": "popular_music",
"rows": [{...}]
{"stat_id": "last_watched",
"rows": [{...}]
{"stat_id": "top_users",
"stat_type": "total_plays",
"rows": [{...}]
{"stat_id": "top_platforms",
"stat_type": "total_plays",
"rows": [{...}]
{"stat_id": "most_concurrent",
"rows": [{...}]'

@cherrypy.expose
@cherrypy.tools.json_out()
@requireAuth(member_of('admin'))
@addtoapi()
def get_home_stats(self, grouping=0, time_range='30', stats_type=0, stats_count='5', **kwargs):

    stats_cards = plexpy.CONFIG.HOME_STATS_CARDS
    notify_watched_percent = plexpy.CONFIG.NOTIFY_WATCHED_PERCENT
    data_factory = datafactory.DataFactory()
    result = data_factory.get_home_stats(grouping=grouping, time_range=time_range, stats_type=stats_type, stats_count=stats_count, stats_cards=stats_cards, notify_watched_percent=notify_watched_percent)
    if result:
        return result
    else:
        logger.warn(u'Unable    to    retrieve    data    for    get_home_stats.')
