mirror of
https://github.com/KnugiHK/WhatsApp-Chat-Exporter.git
synced 2026-04-24 15:01:36 +00:00
Support custom template
This commit is contained in:
@@ -67,6 +67,12 @@ def main():
|
|||||||
default=None,
|
default=None,
|
||||||
help="Path to key file"
|
help="Path to key file"
|
||||||
)
|
)
|
||||||
|
parser.add_option(
|
||||||
|
"-t",
|
||||||
|
"--template",
|
||||||
|
dest="template",
|
||||||
|
default=None,
|
||||||
|
help="Path to custom HTML template")
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
if options.android and options.iphone:
|
if options.android and options.iphone:
|
||||||
@@ -138,7 +144,7 @@ def main():
|
|||||||
messages(db, data)
|
messages(db, data)
|
||||||
media(db, data, options.media)
|
media(db, data, options.media)
|
||||||
vcard(db, data)
|
vcard(db, data)
|
||||||
create_html(data, options.output)
|
create_html(data, options.output, options.template)
|
||||||
|
|
||||||
if not os.path.isdir(f"{options.output}/{options.media}"):
|
if not os.path.isdir(f"{options.output}/{options.media}"):
|
||||||
shutil.move(options.media, f"{options.output}/")
|
shutil.move(options.media, f"{options.output}/")
|
||||||
|
|||||||
@@ -294,12 +294,17 @@ def vcard(db, data):
|
|||||||
print(f"Gathering vCards...({index + 1}/{total_row_number})", end="\r")
|
print(f"Gathering vCards...({index + 1}/{total_row_number})", end="\r")
|
||||||
|
|
||||||
|
|
||||||
def create_html(data, output_folder):
|
def create_html(data, output_folder, template=None):
|
||||||
templateLoader = jinja2.FileSystemLoader(searchpath=os.path.dirname(__file__))
|
if template is None:
|
||||||
|
template_dir = os.path.dirname(__file__)
|
||||||
|
template_file = "whatsapp.html"
|
||||||
|
else:
|
||||||
|
template_dir = os.path.dirname(template)
|
||||||
|
template_file = os.path.basename(template)
|
||||||
|
templateLoader = jinja2.FileSystemLoader(searchpath=template_dir)
|
||||||
templateEnv = jinja2.Environment(loader=templateLoader)
|
templateEnv = jinja2.Environment(loader=templateLoader)
|
||||||
templateEnv.globals.update(determine_day=determine_day)
|
templateEnv.globals.update(determine_day=determine_day)
|
||||||
TEMPLATE_FILE = "whatsapp.html"
|
template = templateEnv.get_template(template_file)
|
||||||
template = templateEnv.get_template(TEMPLATE_FILE)
|
|
||||||
|
|
||||||
total_row_number = len(data)
|
total_row_number = len(data)
|
||||||
print(f"\nCreating HTML...(0/{total_row_number})", end="\r")
|
print(f"\nCreating HTML...(0/{total_row_number})", end="\r")
|
||||||
|
|||||||
@@ -206,12 +206,17 @@ def vcard(db, data):
|
|||||||
print(f"Gathering vCards...({index + 1}/{total_row_number})", end="\r")
|
print(f"Gathering vCards...({index + 1}/{total_row_number})", end="\r")
|
||||||
|
|
||||||
|
|
||||||
def create_html(data, output_folder):
|
def create_html(data, output_folder, template=None):
|
||||||
templateLoader = jinja2.FileSystemLoader(searchpath=os.path.dirname(__file__))
|
if template is None:
|
||||||
|
template_dir = os.path.dirname(__file__)
|
||||||
|
template_file = "whatsapp.html"
|
||||||
|
else:
|
||||||
|
template_dir = os.path.dirname(template)
|
||||||
|
template_file = os.path.basename(template)
|
||||||
|
templateLoader = jinja2.FileSystemLoader(searchpath=template_dir)
|
||||||
templateEnv = jinja2.Environment(loader=templateLoader)
|
templateEnv = jinja2.Environment(loader=templateLoader)
|
||||||
templateEnv.globals.update(determine_day=determine_day)
|
templateEnv.globals.update(determine_day=determine_day)
|
||||||
TEMPLATE_FILE = "whatsapp.html"
|
template = templateEnv.get_template(template_file)
|
||||||
template = templateEnv.get_template(TEMPLATE_FILE)
|
|
||||||
|
|
||||||
total_row_number = len(data)
|
total_row_number = len(data)
|
||||||
print(f"\nCreating HTML...(0/{total_row_number})", end="\r")
|
print(f"\nCreating HTML...(0/{total_row_number})", end="\r")
|
||||||
|
|||||||
Reference in New Issue
Block a user