summaryrefslogtreecommitdiffstats
path: root/cli/objects/live.py
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-12-13 11:07:26 +0100
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-12-13 13:59:39 +0100
commit80a68ceb5aa7ea37670842fbd427d98c9c01d808 (patch)
tree04ec565e1159f926bfde599bcd896adab2528c2e /cli/objects/live.py
parent12d965ce1c1497df6f5d5a63fd562171ce01b9e7 (diff)
live: use human readable date in live list
Parse the unix timestamp into a human readable format like "2024-11-25 12:28:19". Make print_json() print from string and from a json object to enable manipulation of data before printing.
Diffstat (limited to 'cli/objects/live.py')
-rw-r--r--cli/objects/live.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/cli/objects/live.py b/cli/objects/live.py
index 0664c01..64ed3de 100644
--- a/cli/objects/live.py
+++ b/cli/objects/live.py
@@ -8,6 +8,7 @@
import argparse
from cli.config import cfg, OG_CLI_CFG_PATH
+from datetime import datetime
from cli.utils import *
import requests
import shutil
@@ -24,6 +25,15 @@ class OgLive():
tmp_extension = '.tmp'
@staticmethod
+ def _parse_timestamps(payload):
+ for elem in payload['oglive']:
+ if 'date' in elem:
+ timestamp = elem['date']
+ readable_date = datetime.fromtimestamp(timestamp).strftime("%Y-%m-%d %H:%M:%S")
+ elem['date'] = readable_date
+
+
+ @staticmethod
def _get_local_live_dir():
local_live_dir = cfg.get('local_live', '/var/www/html/ogrelive')
if not local_live_dir:
@@ -155,7 +165,10 @@ class OgLive():
res = rest.get('/oglive/list')
if not res:
return 1
- print_json(res.text)
+
+ live_data = json.loads(res.text)
+ OgLive._parse_timestamps(live_data)
+ print_json(live_data)
return 0
@staticmethod