From bb095bbd86bc0baef6210f135ddc5f7370954ab3 Mon Sep 17 00:00:00 2001 From: hyugogirubato <65763543+hyugogirubato@users.noreply.github.com> Date: Mon, 30 Sep 2024 16:28:53 +0200 Subject: [PATCH] Fix LIFETIME duration --- src/ticket.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/ticket.py b/src/ticket.py index 8a26504..8788ebe 100644 --- a/src/ticket.py +++ b/src/ticket.py @@ -64,7 +64,7 @@ class Ticket: self.token = token self.type = TicketType[data['type']] self.version = data['version'] - self.expire = 75616 if self.type == TicketType.LIFETIME else data['expire'] + self.expire = data['expire'] def __repr__(self) -> str: @@ -85,10 +85,12 @@ class Ticket: product details, and configuration. """ current = datetime.now() # Current date and time - expire = current + timedelta(days=self.expire) # Expiration date - # Determine products that this ticket covers - products = self.PRODUCTS if self.type in (TicketType.LIFETIME, TicketType.SUBSCRIBER) else [] + # Expiration date + if self.type == TicketType.LIFETIME: + expire = datetime.fromisoformat('2231-10-10T13:22:44') + else: + expire = current + timedelta(days=self.expire) # Ticket configuration based on ticket type config = { @@ -116,7 +118,7 @@ class Ticket: config['ML'] = (1, 6, 2) # Adjust machine limits if self.type == TicketType.SUBSCRIBER: - config['VP'] = self.expire # Set validity period for Subscriber type + config['VP'] = (expire - current).days # Set validity period for Subscriber type config['VPT'] = round(expire.timestamp()) # Set the expiration timestamp if self.type == TicketType.FREE: @@ -128,8 +130,10 @@ class Ticket: # Construct the ticket export string with MAGIC number and product details items = [self.MAGIC] - # Add products with expiration timestamps - items += [f'{p}:{round(expire.timestamp())}' for p in products] + # Determine products that this ticket covers + if self.type in (TicketType.LIFETIME, TicketType.SUBSCRIBER): + # Add products with expiration timestamps + items += [f'{p}:{round(expire.timestamp())}' for p in self.PRODUCTS] # Add configuration key-value pairs items += [f'{k}:{v}' for k, v in config.items()] @@ -319,7 +323,7 @@ class Ticket: if __name__ == '__main__': - """Main function to parse arguments and handle ticket creation and extraction.""" + # Set up argument parsing parser = argparse.ArgumentParser(description='DVDFab-Ticket: Manage user tickets for DVDFab software.') # Subparsers for account actions @@ -383,6 +387,6 @@ if __name__ == '__main__': # Output the serialized ticket string print(ticket.export()) except Exception as e: - # Print exception message if an error occurs during ticket creation or processing + # Print any errors that occur during execution print(f'[!] {e}') exit(1)