Skip to content

Commit

Permalink
Create a whatsapp-alike theme #97
Browse files Browse the repository at this point in the history
  • Loading branch information
KnugiHK committed Jan 2, 2025
1 parent 7117716 commit a0b8167
Show file tree
Hide file tree
Showing 4 changed files with 391 additions and 9 deletions.
21 changes: 17 additions & 4 deletions Whatsapp_Chat_Exporter/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,15 @@ def main():
default=None,
type=str,
const="result",
help="Export chats in text format similar to what WhatsApp officially provided (default if present: result/)")
help="Export chats in text format similar to what WhatsApp officially provided (default if present: result/)"
)
parser.add_argument(
"--experimental-new-theme",
dest="whatsapp_theme",
default=False,
action='store_true',
help="Use the newly designed WhatsApp-alike theme"
)

args = parser.parse_args()

Expand Down Expand Up @@ -358,6 +366,8 @@ def main():
args.filter_date = f"<= {_timestamp - APPLE_TIME}"
else:
parser.error("Unsupported date format. See https://wts.knugi.dev/docs?dest=date")
if args.whatsapp_theme:
args.template = "whatsapp_new.html"
if args.filter_chat_include is not None and args.filter_chat_exclude is not None:
parser.error("Chat inclusion and exclusion filters cannot be used together.")
if args.filter_chat_include is not None:
Expand Down Expand Up @@ -502,7 +512,8 @@ def main():
args.offline,
args.size,
args.no_avatar,
args.filter_empty
args.filter_empty,
args.whatsapp_theme
)
else:
print(
Expand Down Expand Up @@ -539,7 +550,8 @@ def main():
args.offline,
args.size,
args.no_avatar,
args.filter_empty
args.filter_empty,
args.whatsapp_theme
)
for file in glob.glob(r'*.*'):
shutil.copy(file, args.output)
Expand All @@ -553,7 +565,8 @@ def main():
args.offline,
args.size,
args.no_avatar,
args.filter_empty
args.filter_empty,
args.whatsapp_theme
)

if args.text_format:
Expand Down
5 changes: 3 additions & 2 deletions Whatsapp_Chat_Exporter/android_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,9 +760,10 @@ def create_html(
offline_static=False,
maximum_size=None,
no_avatar=False,
filter_empty=True
filter_empty=True,
experimental=False
):
template = setup_template(template, no_avatar)
template = setup_template(template, no_avatar, experimental)

total_row_number = len(data)
print(f"\nGenerating chats...(0/{total_row_number})", end="\r")
Expand Down
6 changes: 3 additions & 3 deletions Whatsapp_Chat_Exporter/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,10 @@ def get_status_location(output_folder, offline_static):
w3css = os.path.join(offline_static, "w3.css")


def setup_template(template, no_avatar):
if template is None:
def setup_template(template, no_avatar, experimental=False):
if template is None or experimental:
template_dir = os.path.dirname(__file__)
template_file = "whatsapp.html"
template_file = "whatsapp.html" if not experimental else template
else:
template_dir = os.path.dirname(template)
template_file = os.path.basename(template)
Expand Down
Loading

0 comments on commit a0b8167

Please sign in to comment.