more backfiller chat fixes

fixup: more backfiller fixes

Enable backfilling of chat logs
pull/300/head
Mike Lang 2 years ago committed by Mike Lang
parent 05a989f67d
commit c50224415c

@ -21,7 +21,7 @@ import common
from common import dateutil from common import dateutil
from common import database from common import database
from common.requests import InstrumentedSession from common.requests import InstrumentedSession
from common.segments import list_segment_files from common.segments import list_segment_files, unpadded_b64_decode
# Wraps all requests in some metric collection # Wraps all requests in some metric collection
requests = InstrumentedSession() requests = InstrumentedSession()
@ -133,8 +133,9 @@ def get_remote_segment(base_dir, node, channel, quality, hour, missing_segment,
dir_name = os.path.dirname(path) dir_name = os.path.dirname(path)
if quality == "chat": if quality == "chat":
# chat segment # chat segment
_, filename_hash = os.path.basename(path).split('-', 1) _, filename_hash = os.path.splitext(os.path.basename(path))[0].split('-', 1)
temp_name = "{}.{}.temp".format(os.path.basename(path), uuid4()) filename_hash = unpadded_b64_decode(filename_hash)
temp_name = "{}.{}.temp".format(os.path.basename(path), uuid.uuid4())
else: else:
# video segment # video segment
date, duration, _ = os.path.basename(path).split('-', 2) date, duration, _ = os.path.basename(path).split('-', 2)
@ -486,23 +487,26 @@ class BackfillerWorker(object):
pass pass
continue continue
# test to see if file is a segment and get the segments start time # For chat archives, just download whatever is there.
try: # Otherwise, do some basic checks.
segment = common.parse_segment_path(path) if quality != 'chat':
except ValueError as e: # test to see if file is a segment and get the segments start time
self.logger.warning('File {} invalid: {}'.format(path, e)) try:
continue segment = common.parse_segment_path(path)
except ValueError as e:
# Ignore temp segments as they may go away by the time we fetch them. self.logger.warning('File {} invalid: {}'.format(path, e))
if segment.type == "temp": continue
self.logger.debug('Skipping {} as it is a temp segment'.format(path))
continue # Ignore temp segments as they may go away by the time we fetch them.
if segment.type == "temp":
# to avoid getting in the downloader's way ignore segments self.logger.debug('Skipping {} as it is a temp segment'.format(path))
# less than recent_cutoff old continue
if datetime.datetime.utcnow() - segment.start < datetime.timedelta(seconds=self.recent_cutoff):
self.logger.debug('Skipping {} as too recent'.format(path)) # to avoid getting in the downloader's way ignore segments
continue # less than recent_cutoff old
if datetime.datetime.utcnow() - segment.start < datetime.timedelta(seconds=self.recent_cutoff):
self.logger.debug('Skipping {} as too recent'.format(path))
continue
# start segment as soon as a pool slot opens up, then track it in workers # start segment as soon as a pool slot opens up, then track it in workers
workers.append(pool.spawn( workers.append(pool.spawn(

@ -178,6 +178,8 @@
// Twitch user to log in as and path to oauth token // Twitch user to log in as and path to oauth token
user: "dbvideostriketeam", user: "dbvideostriketeam",
token_path: "./chat_token.txt", token_path: "./chat_token.txt",
// Whether to enable backfilling of chat archives to this node (if backfiller enabled)
backfill: true,
}, },
// Extra options to pass via environment variables, // Extra options to pass via environment variables,
@ -253,7 +255,7 @@
command: $.clean_channels + command: $.clean_channels +
[ [
"--base-dir", "/mnt", "--base-dir", "/mnt",
"--qualities", std.join(",", $.qualities), "--qualities", std.join(",", $.qualities + (if $.chat_archiver.backfill then ["chat"] else [])),
"--static-nodes", std.join(",", $.peers), "--static-nodes", std.join(",", $.peers),
"--backdoor-port", std.toString($.backdoor_port), "--backdoor-port", std.toString($.backdoor_port),
"--node-database", $.db_connect, "--node-database", $.db_connect,

Loading…
Cancel
Save