Adding BreadMixer file indexing
This commit is contained in:
parent
41683fe098
commit
78f1232f5b
@ -4,6 +4,7 @@ import json
|
||||
import os
|
||||
import sys
|
||||
import datetime
|
||||
from pprint import pprint
|
||||
|
||||
argument_parser = argparse.ArgumentParser(description="BreadMixer is used to combine media from Discord Voice Calls")
|
||||
argument_parser.add_argument("callid", help="The call id that needs to be mixed")
|
||||
@ -46,5 +47,38 @@ cursor.execute("SELECT call_start_time FROM call_states WHERE call_id = %s", [ar
|
||||
|
||||
call_start_time = cursor.fetchall()
|
||||
|
||||
print(call_start_time)
|
||||
if len(call_start_time) == 0:
|
||||
print('{call_id} does not exist in the database'.format(call_id=args.callid))
|
||||
|
||||
sys.exit(3)
|
||||
|
||||
file_dict = {}
|
||||
user_lut = {}
|
||||
|
||||
for file in os.listdir(os.path.join(json_config["media_voice_folder"], args.callid)):
|
||||
file_name_no_ext = file.split('.')[0]
|
||||
timestamp = file_name_no_ext.split('-')[0]
|
||||
user_snowflake = file_name_no_ext.split('-')[1]
|
||||
|
||||
if not user_snowflake in user_lut:
|
||||
cursor.execute("SELECT user_name FROM users WHERE user_snowflake = %s", [user_snowflake])
|
||||
|
||||
username = cursor.fetchall()
|
||||
|
||||
if len(username) == 0:
|
||||
print('The user snowflake {snowflake} is not present in the DB'.format(snowflake=user_snowflake))
|
||||
|
||||
sys.exit(4)
|
||||
|
||||
# In this instance you have to unwrap both the result list and the result tuple,
|
||||
# which creates the obnoxious 0,0 double dereference operation
|
||||
user_lut[user_snowflake] = username[0][0]
|
||||
|
||||
file_dict[file] = dict(
|
||||
user=user_lut[user_snowflake],
|
||||
real_date=datetime.datetime.fromtimestamp(timestamp / 1000),
|
||||
seconds_from_starttime=(datetime.datetime.fromtimestamp(timestamp / 1000) - call_start_time[0][0]).seconds
|
||||
)
|
||||
|
||||
pprint(file_dict)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user