diff --git a/db_schema.sql b/db_schema.sql
index b4b0b54c056b34d43ab362ca11940194216e72f7..2f2a6eac0f64fe289ae8563e815166492afbb19b 100644
--- a/db_schema.sql
+++ b/db_schema.sql
@@ -126,12 +126,21 @@ CREATE TABLE IF NOT EXISTS `site_texts` (
   `modified_by` text NOT NULL
 );
 CREATE TABLE IF NOT EXISTS `log` (
-	`id` INTEGER,
+	CREATE TABLE IF NOT EXISTS `streamlog` (
+	`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
 	`time` datetime NOT NULL,
 	`date` datetime NOT NULL,
 	`source` INTEGER,
 	`video` INTEGER
 );
+CREATE TABLE IF NOT EXISTS `hlslog` (
+	`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+	`time` datetime NOT NULL,
+	`source` INTEGER,
+	`lecture` INTEGER,
+	`handle` varchar(32),
+	`format` varchar(16)
+);
 CREATE TABLE IF NOT EXISTS `logcache` (
 	`req` varchar(64),
 	`param` varchar(64),
diff --git a/server.py b/server.py
index a9a19bcabb36f559fad287e4451c42d938f622a4..255369cbea27081d4bc31208a6fa094ebcbec927 100644
--- a/server.py
+++ b/server.py
@@ -563,7 +563,7 @@ def auth(): # For use with nginx auth_request
 		return "OK", 200
 	if url.startswith('pub/hls/'):
 		handle = url[len('pub/hls/'):].split('_')[0].split('.')[0]
-		perms = query('''SELECT perm.*
+		perms = query('''SELECT lectures.id AS lecture, perm.*
 				FROM streams
 				JOIN lectures ON (streams.lecture_id = lectures.id)
 				JOIN courses ON (lectures.course_id = courses.id)
@@ -592,6 +592,10 @@ def auth(): # For use with nginx auth_request
 		try:
 			if not url.startswith('pub/hls/'):
 				modify('INSERT INTO log (id, `time`, `date`, video, source) VALUES (?, ?, ?, ?, 1)', cookie, datetime.now(), datetime.combine(date.today(), time()), perms[0]['vid'])
+			elif url.endswith('.ts'):
+				fmt = url.split('_')[-1].split('-')[0]
+				seg = url.split('.')[0].split('-')[-1]
+				modify('INSERT INTO hlslog (id, `time`, segment, lecture, handle, format) VALUES (?, ?, ?, ?, ?, ?)', cookie, datetime.now(), seg, perms[0]['lecture'], handle, fmt)
 		except:
 			pass
 		r = make_response('OK', 200)
diff --git a/stats.py b/stats.py
index 7f5369fefb6f8702d52171983373c0cbc410d185..b0be43cfef0fbdc5d07994ba0f0439018eafa3d7 100644
--- a/stats.py
+++ b/stats.py
@@ -17,6 +17,7 @@ statsqueries['categories_courses'] = "SELECT courses.subject AS labels, count(co
 statsqueries['organizer_courses'] = "SELECT courses.organizer AS labels, count(courses.id) AS `values` FROM courses GROUP BY courses.organizer ORDER BY labels DESC LIMIT 100"
 statsqueries['categories_lectures'] = "SELECT courses.subject AS labels, count(lectures.id) AS `values` FROM lectures JOIN courses ON (courses.id = lectures.course_id) WHERE lectures.visible GROUP BY courses.subject ORDER BY `values` DESC LIMIT 100"
 statsqueries['lecture_views'] = "SELECT lectures.time AS x, count(DISTINCT log.id) AS y FROM log JOIN videos ON (videos.id = log.video) JOIN lectures ON (lectures.id = videos.lecture_id) WHERE (lectures.course_id = ?) GROUP BY lectures.id ORDER BY lectures.time"
+statsqueries['live_views'] = "SELECT hlslog.segment AS x, COUNT(DISTINCT hlslog.id) AS y FROM hlslog WHERE hlslog.lecture = ? GROUP BY hlslog.segment ORDER BY hlslog.segment"
 
 def plotly_date_handler(obj):
 	return obj.strftime("%Y-%m-%d %H:%M:%S")
diff --git a/templates/lecture.html b/templates/lecture.html
index d3561fb71fe7fc33952b60436d9e3833dae3339c..4007263b47de998985e68dad49d5811c18618784 100644
--- a/templates/lecture.html
+++ b/templates/lecture.html
@@ -59,6 +59,7 @@
 					</table>
 				</div>
 				<div class="col-xs-12 plot-view" data-url="{{url_for('stats_viewsperday', req="lecture", param=lecture.id)}}"></div>
+				<div class="col-xs-12 plot-view" data-url="{{url_for('stats_generic', req="live_views", param=lecture.id)}}"></div>
 			{% endif %}
 		</div>
 	</div>