sheetsync: pass in event id instead of event name

pull/401/head
Mike Lang 1 year ago committed by Mike Lang
parent cf41f572f5
commit eebfa5885b

@ -193,9 +193,9 @@
// Set to true to enable reverse-sync mode into Sheets, instead of syncing from it. // Set to true to enable reverse-sync mode into Sheets, instead of syncing from it.
sheet_reverse_sync:: false, sheet_reverse_sync:: false,
// The StreamLog server and event to use, or null to disable sync from StreamLog. // The StreamLog server and event id to use, or null to disable sync from StreamLog.
streamlog_url:: "https://streamlog.example.com", streamlog_url:: "https://streamlog.example.com",
streamlog_event:: "myevent", streamlog_event:: "id_goes_here",
// A map from youtube playlist IDs to a list of tags. // A map from youtube playlist IDs to a list of tags.
// Playlist manager will populate each playlist with all videos which have all those tags. // Playlist manager will populate each playlist with all videos which have all those tags.
@ -456,7 +456,7 @@
type: "streamlog", type: "streamlog",
creds: "/etc/streamlog-token.txt", creds: "/etc/streamlog-token.txt",
url: $.streamlog_url, url: $.streamlog_url,
event_name: $.streamlog_event, event_id: $.streamlog_event,
}, },
local config = std.prune([ local config = std.prune([
if $.sheet_id != null then sync_sheet, if $.sheet_id != null then sync_sheet,

@ -353,7 +353,7 @@ class PlaylistSync:
' type: streamlog', ' type: streamlog',
' creds: path to a file containing the auth key', ' creds: path to a file containing the auth key',
' url: The URL of the streamlog server', ' url: The URL of the streamlog server',
' event_name: The name of the streamlog event to sync', ' event_id: The id of the streamlog event to sync',
]), ]),
) )
def main(dbconnect, sync_configs, metrics_port=8005, backdoor_port=0): def main(dbconnect, sync_configs, metrics_port=8005, backdoor_port=0):
@ -417,7 +417,7 @@ def main(dbconnect, sync_configs, metrics_port=8005, backdoor_port=0):
auth_token = open(config["creds"]).read().strip() auth_token = open(config["creds"]).read().strip()
client = StreamLogClient( client = StreamLogClient(
config["url"], config["url"],
config["event_name"], config["event_id"],
auth_token, auth_token,
) )
middleware = StreamLogMiddleware(client) middleware = StreamLogMiddleware(client)

@ -8,13 +8,12 @@ from common.dateutil import parse_utc_only
class StreamLogClient(): class StreamLogClient():
"""Client for Stream Log server""" """Client for Stream Log server"""
def __init__(self, url, event_name, auth_token): def __init__(self, url, event_id, auth_token):
self.url = url self.url = url
self.auth_token = auth_token self.auth_token = auth_token
self.event_id = event_id
self.session = requests.Session() self.session = requests.Session()
self.event_id = self.request("GET", "event_by_name", event_name)["id"]
def get_rows(self): def get_rows(self):
"""Return a list of rows, where each row is a dict""" """Return a list of rows, where each row is a dict"""
return self.request("GET", "event", self.event_id, "log") return self.request("GET", "event", self.event_id, "log")

Loading…
Cancel
Save