Sanitize player name

This commit is contained in:
Jonathan Wong 2015-12-05 23:26:54 -08:00
parent 8c4292f9ac
commit b47ccd06f9
5 changed files with 35 additions and 14 deletions

View file

@ -108,6 +108,9 @@ class DataFactory(object):
# Rename Mystery platform names
platform = common.PLATFORM_NAME_OVERRIDES.get(item["platform"], item["platform"])
# Sanitize player name
player = helpers.sanitize(item["player"])
row = {"reference_id": item["reference_id"],
"id": item["id"],
"date": item["date"],
@ -119,7 +122,7 @@ class DataFactory(object):
"user": item["user"],
"friendly_name": item["friendly_name"],
"platform": platform,
"player": item["player"],
"player": player,
"ip_address": item["ip_address"],
"media_type": item["media_type"],
"rating_key": item["rating_key"],
@ -545,7 +548,7 @@ class DataFactory(object):
'session_history_metadata.thumb, ' \
'session_history_metadata.grandparent_thumb, ' \
'MAX(session_history.started) as last_watch, ' \
'session_history.player as platform, ' \
'session_history.player, ' \
'((CASE WHEN session_history.view_offset IS NULL THEN 0.1 ELSE \
session_history.view_offset * 1.0 END) / \
(CASE WHEN session_history_metadata.duration IS NULL THEN 1.0 ELSE \
@ -571,6 +574,9 @@ class DataFactory(object):
thumb = item[7]
else:
thumb = item[8]
# Sanitize player name
player = helpers.sanitize(item["player"])
row = {'row_id': item[0],
'user': item[1],
@ -582,7 +588,7 @@ class DataFactory(object):
'thumb': thumb,
'grandparent_thumb': item[8],
'last_watch': item[9],
'platform_type': item[10],
'player': player,
}
last_watched.append(row)